Skip to content

cleanup

Use when post-implementation cleanup is needed — archiving old docs, scanning for orphaned files, removing debug code, organizing imports, and auditing .claude/ for stale references. Also use after a feature ships or periodically to prevent drift.

ModelSourceCategory
sonnetcoreOther

Context: fork

Full Reference

Post-implementation cleanup to keep the codebase and documentation organized. Run after a feature ships or periodically to prevent drift.

Mandatory Announcement — FIRST OUTPUT before anything else:

┏━ 🔧 cleanup ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ [one-line description of what you're cleaning] ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
ScopeStagesWhen
full (default)All 5 stagesAfter a major feature ships
codeStages 2 + 5Quick code hygiene pass
docsStages 1, 3, 4Documentation sync

Move completed plan/design docs to a dated archive.

  1. Scan .claude/docs/plans/ for docs marked completed or fully implemented
  2. Create archive subfolder: .claude/docs/archive/YYYY-MM/
  3. Move completed docs — preserve original filename, add completion date header
  4. Keep the most recent 2-3 handoff docs accessible

Rules: Never delete — always archive. Preserve filenames.

Find files that no longer serve a purpose.

CheckHow
Orphaned componentsComponents not imported anywhere
Dead test filesTests for removed features
Removed feature filesReferenced in history but no longer needed
Dead importsImport paths that don’t resolve

Report findings — do NOT auto-delete:

▪ `path/to/file` — not imported anywhere
▪ `path/to/test` — tests for removed feature
▸ Delete these? [Y/N]

Verify README accurately reflects the codebase:

  • Project structure matches actual directories
  • Commands listed actually work
  • Dependencies match package.json / pyproject.toml
  • Feature list is current

Do NOT add information that wasn’t there — keep same scope and style.

Check .claude/ configuration matches current codebase:

  • File paths referenced in skills/rules still exist
  • Component/collection counts are accurate
  • Skill descriptions match current behavior
  • Rules don’t reference deleted patterns

Update stale references. Report what changed.

Remove development artifacts and enforce consistency.

ActionDetails
Debug codeRemove console.log, console.debug, debugger. Keep console.error in error handlers.
Unused variablesRun type checker / linter to find. Remove unused imports and vars.
PlaceholdersSearch for TODO, FIXME, HACK, TEMP, XXX. Fix, track, or remove.
Import organizationRun formatter. Verify: external → internal → types.
LintRun project linter with auto-fix. Review semantic changes.
## Cleanup Report
### Archived Documents
▪ [N] docs archived to `.claude/docs/archive/YYYY-MM/`
### Orphaned Files
▪ [N] orphaned files found (see details)
### README Updates
▪ [list of changes]
### .claude Updates
▪ [list of files updated]
### Code Cleanup
▪ [N] debug statements removed
▪ [N] unused variables removed
▪ [N] TODOs addressed
▪ [N] lint issues auto-fixed
Total files modified: [N]
  • NEVER delete files without user confirmation
  • ALWAYS archive rather than delete documents
  • NEVER remove console.error in error handling paths
  • NEVER modify files in node_modules/, .vercel/, dist/
  • NEVER change behavior — only clean up artifacts
MistakeFix
Auto-deleting orphaned filesReport and ask — never auto-delete
Removing console.errorOnly remove console.log/debug — keep error handling
Adding new README contentMatch existing scope — don’t expand
Cleaning during active developmentWait until feature is committed and shipped