Repo Audit Swarm
ASecurityCoordinates an audit swarm over a repo with the nine audit skills. Splits the repo into non-overlapping slices, estimates the cost, lets the user pick model and effort per role, sets up read-only database access if needed, runs perf-diagnosis, data-consistency, api-security-review, implicit-state-machines and llm-app-review only on the slices where they apply, correctness-review on every slice with code, and architecture-review, code-structure and infra-review once over the whole repo, verifi...
- 2 stars
- 0 votes
- 0 copies
- 1 view
- Added November 17, 2026
Works with
Security analysis
100/100Pro scans all 20 files and shows the line behind each finding
npx -y skills add OmarAlex24/audit-skills --skill repo-audit-swarm --agent claude-codeAre you the author of Repo Audit Swarm?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/omaralex24-repo-audit-swarm)---
name: repo-audit-swarm
description: Coordinates an audit swarm over a repo with the nine audit skills. Splits the repo into non-overlapping slices, estimates the cost, lets the user pick model and effort per role, sets up read-only database access if needed, runs perf-diagnosis, data-consistency, api-security-review, implicit-state-machines and llm-app-review only on the slices where they apply, correctness-review on every slice with code, and architecture-review, code-structure and infra-review once over the whole repo, verifies each finding blind and writes a remediation plan in waves with stacked PRs. Reports and stops; implements nothing without approval. Use it for "audit this repo with all the skills", "run the audit swarm", "full repo audit", "remediation plan for this repo", "re-audit", "what changed since the last audit". For a single audit use that topic's skill. Also triggers on Spanish requests such as "audita este repo con todas las skills", "swarm de auditoría", "plan de remediación del repo" or "re-audita".
---
# Repo audit swarm
Nine skills audit a repo and deliver their findings in a common format. Six read code line by line, so the repo is split into non-overlapping **slices** and each one runs only on the slices where it applies, with one auditor per slice: five depending on what the map finds in the slice (among them `llm-app-review`, on the slices that call an LLM) and `correctness-review` (logic and calculation errors) on every slice with executable code. The other three (`architecture-review`, `code-structure`, `infra-review`) read structure and run once over the whole repo. A verifier that does not know which skill or slice each finding came from tries to refute them, and at the end an agent merges what survived by root cause and writes a remediation plan.
You are the coordinator: you prepare the ground, launch the Workflow twice (prepare and audit) with a user confirmation in between (or once, after confirming, for a [re-audit](#re-audit)), review what comes back and present the plan. **You implement nothing**: the plan waits for the user's approval. Write the report in the user's language.
Material:
- [references/finding-contract.md](references/finding-contract.md): the common vocabulary (confidence, method, severity, effort, action) and the fields. The schema is [references/finding.schema.json](references/finding.schema.json).
- [references/data-access.md](references/data-access.md): the database access policy and `scripts/db-ro`.
- [references/remediation-plan.md](references/remediation-plan.md): the plan template.
- [references/before-after.md](references/before-after.md): how a plan item is measured before and after the fix. Every finding proposes its measurement in the `metric` field.
- `workflow/audit.js`: the Workflow script, with three modes (prepare, audit and reaudit).
- `scripts/`: the read-only deterministic ones (`count-lines.py`, `propose-slices.py`, `import-graph.py`, `git-history.py`, `estimate-cost.py`) and `db-ro`, `merge-findings.py`, `sync-schema.py`, `migrate-run.py`, and for the re-audit `diff-since.py` and `reaudit-report.py`. All of them print their usage with `-h` or `--help` and exit with 2 on an unknown option.
In the commands, `<skill>` is this skill's folder, `<skills>` the folder that holds the nine skills, `<runs>` the folder that holds every run and `<output>` the run's folder.
## Where the skills and the runs are
The skills can be installed as a Claude Code plugin (in the plugin cache, for example `~/.claude/plugins/cache/audit-skills/audit-skills/<version>/skills/`), as links from `~/.claude/skills/<name>` into a checkout, or as copies in `~/.claude/skills/`. Resolve the paths before phase 0 and print them:
```sh
SKILL=<the folder that holds this SKILL.md>
SKILLS=$(dirname "$(realpath "$SKILL")") # <skills>: plugin skills/ folder, checkout skills/ folder or ~/.claude/skills
PROJECT=$(dirname "$SKILLS")
for s in perf-diagnosis data-consistency api-security-review implicit-state-machines correctness-review \
llm-app-review architecture-review code-structure infra-review; do
test -f "$SKILLS/$s/SKILL.md" || echo "missing: $s"
done
```
If a skill is missing, say which and stop: the auditors read `<skills>/<skill>/SKILL.md` by folder name. Installed as a plugin, the skills may show up as `audit-skills:<name>`; the folders keep the bare names, and everything here uses the folders.
**`<runs>`**, in this order:
1. the folder the user names;
2. `$PROJECT/runs/`, only if it already exists, `$PROJECT/.claude-plugin/plugin.json` exists (a checkout of this repo) and the resolved path has no `/plugins/cache/` segment;
3. otherwise `~/audit-skills-runs/`.
Never inside the plugin cache (an update replaces it), never inside the audited repo and never in a folder that gets published. Tell the user which `<runs>` you picked and that they can change it. A run's folder is `<output>` = `<runs>/<repo>/<date>/`.
## Rules
- **The audited repo is not touched.** No files, no git, no dependencies, no builds, no tests. The scripts use `git --no-optional-locks` and only read. HEAD and `git status --porcelain` are recorded at the start and compared at the end.
- **The output goes outside the repo**, in `<runs>/<repo>/<date>/` ([where](#where-the-skills-and-the-runs-are)) or wherever the user says. `<runs>` holds real vulnerabilities: it is never published or copied along with the skills, and never goes in the plugin cache. The scripts refuse to write inside the repo.
- **Data: a single read-only access**, set up by you with `db-ro` and following [data-access.md](references/data-access.md). Before any query, print which environment it points to.
- **Nothing is launched without confirming** with the user the scope, the slice × skill table, the models, the estimated cost and the data target.
- **Nothing is cut silently.** What does not run (a skipped slice × skill pair, an ignored baseline, a block outside the verification quota) goes to `log()` and to the plan.
- **Report and stop.** Implementation is another step, with approval, and follows the plan in stacked PRs.
- **Language.** Set the `language` arg from the language the user is writing in (for example `"Spanish"`). The agents write prose fields (titles, sequences, impact, fixes, map text, plan, questions) in it; JSON keys and enum values stay in English.
## Phase 0: structure, slices and cost
1. Ask which repo, if they did not say. Record `git -C <repo> rev-parse HEAD` and `git --no-optional-locks -C <repo> status --porcelain`.
2. Run the deterministic scripts, all read-only, with the output in `<output>/structure`:
```sh
E=<output>/structure; mkdir -p $E
python3 -I <skill>/scripts/count-lines.py <repo> [--exclude '<glob>'] > $E/lines.txt
python3 -I <skill>/scripts/propose-slices.py <repo> --output $E [--target 6000] [--min 1500] [--exclude '<glob>']
python3 -I <skill>/scripts/import-graph.py <repo> --output $E [--exclude '<glob>']
python3 -I <skill>/scripts/git-history.py <repo> --output $E [--exclude '<glob>']
```
The `--exclude` go **the same in all four**: what is excluded is a hard boundary, not a suggestion. A glob also covers what is under a folder that matches (`apps/b/**`, `apps/b` and `apps/b/*` leave out all of `apps/b`) and `**/x` also applies at the root. What is excluded does not count in the lines, belongs to no slice (no entry of `slices.json` contains it: the folder above is split), is not a node of the graph and does not count in the history. `slices.md` says which folders were left out.
`propose-slices.py` splits the repo following the modules (folders with a manifest) and, if a module is large, its subfolders, up to a target of lines per slice. Every tracked file falls in exactly one slice. The default target is **6,000 lines**: in the pilot, an auditor over ~11,000 lines did not manage to cover them and a single skill over ~2,600 took 23 min; with 6,000 an auditor finishes in reasonable time without multiplying the agents. If the user wants fewer agents, raise it; if they want more coverage per auditor, lower it. A slice with fewer than `--min` lines (by default target/4, 1,500) is merged with the smallest slice of its same module if the sum does not go over the cap of 1.25 × target (7,500); if there is no one to merge with, it stays alone with a warning. `--min 0` turns it off. `slices.md` and `slices.json` say how many slices come out, of what size, how many executable lines each one has, what was merged and with which warnings (a lone file larger than the target, for example).
3. If the repo is very large, propose a scope: with `--exclude` or auditing only the slices of the hot path. Say it with numbers (how many slices and lines are left). If you change the `--exclude`, run the four scripts again.
4. **Estimate the cost**, always as an estimate and as a range:
```sh
python3 -I <skill>/scripts/estimate-cost.py $E/slices.json [--cpus N] [--slow-map]
```
Without an assignment, the script gives the **worst case** (the six per-slice skills in every slice): use it as a ceiling and say that the phase 2 assignment will lower it. The constants come from the only real run by slices (calibrated on 2026-11-12): a ~13,700-line TypeScript monorepo in 4 slices, map with Sonnet and the rest with Opus at high effort; prepare, ~148k tokens and 1.5 min; audit, 20 agents, **3.13M tokens and 34.6 min**, 43 findings. The per-slice auditors took 4 to 15 min almost regardless of the lines. The previous estimator had given 132–264 min: it overestimated the clock about 4 times. The split of tokens by role is an assumption that adds up to the measured total (the docstring says so).
The script gives low, central and high tokens and minutes (0.6× to 1.5× in tokens, 0.7× to 1.7× in minutes), and the minutes per phase. With Opus or Fable on the map pass `--slow-map`: in the pilot without slices the map with Opus took 19 min. The clock adds up the phases (they run in series); within the audit it counts the slowest auditor and, if there are more auditors than slots (min(16, CPUs − 2)), a few minutes per extra batch. Say that it is calibrated with a single run and that the pilot without slices (95 min, auditors over ~11,000 lines) falls outside the range.
5. **Model and effort per role.** Ask which model and which effort to use in each role: `map` (global explorer and slice explorers), `slice_auditor`, `repo_auditor`, `verifier` and `plan`. The model options **are not written by hand**: they are the values of the `model` field of the Workflow or Agent tool in this session (today, `fable`, `opus`, `sonnet` and `haiku`; if the tool shows others, use those). The efforts are `low`, `medium`, `high`, `xhigh` and `max`. Leaving a role out inherits the session's model and effort. For each option give the estimated cost: the role's tokens from `estimate-cost.py` times the current price of each model, which you look up in Anthropic's pricing documentation at that moment (not from memory) and cite with the date. Tokens change little with the model; price and time, a lot. A reasonable recommendation: the session's model for auditors and verifiers, and a cheaper one for the map if the repo is large.
6. Ask whether they want **baselines** (off by default). A baseline is an auditor of the same topic and on the same slice but without the skill: it measures how much each skill adds. If they want them, you pick a single representative slice (with external inputs and writes, of medium size) and up to three per-slice skills that run on it; say which and why.
7. **Confirm with the user** scope, slice target, models and baselines before going on.
## Phase 1: data access
Follow [data-access.md](references/data-access.md):
1. Identify the stores in scope from the code and the config: the engine and the variable the target comes from. Do not read secret values for that.
2. Print the target you propose (engine, `host:port/db` or path, where it comes from) and whether it is local, shared or production. Only the one the user names or approves is valid; production, never unless they name it.
3. Set up the command:
```sh
# Postgres from a .env of the repo, local
python3 -I <skill>/scripts/db-ro setup --out <output>/db --kind postgres --label "<label>" \
--env-file <repo>/.env --var <VARIABLE_NAME> --target 127.0.0.1:<port>/<db>
# SQLite
python3 -I <skill>/scripts/db-ro setup --out <output>/db --kind sqlite --label "<label>" \
--path <file.db> --target <file.db>
```
A remote target adds `--confirm-remote` and needs a role that is not a superuser.
4. If `setup` fails because the database does not respond, do not start it: go on with `data: null` and record it as a question for the plan. The same with an engine that is not Postgres or SQLite.
## Phase 2: run 1, prepare (map and assignment)
1. Copy the contract, which every agent reads from the output, and check the script's schema:
```sh
mkdir -p <output>/contract
cp <skill>/references/finding-contract.md <skill>/references/finding.schema.json <skill>/references/before-after.md <output>/contract/
python3 -I <skill>/scripts/sync-schema.py --check
```
2. Launch the Workflow tool with `scriptPath` = the absolute path of `<skill>/workflow/audit.js` and `mode: "prepare"`. Every path is absolute except `exclude`, which is relative to the repo; `slices` is the `slices` list of `slices.json`, as it is:
```json
{
"mode": "prepare",
"repo": "/path/to/repo",
"output": "/home/me/audit-skills-runs/repo/2026-01-02",
"structure": "/home/me/audit-skills-runs/repo/2026-01-02/structure",
"date": "2026-01-02",
"skillsDir": "/path/to/audit-skills/skills",
"language": "Spanish",
"exclude": ["**/*.generated.*"],
"data": { "command": "/home/me/audit-skills-runs/repo/2026-01-02/db/q", "label": "local-dev" },
"slices": [ { "id": "S01", "name": "packages/core", "lines": 5200, "files": 41, "entries": [ { "kind": "tree", "path": "packages/core" } ] } ],
"models": { "map": { "model": "sonnet", "effort": "medium" } },
"available_models": ["fable", "opus", "sonnet", "haiku"]
}
```
`exclude` is **the same list** you passed to the scripts (the one in `slices.json`). The script applies it in code: what is excluded belongs to no slice, the explorers' evidence that falls there does not count and there is a warning, and if an entry of `slices` contains something excluded it warns that `slices.json` was not produced with that `exclude`. `available_models` is the list of the tool's `model` field; the script rejects a model that is not in it, an unknown role or an invalid effort. If you do not pass `models`, everything inherits the session. `language` is the language the user writes in; without it, English. The script rejects an empty one.
The run does two things:
- A global explorer writes `<output>/map.md`: a **descriptive and short** map (12,000 characters at most) with stack, modules, slices, entrypoints, stores (without secrets), topology, hot paths with their frequency, claims of the docs without a verdict and the HEAD and `git status` of the start. No suspicions, hypotheses or requested measurements.
- Slice explorers (in batches of ~30,000 lines or 8 slices) write `<output>/map/<slice>.md` with the facts of each slice: external inputs, auth, store writes, external effects, lifecycles, hot paths and LLM calls, each one with its `path:line`.
3. With those facts, the script assigns the skills by rule, and each pair carries its reason with the location that justifies it:
- `api-security-review` if the slice has external inputs (input from someone who is not the operator: HTTP, webhooks, queues, third-party responses or files; the arguments of a CLI the owner runs do not count) or auth;
- `data-consistency` if it writes to stores or has external effects;
- `perf-diagnosis` if it has hot paths (also those of the global map that fall in it);
- `implicit-state-machines` if it has lifecycles;
- `llm-app-review` if it has `llm_calls`: the slice builds a prompt, calls a model (SDK or HTTP of an LLM provider or a gateway), exposes tools to it, or parses or validates a model's output. These do not count: showing LLM spend, reading or aggregating rows of a call log, or saving the model's configuration; a cost panel does not get this skill. A section from an older explorer version that does not carry the fact (the key is missing, not empty) assigns it as a precaution, with a warning;
- `correctness-review` if the slice has executable code (`executable_lines` > 0 in `slices.json`: every language except SQL, Terraform, HCL, Protobuf and GraphQL). It does not depend on the map: it runs by default and is only skipped, with a reason, on a slice that is pure SQL or DDL, IaC, schemas, config or docs. A `slices.json` without that number (from an older version) assigns it as a precaution, with a warning.
A slice without a map section (the explorer failed) gets the six per-slice skills as a precaution. Skipped pairs go to `log()` with their reason. The evidence an explorer cites outside its slice or in the excluded part does not count, and there is a warning (one apart from the other). If the global map cites the excluded part, there is a warning too: remove it from `map.md` before auditing.
4. **Present the table** slice × skill with real data: each slice with its lines, the assigned skills with their reason, the skipped ones, the three whole-repo ones, and the cost again with the real assignment:
```sh
# save what prepare returned in <output>/assignment.json:
# {"assignment": [...], "skipped": [...], "whole_repo": [...]}
# and its git_start in <output>/git_start.json: {"head": ..., "status": ..., "branch": ...}
python3 -I <skill>/scripts/estimate-cost.py $E/slices.json --assignment <output>/assignment.json [--baselines N]
```
The user can remove or add pairs. A pair they remove moves from `assignment` to `skipped` with the reason "removed by the user: <reason>"; one they add leaves `skipped`. A pair is never in both lists. Save the confirmed version in `<output>/assignment.json`, with the three keys. **Nothing is launched without that confirmation.**
## Phase 3: run 2, audit
Launch the Workflow again, with the same `scriptPath` and the same `args` of phase 2, changing `mode` and adding:
```json
{
"mode": "audit",
"assignment": [ { "slice": "S01", "skill": "data-consistency", "reason": "store_writes: packages/core/src/ledger.ts:88 (UPDATE balance)" } ],
"skipped": [ { "slice": "S01", "skill": "implicit-state-machines", "reason": "no lifecycles in the slice map" } ],
"whole_repo": ["architecture-review", "code-structure", "infra-review"],
"git_start": { "head": "<from the prepare result>", "status": "<same>", "branch": "<same; null for a detached HEAD>" },
"baselines": null,
"max_verifiers": null,
"models": { "slice_auditor": { "model": "opus", "effort": "high" }, "verifier": { "effort": "high" } }
}
```
`assignment`, `skipped` and `whole_repo` come from `<output>/assignment.json`, and `git_start` from `<output>/git_start.json`. `git_start.branch` is the audited branch: the plan suggests it as the base of the PR stack, never `main` by default; with `null` (detached HEAD) or without it, the plan says "base: unknown, ask the user". `git_start.json` is also what a later re-audit reads to know which commit was audited. `skipped` is optional but worth passing: the script validates it (known slices and skills, non-empty reason, no pair also in `assignment`) and passes it to the plan, whose "Coverage" section lists each pair that did not run with its reason. A pair that is in neither list is warned and goes to the plan "no reason"; without `skipped`, every pair that does not run goes that way, with a warning. `baselines` is `null` or `{ "slice": "S03", "skills": ["data-consistency"] }`; the script ignores with a warning the skills that do not run on that slice. `max_verifiers` is `null` (no cap) unless the user asks for one; if there is one, the most severe blocks go first and the rest stays unverified, with a warning.
What it does:
1. **Audit.** One auditor per slice × skill pair, which reads its `SKILL.md` and applies its "Swarm mode" with the global map, its slice's section and `structure:`. It only reports findings whose main location belongs to its slice; it may open files outside only to follow a sequence that starts inside, and declares them in `outside_slice`. The three whole-repo ones read structure (including the graph and the history of `structure/`). Each one writes only `<output>/auditors/<skill>/<slice>/findings.json` (or `<output>/auditors/<skill>/findings.json` for the whole-repo ones): in swarm mode there is no `report.md`. Two auditors of the same skill never share a slice. The code checks the slice rule and marks, without deleting, what falls outside. What is excluded is out of scope for everyone, also for the three whole-repo ones (they audit the repo minus what is excluded): nobody audits it or cites it as evidence, and it is only opened to understand a call that leaves the scope. A finding whose main location falls in the excluded part is marked "out of scope", warned and verified anyway; the plan puts it in a separate section, out of the waves.
2. **Verification.** The code gives them neutral ids (`N001`…) in deterministic order, removes skill, slice, confidence, category and sources, and **groups without merging** the duplicate candidates: same file and nearby lines, or two or more `path:line` in common. The groups go whole in blocks of about 15 findings, one verifier per block, with no fixed cap: the verifiers grow with the findings. Each verifier gives one verdict per member (and can mark which ones of the group are the same defect), refutes by default and writes `<output>/verification/<block>.json`.
3. **Plan.** Every plan item carries a "Before/after" line from the `metric` of its findings ([before-after.md](references/before-after.md)). With more than 60 live findings, some consolidators merge by root cause in chunks that do not split groups. The plan agent writes `<output>/ids.tsv` (the table of ids and origins the code passes it), runs `merge-findings.py` to write `<output>/findings.json`, writes `plan.md` with the [template](references/remediation-plan.md), merges by root cause keeping the list of origins, writes `comparison.md` only if there were baselines and compares HEAD and `git status` with those of the start.
`merge-findings.py` fails hard (exit 1) if `ids.tsv` does not match its total, if an id repeats, if a verifier's file is missing or if a verdict appears twice; even so it writes `findings.json` with what is affected marked.
## Phase 4: review and present
1. Read the Workflow result: the `warnings`, the auditors that failed, `outside_slice`, `out_of_scope`, what stayed unverified and whether some block refuted nothing (the script warns if 15 or more verified have no refutation: the verifier's ability to refute is not measured).
2. Check `git -C <repo> status --porcelain` and HEAD yourself against those of the start. If something changed, it is the first thing you say.
3. Read `plan.md` and reread in the code the `path:line` of the items of waves 0 and 1. If one does not hold, fix it in the plan and say so.
4. Present in the chat: the summary, what needs a decision, the waves with their items, the refuted ones and the questions, with links to `plan.md`, `findings.json` and, if there were baselines, `comparison.md`. Add the real cost (tokens and minutes the Workflow reports) next to the estimate, to refine the next estimate.
5. If there was data access, `<output>/db/target.env` holds credentials: offer to delete it and close the tunnel, if you opened one.
6. **Stop.** Ask which items to approve. Implementation comes later, item by item, in stacked branches as the plan suggests, with the test first (`apply-remediation` does it).
## Re-audit
When the user asks to audit again a repo the swarm already audited ("re-audit", "what changed since the last audit", "re-audita el repo", "¿qué cambió desde la última auditoría?"), audit only what changed since a previous run. Slices, ids and plan items stay those of the previous run, so plans, remediation records and re-audits keep pointing at the same things.
1. **The previous run.** The most recent `<runs>/<repo>/<date>/` with `findings.json`, or the one the user names. If it is in the Spanish format (`hallazgos.json`, `auditores/`), copy it first with `migrate-run.py` (below) and re-audit from the copy. The repo's working tree must be clean; if it is not, ask the user to commit or stash (never do it yourself).
2. **Structure without re-slicing.** Create the new run `<new>` and copy what is kept from `<prev>`; the graph and the history are computed again at HEAD with the previous `exclude` (the one in `slices.json`), but `propose-slices.py` does not run:
```sh
E=<new>/structure; mkdir -p $E <new>/contract
cp <prev>/structure/slices.json <prev>/structure/slices.md $E/
cp <prev>/map.md <new>/
cp <skill>/references/finding-contract.md <skill>/references/finding.schema.json <skill>/references/before-after.md <new>/contract/
python3 -I <skill>/scripts/import-graph.py <repo> --output $E [--exclude '<glob>']
python3 -I <skill>/scripts/git-history.py <repo> --output $E [--exclude '<glob>']
python3 -I <skill>/scripts/diff-since.py <prev> <repo> --output $E [--since <sha>]
```
`diff-since.py` maps `git diff <previous head>..HEAD` onto the previous slices (a new file goes to the slice of its nearest folder, or is listed as unassigned), counts the changed lines per slice, says whether the structure changed, picks the previous findings to re-verify, computes repo metrics on both commits with `git archive` and re-runs the safe metric commands of the open findings. It writes `diff-since.json`, `diff-since.md` and `reaudit-args.json`. It refuses a Spanish run, a dirty tree and an unknown previous commit.
3. **Show the user `diff-since.md`** before anything else: the changed-slice table (changed files and lines, re-audited or not, previous pairs), the unassigned files, the structure verdict, how many previous findings get re-verified and the recommendation. **A full audit is recommended** when more than 30 % of the previous code lines changed, a new top-level module appeared, or the unassigned code reaches 10 % of the previous lines or 25 % of the changed code files (at least 3). Then offer the full audit (phases 0 to 4) as the first option. **The structure changed** when a manifest, an infra, CI or deploy file, a new module or top-level folder with code, or the import graph between modules (its modules or its edges) changed; only then do the whole-repo skills run again, and the user can force them.
4. **Cost**, as an estimate (not calibrated yet: say so):
```sh
python3 -I <skill>/scripts/estimate-cost.py --reaudit $E/diff-since.json [--cpus N] [--force-whole-repo] [--slow-map]
```
Ask the models per role as in phase 0; the re-verifiers use the `verifier` role.
5. **Confirm** the slices to re-audit, the pairs to remove, whether to force the whole-repo skills, the models and the cost. **Nothing is launched without that confirmation.**
6. **Launch** the Workflow with `mode: "reaudit"` and the args of phase 2 (`output` = `<new>`, `structure` = `$E`, `slices` = the `slices` list of the copied `slices.json`, `exclude` = its `exclude`), plus:
```json
{
"mode": "reaudit",
"previous": "<the content of $E/reaudit-args.json, as it is>",
"git_start": { "head": "<head of diff-since.json>", "status": "", "branch": "<branch of diff-since.json, or null>" },
"force_whole_repo": false,
"removed": [ { "slice": "S02", "skill": "perf-diagnosis", "reason": "not needed this time" } ],
"max_verifiers": null
}
```
What it does:
- **Map**: explorers only for the changed slices. The global map is not run again (`map.md` is the copy). A new file `diff-since.py` placed by its nearest folder joins that slice as a file entry; an unassigned one is read by no slice auditor, and it is warned and listed in the plan's coverage and in `reaudit.md`. The assignment rules are applied again to the changed slices. A previous `perf-diagnosis` pair the rules no longer give is kept, because it may come from a hot path of the global map; any other previous pair they no longer give does not run and is listed with its previous reason. The `removed` ones do not run.
- **Audit**: auditors only on the changed slices; the whole-repo skills only if the structure changed or `force_whole_repo`, otherwise skipped with the reason.
- **Re-verification**, at the same time: the open previous findings that touch a changed, renamed or deleted file, or that a remediation record says were applied, go blind (no skill, slice or record) to re-verifiers in blocks `R01`…, which say `fixed`, `still present` or `moved` (with the new `path:line`) at HEAD and write `<new>/reverification/<block>.json`. The others carry over as `unchanged`. A finding with an applied record is expected fixed: if it is still present there is a warning.
- **Verification** of the new findings: their ids continue after the previous maximum (and the groups too); old `N` ids never change. Each one is labeled `in changed code` or `in unchanged code` and compared with the still-open previous findings, with the grouping rule, to flag a `likely duplicate of`. Blind verifiers as in phase 3; `max_verifiers` caps only these blocks.
- **Plan**: the plan agent writes `ids.tsv` (with `# first=<n>`) and `reaudit.json` as the code passes them, runs `merge-findings.py <new> --name new-findings.json`, writes the updated `plan.md` (a previous item keeps its id while its findings are open; one whose findings were all fixed leaves the waves; new items get new ids) and runs `reaudit-report.py <prev> <new>`. There is no `comparison.md`.
7. **Present** as in phase 4, with `reaudit.md`, which `reaudit-report.py` writes:
- per skill and per severity: open before, fixed (verified), still open, moved, new (verified) and open after, labeled as counts of findings, not metrics, with a line for the new findings that are likely duplicates of still-open ones (counted twice until the plan merges them);
- repo metrics on both commits (lines, cycles, imports between modules…), from `git archive`;
- the previous run's remediation records, with the status of their findings now (an applied one whose finding is still present goes in its own list);
- the metric of each still-open finding re-run on both commits, or "not re-run: <why>";
- the plan items kept with their id, fixed (every finding fixed or refuted earlier), new, and the ones that left the plan with findings still open, classified by the status of their findings, not by the plan's headings;
- the changed files no slice auditor read;
- the previous findings with their re-audit status and the new ones with their verdict, label and likely duplicate.
`<new>/findings.json` has every previous and new finding with a `reaudit` object (`status`, `location_then`, `location_now`, `evidence`, `note`, `expected_fixed_by`, `label`, `likely_duplicate_of`); the next re-audit reads it as its previous run. The script also writes `<new>/git_start.json` (this run's head, so the next diff starts there) and `<new>/assignment.json` (the previous pairs of the unchanged slices plus the re-audit's). The new/unchanged label is per file, not per line.
## Without the Workflow tool
If it is not available, do the same phases with subagents and with the same prompts `workflow/audit.js` builds (read it: `mapPrompt`, `explorerPrompt`, `sliceAuditorPrompt`, `repoAuditorPrompt`, `baselinePrompt`, `verifierPrompt`, `consolidatorPrompt` and `planPrompt` are the reference, and the assignment follows the `APPLIES` table and `codeRule` for `correctness-review`):
1. The global explorer and the slice ones; wait for their results. Assign with the same rules, present the table and confirm.
2. The auditors in parallel, in batches if there are many. Do not give the baselines the path of the skills.
3. Merge the findings yourself applying `group()`, `inBlocks()` and `neutralize()`: deterministic order, ids `N001`…, groups without merging, blocks of about 15, only id, claim, absolute locations, same pattern, sequence and impact, without skill or slice names. Launch one verifier per block.
4. Write `<output>/ids.tsv` with the same format (`# total=<n>`, header and one row per finding), run `merge-findings.py` and write the plan yourself or with a last subagent.
5. Go on with phase 4.
A re-audit without the tool follows `reaudit()` the same way: `explorerPrompt` for the changed slices, `reassign()`, `reverifierPrompt` in blocks of 15, `numberFindings()` with the previous `max_id` and `max_group`, `ids.tsv` with `# first=<n>`, `reaudit.json` with the shape the script builds, then `merge-findings.py --name new-findings.json` and `reaudit-report.py`.
## Runs from before the English version
Runs written before the translation use Spanish names (`mapa.md`, `auditores/`, `hallazgos.json`, `"gravedad": "Alta"`…). Copy one into the current format before using it with `merge-findings.py`, `apply-remediation` or a reaudit:
```sh
python3 -I <skill>/scripts/migrate-run.py <old-run-dir> <new-run-dir>
```
It renames files and folders and translates keys and enum values; prose stays as it was. It never writes in the old folder and skips `db/` (credentials): set up `db-ro` again if needed. Findings without `metric` get `metric: null`. Remediation records are translated with the fields `apply-remediation` adds (`pila` → `stack`, `verde` → `green`, `falla:` → `fails:`…); `test.fails_with` and `suggested_branch` did not exist then, so they stay absent with a warning per applied record: add them by hand before `validate-record.py --recheck`.
## Maintenance
- The schema is changed in `references/finding.schema.json` and copied into the script with `python3 -I scripts/sync-schema.py`. `--check` fails if they differ.
- `code-structure/scripts/` has exact copies of `lines.py`, `import-graph.py` and `git-history.py`; if you change one, copy it (the structure test fails if they differ).
- Exclusion and membership are written twice: `lines.excluded()` and `lines.slice_of()` in Python, and between the `<membership:start>` and `<membership:end>` markers of `workflow/audit.js`. The structure test runs both on the same cases.
- Tests, without network or real databases, each one with an empty directory:
```sh
node tests/test-workflow.mjs <empty dir>
python3 -I -B tests/test_db_ro.py <empty dir>
python3 -I -B tests/test_merge.py <empty dir>
python3 -I -B tests/test_structure.py <empty dir>
python3 -I -B tests/test_migrate.py <empty dir>
python3 -I -B tests/test_reaudit.py <empty dir>
```
`node --check` on the literal script fails because of the final `return`, which only the Workflow runtime accepts; the test uses a copy wrapped in a function. The live Postgres test is `scripts/test-db-ro-postgres.sh`, against a disposable database the user names.
Files in this skill
- SKILL.md
- references/before-after.md
- references/data-access.md
- references/finding-contract.md
- references/finding.schema.json
- references/remediation-plan.md
- scripts/count-lines.py
- scripts/db-ro
- scripts/diff-since.py
- scripts/estimate-cost.py
- scripts/git-history.py
- scripts/import-graph.py
- scripts/lines.py
- scripts/merge-findings.py
- scripts/migrate-run.py
- scripts/propose-slices.py
- scripts/reaudit-report.py
- scripts/sync-schema.py
- scripts/test-db-ro-postgres.sh
- tests/test-workflow.mjs
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.