/debt-scan — Technical Debt Scanner
Scan the codebase for all known anti-patterns from .claude/rules/anti-patterns*.md files. Produce a report with counts, locations, and trend comparison.
Scan Checklist
Run these Grep searches across src/ and report counts:
General Anti-Patterns
as any— Grep foras anyin*.ts,*.tsx(type safety violation)Record<string, unknown>— Grep forRecord<string, unknown>(untyped payloads)db: any— Grep fordb: any(untyped database)console.log— Grep forconsole.loginsrc/server/(use logger)console.error— Grep forconsole.errorinsrc/server/(use logger)export *— Grep forexport \*(breaks tree-shaking)await import(— Grep forawait import\(insrc/(dynamic imports)
React/Next.js Anti-Patterns
forwardRef— Grep forforwardRef(React 19 doesn't need it)getServerSideProps— Grep forgetServerSideProps(App Router doesn't use it)useContextin tRPC — Grep fortrpc.useContext()(deprecated, use useUtils)
tRPC/Drizzle Anti-Patterns
queryClient.invalidate— Grep forqueryClient.invalidate(use utils.x.invalidate)ctx.dbwithout comment — Grep forctx.dboutside repositories (should use ctx.uow)- Sequential await — Grep for patterns like
await.*\n.*awaitthat could be parallel
Security Anti-Patterns
- Missing ownerId scope — Grep for queries without
ownerIdfilter dangerouslySetInnerHTML— Grep fordangerouslySetInnerHTML
Output Format
After running all scans, produce a summary table:
| # | Anti-Pattern | Count | Files |
|---|-------------|-------|-------|
| 1 | as any | 3 | router.ts, helper.ts, ... |
Save results to .claude/instincts/debt-scan.json:
{
"date": "2026-02-26",
"total_issues": 15,
"by_pattern": { "as_any": 3, "console_log": 5, ... },
"trend": "improving" // compare against previous scan if exists
}
Trend Comparison
If a previous debt-scan.json exists, compare counts and report:
- Patterns that improved (count decreased)
- Patterns that regressed (count increased)
- New patterns detected