Agent skill
scan-codebase-health
[Documentation] Detect codebase health issues: unused exports, doc count-drift, orphan files, stale config references. Generic — reads project structure from project-config.json dynamically.
Install this agent skill to your Project
npx add-skill https://github.com/duc01226/EasyPlatform/tree/main/.claude/skills/scan-codebase-health
SKILL.md
[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting.
Quick Summary
Goal: Detect structural rot in AI-assisted codebases — dead code, count-drift, orphan files, stale configs. Works on any project via docs/project-config.json.
Workflow:
- Read Config — Load
docs/project-config.jsonfor source paths, doc paths, config patterns - Run Detections — Execute 5 detection categories (graph-dependent checks skipped if no graph.db)
- Generate Report — Write findings to
plans/reports/codebase-health-scan-{YYMMDD}.md - Present Summary — Show actionable findings with severity levels
Key Rules:
- Generic — reads all paths from project-config.json, never hardcodes project names
- Graceful degradation — graph-dependent checks skipped if
.code-graph/graph.dbnot found - Report format — each finding has file path, category, severity (HIGH/MEDIUM/LOW), suggested action
Scan Codebase Health
Phase 0: Read Configuration
Read docs/project-config.json for the codebaseHealth section:
{
"codebaseHealth": {
"sourcePaths": ["src/"],
"docPaths": ["docs/"],
"configPatterns": ["**/appsettings*.json", "**/environment*.ts"],
"excludePaths": ["node_modules", "dist", "bin", "obj"]
}
}
If codebaseHealth section is missing, use defaults: sourcePaths: ["src/"], docPaths: ["docs/"], configPatterns: [], excludePaths: ["node_modules", "dist", "bin", "obj"].
Phase 1: Doc Count-Drift Detection (No Graph Required)
Scan docs/ for numeric claims like "N files", "N tests", "N hooks", "N services", "N skills".
For each claim found:
- Extract the number and what it counts
- Glob/grep to verify the actual count
- Flag if actual differs from claimed (drift)
Example: Doc says "133 markdown files" → glob docs/**/*.md → actual is 135 → flag as MEDIUM drift.
Phase 2: Stale Config Reference Detection (No Graph Required)
For each file matching configPatterns:
- Extract class names, module names, or connection strings referenced
- Grep codebase to verify each reference still exists
- Flag missing references as HIGH severity
Phase 3: Unused Exports Detection (Graph Required)
Skip if .code-graph/graph.db does not exist.
For key exported symbols in source files:
- Run
python .claude/scripts/code_graph query importers_of <symbol> --json - Flag symbols with zero importers as MEDIUM severity
- Focus on public API surface (exported classes, functions, constants)
Phase 4: Orphan File Detection (Graph Required)
Skip if .code-graph/graph.db does not exist.
Find source files (.ts, .cs, .py, etc.) with zero inbound edges:
- Run
python .claude/scripts/code_graph query importers_of <file> --json - Flag files with zero importers as LOW severity (may be entry points)
- Exclude known entry points (main files, test files, config files)
Phase 5: Pattern Drift Detection (No Graph Required)
Compare the same pattern across services/modules:
- Pick a pattern (e.g., repository registration, service configuration)
- Grep across all services/modules
- Flag inconsistencies as MEDIUM severity
Phase 6: Generate Report
Write to plans/reports/codebase-health-scan-{YYMMDD}.md:
# Codebase Health Scan Report
**Date:** {YYYY-MM-DD}
**Categories Scanned:** {N}/5
**Findings:** {total} ({HIGH} high, {MEDIUM} medium, {LOW} low)
## Summary
| Category | Status | Findings |
| ----------------- | --------------- | ---------- |
| Doc Count-Drift | Scanned | N findings |
| Stale Config Refs | Scanned | N findings |
| Unused Exports | Scanned/Skipped | N findings |
| Orphan Files | Scanned/Skipped | N findings |
| Pattern Drift | Scanned | N findings |
## Findings
### HIGH Severity
- {file}: {description} — Suggested action: {action}
### MEDIUM Severity
- {file}: {description} — Suggested action: {action}
### LOW Severity
- {file}: {description} — Suggested action: {action}
Closing Reminders
- MUST break work into small todo tasks using
TaskCreateBEFORE starting - MUST search codebase for 3+ similar patterns before creating new code
- MUST cite
file:lineevidence for every claim (confidence >80% to act) - MUST add a final review todo task to verify work quality
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
fix-parallel
[Implementation] Analyze & fix issues with parallel fullstack-developer agents
ask
[Utilities] Answer technical and architectural questions.
claude-code
[Utilities] Claude Code CLI setup, configuration, troubleshooting, and feature guidance. Triggers on claude code setup, hook not firing, MCP connection, context limit, skill creation, slash command setup.
workflow-deployment
[Workflow] Trigger Deployment & Infrastructure workflow — CI/CD pipelines, Docker, Kubernetes setup and deployment.
workflow-idea-to-pbi
[Workflow] Trigger Idea to PBI workflow — po/ba workflow: capture idea, refine to pbi, create stories, prioritize.
easy-claude-help
[Utilities] Configuration guide for the easy-claude framework — explain settings, guide users through configuring .ck.json.
Didn't find tool you were looking for?