Code audit
Audit the current feature branch against the project's own standards before opening or merging a PR, producing a P0/P1/P2/P3-graded report with `path:line` references. Use this skill whenever the user wants to "audit my branch", "check my changes", "verify standards", "run a pre-PR review", "do a code-quality check", "make sure this follows our rules", "lint the diff against our conventions", or any phrasing that combines branch/diff/PR with review/audit/standards/compliance/conventions. The skill is project-aware at runtime: it learns the repo's documented rules and its automated gates (see the discovery contract) and runs the existing gates (build, test, lint, typecheck, plus a secrets sweep) rather than re-implementing them, then delegates the per-rule judgment to the bundled `audit` workflow so the rule set lives in one place. Report-only; never auto-fixes. Prefer this over the generic `review` / `security-review` skills for a branch-level standards check inside a project that documents its own rules.From its SKILL.md
npx -y skills add tracstarr/shipyard --skill code-auditAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
14.5 KB, as published. Nobody here has run it
Code Audit
Walk the current feature branch's diff against the project's standards and emit a graded
P0/P1/P2/P3 report. The skill exists because a project's rules are usually spread across
several files (CLAUDE.md, AGENTS.md, CONTRIBUTING.md, coding-standards docs, ADRs) —
nobody, human or AI, reliably remembers the full list.
This is the full pre-PR audit: it runs the heavy gates the project already has,
persists a report, and delegates the rule judgment to the bundled audit workflow,
which reads the project's rule file and runs a parallel, adversarially-verified sweep. The
rule judgment lives in one place — the workflow — so the gates and the rule sweep can't
drift. (For just the fast rule sweep with no gates, invoke the audit workflow directly.)
Report-only. This skill never modifies application code, tests, configs, or migrations,
never auto-fixes findings, and never runs destructive commands. The only artifact it writes
is its own report (see step 8). If a non-mutating run is required (a CI invocation that must
not touch the worktree), pass --no-write and print the report inline only.
Workflow authorization. This skill authorizes invoking the
Workflowtool for the bundledauditworkflow (only). That is the opt-in — do not invoke any other workflow without a fresh user request.
When to take over from /review and /security-review
The built-in /review is for generic PR review; /security-review is for security
posture. Neither knows this project's documented rules. This skill drives whenever the
user is in a repo that documents its own conventions and asks for a branch-level standards
/ pre-PR audit. If they specifically ask for security posture only, hand off to
/security-review.
Invocation
code-audit [--scope=branch|files|all] [--allow-dirty] [--no-write] [<paths…>]
Defaults: --scope=branch, base = the detected default branch, output = inline and a
report file. Pass --no-write to suppress the file (the report still prints inline).
The flow
Walk these in order. Never skip a step silently — if a step doesn't apply, say so.
0. Discover the project
Learn the repo per ${CLAUDE_PLUGIN_ROOT}/reference/discover-project.md: the
rule file, the automated gates (build / test / lint / typecheck commands and any
project-specific check scripts), the base branch, and what CI runs on PRs. These
drive steps 3 and 4.
1. Resolve scope
BASE=$(git merge-base origin/<default-branch> HEAD)
git diff --name-status "$BASE...HEAD"
--scope=files <paths>→ use those paths instead.--scope=all→ all tracked files. Warn it's heavy and rarely what they want; confirm first.- If the working tree is dirty and
--allow-dirtywas not passed, refuse and tell the user to commit, stash, or pass--allow-dirty. Never auto-stash. - If the default-branch ref doesn't resolve, fall back; if nothing works, ask for the base.
- If the branch has no diff vs base, report "nothing to audit" and exit before running gates.
2. Categorize files
Bucket every changed path by the project's layout (controllers/handlers, domain/entities,
migrations, jobs, frontend components, styles, config, docs, scripts, …). Ambiguous paths
go to unknown — don't guess. Print the bucket counts before continuing.
3. Run the automated gates
Scale the gates to the diff. Gates exist to catch regressions the branch could have introduced — a lane the diff cannot affect is wasted wall-clock and false-failure surface. Using the step-2 buckets and the project's gate trigger buckets (see the discovery contract), run only the gate lanes whose changed buckets are present, and skip the rest — saying so in the report:
- A gate runs when its own subtree changed — a frontend lint/build when frontend files changed, the backend build/test when backend sources changed, a config-drift check when config files changed.
- A gate also runs on its cross-bucket trigger — a gate that a different bucket must fire. The canonical case: a backend API/DTO change invalidates the generated client, so a generated-client / schema-drift check must run even when no frontend file changed.
- A diff that touches only docs/scripts fires no build/test lane at all; the audit is then the hygiene + rule-judgment + secrets sweep. Note the skipped lanes in the report so a skipped gate can't be mistaken for a green one.
When in doubt, run the lane — skipping is an optimization, never a dodge.
Pre-flight — environment health (check-only). Confirm the environment is healthy via
shipyard:preflight in check-only mode (no repair — this skill must not mutate the
worktree). If it reports a blocking failure (DB down, deps missing), stop and tell the
user to repair it (shipyard:preflight repair, or shipyard:local-reset) before
re-running — don't proceed to the test gate and report hundreds of false failures because
infra wasn't up. Note pending-migration warnings in the report.
Run each detected gate, capture pass/fail + the first ~30 lines of any failure. Each failure is a P0 tagged with the gate name. Do not re-implement these — they are the source of truth. Typical set (use what the project actually has):
<BUILD_CMD> # e.g. the project's build: npm run build, cargo build, go build ./..., gradle build
<TEST_CMD> # the test suite(s); note if CI skips a slow layer this run includes
<TYPECHECK_CMD> # e.g. tsc / mypy, if present
<LINT_CMD> # e.g. eslint / clippy / ruff, if present
<PROJECT_CHECKS> # any repo-specific check scripts (config-drift, design-tokens, codegen-drift…)
Enumerate the gates at runtime — don't trust a static list. New check scripts land in
the project's manifest (package.json scripts, a Makefile, a CI file) before anyone
documents them, and a gate this skill doesn't know about is still a gate the PR must pass.
Read the manifest and list the actual check / lint / test targets rather than assuming a
fixed set. But a script is only a gate if CI (or an umbrella/aggregate script) actually
chains it. Deliberately diagnostic variants exist — an unfiltered :full / :all scan
kept as a human cleanup signal, say — and gating those would fail on intentional, benign
patterns. Run an umbrella-uncovered script only when its own docs or CI wiring say it gates;
otherwise its output is informational — grade it no higher than a minor finding (P3),
never a P0 build-breaker.
Note for each gate what it covers, so failure notes are meaningful. If the local audit runs gates CI skips (e.g. an integration suite CI filters out), call that out — local audit may be the primary regression check for those.
Heavy test layers — isolate before grading. Some projects have a heavy test layer (integration / e2e) that touches a real DB or service and that CI deliberately filters out of the PR gate (too slow or too resource-hungry to run per-PR). Run locally, that layer often mass-fails from resource exhaustion or transient load under contention — which is NOT regression, and treating that output as findings produces a wall of false P0s. Before grading such a failure, don't trust a whole-suite mass-run: re-run the failing test class / file in isolation. A failure that reproduces alone is a real finding; a class that only fails inside the full run is exhaustion. Never grade a whole-suite mass-fail as P0 without the isolation step.
4. Rule judgment — delegated to the audit workflow
Rather than re-encode the project's rules here (and let two copies drift), delegate the
per-rule judgment to the bundled audit workflow, which reads the project's rule file,
clusters the rules into parallel domains, and runs an adversarial cross-check that drops
false positives before returning. Invoke it by path, scoped to the same base:
CRLF guard — before any
Workflowcall. The bundled workflow scripts (workflows/audit.js, andworkflows/audit-deep.jswhen you run the deep pass) are committed LF-only, but a worktree checkout has occasionally been seen serving a stale CRLF copy, which theWorkflowtool rejects outright ("script contains control characters that would be hidden in the approval dialog").Readthe script under$CLAUDE_PLUGIN_ROOT/workflows/first; if it contains any\r,Editit back with every\rstripped before invoking. (Windows-relevant.)
echo "$CLAUDE_PLUGIN_ROOT"
Workflow({ scriptPath: "<that path>/workflows/audit.js",
args: { base: "origin/<default-branch>", rulesFile: RULES_FILE, projectFacts: {…} } })
--scope=all→ addrepoWide: trueso the domains sweep invariants repo-wide.--scope=files <paths>→ the workflow is diff-scoped; run it branch-scoped and note in the report that the rule sweep covered the branch diff, not the narrowed file set.
It returns { verdict, report, findings } where each finding is
{ domain, path, line, severity, rule, what, fix }, already adversarially cross-checked.
Fold these findings into this audit's finding set. Don't re-walk the files by hand —
the workflow is the source of truth, and a parallel hand walk would only drift. If the
workflow can't run (a truly headless context with no agent runtime), say so explicitly
rather than silently skipping the rule sweep.
Files that landed in unknown (step 2) won't match any domain — list them under "Not
categorized — manual review recommended."
Deeper pass (optional, higher confidence). For a large or security-sensitive diff, or
when the rule-cluster sweep feels too coarse, invoke workflows/audit-deep.js instead. It
reviews each changed file individually against its category's project rules, runs the
detected gates itself, and refutes every finding with a 3-skeptic panel to kill false
positives — slower and heavier (one reviewer per file + three verifiers per finding), but
the highest-confidence option. Same args shape; it returns
{ scope, gates, findings, droppedCount }. Fold its findings in the same way — and since
it runs the gates internally, you can skip re-running them in step 3 if you lead with it.
5. Commit-level checks
git log "$BASE..HEAD" --format="%H%n%s%n%b%n---"
- Every commit subject matches conventional-commit form:
^(feat|fix|chore|docs|refactor|test|perf|build|ci|style|revert)(\([^)]+\))?!?: .+(scopes and!breaking-markers are valid — don't flag them). - Each commit is one logical change. Flag a commit whose changeset spans unrelated buckets as P2 unless the message explains the cross-cutting reason.
6. Secrets sweep
Grep the diff for credential shapes (passwords, API keys, tokens, private keys, known
cloud-key patterns). Exclude *.example files and well-known local dev placeholders. Any
real hit → P0 with path:line.
7. Render the report
Sort findings P0 → P3:
# Code Audit — <branch> — <date>
## Scope
`<base>..<head>`, N files changed — <bucket counts>
## Automated gates
| Gate | Result | Notes |
|------|--------|-------|
| <build> | ✅/❌/➖ skipped (no backend diff) | |
| <test> | ✅/❌/➖ | heavy layer targeted + isolated |
| <typecheck/lint> | ✅/❌/➖ skipped (no frontend diff) | |
| <project-checks> | ✅/❌/➖ skipped (no config diff) | incl. generated-client / schema-drift |
## Findings
### P0 — must fix before merge
- `path:line` — <rule> — <what's wrong> — <fix direction>
### P1 — fix before merge unless justified
### P2 — follow-up acceptable
### P3 — nit
## End-of-flow checklist
- [x] Gates run · [x] Rule judgment delegated to `audit`, findings folded in
- [x] Commits reviewed · [x] Secrets sweep run · [x] Report written
8. Persist the report
Unless --no-write was passed, write the report where the project keeps review artifacts
if it has such a convention (e.g. a docs/reviews/ dir), else a clearly-named file outside
tracked sources (and say where). Same-day re-runs on the same branch overwrite without
prompting. The report file is the only thing this skill writes to the worktree. Print
the same content inline regardless.
Edge cases
- No diff vs base — "nothing to audit"; exit before gates.
- Dirty tree — refuse without
--allow-dirty; never auto-stash. - No rule file — the
auditworkflow audits against visible code conventions + general best practice; note in the report that the rule set was inferred, not documented. - Diff > 50 files — chunk by category; declare a partial walk in the header. Run all gates regardless.
End-of-flow checklist
Confirm out loud before declaring the audit complete:
- Right scope resolved (branch / files / all)
- Environment preflight passed check-only (or the skill refused with a clear message)
- Every applicable gate ran and its result captured (lanes scaled to the diff buckets, skips noted in the report; the check-script list enumerated at runtime, not assumed; heavy test-layer failures re-run in isolation before any P0)
- Every changed file landed in a bucket (or surfaced as
unknown) - Rule judgment delegated to
audit; its findings folded in (each withpath:line+ grade + fix direction) - Commit messages reviewed · [ ] Secrets sweep run
- Report rendered inline AND (unless
--no-write) written - Only the report file was written; no code/test/config/migration modified; no destructive command run
Skipping any item silently is the failure mode this skill exists to prevent.