---
description: Audit codebase for systemic tech debt - inconsistent patterns that should be unified
argument-hint: <category, e.g., "error-handling", "logging", "api-calls", "auth", or "all">
allowed-tools: Task, Read, Write, Edit, Glob, Grep, Bash
---

Audit for systemic tech debt: $ARGUMENTS

## Instructions

Load the `systemic-debt-auditor` skill, then:

### If "all" or no category:

High-level scan:

```markdown
| Category | Variations | Worst Issue | Priority |
|----------|------------|-------------|----------|
| Error Handling | 4 patterns | unwrap in prod | HIGH |
| Logging | 3 patterns | println debug | MEDIUM |
```

Then ask which to deep dive.

### If specific category:

1. **Survey** - Find all variations with grep
2. **Categorize** - Document each pattern
3. **Identify canonical** - Best existing pattern
4. **Risk assess** - CRITICAL > HIGH > MEDIUM > LOW
5. **Propose plan** - Incremental unification

## Quick Reference

### Error Handling (Go)
```bash
grep -rn "panic(" --include="*.go" | wc -l
grep -rn "log.Fatal" --include="*.go" | wc -l
grep -rn "if err != nil" --include="*.go" | wc -l
```

### Logging
```bash
grep -rn "fmt.Print" --include="*.go" | wc -l
grep -rn "slog\.\|log\." --include="*.go" | wc -l
```

## Output Requirements

1. Patterns found with counts
2. Canonical pattern recommendation
3. Risk assessment table
4. Unification plan (stop bleeding → fix critical → gradual cleanup)
5. Enforcement mechanism
