with one click
audit-refactoring
Run a single-session refactoring audit on the codebase
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Run a single-session refactoring audit on the codebase
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | audit-refactoring |
| description | Run a single-session refactoring audit on the codebase |
| supports_parallel | true |
| fallback_available | true |
| estimated_time_parallel | 20 min |
| estimated_time_sequential | 60 min |
/audit-refactoringThis audit identifies technical debt related to code structure, duplication, and complexity that requires refactoring. It focuses on five key areas:
When to use this audit:
Scope:
src/, components/, lib/, hooks/node_modules/, dist/, build/, docs/| Condition | Mode | Time |
|---|---|---|
| Task tool available + no context pressure | Parallel | ~20 min |
| Task tool unavailable | Sequential | ~60 min |
| Context running low (<20% remaining) | Sequential | ~60 min |
| User requests sequential | Sequential | ~60 min |
When to use: Task tool available, sufficient context budget
Focus Areas:
Files:
src/**/*.tsx, components/**/*.tsxlib/**/*.ts, hooks/**/*.tswc -l analysisTargets:
Focus Areas:
Files:
Targets:
Focus Areas:
Files:
Targets:
Invoke all 3 agents in a SINGLE Task message:
Task 1: structure-and-duplication agent - audit god objects and code duplication
Task 2: complexity-and-coupling agent - audit cognitive complexity and
architecture violations Task 3: dead-code-and-markers agent - audit tech debt
markers and dead code
Each agent prompt MUST end with:
CRITICAL RETURN PROTOCOL:
- Write findings to the specified output file using Write tool or Bash
- Return ONLY: `COMPLETE: [agent-id] wrote N findings to [output-path]`
- Do NOT return full findings content — orchestrator checks completion via file
Dependency constraints: All 3 agents are independent -- no ordering required. Each writes to a separate JSONL section. Results are merged after all agents complete.
When to use: Task tool unavailable, context limits, or user preference
Execution Order:
Total: ~60 min (vs ~20 min parallel)
{
"started_at": "ISO timestamp",
"categories_completed": ["Complexity", "GodObjects"],
"current_category": "Architecture",
"findings_count": 12,
"last_file_written": "stage-2-findings.jsonl"
}
Step 0: Episodic Memory Search
Before running refactoring audit, search for context from past sessions:
mcp__plugin_episodic_memory_episodic_memory__search({
query: ['refactoring audit', 'god object', 'complexity'],
limit: 5,
});
mcp__plugin_episodic_memory_episodic_memory__search({
query: ['cognitive complexity', 'duplicate code', 'circular'],
limit: 5,
});
Why this matters:
Step 1: Check Thresholds
Run npm run review:check and report results.
Step 2: Gather Current Baselines
Collect these metrics by running commands:
# Circular dependencies (if tool available)
npm run deps:circular 2>&1 || echo "No circular dep tool configured"
# Large files (potential god objects)
find src components lib -name "*.ts" -o -name "*.tsx" 2>/dev/null | xargs wc -l 2>/dev/null | sort -n | tail -20
# Duplicate code patterns
grep -rn "TODO\|FIXME\|HACK" --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l
Step 3: Load False Positives Database
Read docs/technical-debt/FALSE_POSITIVES.jsonl and filter findings matching:
refactoringexpires date passed)Note patterns to exclude from final findings.
Step 4: Check Prior Audit Results
Check docs/audits/single-session/refactoring/ for previous audit results:
Focus Areas (5 Categories):
For each category:
Category Field: All findings MUST use category: "refactoring"
Output Directory: docs/audits/single-session/refactoring/audit-YYYY-MM-DD/
1. Markdown Summary (display to user):
## Refactoring Audit - [DATE]
### Baselines
- Circular dependencies: X
- Files > 300 lines: X
- TODO/FIXME/HACK markers: X
### Findings Summary
| Severity | Count | Category | Confidence |
| -------- | ----- | -------- | ----------- |
| S0 | X | ... | HIGH/MEDIUM |
| S1 | X | ... | HIGH/MEDIUM |
| S2 | X | ... | ... |
| S3 | X | ... | ... |
### Top Refactoring Candidates
1. [file] - X lines, Y responsibilities (S1/E2) - DUAL_PASS_CONFIRMED
2. ...
### False Positives Filtered
- X findings excluded (matched FALSE_POSITIVES.jsonl patterns)
### Quick Wins (E0-E1)
- ...
### Batch Fix Opportunities
- X instances of [pattern] can be auto-fixed
- ...
### Recommendations
- ...
2. JSONL Findings (save to file):
Create file:
docs/audits/single-session/refactoring/audit-[YYYY-MM-DD]/findings.jsonl
Category field: category MUST be refactoring. Also include symbols and
optionally duplication_cluster for duplication findings.
3. Markdown Report (save to file):
Create file:
docs/audits/single-session/refactoring/audit-[YYYY-MM-DD]/REPORT.md
Full markdown report with all findings, baselines, and refactoring plan.
Read
CANON/templates/AUDIT_TEMPLATE.mdfor: Evidence Requirements, Dual-Pass Verification, Cross-Reference Validation, JSONL Output Format, Context Recovery, Post-Audit Validation, MASTER_DEBT Cross-Reference, Interactive Review, TDMS Intake & Commit, Documentation References, Agent Return Protocol, and Honesty Guardrails.
Skill-specific TDMS intake:
node scripts/debt/intake-audit.js <output.jsonl> --source "audit-refactoring-<date>"
Refactoring audit triggers (check AUDIT_TRACKER.md):
| Version | Date | Description |
|---|---|---|
| 1.0 | 2026-02-25 | Initial implementation |
Run a single-session AI optimization audit on the codebase
Run a single-session code review audit on the codebase
Run a single-session engineering productivity audit on the codebase
Run a comprehensive enhancement audit across the entire project - code, product, UX, content, workflows, infrastructure, external services, and meta-tooling.
Run a single-session performance audit on the codebase
Run a comprehensive multi-stage automation audit with parallel agents