Audit whether current code truly needs a directory, file, export, API, wrapper, compatibility layer, defensive branch, fallback, default value, or config before simplifying or deleting it. Use for agent-assisted code cleanup, refactoring, technical-debt reduction, used-but-unnecessary code, legacy cleanup, stale public APIs, meaningless wrappers, defensive-code removal, no-backward-compatibility cleanup, deep review, continued cleanup, or "is this still necessary?" requests.
How this skill is triggered — by the user, by Claude, or both
Slash command
/page-flow-cleanup-audit:necessary-code-auditThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Optimize for current necessity, not only for zero references. A symbol can be used and still be unnecessary when it is only a wrapper, compatibility surface, defensive branch, stale public API, or speculative extension point.
Optimize for current necessity, not only for zero references. A symbol can be used and still be unnecessary when it is only a wrapper, compatibility surface, defensive branch, stale public API, or speculative extension point.
The core trigger is: "this code is used, but does current code really need it?"
Do not delete real runtime constraints. Keep branches that represent actual loading, empty, error, permission, lifecycle, browser, SSR, quota, external input, or domain-nullable states.
This skill is the primary entrypoint for a three-skill cleanup system:
necessary-code-audit to decide whether used code is still necessary.unused-code-audit to prove whether deletion candidates are still consumed.page-flow-cleanup-audit when the target includes page state, query/mutation flow, permissions, error states, stores, or user-visible behavior.Do not require repository-specific graph tools or project-specific agent skills. Use the best local tools available in the environment, such as file listings, language tooling, typecheck/build commands, manifests, import graphs, and text search.
This skill is useful for any AI coding agent or human reviewer that can read Markdown instructions. Do not assume a specific AI product.
Start with:
git status --short --untracked-files=allgit diff --name-status -- <scope>git diff --cached --name-status -- <scope>Do not assume staged changes are yours. Work with dirty files without reverting unrelated changes.
Classify every meaningful file, export, method, field, option, fallback, and branch in the target scope:
current necessity: required by current product behavior or platform/runtime constraints.direct replacement: wrapper or facade whose call sites can call the underlying primitive directly.compatibility surface: old export, optional field, default value, alias, factory, config, or public type kept for external or historical consumers.defensive branch: try/catch, fallback, optional chaining, null guard, feature detection, or corrupted-data handling.speculative capability: API surface with no current caller or only hypothetical future value.duplicated source: second cache, store, query, invalidation path, state source, or derived calculation.dead code: no real consumer after re-exports, dynamic references, and framework entrypoints are ruled out.real constraint: SSR, browser storage availability, quota, permissions, loading/error/empty lifecycle, external input, or valid optional domain state.For each candidate, answer before editing:
Push back when the user's deletion target is a real constraint, not defensive code.
Avoid creating new abstractions to justify deleting old ones.
Use the available repository tools for structure:
Use fast text search for literal residuals:
legacy, deprecated, backward, compat, fallback, debug, old-format comments, and commented-out code.try, catch, optional fields, optional chaining, as any, constant boolean parameters, and default config values.If an unused-export script or dependency analyzer is available in the current environment, use it as a candidate generator only. Treat automated output as leads, not proof.
Run the narrowest checks that cover the edited boundary:
rg scans for removed symbols and old import paths.git diff --check -- <scope> and, when staged changes exist, git diff --cached --check -- <scope>.If a broad typecheck fails, identify whether the failure is related to this cleanup or an existing unrelated dirty state.
Report:
Be explicit when the first-pass unused audit would miss something because it is used but unnecessary.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
npx claudepluginhub danhuaxiansheng/claude-code-cleanup-skills --plugin claude-code-cleanup-skills