Codebase Audit
Core Insight: Different domains need different lenses. A security audit looks for injection; a UX audit looks for confusion. Same codebase, different questions.
When to Use What
| Need |
Skill |
| Find and report domain-specific issues |
codebase-audit (this) |
| Find bugs and fix them iteratively |
multi-pass-bug-hunting |
| Evaluate usability specifically |
ux-audit |
| Make UI visually polished |
ui-polish |
THE EXACT PROMPT
Perform a comprehensive [DOMAIN] audit of this codebase.
Domain: security | ux | performance | api | copy | cli
Return a detailed report with:
- File path and line numbers for each issue
- Severity (Critical/High/Medium/Low)
- Root cause analysis
- Recommended fix
Use the output template and domain checklist from references.
Quick Multi-Domain Sweep
Run quick audits across: security, performance, api
For each domain: top 3 issues only, with severity and fix.
Total output under 100 lines.
Domains at a Glance
| Domain |
Key Question |
Top Signals |
| security |
Can attackers exploit this? |
injection, auth bypass, secrets in code |
| ux |
Is this confusing? |
accessibility, error handling, flows |
| performance |
Is this slow? |
N+1 queries, blocking I/O, missing cache |
| api |
Is this pleasant to consume? |
status codes, error format, pagination |
| copy |
Is this clear? |
jargon, tone, error messages |
| cli |
Is this discoverable? |
--help, exit codes, progress feedback |
Full checklists: CHECKLISTS.md
Output Template
# [Domain] Audit Report: [Project]
## Summary
- **Total:** N findings
- **Critical:** X | **High:** Y | **Medium:** Z | **Low:** W
## Critical Findings
### [Title]
- **Location:** `file.rs:42`
- **Issue:** [What's wrong]
- **Root Cause:** [Why]
- **Fix:** [Solution]
## High / Medium / Low
[Same format, decreasing detail]
Severity
| Level |
Criteria |
Example |
| Critical |
Exploitable now, data loss |
SQL injection, unauth admin |
| High |
Serious, harder to exploit |
CSRF missing, N+1 on hot path |
| Medium |
Real issue, limited scope |
Missing validation, vague errors |
| Low |
Polish, best practice |
Naming inconsistency, missing docs |
codebase-audit vs multi-pass-bug-hunting
| Aspect |
codebase-audit |
multi-pass-bug-hunting |
| Goal |
Find and report |
Find and fix |
| Output |
Severity-rated report |
Fixed code |
| Loop |
One-shot exploration |
Iterative convergence |
| Domains |
Parameterized by domain |
Generic bugs |
| Use case |
Assessment, planning |
Pre-release hardening |
Workflow Integration
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ codebase-audit │────▶│ Create beads for │────▶│ multi-pass-bug │
│ (find + report) │ │ critical issues │ │ hunting (fix) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
# After audit, create issues
br create --title="[Security] SQL injection in user_search" \
--type=bug --priority=0 --body="Found at src/search.rs:42"
Quick Grep Patterns
Security
rg -n "unwrap\(\)|panic!" --type rust # Rust panics
rg -n "eval\(|exec\(" --type js --type py # Code injection
rg -n "password|secret|api_key" --type-not lock # Hardcoded secrets
Performance
rg -n "for.*await|\.await.*for" --type rust # Async in loops
rg -n "SELECT.*FROM.*WHERE" | grep -v "LIMIT" # Unbounded queries
CLI
./tool --help | head -20 # Help exists?
./tool --unknown 2>&1; echo "Exit: $?" # Error handling
More patterns: TOOLS.md
Anti-Patterns
| Don't |
Do |
| "code is bad" |
Specific file:line + fix |
| Mix severities |
Group by impact |
| Audit everything at once |
One domain, deep |
| Skip root cause |
Explain WHY, not just WHAT |
| Report-only |
Create issues for criticals |
References
| Topic |
File |
| Full domain checklists |
CHECKLISTS.md |
| Example audit reports |
EXAMPLES.md |
| Tool commands by domain |
TOOLS.md |
1---2name: codebase-audit3description: >-4 Domain-parameterized codebase auditing (security, UX, performance, API, copy, CLI).5 Use when auditing code, assessing quality, finding issues, or pre-launch review.6---78<!-- TOC: Core | Prompt | Domains | Output | Severity | Integration | Anti-Patterns | References -->910# Codebase Audit1112> **Core Insight:** Different domains need different lenses. A security audit looks for injection; a UX audit looks for confusion. Same codebase, different questions.1314## When to Use What1516| Need | Skill |17|------|-------|18| Find and **report** domain-specific issues | **codebase-audit** (this) |19| Find bugs and **fix them iteratively** | multi-pass-bug-hunting |20| Evaluate **usability** specifically | ux-audit |21| Make UI **visually polished** | ui-polish |2223---2425## THE EXACT PROMPT2627```28Perform a comprehensive [DOMAIN] audit of this codebase.2930Domain: security | ux | performance | api | copy | cli3132Return a detailed report with:33- File path and line numbers for each issue34- Severity (Critical/High/Medium/Low)35- Root cause analysis36- Recommended fix3738Use the output template and domain checklist from references.39```4041### Quick Multi-Domain Sweep4243```44Run quick audits across: security, performance, api4546For each domain: top 3 issues only, with severity and fix.47Total output under 100 lines.48```4950---5152## Domains at a Glance5354| Domain | Key Question | Top Signals |55|--------|--------------|-------------|56| **security** | Can attackers exploit this? | injection, auth bypass, secrets in code |57| **ux** | Is this confusing? | accessibility, error handling, flows |58| **performance** | Is this slow? | N+1 queries, blocking I/O, missing cache |59| **api** | Is this pleasant to consume? | status codes, error format, pagination |60| **copy** | Is this clear? | jargon, tone, error messages |61| **cli** | Is this discoverable? | --help, exit codes, progress feedback |6263Full checklists: [CHECKLISTS.md](references/CHECKLISTS.md)6465---6667## Output Template6869```markdown70# [Domain] Audit Report: [Project]7172## Summary73- **Total:** N findings74- **Critical:** X | **High:** Y | **Medium:** Z | **Low:** W7576## Critical Findings7778### [Title]79- **Location:** `file.rs:42`80- **Issue:** [What's wrong]81- **Root Cause:** [Why]82- **Fix:** [Solution]8384## High / Medium / Low85[Same format, decreasing detail]86```8788---8990## Severity9192| Level | Criteria | Example |93|-------|----------|---------|94| **Critical** | Exploitable now, data loss | SQL injection, unauth admin |95| **High** | Serious, harder to exploit | CSRF missing, N+1 on hot path |96| **Medium** | Real issue, limited scope | Missing validation, vague errors |97| **Low** | Polish, best practice | Naming inconsistency, missing docs |9899---100101## codebase-audit vs multi-pass-bug-hunting102103| Aspect | codebase-audit | multi-pass-bug-hunting |104|--------|----------------|------------------------|105| **Goal** | Find and **report** | Find and **fix** |106| **Output** | Severity-rated report | Fixed code |107| **Loop** | One-shot exploration | Iterative convergence |108| **Domains** | Parameterized by domain | Generic bugs |109| **Use case** | Assessment, planning | Pre-release hardening |110111---112113## Workflow Integration114115```116┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐117│ codebase-audit │────▶│ Create beads for │────▶│ multi-pass-bug │118│ (find + report) │ │ critical issues │ │ hunting (fix) │119└─────────────────┘ └──────────────────┘ └─────────────────┘120```121122```bash123# After audit, create issues124br create --title="[Security] SQL injection in user_search" \125 --type=bug --priority=0 --body="Found at src/search.rs:42"126```127128---129130## Quick Grep Patterns131132### Security133```bash134rg -n "unwrap\(\)|panic!" --type rust # Rust panics135rg -n "eval\(|exec\(" --type js --type py # Code injection136rg -n "password|secret|api_key" --type-not lock # Hardcoded secrets137```138139### Performance140```bash141rg -n "for.*await|\.await.*for" --type rust # Async in loops142rg -n "SELECT.*FROM.*WHERE" | grep -v "LIMIT" # Unbounded queries143```144145### CLI146```bash147./tool --help | head -20 # Help exists?148./tool --unknown 2>&1; echo "Exit: $?" # Error handling149```150151More patterns: [TOOLS.md](references/TOOLS.md)152153---154155## Anti-Patterns156157| Don't | Do |158|-------|-----|159| "code is bad" | Specific `file:line` + fix |160| Mix severities | Group by impact |161| Audit everything at once | One domain, deep |162| Skip root cause | Explain WHY, not just WHAT |163| Report-only | Create issues for criticals |164165---166167## References168169| Topic | File |170|-------|------|171| Full domain checklists | [CHECKLISTS.md](references/CHECKLISTS.md) |172| Example audit reports | [EXAMPLES.md](references/EXAMPLES.md) |173| Tool commands by domain | [TOOLS.md](references/TOOLS.md) |