skills/code-audit/SKILL.md
Structural health assessment for codebases. Use when the user asks to audit code quality, assess code health, review a codebase, find technical debt, clean up code structure, or identify refactoring opportunities. Also use when asked to do a "code audit", "codebase review", "quality assessment", or "tech debt analysis". Provides parallel multi-lens analysis via sub-agents with specialized checklists for code health, cross-module coherence, refactoring detection, and security.
npx skillsauth add pietz/skills code-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Multi-lens audit system that uses parallel sub-agents with directed checklists to assess the structural health of a codebase. Built on research showing that LLMs find significantly more issues when given specific, scoped checklists than when asked to "review thoroughly" (BitsAI-CR: 75% precision with structured rules; ECSA: 64%→82% precision with prompt detail; SWRBench: +43.67% F1 with multi-review aggregation).
Cost note: Token and runtime cost scales with scope and the number of active lenses. For large repositories, narrow the audit scope before running.
Model note: This skill performs deep analytical work. Use the most capable model available.
| User Request | Workflow | |---|---| | "Audit this codebase / module / directory" | Codebase Audit — Three-phase lens analysis below | | "Assess code quality / code health" | Codebase Audit — Same workflow | | "Refactor this code" | Refactoring — Read references/refactoring-guide.md and follow that workflow |
Before starting: Inform the user that a multi-lens code audit is a thorough, multi-step process that will consume a significant number of tokens. Confirm the audit scope (which directory, module, or repo) and proceed only after the user acknowledges.
{repo_path}).{skill_dir}) — provided when the skill is loaded.{repo_path}/.audit/Spawn a scout sub-agent to map the codebase. The scout reads files and produces a structured codemap — the orchestrator does not read source files itself.
Dispatch via Task tool:
Read your instructions at {skill_dir}/phases/phase-1-scout.md.
Target repository: {repo_path}
Audit focus: {user_focus or "general structural health assessment"}
Create the directory {repo_path}/.audit/ if it doesn't exist.
Write your output to:
- {repo_path}/.audit/codemap.md
- {repo_path}/.audit/static-analysis.md
Wait for the scout to complete before proceeding.
Always run: Code Health, Cross-Module Coherence, Refactoring Opportunities, Security/Performance (Lenses 1-4).
Correctness (Lens 5) is not included by default. This skill focuses on structural health assessment — line-level correctness checking is the domain of tests, type checkers, and change-level review tools. Only include the correctness lens when the user explicitly requests it.
| # | Lens | Reference File | Role | |---|------|---------------|------| | 1 | Code Health & Conventions | lens-code-health.md | Primary — structural quality | | 2 | Cross-Module Coherence | lens-cross-module.md | Primary — the differentiator | | 3 | Refactoring Opportunities | lens-refactoring.md | Primary — structural debt | | 4 | Security & Performance | lens-security-performance.md | Standard | | 5 | Correctness & Logic | lens-correctness.md | Opt-in (user request only) |
Launch all active lenses simultaneously in a single message using the Task tool. Each lens receives a minimal prompt — the lens reads its own instructions and the codemap from disk.
Per-lens prompt:
You are performing a focused code audit.
Read your lens instructions at {skill_dir}/references/lens-{name}.md.
Read the codemap at {repo_path}/.audit/codemap.md.
Read static analysis output at {repo_path}/.audit/static-analysis.md (if it exists).
Target repository: {repo_path}
Audit focus: {user_focus or "general structural health assessment"}
Write your findings to {repo_path}/.audit/lens-{name}.md.
If you find no issues, write that explicitly to the output file.
Wait for all lenses to complete before proceeding to Phase 3.
.audit/lens-*.md files.Merge findings from all lenses. If two lenses flag the same location for the same underlying issue, merge — keep the more detailed evidence and the higher severity.
Group findings into themes based on the underlying issue pattern. Examples:
Each theme group should include:
Map each finding to the priority scale:
| Priority | Criteria | |---|---| | P0 (Critical) | Security vulnerabilities, data loss risk, broken core functionality, crashes in production paths | | P1 (High) | Logic bugs, broken contracts, inconsistent interfaces, missing call site updates, regression risk | | P2 (Medium) | Convention violations, duplication clusters, missing tests, incomplete error handling, performance concerns | | P3 (Low) | Style suggestions, minor optimization, refactoring opportunities that aren't urgent |
Severity gating: P0 and P1 findings require either tool confirmation (static analysis, type checker, build error) or concrete code evidence with a specific failure path. If a finding can't meet this bar, downgrade to P2 or move to Questions.
For each finding, also assess:
Write the final report to {repo_path}/.audit/report.md using this format:
## Theme: [Theme title]
**Remediation path:** [Brief description of how to address this theme]
**Estimated effort:** low / medium / high
### P[0-3]: [Finding title]
**Priority:** P0/P1/P2/P3 | **Complexity:** low/medium/high | **Validity:** low/medium/high
**Location:** `file:line`
**Evidence:** [specific code observation]
**Impact:** [what goes wrong or what's at risk]
**Suggestion:** [concrete fix or investigation step]
**Validation:** [specific tests, checks, or CI steps to verify the fix]
Order: themes by highest-priority finding first. Within each theme, P0 → P3. Within same priority, high validity first.
Include a Questions section for uncertain items:
## Questions
1. **[Question]** at `file:line` — [why this is unclear and what would resolve it]
End with the Structural Health Summary:
## Structural Health Summary
### Overall Assessment
[1-2 sentence diagnosis of the codebase's structural health]
### Top Systemic Issues
1. [Most impactful structural problem — what it is, why it matters, what to do]
2. [Second most impactful]
3. [Third most impactful]
### Findings Overview
| Priority | Count |
|----------|-------|
| P0 | N |
| P1 | N |
| P2 | N |
| P3 | N |
**Lenses applied:** [list which ran] | **Scope:** [what was audited]
### Coverage
[Sourced from the codemap's coverage notes — what was examined, what wasn't]
### Recommended Next Steps
[Ordered list of what to tackle first, considering priority x effort x blast radius]
After writing the report, present a concise summary to the user:
.audit/report.md"Watch for these during synthesis and verification:
| Blind Spot | What Happens | Mitigation | |---|---|---| | Invisible coupling | Modules appear independent but share implicit contracts via shared state, config, or conventions | Scout dependency map + cross-module lens | | Duplication creep | Same logic reimplemented across modules instead of using shared utilities | Scout utility inventory + code health lens | | Plausible code | Code looks right but is semantically wrong or subtly inconsistent | Cross-module contract checks + static analysis. For deeper analysis, request the correctness lens. | | Convention drift | Different parts of the codebase follow different conventions that evolved over time | Scout convention fingerprint + code health lens | | Partial migrations | Old and new patterns coexist with no clear boundary or completion path | Cross-module migration completeness checks | | Security regression | A "redundant" check was a security guard; removing it creates a vulnerability | Security lens explicit checklist | | Architectural violation | Imports cross layer boundaries the project doesn't allow | Cross-module dependency direction checks |
For refactoring tasks (executing changes after an audit identifies opportunities), read the detailed guide: references/refactoring-guide.md
Key concepts:
development
Finish a build session by shipping the work. Ensure tests exist and pass, validate the functionality, spawn a fresh-eyes subagent review when the change is large or risky, then commit and push to main. Use when the user says "ship", "ship it", "wrap this up and push", "test, commit and push", or otherwise wants the session's changes tested, reviewed, committed, and pushed.
development
Search YouTube and read video transcripts from the command line. Use this whenever the user wants to find YouTube videos or channels, answer a question using knowledge from YouTube videos, get/read/summarize a video's transcript or captions, or find where in a video something is discussed. Also consider this skill for general purpose research, since YouTube is a rich source of information.
development
Create visual documents (presentations, flyers, brochures, posters) by generating HTML/CSS and converting to PDF via headless Chromium. Use this skill when the user wants to create slides, presentations, pitch decks, flyers, brochures, or posters.
development
Find and remove incidental architectural complexity in an existing codebase — structure that accreted through many locally-reasonable edits until the whole became more complex than the problem warrants. Preserves what the software does for its callers while simplifying how it's built. NOT for bug fixes, feature work, formatting/style cleanup, or refactors whose change is already obvious.