pjt222/agent-almanac/clean-codebase
- community
Checking that the SKILL.md file is still in the repository.
Remove dead code, unused imports, fix lint warnings, and normalize formatting across a codebase without changing business logic or architecture. Use when lint warnings have piled up during rapid development, unused imports and variables clutter files, dead code paths were never removed, formatting is inconsistent, or static analysis tools report fixable hygiene issues.
Install
npx vskill@latest install pjt222/agent-almanac/clean-codebaseSKILL.md
clean-codebase
Cuándo Usar
Use this skill when a codebase has accumulated hygiene debt:
- Lint warnings have piled up during rapid development
- Unused imports and variables clutter files
- Dead code paths exist but were never removed
- Formatting is inconsistent across files
- Static analysis tools report fixable issues
Do NOT use for architectural refactoring, bug fixes, or business logic changes. This skill focuses purely on hygiene and automated cleanup.
Entradas
| Parameter | Type | Required | Description | |
|---|---|---|---|---|
codebase_path | string | Yes | Absolute path to codebase root | |
language | string | Yes | Primary language (js, python, r, rust, etc.) | |
cleanup_mode | enum | No | safe (default) or aggressive | |
run_tests | boolean | No | Run test suite after cleanup (default: true) | |
backup | boolean | No | Create backup before deletion (default: true) |
Procedimiento
Paso 1: Pre-Cleanup Assessment
Measure the current state to quantify improvements later.
Esperado: Baseline metrics saved to lint_before.json and cloc_before.json
En caso de fallo: If lint tool not found, skip automated fixes and focus on manual review
Paso 2: Fix Automated Lint Warnings
Apply safe automated fixes (spacing, quotes, semicolons, trailing whitespace).
JavaScript/TypeScript:
Python:
R:
Rust:
Esperado: All safe lint warnings resolved; files formatted consistently
En caso de fallo: If automated fixes introduce test failures, revert changes and escalate
Paso 3: Identify Dead Code Paths
Use static analysis to find unreferenced functions, unused variables, and orphaned files.
JavaScript/TypeScript:
Python:
R:
General approach:
- Grep for function definitions
- Grep for function calls
- Report functions defined but never called
Esperado: dead_code.txt lists unused functions, variables, and files
En caso de fallo: If static analysis tool unavailable, manually review recent commit history for orphaned code
Paso 4: Remove Unused Imports
Clean up import blocks by removing references to packages never used.
JavaScript:
Python:
R:
Esperado: All unused import statements removed
En caso de fallo: If removing imports breaks build, they were used indirectly — restore and document
Paso 5: Remove Dead Code (Mode-Dependent)
Safe Mode (default):
- Only remove code explicitly marked as deprecated
- Remove commented-out code blocks (if >10 lines and >6 months old)
- Remove TODO comments referencing completed issues
Aggressive Mode (opt-in):
- Remove all functions identified as unused in Step 3
- Remove private methods with zero references
- Remove feature flags for deprecated features
For each candidate deletion:
- Verify zero references in codebase
- Check git history for recent activity (skip if modified in last 30 days)
- Remove code and add entry to
CLEANUP_LOG.md
Esperado: Dead code removed; CLEANUP_LOG.md documents all deletions
En caso de fallo: If uncertain whether code is truly dead, move to archive/ directory instead
Paso 6: Normalize Formatting
Ensure consistent formatting across all files (even if not caught by linters).
- Normalize line endings (LF vs CRLF)
- Ensure single newline at end of file
- Remove trailing whitespace
- Normalize indentation (spaces vs tabs, indent width)
Esperado: All files follow consistent formatting conventions
En caso de fallo: If sed breaks binary files, skip and document
Paso 7: Run Tests
Validate that cleanup didn't break functionality.
Esperado: All tests pass (or same failures as before cleanup)
En caso de fallo: Revert changes incrementally to identify breaking change, then escalate
Paso 8: Generate Cleanup Report
Document all changes for review.
Esperado: Report saved to CLEANUP_REPORT.md in project root
En caso de fallo: (N/A — generate report regardless of outcome)
Validación
After cleanup:
- [ ] All tests pass (or same failures as before)
- [ ] No new lint warnings introduced
- [ ] Backup created before any deletions
- [ ]
CLEANUP_LOG.mddocuments all removed code - [ ] Cleanup report generated with metrics
- [ ] Git diff reviewed for unexpected changes
- [ ] CI pipeline passes
Errores Comunes
- Removing Code Still Used via Reflection: Static analysis misses dynamic calls (e.g.,
eval(), metaprogramming). Always check git history.
- Breaking Implicit Dependencies: Removing imports that were used by dependencies. Run tests after every import removal.
- Deleting Feature Flags for Active Features: Even if unused in current branch, feature flags may be active in other environments. Check deployment configs.
- Over-Aggressive Formatting: Tools like
blackorprettiermay reformat code in ways that trigger unnecessary diffs. Configure tools to match project style.
- Ignoring Test Coverage: Cannot safely clean codebases without tests. If coverage is low, escalate for test additions first.
- Not Backing Up: Always create
backup_YYYYMMDD/directory before deleting anything, even if using git.
- Wrong R binary on hybrid systems: On WSL or Docker,
Rscriptmay resolve to a cross-platform wrapper instead of native R. Check withwhich Rscript && Rscript --version. Prefer the native R binary (e.g.,/usr/local/bin/Rscripton Linux/WSL) for reliability. See Setting Up Your Environment for R path configuration.
Habilidades Relacionadas
- tidy-project-structure — Organize directory layout, update READMEs
- repair-broken-references — Fix dead links and imports
- escalate-issues — Route complex problems to specialists
- r-packages/run-r-cmd-check — Run full R package checks
- devops/dependency-audit — Check for outdated dependencies
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingi18n/es/skills/clean-codebase/SKILL.md
Popularity
- Repository stars
- 20
- Repository forks
- 2
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pjt222/agent-almanac/clean-codebase)