From FORSVN Dev
Audits and refactors code for readability, maintainability, and dead code removal without changing behavior. Produces a dated cleanup record. Use before releases or after feature additions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/forsvn-dev:clean-code [file or directory to clean][file or directory to clean]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
*Productivity — Multi-agent orchestration. Audits and refactors existing code in-place for readability, maintainability, and dead-code removal — without changing behavior. Produces a dated cleanup record.*
agents/_template.mdagents/asset-scanner-agent.mdagents/code-scanner-agent.mdagents/critic-agent.mdagents/dependency-scanner-agent.mdagents/refactoring-agent.mdagents/safe-removal-agent.mdagents/structural-scanner-agent.mdagents/validation-agent.mdreferences/_shared/artifact-contract-template.mdreferences/_shared/before-starting-check.mdreferences/_shared/execution-policy.mdreferences/_shared/manifest-spec.mdreferences/_shared/mode-resolver.mdreferences/_shared/pre-dispatch-protocol.mdreferences/ai-slop-patterns.mdreferences/anti-patterns.mdreferences/examples/cleanup-walkthrough.mdreferences/playbook.mdreferences/pre-dispatch-prompts.mdProductivity — Multi-agent orchestration. Audits and refactors existing code in-place for readability, maintainability, and dead-code removal — without changing behavior. Produces a dated cleanup record.
Core Question: "Is this change purely structural with zero behavioral impact?"
Why this skill exists, methodology, principles, when NOT to refactor, history:
references/playbook.md[PLAYBOOK].
references/anti-patterns.md [ANTI-PATTERN] "When NOT to refactor")./extract-service. clean-code removes dead code and slop; it does not design service boundaries.Before delivering, the critic-agent verifies ALL golden rules pass:
Additional gate: Session limits — target ~30 changes per cleanup session. After 15 changes, generate an interim summary. If each fix spawns 2+ new issues, stop and reassess.
If any golden rule fails: the critic identifies the specific change that violated it and recommends reverting. Never silently bypass — the rules are the safety contract. Full failure-handling flow: references/anti-patterns.md [ANTI-PATTERN] "When the critic FAILs."
Safety supersedes --fast: all 5 rules fire under --fast, single-agent fallback, and dry-run modes (per mode-resolver safety-gates-supersede contract).
Session execution profile (single-vs-multi): inherit per references/_shared/execution-policy.md.
Apply the before-starting-check [PLAYBOOK]:
| Step | Action |
|---|---|
| 0 | Mode resolution — budget: deep. Mode-resolver (references/_shared/mode-resolver.md [PROCEDURE]) auto-downgrades to fast for ≤5-file scopes (→ Single-Agent Fallback in dispatch-mechanics); --fast flag forces single-agent. Safety gates supersede --fast. |
| 1 | Read implementation-roadmap/canonical-paths.md if present — verify output path matches canonical inventory. |
| 2 | Read .forsvn/index/manifest.json for prior cleanup runs against the same scope; surface staleness if recent cleanup already covered this path. |
| 3 | Read docs/forsvn/experience/technical.md for prior conventions notes. |
Run the Pre-Dispatch protocol (references/_shared/pre-dispatch-protocol.md).
Needed dimensions: codebase path, cleanup intent (dead code / unused deps / asset / refactor / mixed), test suite available, conventions to preserve.
Read order: (1) codebase scan — package manifest, test config, lint config, framework hints (CLAUDE.md, .editorconfig); (2) docs/forsvn/experience/technical.md for prior conventions notes.
Warm Start (obvious intent), Cold Start (vague invocation), and write-back rules: references/pre-dispatch-prompts.md [PROCEDURE].
Multi-agent orchestration (8 agents across 2 layers: 4 parallel scanners → safe-removal → refactoring → validation → critic), triage rules, dispatch protocol, routing-rules table, and single-agent fallback: references/procedures/dispatch-mechanics.md [PROCEDURE]. Load at Layer 1 dispatch entry.
For an annotated full-codebase walkthrough (Express API, all 4 scanners + Layer 2 + critic decisions): references/examples/cleanup-walkthrough.md [EXAMPLE].
docs/forsvn/artifacts/meta-clean-code-<YYYY-MM-DD>-cleanup-<slug>.md (flat v2 grammar; re-run same slug same day → append .v[N]). Stack is meta (cleanup records are meta-stack snapshots, like diagnose); skill is in product/ because consumers are product-side.snapshot (dated, immutable record of one cleanup run).skill, version, date, status (DONE / DONE_WITH_CONCERNS / BLOCKED / NEEDS_CONTEXT), stack (=meta), review_surface (=none — snapshot defaults to decision_state: not_required), lifecycle, produced_by, provenance. v2 schema: references/_shared/artifact-contract-template.md.clean-artifacts (scans filenames for staleness), review-work (when reviewing cleanup-touched code), operator (history audit).references/report-template.md [PROCEDURE].Previous: none | Next: none (standalone).
Re-run triggers: after major feature additions, before release milestones, when test runtime grows significantly, when onboarding new team members.
Critic-load reference: references/anti-patterns.md [ANTI-PATTERN]. Re-read before applying any change that smells off — large batch, behavioral side-effect, untested deletion, convention override, generated-code touch. "When NOT to refactor" exit conditions also live there.
Run /review-work for a fresh-eyes quality review on cleanup-touched code.
Every run ends with explicit status:
references/playbook.md [PLAYBOOK] — why, methodology, principles, when NOT to refactor, historyreferences/procedures/dispatch-mechanics.md [PROCEDURE] — agent roster, execution layers, dispatch protocol, routing rules, single-agent fallbackreferences/_shared/{pre-dispatch-protocol, before-starting-check, mode-resolver, artifact-contract-template}.md — canonical shared specsreferences/pre-dispatch-prompts.md [PROCEDURE] — Warm + Cold prompts verbatimreferences/ai-slop-patterns.md — code-scanner pattern catalogreferences/production-waste-patterns.md — asset-scanner pattern catalogreferences/anti-patterns.md [ANTI-PATTERN] — failure modes + When NOT to refactor + When the critic FAILsreferences/report-template.md [PROCEDURE] — artifact frontmatter + section template + filename conventionsreferences/examples/cleanup-walkthrough.md [EXAMPLE] — Express API cleanup end-to-endscripts/analyze_codebase.py — static analysis tool used by structural-scanner, dependency-scanner, asset-scanner (junk files, empty dirs, large dirs, unused code, unused/broken/duplicate assets, unoptimized media)npx claudepluginhub hungv47/meta-skills --plugin forsvn-devAudits codebases to remove dead code, AI slop, and DRY/SOLID violations, restructuring toward simplest correct implementation. Detects stack and applies idiomatic patterns.
Cleans AI-generated code by systematically removing LLM smells like dead code, over-commenting, verbose naming while preserving exact behavior via tests. Use after generation or on 'clean up', 'deslop' requests.
Performs a strict whole-codebase maintainability audit checking structural quality, file sprawl, thin wrappers, leaked logic, and dependency freshness via context7. Pushes code-judo simplification moves and auto-updates docs. For periodic audits alongside per-diff /review.