# audit

Adopt this skill: https://proskills.md/skills/other/rainmanjam-poka-yoke-plugins-poka-yoke-skills-audit

Page: https://proskills.md/skills/other/rainmanjam-poka-yoke-plugins-poka-yoke-skills-audit
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: plugins/poka-yoke/skills/audit/SKILL.md
size: 8024
upstream: https://github.com/rainmanjam/poka-yoke/blob/main/plugins/poka-yoke/skills/audit/SKILL.md

````text
---
name: audit
description: >-
  Find footguns in code that already exists: swappable arguments, silent fallbacks, unguarded deletes, signatures that are easy to misuse. Use when someone asks "what could bite us here", "what is easy to misuse", "poka-yoke this repo", or wants a diff or PR reviewed for ways to get it wrong. Ranks by blast radius. For code not yet written use design; for something that already broke use retro.
---

# Poka-Yoke Audit

Find the mistakes that are *available* in this code, then close them. You are not looking for
bugs: a bug is a mistake that already happened. You are looking for **affordances for
mistakes**: places where doing the wrong thing is easy, silent, and looks correct.

The load-bearing question throughout: *if a competent, tired engineer used this at 4pm on a
Friday, what would go wrong and would anything stop them?*

## 1. Establish scope

Default, when the user names no path:

1. `git diff HEAD`: uncommitted work. This is what they are most likely asking about.
2. If the tree is clean, `git diff HEAD~5..HEAD`: recent commits.
3. If neither yields anything (fresh repo, no git), fall back to the risk surfaces below and
   say that's what you did.

Widen to the whole repo only when asked ("audit the whole codebase", "full audit"). It is
slow and it buries the important findings in volume. When you do go wide, prioritize by
**risk surface** rather than by directory, go straight to code that touches money,
authentication, authorization, deletion or overwriting, migrations, external I/O,
concurrency, and anything with `admin`, `force`, `bulk`, `sync`, or `delete` in its name.

State the scope you chose in one line before you start, so the user can redirect you cheaply.

## 2. Run the detector, then think

```bash
python3 ../../scripts/detect_hazards.py --diff   # path is relative to this SKILL.md
```

Other useful forms: `--paths src/ lib/`, `--staged`, `--since HEAD~10`, `--json`,
`--severity high`, `--id C1 M2` to filter to specific rules. Run `--help` for the full set.

The script finds the mechanically detectable shapes, adjacent same-type parameters, boolean
flag arguments, unbounded deletes, money held as a float, unvalidated request bodies, retries
without an idempotency key. Shapes a real linter already covers, bare `except`, mutable
default arguments, `any` escape hatches, are off by default and named in the footer; `--all`
runs them too. It is a **fast first pass with real false positives**, not an oracle. Treat
each hit as a question to investigate, and read the surrounding code before you believe it.

Then do the part the script cannot: read the interfaces and run the three lenses over them.

**Contact, can the wrong thing fit?** Look at every public signature. Are two adjacent
parameters the same type? Could a caller pass an order ID where a user ID belongs, cents
where dollars belong, a raw string where a validated one belongs? Does the boundary accept
`any` / `dict` / `interface{}` and hope?

**Fixed-value, can an incomplete or wrong-sized set pass?** Is every enum branch handled,
and will adding a variant break the build or silently fall through? Can a bulk operation run
with an empty or unexpectedly huge set? Is config validated as a whole, or discovered
missing at 3am? Are required fields actually required, or optional-with-a-default?

**Motion-step, can the order be wrong?** Must something be called before something else, with
nothing enforcing it? Can a retry double-charge? Can a resource leak on the error path? Can
two callers interleave between a check and the act that depends on it?

The script only sees text. These three questions are where the audit's value comes from.

## 3. Classify every finding

Each finding gets four fields. Fill all four: an unclassified finding is just an opinion.

- **Mistake**: the specific wrong thing a person can do, stated as an action.
  *"Call `transfer(dst, src)` with the accounts reversed."*
- **Consequence**: what happens when they do, and how loudly. Silence is the aggravator: a mistake that throws immediately is far less dangerous than one that returns a plausible
  wrong answer.
- **Current rung**: what exists today, Control / Warning / Detection / **None**.
- **Proposed device + rung**: the specific change, and the rung it reaches. If you're
  proposing Warning, say what would be needed for Control and why you didn't.

## 4. Rank by expected damage, not by count

Priority is **blast radius × ease of mistake**, and nothing else. A hundred stringly-typed
internal helpers matter less than one `delete_users(filter)` where `filter` can be empty.

Blast radius, descending: irreversible data loss or money movement → security or
authorization bypass → silent data corruption → wrong output the user acts on → crash →
degraded experience. A crash ranking *below* silent wrong output is deliberate and worth
saying out loud: loud failures are cheap, quiet ones compound.

Ease of mistake, descending: silent and plausible-looking → requires only forgetting → needs
an unusual-but-reachable input → needs deliberate misuse.

Report the top findings in priority order and stop somewhere sensible, ten well-argued
findings beat forty. Say how many you set aside and why.

## 5. Report

Use this structure. It is short on purpose; the detail lives per-finding.

```markdown
# Poka-Yoke Audit · <scope> · <YYYY-MM-DD>

**Scope**: <what was examined, e.g. "uncommitted diff, 7 files, 340 lines">
**Verdict**: <one sentence, the single most important thing they should fix>

## Findings

### 1. <Short name of the mistake> · <Blast radius>/<Ease>
**Where**: `path/to/file.ts:42`
**Mistake**: <the wrong action a person can take>
**Consequence**: <what happens, and whether it is silent>
**Today**: <Control | Warning | Detection | None>
**Device**: <the specific change> → **<Control | Warning | Detection>**

<a short diff or code sketch>

<if not Control: one line on what Control would cost>

### 2. …

## Set aside
<n low-priority hazards, one line each, or "none">
```

Write it to `docs/poka-yoke/audit-YYYY-MM-DD.md` in the user's repo. If they'd rather not
have a file, keep it in the conversation, ask if it isn't obvious.

## 6. Propose, then apply

Present the findings and wait. Do not edit files yet. These changes alter interface shapes
and ripple through call sites; people reasonably want to see the plan first.

When they approve some or all of it: apply each device, leave a `poka-yoke:` marker comment
at it saying which mistake it blocks, and run the tests.

## Recording what a device is for

Devices only stay valuable if people know they are load-bearing. Without a record, the next
person deletes the "redundant" check or relaxes the "annoying" constraint, and the mistake
comes back. A device that has never fired looks like dead weight precisely because it is
working.

The obvious answer, keep a registry file listing every device, is **wrong, by this skill's
own argument.** A Markdown file someone must remember to update is training, not a device. It
goes stale exactly when it matters: the moment someone removes a constraint without touching
the doc. Do not ask anyone to maintain one.

**Put the reason where the device is.** A marker comment at the constraint travels with it,
gets read by the person about to delete it, and cannot drift out of sync because it is not a
separate thing:

```python
# poka-yoke: rejects a second charge for the same idempotency key   [control]
UNIQUE (account_id, idempotency_key)
```

```ts
// poka-yoke: forgetting to await this write would lose it silently [warning]
"@typescript-eslint/no-floating-promises": "error",
```

The bracketed rung is optional. What earns its place is the clause after the colon: the
*mistake*, stated as something a person could do. "Uniqueness constraint" tells a future
engineer nothing; "rejects a second charge for the same key" tells them what breaks if they
drop it.

**If someone wants an index, generate it.** Never hand-mainta
````

## File: README.md
upstream: https://github.com/rainmanjam/poka-yoke/blob/main/README.md

```text
<p align="center">
  <img src="docs/assets/banner/readme-header.png" width="100%"
       alt="poka-yoke: an andon signal tower beside the wordmark, with the severity ladder: green Control, the mistake is impossible; amber Warning, announced as it happens; red Detection, found afterwards.">
</p>

# Poka-Yoke

> **An agent will tell you what to fix. It will rarely tell you what its fix makes impossible.**
>
> Unprompted, models close a design by naming what it forecloses **45%** of the time. With
> these skills, **80%**, measured across 132 graded verdicts and six model families. That one
> habit is most of what this does, and it is the difference between advice you agree with and
> a constraint you can rely on.
>
> The average conceals where the effect lives. Asked squarely to design an interface, models
> already do this 77% of the time unprompted and the skills add eleven points. The large gains
> are in the scenarios where nobody asked for a design review — see the table below.
>
> A dependency-free **hazard scanner** for TypeScript, Python, Go, Rust and SQL; installable
> **pre-commit / CI / lint / hook devices**; and **11 skills** that apply the same method while
> you design. [Shigeo Shingo](https://en.wikipedia.org/wiki/Shigeo_Shingo)'s method, applied to
> code, process, interfaces, infrastructure, and AI.
>
> Runs on **19 agent runtimes** from one set of skills, 10 with a native manifest.
> Benchmarked on Claude Code;
> [the support tiers are stated honestly](docs/install.md#support-tiers-stated-honestly).

[![Claude Code](https://img.shields.io/badge/Claude_Code-benchmarked-d97757)](#install)
[![Codex](https://img.shields.io/badge/Codex-benchmarked-black)](#does-it-work-outside-claude-code)
[![Antigravity](https://img.shields.io/badge/Antigravity-benchmarked-4285f4)](#does-it-work-outside-claude-code)
[![Agent SDK](https://img.shields.io/badge/Agent_SDK-native-d97757)](docs/install.md#claude-agent-sdk)
[![Cursor](https://img.shields.io/badge/Cursor-native-6b46c1)](docs/install.md#cursor)
[![Gemini CLI](https://img.shields.io/badge/Gemini_CLI-native-4285f4)](docs/install.md#codex-copilot-cli-gemini-cli-via-agentsskills)
[![runtimes](https://img.shields.io/badge/runtimes-19-2ea043)](docs/install.md#support-tiers-stated-honestly)

[![skills](https://img.shields.io/badge/skills-11-8250df)](#whats-inside)
[![dependencies](https://img.shields.io/badge/dependencies-zero-2ea043)](#requirements)
[![devices](https://img.shields.io/badge/devices%20in%20CI-32-0969da)](docs/poka-yoke/registry.md)
[![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

<p align="center">
  <img src="docs/assets/lenses.svg" alt="The three poka-yoke inspection lenses: contact, can the wrong thing fit; fixed-value, is the set complete; motion-step, is the order right." width="100%">
</p>

> [!NOTE]
> **591 blind-graded runs across six runtimes**, at the first turn of a fresh session, scored
> against pre-written assertions by a grader that never sees which configuration produced a
> response. Every model improves on a no-skill baseline by more than noise: Fable 5
> **+8.3 pp**, Opus 5 **+3.6 pp**, Sonnet 5 **+8.6 pp**, Haiku 4.5 **+12.9 pp**: all four 95%
> intervals exclude zero. Nine of the 52 cells came out negative, where chance alone would
> produce about 18: individual cells hold 1 to 7 runs and are too small to read on their own,
> so the scarcity of regressions is the signal rather than their existence.
> [See the numbers](#benchmarks).
>
> All 591 runs are verified against the scenario prompts as they stand in this commit.
>
> **What this does not yet establish.** Blind grading controls bias, not accuracy. The baseline
> is *no skill*, not *a different methodology*, so whether any structured method in context
> would do the same is untested; a control arm is designed and unrun. And every run is a first
> turn, which measures the ceiling rather than what survives an afternoon of accumulated
> context. [The full list of what the numbers cannot tell you](#caveats).

## Contents

- [What it trades](#what-it-trades), read this before installing
- [Install](#install) · [Requirements](#requirements) · [Other runtimes](docs/install.md) · [Updating and uninstalling](#updating-and-uninstalling)
- [The hazard detector](#the-hazard-detector), the part that does not decay
- [What's inside](#whats-inside), 11 skills, starting with `design`
- [The method](#the-method): the two axes that do the work
- [What it looks like](#what-it-looks-like) · [Invocation](#invocation)
- [Benchmarks](#benchmarks) · [Caveats](#caveats) · [Repo layout](#repo-layout) · [Prior art](#prior-art)
- [Contributing](CONTRIBUTING.md) · [Releasing](RELEASING.md) · [Changelog](CHANGELOG.md) · [Code of conduct](CODE_OF_CONDUCT.md) · [License](#license)

---

## What it trades

Loading a method changes what a model attends to, and attention is finite. Measured across the
same 591 runs, the skills make responses markedly more constructive and slightly worse at
noticing the specific defect already in front of them:

| Behaviour | Baseline | With skill |
|---|---:|---:|
| Proposes a concrete device per finding, not "add validation" | 62% | **100%** |
| Names what the design makes impossible | 45% | **80%** |

Where that one behaviour is measured, broken out. The family mean above averages a
task where models already do it with three where they largely do not, which flatters the
easy case and buries the interesting one:

| Scenario | What the model was asked for | Baseline | With skill | n per arm |
|---|---|---:|---:|---:|
| `build-endpoint` | Write an endpoint | 14% | **79%** | 14 |
| `build-agent-feature` | Ship an agent feature | 33% | **83%** | 12 |
| `build-form` | Build a form | 29% | **64%** | 14 |
| `design` | Design an interface | 77% | **88%** | 26 |

The skills matter most when nobody asked for a design review.
| Notes `pre-commit` is bypassable and must be backed by CI | 35% | **92%** |
| Identifies a raw SQL interpolation as an injection vector | 92% | **69%** |
| Explains why a silently wrong number beats a failed pipeline | 54% | **31%** |

**So: if you want the bug in front of you found, use a reviewer. If you want the shape changed
so that class of bug stops being expressible, use this.** Loading it for the first job makes
the model measurably worse at it. That trade is the product, not a caveat about it.

---

**People will always make mistakes. That is not the problem worth solving: the problem is
letting a mistake become a defect.**

Shigeo Shingo: the industrial engineer who named poka-yoke and worked it out on the factory
floor, built his quality method on that distinction. Instead of asking workers to be more
careful, he redesigned the work so a mistake could not survive it. Assemblers kept forgetting
a spring inside a switch, so he had them lay both springs in a dish first: a spring still in
the dish was the error announcing itself, before the unit could move on.

This plugin applies that method to software. Not as a metaphor: the taxonomy is the actual
working tool. Every finding is classified by **what happens when the mistake occurs** and
**how the device notices**, which is what keeps it from collapsing into generic code review.

**The line that does most of the work:**

> A comment, a docstring, a wiki page, a review checklist, or a line in CLAUDE.md saying
> "don't do X" is **not** a poka-yoke. It is training, and training degrades. A device does
> not. If your fix relies on someone remembering something, keep going.

**You have already tried writing the rule down.** Every repository that needs this has a
`CLAUDE.md`, an `AGENTS.md` or a `CONTRIBUTING.md` with a list of things everyone is supposed to
remember, and the list is longer than it was a year ago because the reminders did not hold. That
list is the real alternative to this plugin, not an unassisted model, and the argument here is
about why it decays and what to put in its place.

That is also the honest limit o
```
