Audit
This skill provides two modes:
- Branch audit (default) — a pre-push review of the branch diff, checking 8
categories and producing a Clean/Minor/Blocking verdict.
- Deep-dive audits — project-wide analyses that use sub-agents to examine
code quality, documentation brittleness, security, or UI design in depth.
If the user says "audit" without further context and there's a branch with changes,
run the branch audit. If they ask for something specific (e.g., "audit for security
vulnerabilities", "check our docs", "review the UI"), run the relevant deep-dive.
They can also request multiple audits at once.
Branch Audit
Step 1: Gather context
Determine the base branch (main, master, or the upstream tracking branch), then:
- Run
git diff <base>...HEAD to get the full branch diff
- Run
git diff and git diff --cached for any uncommitted/staged changes
- Run
git log --oneline <base>..HEAD to see the commit list
- Note which files changed and what the branch is trying to accomplish
Start your report with a brief branch summary: branch name, base, number of
commits, and a one-sentence description of the purpose of the changes.
Step 2: Audit each category
Work through each category below. Report only categories that have findings — omit
categories with nothing to report (don't include "No findings" sections).
Each finding should appear once. If something could fit multiple categories, put it
in the most relevant one and don't repeat it elsewhere.
For every reported finding, require objective evidence from the inspected diff or
repo. Evidence can be a file/line, symbol, command output, or a short redacted code
snippet. Do not report a suspicion just because a filename, dependency, quoted text,
or test fixture looks risky. First decide whether there is a concrete source,
affected sink/path, and user or release impact.
If an obvious-looking decoy is in scope and could be mistaken for a bug (fake test
secret, quoted TODO in docs, lockfile paired with dependency change, safe
parameterized query, toy repo with no attack surface), either omit it or briefly
call it out under Not findings with the evidence that clears it. Do not assign
severity to non-findings.
Secrets and credentials
Check this first — it's the most critical category.
- API keys, tokens, passwords, connection strings in the diff
- Private keys or certificates
.env files or equivalents staged for commit
- Hard-coded URLs pointing to internal/staging environments
When reporting secrets findings, never include the actual secret value in your
output. Redact credentials to show only enough to identify the location — e.g.,
"API key sk_live_...7dc found at src/config.py:42". The whole point of flagging
secrets is to prevent exposure; echoing them in the report would defeat that purpose.
Unintended changes
- Files modified that don't relate to the branch's purpose (infer the purpose from
the branch name, commit messages, and the bulk of the diff)
- Formatting-only diffs in files the branch didn't otherwise need to touch
- Changes to generated files (lock files are fine if dependencies changed)
Be specific: name each file you think is unrelated and explain why.
Debug artifacts
console.log, debugger, print(), pp, binding.pry, dbg! left in
production code (test files are fine)
- Commented-out code blocks (small explanatory comments are fine)
TODO, FIXME, HACK, XXX introduced in this branch
Test coverage
- New or modified production code without corresponding test changes
- Skipped or disabled tests (
.skip, @pytest.mark.skip, #[ignore])
- Test files that import but don't exercise new code paths
Build and suite
Try to run the project's test suite, linter, and type checker. If the project
doesn't have the tooling set up, or dependencies aren't installed, note that and
move on — don't spend time troubleshooting environment issues. Report what you can.
Commit hygiene
- Commit messages that don't follow the project's conventions
- Fixup commits that should be squashed
- Commits containing unrelated changes that should be split
Integration check
- New modules that aren't imported anywhere
- New routes or endpoints that aren't registered
- New migrations that aren't referenced
- New dependencies that are imported but not declared in the project's dependency file
Merge conflicts and rebase state
- Unresolved conflict markers (
<<<<<<<, =======, >>>>>>>)
- Stale branch: base branch has moved significantly since branch point
Evidence and severity rules
Before assigning severity, separate Confirmed findings, Suspected needs
verification, and Not findings:
- Confirmed findings need concrete evidence, impact, and an actionable fix.
- Suspected items may be mentioned only when the evidence is incomplete; say what
to inspect next and do not inflate them to Blocking.
- Not findings are decoys cleared by evidence and should not be counted in the
verdict.
Severity calibration for branch audits:
- Blocking — likely unsafe to push/release: leaked credentials, unresolved
conflict markers, production debug artifacts, skipped/disabled tests or missing
tests for changed production behavior, reachable security vulnerabilities,
unregistered claimed features, likely data loss, or concurrency/resource bugs
with a plausible failure path.
- Minor — low-risk cleanup or hygiene: TODO/FIXME comments, commit hygiene,
small docs-code drift, or integration issues without immediate user impact.
- Clean — no confirmed actionable findings after checking the requested scope.
For deep-dive security reports, use Critical/High/Medium/Low for each finding, but
when summarizing a pre-push branch still map the overall verdict to
Clean/Minor/Blocking. Always explain the severity with the evidence path, not just
the category name.
Step 3: Verdict
End with a summary table of confirmed findings (file, line, issue, severity) and
one of these verdicts:
- Clean — no findings, safe to push
- Minor — cosmetic or low-risk issues found (list them), push at your discretion
- Blocking — issues that should be fixed before pushing (list them)
If the user asks you to fix any findings, fix them. Otherwise, just report.
Deep-Dive Audits
Each deep-dive audit should be delegated to a sub-agent so it can explore the
codebase thoroughly without bloating the main conversation. Launch them in parallel
when multiple are requested. Each sub-agent should produce a written report saved
to a file, then summarize the key findings back to the user.
Code quality audit
Spawn a sub-agent to audit the project for:
- Duplication — repeated logic, copy-pasted code blocks, near-identical
functions or components that could be consolidated
- Internal inconsistency — naming conventions that vary across files, mixed
patterns (e.g., callbacks in some places, promises in others), conflicting
approaches to the same problem
- Simplification and subtraction — dead code, unused exports, over-abstracted
layers that add indirection without value, features or config that nobody uses.
The goal is to identify things that can be removed or simplified. Less code is
better code — every line is a liability.
The report should group findings by theme (not by file) and suggest concrete actions.
Documentation brittleness audit
Spawn a sub-agent to audit documentation (READMEs, doc comments, guides, wikis,
SKILL.md files, onboarding docs) for:
- Fragile references — line numbers, specific function signatures, or exact
file paths that will break when code changes. Prefer linking to symbols, sections,
or concepts instead.
- Over-specified details — documentation that mirrors the code so closely that
any refactor makes the docs wrong. Good docs explain why and how to use,
not what each line does.
- Staleness risk — instructions that reference specific versions, temporary
workarounds, or "current" states that will age poorly. Flag anything that reads
like it was written for a moment in time rather than for the long term.
The report should recommend specific rewrites, not just flag problems.
Documentation–code sync audit
Spawn a sub-agent to verify that documentation actually matches the current state
of the code. The brittleness audit (above) asks whether docs will break — this
one asks whether they already have.
- API docs vs implementation — do documented endpoints, parameters, return
types, and error codes match what the code actually does? Check REST routes,
GraphQL schemas, CLI flags, library APIs.
- Setup and install instructions — do the steps in the README or getting-started
guide actually work? Are prerequisites listed correctly? Are environment variables
documented that the code actually reads?
- Architecture descriptions — do diagrams or written descriptions of the system
architecture reflect the current module structure, data flow, and dependencies?
Flag components described in docs that no longer exist, and components in code
that docs don't mention.
- Config and feature flags — are all configuration options documented? Are there
documented options that the code no longer reads, or code that reads undocumented
config?
- Examples and code snippets — do inline examples in docs compile/run against
the current codebase? Flag examples that use deprecated APIs or deleted functions.
For each discrepancy, show the doc excerpt and the conflicting code side by side,
and recommend which one should change.
Language best practices audit
Spawn a sub-agent to review the codebase against idiomatic best practices for
each programming language used in the project. The agent should first identify
which languages are present, then check each against its community standards:
- Python — PEP 8 style, type hints on public APIs, context managers for
resources, dataclasses/attrs over raw dicts, avoiding mutable default arguments,
proper use of
__init__.py, virtual environments
- JavaScript/TypeScript — strict mode,
const/let over var, async/await
over raw promises, proper error handling in async code, avoiding any in TS,
ESM over CommonJS where appropriate
- Go — error handling (no ignored errors), proper use of goroutines and channels,
effective Go naming conventions, avoiding package-level state, using
context.Context
- Rust — ownership patterns, avoiding unnecessary
clone(), proper error types
over unwrap(), using clippy suggestions, derive macros for common traits
- Java/Kotlin — null safety, resource management (try-with-resources), immutable
collections where possible, avoiding raw types, proper logging frameworks
- Ruby — Ruby style guide conventions, frozen string literals, proper use of
blocks/procs/lambdas, avoiding monkey-patching in production code
- Shell —
set -euo pipefail, quoting variables, avoiding eval, using shellcheck
patterns
Only audit languages actually present in the project. The report should distinguish
between style preferences (informational) and genuine anti-patterns that cause bugs
or maintenance burden (actionable). Focus on the actionable ones.
Concurrency audit
Spawn a sub-agent to audit the codebase for concurrency bugs. These are among the
hardest bugs to find because they're often intermittent and don't show up in normal
testing.
- Shared mutable state — global variables, module-level dicts/lists, class
attributes modified by multiple threads/goroutines/tasks without synchronization.
Trace writes to shared state and check whether they're protected.
- Missing synchronization — data races, unguarded concurrent map access (Go),
missing locks around read-modify-write sequences, async functions that modify
shared state without awaiting in order
- Goroutine/thread/task leaks — spawned work that's never joined or cancelled,
missing context cancellation, channels that are never closed or drained, fire-and-
forget patterns with no error handling
- Deadlock risk — lock ordering violations (acquiring A then B in one place, B
then A in another), holding locks across blocking I/O, channels with no buffer
where sender and receiver can both block
- Atomicity gaps — check-then-act patterns without locks (e.g., check if key
exists then insert), non-atomic counter increments, time-of-check-to-time-of-use
(TOCTOU) bugs
For each finding, describe the race scenario: what two operations can interleave
and what goes wrong when they do.
Resource management audit
Spawn a sub-agent to audit the codebase for resource leaks and cleanup failures.
Leaked resources cause slow degradation — the app works fine in testing but fails
under sustained load.
- File handles — opened files without corresponding close, missing context
managers (Python
with), missing defer file.Close() (Go), missing
try-with-resources (Java)
- Network connections — HTTP clients without timeouts, unclosed response bodies,
database connections not returned to pool, WebSocket connections without cleanup
on disconnect
- Subprocesses — spawned processes without
wait(), zombie processes,
missing signal handling for graceful shutdown
- Event listeners and subscriptions — listeners registered but never removed,
subscriptions without unsubscribe on teardown, leading to memory leaks in
long-running processes
- Temporary files and directories — created but never cleaned up, missing
cleanup in error paths (file created, operation fails, file left behind)
The report should note whether cleanup happens in all code paths, including error
paths — resources opened before a try block but closed inside it are a common
source of leaks.
Test quality audit
Spawn a sub-agent to audit the test suite beyond simple coverage numbers. Existing
tests can be worse than no tests if they give false confidence.
- Assertion quality — tests that call functions but don't assert meaningful
properties, tests that only check "no exception thrown", assertions on
implementation details rather than behavior. A test with no assertions is just
a smoke test — label it accordingly.
- Test isolation — tests that depend on execution order, shared mutable state
between tests (module-level lists that accumulate across tests), tests that
hit real networks or databases without mocking
- Flaky patterns — time-dependent tests using
sleep() instead of polling or
mocking, tests that depend on filesystem ordering, floating-point equality
checks, tests that race against async operations
- Property-based testing opportunities — pure functions, serialization
roundtrips, parsers, validators, and codecs are ideal candidates. If the project
has these and only tests with a handful of examples, flag the opportunity.
- Missing negative tests — are error paths tested? Do tests verify that invalid
input is rejected, not just that valid input is accepted?
- Test naming and organization — can you tell what a test verifies from its
name? Are related tests grouped? Are test utilities/fixtures extracted where
they should be?
The report should distinguish between tests that are wrong (give false
confidence) and tests that are weak (could be stronger). Prioritize the wrong
ones.
Feature completeness audit
Spawn a sub-agent to compare what the project claims to support against what
it actually implements. This catches the common pattern where documentation,
specs, or READMEs describe features that were planned but never built, or were
built and later removed without updating the docs.
- Documented features vs exports — for libraries, check that every documented
function/class/method actually exists and is exported. For CLIs, check that every
documented flag/subcommand is actually implemented (not a stub that prints
"not yet implemented").
- Spec vs implementation — if the project has spec files, design docs, or
feature lists, compare them against the codebase. Flag features described as
"done" or "implemented" that aren't.
- Route/endpoint coverage — for APIs, check that every documented endpoint
exists and handles the documented methods. Flag routes that exist in code but
aren't documented, and documented routes that don't exist in code.
- Config completeness — check that every documented config option is actually
read by the code, and that every config value the code reads is documented
somewhere.
For each gap, note which side should change — is the feature actually needed
(implement it) or was it abandoned (remove it from docs)?
Performance audit
Spawn a sub-agent to review the codebase for performance issues that are
detectable through static analysis. This isn't a substitute for profiling, but
many performance problems are visible in the code itself.
- Hot-path allocations — object creation inside tight loops, string
concatenation in loops (use builders/joins), creating regex objects on every
call instead of compiling once, allocating buffers that could be pooled or reused
- N+1 queries — database access patterns where a loop issues one query per
item instead of batching. Also: ORM lazy-loading that triggers queries inside
templates or serializers.
- Unbounded growth — caches without eviction, event listener lists that grow
without bound, log buffers that aren't flushed, in-memory stores with no size
limit
- Blocking the event loop — synchronous I/O in async contexts, CPU-heavy
computation on the main thread, missing
await on async calls that should be
awaited
- Unnecessary work — recomputing values that could be cached, re-reading
files on every request, re-parsing config on every call, redundant database
queries for data already in memory
The report should focus on patterns that cause real problems under load, not
micro-optimizations. Flag the likely impact (latency, memory, throughput) for
each finding.
Bug pattern audit
Spawn a sub-agent to scan the codebase for known bug patterns — recurring shapes
that cause defects across many projects. These patterns are language-agnostic
and often survive code review because each instance looks reasonable in isolation.
- Shallow merge/copy — objects or maps merged with spread or
Object.assign
where nested structures need deep merging. The first level looks correct but
nested fields get shared references. Common in state management, config merging,
and option defaults.
- Serialization boundary mismatch — data that crosses a serialization boundary
(JSON, database, IPC, network) but the two sides disagree on the schema. Field
renames on one side but not the other, enum values that don't round-trip, dates
stored as strings with ambiguous formats.
- Silent data loss — operations that can fail but whose failure is silently
ignored.
catch {} blocks with no body, write operations with no error check,
event handlers that mutate local state but don't propagate the change upstream.
- Off-by-one in boundaries — fence-post errors in pagination, range
calculations, array slicing, date range queries (inclusive vs exclusive
endpoints), and loop bounds.
- Stale closures — callbacks or event handlers that capture a variable by
reference but the variable changes before the callback runs. Common in React
useEffect dependencies, Go goroutines over loop variables, and setTimeout
callbacks.
- Type coercion surprises — implicit conversions that produce unexpected
results:
"5" + 3 in JavaScript, falsy-value checks that catch 0 and ""
along with null, integer overflow in languages without checked arithmetic.
For each pattern found, show the specific code and explain what would go wrong.
Group findings by pattern type so recurring themes are visible.
Design philosophy compliance audit
Spawn a sub-agent to evaluate the project against its own stated design
principles. Look for a design philosophy in CLAUDE.md, README, CONTRIBUTING,
design docs, or architecture decision records (ADRs). If the project has no
stated principles, skip this audit and say so.
- Extract principles — read the project's own docs and identify the stated
values, constraints, or design goals. These might be explicit ("we prefer
composition over inheritance") or implicit in the architecture.
- Evaluate compliance — for each principle, scan the codebase for violations.
Does the code follow its own rules? Are there areas where the principle was
abandoned under pressure?
- Consistency — do the stated principles contradict each other? Does the
README say one thing while CLAUDE.md says another?
The report should list each principle, show examples of compliance and violation,
and give an overall compliance score. This isn't about imposing external standards
— it's about holding the project accountable to the standards it set for itself.
Security vulnerability audit
Spawn a sub-agent to step back from the current task and analyse the codebase for
security vulnerabilities. This is not the quick secrets-in-diff check from the
branch audit — it's a deeper review of the project's security posture:
- Injection — SQL injection, command injection, XSS, template injection.
Trace a concrete source → construction → sink path before calling it a
vulnerability: where user-controlled input enters, how it is interpolated or
escaped, and which database query, shell command, template, or renderer consumes
it. Parameterized queries, bind variables, and safe ORM calls are not findings
unless the evidence shows unsafe dynamic SQL or identifiers.
- Authentication and authorization — missing auth checks on sensitive endpoints,
insecure session handling, hardcoded credentials, weak password policies
- Data exposure — sensitive data in logs, error messages that leak internals,
overly permissive API responses, missing field-level access control.
When reporting findings in this category, redact any actual secret values —
show the file, line, and type of secret but never echo credentials, tokens,
or keys verbatim in the report.
- Dependency risks — known vulnerable packages, outdated dependencies with
published CVEs, unnecessary dependencies that increase attack surface
- Configuration — debug mode enabled in production config, permissive CORS,
missing security headers, insecure defaults
The report should rate each finding by severity (Critical/High/Medium/Low) with
the affected file and a recommended fix. For each confirmed positive, include
Evidence, Attack path/source→sink, Impact, Fix, and Verify/test. If the source,
sink, or exploitability is not evidenced, mark it suspected or not a finding rather
than inventing unrelated vulnerabilities.
UI design audit (CRAP principles)
Spawn a sub-agent to review the project's UI using Robin Williams' four
fundamental design principles — Contrast, Repetition, Alignment, and Proximity
(CRAP). This applies to web interfaces, CLI output, terminal UIs, documentation
layouts, or any visual/textual output the project produces.
- Contrast — Are different elements visually distinct? Do headings stand out
from body text? Are interactive elements (buttons, links) clearly differentiated
from static content? Is there enough contrast between foreground and background?
Weak contrast makes interfaces feel flat and hard to scan.
- Repetition — Is there a consistent visual language? Are colors, fonts, spacing,
and component styles reused consistently throughout? Repetition creates unity — if
every page/screen uses different styling, the interface feels disjointed.
- Alignment — Is every element visually connected to something else on the page?
Nothing should be placed arbitrarily. Check for elements that are "almost but not
quite" aligned — these are worse than clearly different placements because they
look like mistakes.
- Proximity — Are related items grouped together? Are unrelated items separated?
Physical closeness implies relationship. Check for cases where labels are far from
their fields, or where unrelated controls are clustered together.
The report should include specific examples with file paths and, where possible,
screenshots or descriptions of the visual issues. Suggest concrete improvements
for each finding.
1---2name: audit3description: Comprehensive audit toolkit with 14 audit types. Includes a pre-push branch audit (8-category checklist with Clean/Minor/Blocking verdicts) plus 13 deep-dive audits run via sub-agents: code quality, documentation brittleness, docs-code sync, language best practices, concurrency, resource management, test quality, feature completeness, performance, bug patterns, design philosophy compliance, security vulnerabilities, and UI design (CRAP principles). Use this skill when the user wants to inspect a concrete codebase, branch, diff, repository, service, or docs/source pair: audit before pushing, check their branch, look for duplication or dead code, check docs-code sync, review test quality, find concurrency bugs or resource leaks, analyze concrete security/performance risks in code, review UI implementation, verify feature completeness, or check code against best practices/design principles. Do not use for conceptual explainers about audits, summarizing audit logs, changelog writing, or general security education4---56# Audit78This skill provides two modes:9101. **Branch audit** (default) — a pre-push review of the branch diff, checking 811 categories and producing a Clean/Minor/Blocking verdict.122. **Deep-dive audits** — project-wide analyses that use sub-agents to examine13 code quality, documentation brittleness, security, or UI design in depth.1415If the user says "audit" without further context and there's a branch with changes,16run the branch audit. If they ask for something specific (e.g., "audit for security17vulnerabilities", "check our docs", "review the UI"), run the relevant deep-dive.18They can also request multiple audits at once.1920---2122# Branch Audit2324## Step 1: Gather context2526Determine the base branch (`main`, `master`, or the upstream tracking branch), then:27281. Run `git diff <base>...HEAD` to get the full branch diff292. Run `git diff` and `git diff --cached` for any uncommitted/staged changes303. Run `git log --oneline <base>..HEAD` to see the commit list314. Note which files changed and what the branch is trying to accomplish3233Start your report with a brief **branch summary**: branch name, base, number of34commits, and a one-sentence description of the purpose of the changes.3536## Step 2: Audit each category3738Work through each category below. Report only categories that have findings — omit39categories with nothing to report (don't include "No findings" sections).4041Each finding should appear once. If something could fit multiple categories, put it42in the most relevant one and don't repeat it elsewhere.4344For every reported finding, require objective evidence from the inspected diff or45repo. Evidence can be a file/line, symbol, command output, or a short redacted code46snippet. Do not report a suspicion just because a filename, dependency, quoted text,47or test fixture looks risky. First decide whether there is a concrete source,48affected sink/path, and user or release impact.4950If an obvious-looking decoy is in scope and could be mistaken for a bug (fake test51secret, quoted TODO in docs, lockfile paired with dependency change, safe52parameterized query, toy repo with no attack surface), either omit it or briefly53call it out under **Not findings** with the evidence that clears it. Do not assign54severity to non-findings.5556### Secrets and credentials5758Check this first — it's the most critical category.5960- API keys, tokens, passwords, connection strings in the diff61- Private keys or certificates62- `.env` files or equivalents staged for commit63- Hard-coded URLs pointing to internal/staging environments6465When reporting secrets findings, never include the actual secret value in your66output. Redact credentials to show only enough to identify the location — e.g.,67"API key `sk_live_...7dc` found at src/config.py:42". The whole point of flagging68secrets is to prevent exposure; echoing them in the report would defeat that purpose.6970### Unintended changes7172- Files modified that don't relate to the branch's purpose (infer the purpose from73 the branch name, commit messages, and the bulk of the diff)74- Formatting-only diffs in files the branch didn't otherwise need to touch75- Changes to generated files (lock files are fine if dependencies changed)7677Be specific: name each file you think is unrelated and explain why.7879### Debug artifacts8081- `console.log`, `debugger`, `print()`, `pp`, `binding.pry`, `dbg!` left in82 production code (test files are fine)83- Commented-out code blocks (small explanatory comments are fine)84- `TODO`, `FIXME`, `HACK`, `XXX` introduced in this branch8586### Test coverage8788- New or modified production code without corresponding test changes89- Skipped or disabled tests (`.skip`, `@pytest.mark.skip`, `#[ignore]`)90- Test files that import but don't exercise new code paths9192### Build and suite9394Try to run the project's test suite, linter, and type checker. If the project95doesn't have the tooling set up, or dependencies aren't installed, note that and96move on — don't spend time troubleshooting environment issues. Report what you can.9798### Commit hygiene99100- Commit messages that don't follow the project's conventions101- Fixup commits that should be squashed102- Commits containing unrelated changes that should be split103104### Integration check105106- New modules that aren't imported anywhere107- New routes or endpoints that aren't registered108- New migrations that aren't referenced109- New dependencies that are imported but not declared in the project's dependency file110111### Merge conflicts and rebase state112113- Unresolved conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`)114- Stale branch: base branch has moved significantly since branch point115116## Evidence and severity rules117118Before assigning severity, separate **Confirmed findings**, **Suspected needs119verification**, and **Not findings**:120121- Confirmed findings need concrete evidence, impact, and an actionable fix.122- Suspected items may be mentioned only when the evidence is incomplete; say what123 to inspect next and do not inflate them to Blocking.124- Not findings are decoys cleared by evidence and should not be counted in the125 verdict.126127Severity calibration for branch audits:128129- **Blocking** — likely unsafe to push/release: leaked credentials, unresolved130 conflict markers, production debug artifacts, skipped/disabled tests or missing131 tests for changed production behavior, reachable security vulnerabilities,132 unregistered claimed features, likely data loss, or concurrency/resource bugs133 with a plausible failure path.134- **Minor** — low-risk cleanup or hygiene: TODO/FIXME comments, commit hygiene,135 small docs-code drift, or integration issues without immediate user impact.136- **Clean** — no confirmed actionable findings after checking the requested scope.137138For deep-dive security reports, use Critical/High/Medium/Low for each finding, but139when summarizing a pre-push branch still map the overall verdict to140Clean/Minor/Blocking. Always explain the severity with the evidence path, not just141the category name.142143## Step 3: Verdict144145End with a summary table of confirmed findings (file, line, issue, severity) and146one of these verdicts:147148- **Clean** — no findings, safe to push149- **Minor** — cosmetic or low-risk issues found (list them), push at your discretion150- **Blocking** — issues that should be fixed before pushing (list them)151152If the user asks you to fix any findings, fix them. Otherwise, just report.153154---155156# Deep-Dive Audits157158Each deep-dive audit should be delegated to a sub-agent so it can explore the159codebase thoroughly without bloating the main conversation. Launch them in parallel160when multiple are requested. Each sub-agent should produce a written report saved161to a file, then summarize the key findings back to the user.162163## Code quality audit164165Spawn a sub-agent to audit the project for:166167- **Duplication** — repeated logic, copy-pasted code blocks, near-identical168 functions or components that could be consolidated169- **Internal inconsistency** — naming conventions that vary across files, mixed170 patterns (e.g., callbacks in some places, promises in others), conflicting171 approaches to the same problem172- **Simplification and subtraction** — dead code, unused exports, over-abstracted173 layers that add indirection without value, features or config that nobody uses.174 The goal is to identify things that can be removed or simplified. Less code is175 better code — every line is a liability.176177The report should group findings by theme (not by file) and suggest concrete actions.178179## Documentation brittleness audit180181Spawn a sub-agent to audit documentation (READMEs, doc comments, guides, wikis,182SKILL.md files, onboarding docs) for:183184- **Fragile references** — line numbers, specific function signatures, or exact185 file paths that will break when code changes. Prefer linking to symbols, sections,186 or concepts instead.187- **Over-specified details** — documentation that mirrors the code so closely that188 any refactor makes the docs wrong. Good docs explain *why* and *how to use*,189 not *what each line does*.190- **Staleness risk** — instructions that reference specific versions, temporary191 workarounds, or "current" states that will age poorly. Flag anything that reads192 like it was written for a moment in time rather than for the long term.193194The report should recommend specific rewrites, not just flag problems.195196## Documentation–code sync audit197198Spawn a sub-agent to verify that documentation actually matches the current state199of the code. The brittleness audit (above) asks whether docs *will* break — this200one asks whether they *already have*.201202- **API docs vs implementation** — do documented endpoints, parameters, return203 types, and error codes match what the code actually does? Check REST routes,204 GraphQL schemas, CLI flags, library APIs.205- **Setup and install instructions** — do the steps in the README or getting-started206 guide actually work? Are prerequisites listed correctly? Are environment variables207 documented that the code actually reads?208- **Architecture descriptions** — do diagrams or written descriptions of the system209 architecture reflect the current module structure, data flow, and dependencies?210 Flag components described in docs that no longer exist, and components in code211 that docs don't mention.212- **Config and feature flags** — are all configuration options documented? Are there213 documented options that the code no longer reads, or code that reads undocumented214 config?215- **Examples and code snippets** — do inline examples in docs compile/run against216 the current codebase? Flag examples that use deprecated APIs or deleted functions.217218For each discrepancy, show the doc excerpt and the conflicting code side by side,219and recommend which one should change.220221## Language best practices audit222223Spawn a sub-agent to review the codebase against idiomatic best practices for224each programming language used in the project. The agent should first identify225which languages are present, then check each against its community standards:226227- **Python** — PEP 8 style, type hints on public APIs, context managers for228 resources, dataclasses/attrs over raw dicts, avoiding mutable default arguments,229 proper use of `__init__.py`, virtual environments230- **JavaScript/TypeScript** — strict mode, `const`/`let` over `var`, async/await231 over raw promises, proper error handling in async code, avoiding `any` in TS,232 ESM over CommonJS where appropriate233- **Go** — error handling (no ignored errors), proper use of goroutines and channels,234 effective Go naming conventions, avoiding package-level state, using `context.Context`235- **Rust** — ownership patterns, avoiding unnecessary `clone()`, proper error types236 over `unwrap()`, using `clippy` suggestions, derive macros for common traits237- **Java/Kotlin** — null safety, resource management (try-with-resources), immutable238 collections where possible, avoiding raw types, proper logging frameworks239- **Ruby** — Ruby style guide conventions, frozen string literals, proper use of240 blocks/procs/lambdas, avoiding monkey-patching in production code241- **Shell** — `set -euo pipefail`, quoting variables, avoiding eval, using `shellcheck`242 patterns243244Only audit languages actually present in the project. The report should distinguish245between style preferences (informational) and genuine anti-patterns that cause bugs246or maintenance burden (actionable). Focus on the actionable ones.247248## Concurrency audit249250Spawn a sub-agent to audit the codebase for concurrency bugs. These are among the251hardest bugs to find because they're often intermittent and don't show up in normal252testing.253254- **Shared mutable state** — global variables, module-level dicts/lists, class255 attributes modified by multiple threads/goroutines/tasks without synchronization.256 Trace writes to shared state and check whether they're protected.257- **Missing synchronization** — data races, unguarded concurrent map access (Go),258 missing locks around read-modify-write sequences, async functions that modify259 shared state without awaiting in order260- **Goroutine/thread/task leaks** — spawned work that's never joined or cancelled,261 missing context cancellation, channels that are never closed or drained, fire-and-262 forget patterns with no error handling263- **Deadlock risk** — lock ordering violations (acquiring A then B in one place, B264 then A in another), holding locks across blocking I/O, channels with no buffer265 where sender and receiver can both block266- **Atomicity gaps** — check-then-act patterns without locks (e.g., check if key267 exists then insert), non-atomic counter increments, time-of-check-to-time-of-use268 (TOCTOU) bugs269270For each finding, describe the race scenario: what two operations can interleave271and what goes wrong when they do.272273## Resource management audit274275Spawn a sub-agent to audit the codebase for resource leaks and cleanup failures.276Leaked resources cause slow degradation — the app works fine in testing but fails277under sustained load.278279- **File handles** — opened files without corresponding close, missing context280 managers (Python `with`), missing `defer file.Close()` (Go), missing281 try-with-resources (Java)282- **Network connections** — HTTP clients without timeouts, unclosed response bodies,283 database connections not returned to pool, WebSocket connections without cleanup284 on disconnect285- **Subprocesses** — spawned processes without `wait()`, zombie processes,286 missing signal handling for graceful shutdown287- **Event listeners and subscriptions** — listeners registered but never removed,288 subscriptions without unsubscribe on teardown, leading to memory leaks in289 long-running processes290- **Temporary files and directories** — created but never cleaned up, missing291 cleanup in error paths (file created, operation fails, file left behind)292293The report should note whether cleanup happens in all code paths, including error294paths — resources opened before a try block but closed inside it are a common295source of leaks.296297## Test quality audit298299Spawn a sub-agent to audit the test suite beyond simple coverage numbers. Existing300tests can be worse than no tests if they give false confidence.301302- **Assertion quality** — tests that call functions but don't assert meaningful303 properties, tests that only check "no exception thrown", assertions on304 implementation details rather than behavior. A test with no assertions is just305 a smoke test — label it accordingly.306- **Test isolation** — tests that depend on execution order, shared mutable state307 between tests (module-level lists that accumulate across tests), tests that308 hit real networks or databases without mocking309- **Flaky patterns** — time-dependent tests using `sleep()` instead of polling or310 mocking, tests that depend on filesystem ordering, floating-point equality311 checks, tests that race against async operations312- **Property-based testing opportunities** — pure functions, serialization313 roundtrips, parsers, validators, and codecs are ideal candidates. If the project314 has these and only tests with a handful of examples, flag the opportunity.315- **Missing negative tests** — are error paths tested? Do tests verify that invalid316 input is rejected, not just that valid input is accepted?317- **Test naming and organization** — can you tell what a test verifies from its318 name? Are related tests grouped? Are test utilities/fixtures extracted where319 they should be?320321The report should distinguish between tests that are *wrong* (give false322confidence) and tests that are *weak* (could be stronger). Prioritize the wrong323ones.324325## Feature completeness audit326327Spawn a sub-agent to compare what the project *claims* to support against what328it *actually* implements. This catches the common pattern where documentation,329specs, or READMEs describe features that were planned but never built, or were330built and later removed without updating the docs.331332- **Documented features vs exports** — for libraries, check that every documented333 function/class/method actually exists and is exported. For CLIs, check that every334 documented flag/subcommand is actually implemented (not a stub that prints335 "not yet implemented").336- **Spec vs implementation** — if the project has spec files, design docs, or337 feature lists, compare them against the codebase. Flag features described as338 "done" or "implemented" that aren't.339- **Route/endpoint coverage** — for APIs, check that every documented endpoint340 exists and handles the documented methods. Flag routes that exist in code but341 aren't documented, and documented routes that don't exist in code.342- **Config completeness** — check that every documented config option is actually343 read by the code, and that every config value the code reads is documented344 somewhere.345346For each gap, note which side should change — is the feature actually needed347(implement it) or was it abandoned (remove it from docs)?348349## Performance audit350351Spawn a sub-agent to review the codebase for performance issues that are352detectable through static analysis. This isn't a substitute for profiling, but353many performance problems are visible in the code itself.354355- **Hot-path allocations** — object creation inside tight loops, string356 concatenation in loops (use builders/joins), creating regex objects on every357 call instead of compiling once, allocating buffers that could be pooled or reused358- **N+1 queries** — database access patterns where a loop issues one query per359 item instead of batching. Also: ORM lazy-loading that triggers queries inside360 templates or serializers.361- **Unbounded growth** — caches without eviction, event listener lists that grow362 without bound, log buffers that aren't flushed, in-memory stores with no size363 limit364- **Blocking the event loop** — synchronous I/O in async contexts, CPU-heavy365 computation on the main thread, missing `await` on async calls that should be366 awaited367- **Unnecessary work** — recomputing values that could be cached, re-reading368 files on every request, re-parsing config on every call, redundant database369 queries for data already in memory370371The report should focus on patterns that cause real problems under load, not372micro-optimizations. Flag the likely impact (latency, memory, throughput) for373each finding.374375## Bug pattern audit376377Spawn a sub-agent to scan the codebase for known bug patterns — recurring shapes378that cause defects across many projects. These patterns are language-agnostic379and often survive code review because each instance looks reasonable in isolation.380381- **Shallow merge/copy** — objects or maps merged with spread or `Object.assign`382 where nested structures need deep merging. The first level looks correct but383 nested fields get shared references. Common in state management, config merging,384 and option defaults.385- **Serialization boundary mismatch** — data that crosses a serialization boundary386 (JSON, database, IPC, network) but the two sides disagree on the schema. Field387 renames on one side but not the other, enum values that don't round-trip, dates388 stored as strings with ambiguous formats.389- **Silent data loss** — operations that can fail but whose failure is silently390 ignored. `catch {}` blocks with no body, write operations with no error check,391 event handlers that mutate local state but don't propagate the change upstream.392- **Off-by-one in boundaries** — fence-post errors in pagination, range393 calculations, array slicing, date range queries (inclusive vs exclusive394 endpoints), and loop bounds.395- **Stale closures** — callbacks or event handlers that capture a variable by396 reference but the variable changes before the callback runs. Common in React397 `useEffect` dependencies, Go goroutines over loop variables, and setTimeout398 callbacks.399- **Type coercion surprises** — implicit conversions that produce unexpected400 results: `"5" + 3` in JavaScript, falsy-value checks that catch `0` and `""`401 along with `null`, integer overflow in languages without checked arithmetic.402403For each pattern found, show the specific code and explain what would go wrong.404Group findings by pattern type so recurring themes are visible.405406## Design philosophy compliance audit407408Spawn a sub-agent to evaluate the project against its own stated design409principles. Look for a design philosophy in CLAUDE.md, README, CONTRIBUTING,410design docs, or architecture decision records (ADRs). If the project has no411stated principles, skip this audit and say so.412413- **Extract principles** — read the project's own docs and identify the stated414 values, constraints, or design goals. These might be explicit ("we prefer415 composition over inheritance") or implicit in the architecture.416- **Evaluate compliance** — for each principle, scan the codebase for violations.417 Does the code follow its own rules? Are there areas where the principle was418 abandoned under pressure?419- **Consistency** — do the stated principles contradict each other? Does the420 README say one thing while CLAUDE.md says another?421422The report should list each principle, show examples of compliance and violation,423and give an overall compliance score. This isn't about imposing external standards424— it's about holding the project accountable to the standards it set for itself.425426## Security vulnerability audit427428Spawn a sub-agent to step back from the current task and analyse the codebase for429security vulnerabilities. This is not the quick secrets-in-diff check from the430branch audit — it's a deeper review of the project's security posture:431432- **Injection** — SQL injection, command injection, XSS, template injection.433 Trace a concrete source → construction → sink path before calling it a434 vulnerability: where user-controlled input enters, how it is interpolated or435 escaped, and which database query, shell command, template, or renderer consumes436 it. Parameterized queries, bind variables, and safe ORM calls are not findings437 unless the evidence shows unsafe dynamic SQL or identifiers.438- **Authentication and authorization** — missing auth checks on sensitive endpoints,439 insecure session handling, hardcoded credentials, weak password policies440- **Data exposure** — sensitive data in logs, error messages that leak internals,441 overly permissive API responses, missing field-level access control.442 When reporting findings in this category, redact any actual secret values —443 show the file, line, and type of secret but never echo credentials, tokens,444 or keys verbatim in the report.445- **Dependency risks** — known vulnerable packages, outdated dependencies with446 published CVEs, unnecessary dependencies that increase attack surface447- **Configuration** — debug mode enabled in production config, permissive CORS,448 missing security headers, insecure defaults449450The report should rate each finding by severity (Critical/High/Medium/Low) with451the affected file and a recommended fix. For each confirmed positive, include452Evidence, Attack path/source→sink, Impact, Fix, and Verify/test. If the source,453sink, or exploitability is not evidenced, mark it suspected or not a finding rather454than inventing unrelated vulnerabilities.455456## UI design audit (CRAP principles)457458Spawn a sub-agent to review the project's UI using Robin Williams' four459fundamental design principles — **Contrast, Repetition, Alignment, and Proximity**460(CRAP). This applies to web interfaces, CLI output, terminal UIs, documentation461layouts, or any visual/textual output the project produces.462463- **Contrast** — Are different elements visually distinct? Do headings stand out464 from body text? Are interactive elements (buttons, links) clearly differentiated465 from static content? Is there enough contrast between foreground and background?466 Weak contrast makes interfaces feel flat and hard to scan.467- **Repetition** — Is there a consistent visual language? Are colors, fonts, spacing,468 and component styles reused consistently throughout? Repetition creates unity — if469 every page/screen uses different styling, the interface feels disjointed.470- **Alignment** — Is every element visually connected to something else on the page?471 Nothing should be placed arbitrarily. Check for elements that are "almost but not472 quite" aligned — these are worse than clearly different placements because they473 look like mistakes.474- **Proximity** — Are related items grouped together? Are unrelated items separated?475 Physical closeness implies relationship. Check for cases where labels are far from476 their fields, or where unrelated controls are clustered together.477478The report should include specific examples with file paths and, where possible,479screenshots or descriptions of the visual issues. Suggest concrete improvements480for each finding.