Find the states
you never intended.
An evidence-backed audit of state machines, async races, and data that gets out of sync. Run it with the coding agent you already use.
When to use this: before a state-heavy release, after a race-condition incident, or when a lifecycle has become difficult to reason about.
Install for your agent #
You need an installed coding agent and Node.js 22.20+ for the community Skills CLI. Run the command below, review the installer prompts, then reopen your agent session.
npx skills add adityaarakeri/state-machine-audit --skill state-machine-audit --global --agent claude-codeSelect Claude Code in the installer. Use the prompt in step 02 from a session opened in the repository you want audited.
--global makes the skill available across projects. For a project-only install, run the command inside that project and omit --global. Agent authentication and model access are configured separately.
Prefer a local clone or an offline skill copy?
The repository scripts require Node 18+; the bundled installer requires Bash (Git Bash or WSL on Windows).
git clone https://github.com/adityaarakeri/state-machine-audit.git
cd state-machine-audit
npm run lint
bash scripts/install.sh --agent claudeThe bundled installer accepts claude, codex, cursor, or all. For Antigravity and OpenCode, use the Skills CLI above. For a manual install, copy the entire skills/state-machine-audit/ folder, including references/, into your agent's documented skill directory.
The Bash installer replaces an existing installed folder of the same name. Save local customizations before rerunning it.
Installation options and agent identifiers follow the Skills CLI documentation and its supported-agent reference.
Open the target repository
Start Claude Code, Codex, OpenCode, or an Antigravity workspace in the codebase you want reviewed. Record your existing changes first so you can distinguish them from the audit output.
git status --shortSend this in your agent's chat. The same plain-language request works across the four agents; there is no special audit CLI to launch.
Use the state-machine-audit skill on this repository.
Focus on checkout, payment status transitions, and async UI updates.
Read and search only. Do not change application code or run builds.
Write an evidence-backed report with exact file locations,
verbatim snippets, concrete failure scenarios, and structural fixes.
State which modules you covered and which you skipped.The skill writes REPORT.md. If that exists, it uses REPORT-state-audit.md, then a dated fallback. Existing reports must not be overwritten. If every suggested filename is occupied, ask for a fresh filename before writing.
For an agent without native skills, run npm run build in this skill's clone and paste dist/prompt/state-machine-audit.md into its chat. Generated adapters also support Cursor rules, Copilot prompts, GEMINI.md, and AGENTS.md. Merge instructions carefully into any existing instruction file.
A payment finishes late
Imagine a checkout that lets a customer cancel while a payment request is still running. Its status can say cancelled, then jump to paid when the old promise resolves.
Illustrative code, not a finding from your repository:
async function pay() {
setStatus('paying');
await charge(orderId);
setStatus('paid');
}
function cancel() {
setStatus('cancelled');
}A useful finding describes the ordering that causes the bug, cites the actual lines, and checks whether cancellation or an operation identifier already prevents it. A suspicious pattern alone is not evidence.
The proposed fix might centralize legal transitions and associate each completion with its operation ID. Payment reconciliation still belongs on the server; ignoring a stale UI response does not undo a charge.
Try the included fixture
Open evals/fixtures/react-shop/ in your agent and request the audit there. This synthetic fixture contains planted bugs and correct decoys. Keep the answer key in evals/expected/ out of the audit context. Review its report against the fixture afterward.
Read the evidence first
A report is an investigation, not proof that the repository is bug-free. Use this checklist before turning findings into work items.
git status --short
git diffExpected report sections: executive summary, structural metrics and inventory, detailed findings, and a prioritized remediation roadmap. Choose specific finding IDs for a separate implementation request.
Update or remove
For Skills CLI installs, use its interactive commands to inspect updates or remove the skill. Select the installation scope and agent you originally used.
npx skills check
npx skills update state-machine-audit
npx skills remove state-machine-auditThese are separate actions: run only the line you need. For a Bash installation, run bash scripts/install.sh --uninstall --agent claude from the clone, substituting your original agent and scope flags. Removal deletes the installed skill copy, not reports in audited projects.
When something gets stuck
| Symptom | What to check |
|---|---|
| Agent cannot find the skill | Reopen the session. Check npx skills list and confirm the installation scope and selected agent. |
| Agent starts fixing code | Stop the run. Restate the read-only request. Inspect the diff against your baseline before deciding which changes to undo. |
| References cannot be opened | Reinstall the complete skill folder. Copying only SKILL.md omits the rubric and report template. |
| Install command fails on Node | Run node --version. The current Skills CLI needs 22.20+; repository scripts need 18+. |
| No findings in a large repository | Read the declared scope. Run another audit on a specific state-heavy module; zero findings is not full coverage. |
| Windows scorer test fails | A known assertion expects forward slashes in a path. The last local run passed 14 of 15 tests; validation and adapter build passed. This does not establish an agent's audit quality. |
Six ways state goes wrong
- Invalid combinations: independent booleans admit contradictory states.
- Illegal transitions: status writes bypass lifecycle rules.
- Async races: stale responses overwrite newer work.
- Failure boundaries: state and external side effects disagree.
- Hydration gaps: stored or incoming values are trusted without validation.
- Global interruptions: logout, cancellation, or recovery logic drifts across modules.
The audit skips generated and vendored code. An explicit state machine needs both a declared set of states and one place that determines legal transitions.
Validate the skill itself
From the skill repository, these commands check the instructions, test the report scorer, and build agent adapters. They are maintainer tasks, not commands the audit should run in the target codebase.
npm run lint
npm test
npm run buildReal-agent evaluations require a configured agent and may use paid model calls. See the evaluation guide and recorded results and limitations.