aipromptguide-workflows / tests
CLAUDE.md1 starsChanged 2 months agoMITView on GitHub
Who this is for. This file is for changing the workflows. The root CLAUDE.md and each workflows/<x>/CLAUDE.md are for running them inside someone's project — they happen to be useful reference when editing, but they are not where development lore belongs. It goes here. Everything below was learned the expensive way. Read it before you change an engine. The single most productive habit in this repo. The engines are deliberately standalone copies (#11 does not apply across them — see…
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- tools/CLAUDE.mdCLAUDE.md
- brainstormSkill
- debugSkill
- decideSkill
- developSkill
- docsSkill
- enhanceSkill
- investigateSkill
- refineSkill
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 65
metamust be a PURE LITERAL: No variables, no calls, no ${}. - Distinctive: line 72
The harness is not an LLM: No context window, no tools: it cannot read a file, run git, or shell out.
- Very specific: line 89
Ask of every ?. on an agent return: does the failure case look identical to a success case?
- Very specific: line 109
Write-confirmation asymmetry: If one role's schema has wrote_file and its siblings don't, the ones without can report success having …
- Distinctive: line 149
Save strictly before clear: If the patch cannot be written, leave the tree exactly as it is.
- Distinctive: line 172
No prompt-quality tests: Not testable here by construction — see §6.
- Distinctive: line 184
Verify a regression test fails against the old code: before trusting it. Reintroduce the bug, watch it go red, put it back.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Working on the engines — gotchas (for Claude)
Who this is for. This file is for changing the workflows. The root CLAUDE.md and each
workflows/<x>/CLAUDE.md are for running them inside someone's project — they happen to be useful
reference when editing, but they are not where development lore belongs. It goes here.
Everything below was learned the expensive way. Read it before you change an engine.
1. Fix it in EVERY engine, not the one you found it in
The single most productive habit in this repo. The engines are deliberately standalone copies (#11 does not apply across them — see §5), so a defect in one is usually a defect in three. And the review workflow structurally cannot see this: each reviewer gets one unit, so a sibling's copy of the same bug is invisible to it. Finding the twins is the operator's job at triage.
Real examples, all from one week:
| Defect | Found in | Actually in |
target.repo documented Required, defaulted to '.' | migrate | feature, migrate, resolve, review (+ enhance) |
gates.build unvalidated → build-only auto-passes | migrate | feature, migrate, resolve |
runOnly ids never validated (a typo = silent no-op) | feature | feature, migrate |
Acceptance stages on pass without reading regression | feature | feature, migrate |
| Park names a review file that was never written | migrate | migrate, feature |
| Lens/source id collision overwrites a sibling's file | brainstorm | brainstorm, decide, docs, enhance |
Non-numeric maxRounds → NaN → zero-round run reported as a normal terminal state | investigate | investigate, decide, docs, feature, migrate, resolve |
The families — a fix in one member almost always belongs in the others:
- Build loop:
develop-cyclealone. Itsfeature,sectionandfixmodes share one loop (develop → blind quality → acceptance, park, staging,DISMISSED-<id>.md,NEEDS-USER.md), so the loop twins across the retired feature, migrate and resolve engines no longer exist. A defect in one mode's frame can still recur in the other two modes' frames in the same file. - Read-only fan-outs:
debug/review·enhance-cycle(finder → verifier, one output file per unit/lens, clean-marker written by the finder) - Lensed generative:
brainstorm·decide·docs·enhance(an id-keyed array fanned out to one file each) - Non-blind review loops:
decide·investigate·refine(producer ⇄ adversarial critic against a fixed rubric, bounded bymaxRounds, solo critical agents that throw on a null return rather than defaulting to a clean verdict).refinepairs a read-only critic with a minimal-fold editor under a fixed defect bar. Its dead critic throws, because zero gaps from a dead agent would read as convergence.
investigate is the family's odd member: its candidates are found round by round rather than fanned
out once, so its loop state lives in a ledger (DISQUALIFIED.md) instead of an up-front id array. When
fixing a loop defect in decide, check whether investigate's round loop has the same shape — and note
that the reverse is often NOT true, since decide's two-variable reviewPath/lastReviewFile split
(decide-cycle.mjs:304-305) is correct there only because it has an agree-gate investigate lacks.
Do it by grep, not memory. grep -n "TARGET.repo" workflows/*/*.mjs finds in seconds what a reviewer
cannot find at all. Then fix each in its own file with parallel wording — never by extracting a shared
module (§5).
2. The runtime contract — things that break silently
An engine is not an ordinary Node module. The harness executes the file body with
agent/parallel/pipeline/phase/log/args/budget/workflow injected as globals.
node --checkdoes not work on an engine — top-levelreturnis legal here and a syntax error there. Use the harness wrap (tests/harness.mjs, ornode tests/run.mjs).metamust be a PURE LITERAL. No variables, no calls, no${}. The tool parses it statically; interpolation breaks discovery at launch, not at edit time.Date.now(),Math.random(), arglessnew Date()THROW. They would break resume. Pass timestamps in viaargs; vary by index instead of randomly.- LF only. One CR byte and the Workflow tool rejects the file outright.
.gitattributesenforces it and the suite checks it, but an editor can still reintroduce it. gen-units.mjsis the exception — ordinary Node with real imports, run directly. Judge it normally.- The harness is not an LLM. No context window, no tools: it cannot read a file, run git, or shell out. "The harness should just read X" is never a valid fix — that work belongs to an agent, or to the main agent before the run (#4).
3. Recurring defect shapes — check these first
A dead agent is the number one source of real bugs. agent() inside parallel()/pipeline()
resolves to null when that agent dies. Every one of these launders a dead agent into a plausible value:
const gaps = curate?.gaps ?? []; if (!gaps.length) break; // dead curator == "finished, no gaps"
const dirty = fix?.baseline_dirty_files ?? -1; // -1 means "n/a"; null collapses into it
const verdicts = v?.verdicts || []; // dead verifier == "nothing to report"Ask of every ?. on an agent return: does the failure case look identical to a success case? If yes,
guard it. The house pattern is a throw for a solo critical agent (decide, docs curator) and an explicit
halt for one inside a loop (develop's round roles).
Sentinel collisions. Any ?? -1 / ?? 0 / || [] meaning "not applicable" must not be reachable by
a missing value. Check the null path separately, before the sentinel logic.
Attestation theater. A schema field the prompt demands and the harness never reads does nothing.
unstaged_confirmed was required, instructed in bold, and read nowhere for months; wrote_file sat
unread in review.mjs until 2026-08-01. TOP-LEVEL fields are gate-enforced now: static.test.mjs
resolves every schema an agent() call is handed — including the function-built one — and fails any
top-level property with no .field / ['field'] / destructured read through that site's RECEIVER
variable (aliases via bare x = recv; assignments count, transitively; a receiver name with more
than one binding in the file is a loud extractor error — rename the colliding local). Sites with no
resolvable receiver (pipeline stages, .then chains, bare return agent() fall back to the old
file-wide name-level match and are LISTED in the test file, so degraded coverage is visible. NESTED item
fields are still on you: they are excluded deliberately (measured — an all-depth rule was 33 false
positives out of 36) because a container is routinely consumed wholesale, so a dead field one level down
is invisible to the sweep.
Write-confirmation asymmetry. If one role's schema has wrote_file and its siblings don't, the ones
without can report success having written nothing. Make the set consistent.
Prose-sniffing for control flow. status = haltReason.includes('needs user') ? … : … silently
reports the wrong thing the moment someone adds a halt reason. Set an explicit haltKind at every halt
site and map it. feature did this; migrate had to catch up.
A flag derived from a halt-kind DEFAULT inherits a lie no sweep can see. (Its first-order cousin —
a coerced numeric bound silently producing a zero-agent run — is gate-enforced now: static.test.mjs
runs every engine against garbage bounds and expects a throw, so it needs no manual vigilance.)
haltKind starts as 'rounds', so determination: haltKind === 'rounds' ? FILE : '' named a file
nothing wrote. Gate such a flag on round > 0 — the proof an agent actually ran — the way decide's
round ? decisionFile(round) : '' already did.
A pre-filter that drops candidates before the verifier makes the floor invisible. enhance cut
below-floor candidates on the finder's own unverified score, logged the count, and dropped it — so a
minImpact set too high was indistinguishable from a clean system, and those candidates appeared in no
proposal file at all. If a knob silently removes work, its count belongs in the return (#8: a count is
control plane), or the operator cannot tell the knob from the verdict.
Documented-Required-but-defaulted. abs() resolves a relative path against ROOT, and ROOT is the
tool's directory — so TARGET.repo ?? '.' silently means "operate on the workflow tool itself." For an
engine that runs git checkout -- and deletes files, that is the destructive case. If a doc says
Required, the engine must throw.
Self-contradictory agent returns. {pass: true, regression: true} violates pass's own schema
description. Decide deliberately whether each contradiction halts or is merely flagged — the test we
settled on is does the harm compound? A regression poisons the baseline every later unit is judged
against (halt); an unreachable feature does not (flag).
4. Invariants you must not break
- Every terminal exit leaves a clean unstaged tree. Accepted work is staged, unfinished work is
parked (saved to
parked-<id>.patch, then cleared). This is load-bearing: it is what makes the round-1 clean-baseline precondition correct on a resume, not just a fresh run. Add a new exit path and it must either park or have changed nothing. The two deliberate exceptions are a dirty baseline (nothing was changed; that work is the operator's) and passed-but-unstaged (the work is good and onegit addfixes it — parking would be worse). - Save strictly before clear. If the patch cannot be written, leave the tree exactly as it is.
- Never tell a user to apply a parked patch and then resume. It makes the tree dirty and the round-1
precondition rejects it. The honest options are resume clean and redo or apply and finish by hand —
and never
git add -Athe restored work, which promotes un-reviewed code into the accepted baseline where the blind reviewer cannot see it and every later regression check treats it as known-good. - Staging is the only boundary, and nothing is ever committed. The user commits.
- The blind reviewer is blind by placement. Run-state lives outside the target repo so it cannot
reach the issue files, and the blind prompt's only run-state paths point into its own
runs/<runId>/gate/(its review files + DISMISSED ledgers). Never hand it a path intoruns/<runId>/outsidegate/— NEEDS-USER, AMENDED, critiques and issue files all live there. - debug hunts defects only. Its inventory feeds an autonomous fixer, and an improvement list never
converges. Improvements are
enhance, which deliberately has no fix-mode output.
5. Not defects — don't spend review cycles here
- Duplication between sibling engines. Deliberate: each is standalone and copyable. Never extract a shared module or import across workflows. (#11 governs facts, not code across independent tools.)
- WHY comments. A one or two line comment stating a constraint the code cannot show is the house style. A long one, a history note or a restated guide is a #13 finding, not a defect: it belongs to an enhance conciseness pass, never to debug.
- Missing JSDoc, "this function is long", naming preferences, formatting.
- No prompt-quality tests. Not testable here by construction — see §6.
6. Testing
node tests/run.mjs. See README.md for the API; the short version:
- Test failure paths. The happy path is exercised constantly by real runs. Halts, parks, dead agents, contradictory returns and bad args are what rot silently — and are where every real defect has been.
respond: { 'label': null }simulates a dead agent — one character, and it covers §3's number-one defect shape.- Verify a regression test fails against the old code before trusting it. Reintroduce the bug, watch it go red, put it back. A green test that would never have caught the bug is worse than none.
- A cross-engine sweep must RUN each engine, not grep it. The numeric-bound sweep started as a source
grep for
Number.isFiniteand was a false gate: the pattern was satisfied by a different arg's validator in the same file, so an engine could reintroduceNumber(A.maxRounds)on the arg that mattered and still pass — proven with a mutant that produced a zero-agent run. Grepping for the shape of a fix cannot tell you the fix is wired to the thing it must guard. Same trap as attestation theater, one level up. - Don't hand an unguarded loop a huge bound to prove a cap exists. Probing
maxRounds: 1e21against an engine that lost its cap does not fail the assertion — it runs until V8 dies, and a heap-exhaustion stack trace buries every other result. Probe just above the cap (51). - Prompt correctness is testable; prompt quality is not. "Does this interpolate a path that
exists" is a contract — assert it with
prompt(prefix). "Is this well written" is what the review loops are for. - The suite tests the ENGINE, never the AGENTS. Green does not mean the workflows work; it means the control plane does.
7. Flow maps — the diagrams are a gate, not decoration
workflows/<x>/FLOW.md is generated: tools/gen-flows.mjs runs each engine through
tests/harness.mjs against a scenario table in tools/flows/<name>.flow.mjs and draws what it watched.
Edit an engine and you must regenerate, or the suite goes red:
node tools/gen-flows.mjs # regenerate all
node tools/gen-flows.mjs develop # just one
node tools/gen-flows.mjs --check # what the gate runs; exit 1 lists the stale filestests/flow-coverage.test.mjs is the part that earns its keep. Per engine it asserts that every
agent() role, every throw new Error( site and every HALT_STATUS value is reached by some scenario,
that the committed map is fresh, and that meta.phases matches the phases agents really run under.
Three things to know before you touch it:
- Phases are read from each call's
opts.phase, never from firedphase()calls.review.mjsandenhance-cyclenever callphase()at all, anddocs-cyclecalls it once against three declared phases — measuring the calls would report three engines as drifted and the "fix" would be deleting correct launch documentation. - Coverage cannot see a branch that adds no role, no throw and no new terminal. A dead-agent path, a skipped stage, or a second route into an existing terminal is invisible to every assertion. The scenario tables carry comments saying which branches are load-bearing for exactly this reason — read them before deleting a scenario that looks redundant.
- Add a scenario, don't loosen a check.
allowUncovereddemands a reason and fails if the item turns out to be covered, so it cannot quietly become a dumping ground. - The maps are published, so they are dash-free.
dedashflattens em/en/horizontal-bar dashes to ASCII hyphens in the finished document, and a coverage assertion holds every map to it. Do not strip dashes from engine prose to satisfy it: aHALT_STATUSstring is an engine return value that tests assert verbatim, and the normalization is presentation-only by design.
The tables are deliberately parallel to the *.test.mjs files rather than shared with them: the tests
optimize for failure paths, the maps for complete terminal coverage, and a test deleted as redundant
would otherwise blank a branch of the diagram.
Is the diagram READABLE? — tools/render-flows.mjs
gen-flows.mjs proves a map is correct; it cannot tell you the picture is legible. Mermaid does no
collision avoidance on edge labels, so two long ones leaving the same node render on top of each other
and neither can be read — invisible to every text assertion, and for a while it was only caught by a
human squinting at screenshots.
node tools/render-flows.mjs # lay every map out in real Mermaid, report overlapping labels
node tools/render-flows.mjs develop # one
node tools/render-flows.mjs --png # also write PNGs to tools/.cache/render/ (gitignored)It drives the Chrome already on the machine with --dump-dom — no puppeteer, no playwright, still zero
npm dependencies. Mermaid itself is fetched once into tools/.cache/. It is not wired into
node tests/run.mjs, deliberately: it needs a browser and (once) the network, and the suite must stay
runnable anywhere. Run it by hand after changing anything that affects layout.
Layout knobs, all tuned against it — raise spacing before shortening text, because room is free and dropped information is not:
NODE_SPACING/RANK_SPACINGingen-flows.mjs(override viaFLOW_NODE_SPACING/FLOW_RANK_SPACINGto re-run the sweep). 60/90 left 8 of 9 maps colliding; 80/200 leaves 2.WHEN_BUDGETcaps an edge label by length. It bounds the string Mermaid receives (beforeesc()) — the· +N moretail and the(×N)repeat count are charged against it, not added after. They used to be added after, so a 34-char budget could emit 50 characters. The budget decides how many conditions to show, never how many characters of the last one: a single over-budget condition is emitted whole, because a back edge is not a terminal and no table below carries its text, so truncating destroys the only copy.- Two edge kinds carry a reference instead of their text, and never collide as a result: edges into a
terminal are drawn unlabelled (one agent often fans out to six endings) with their conditions in the
Terminal states table; self-loops carry a marker (
L1 ×4) with their conditions in the Loops table. Both are indexed by the question a reader actually asks, both are complete rather than truncated to fit on an arrow, and both are bounded by construction — which is the property that matters, since it cannot regress when a diagram grows a node or a renderer retunes its layout. That only works while the tables are actually populated.buildGraphcollected the terminals' conditions and the projection dropped the field, so for nine committed maps the "Reached when" column was blank: the conditions were on no arrow and in no table. Moving text off an arrow is only half the fix — assert the destination, whichflow-coverage.test.mjsnow does on the rendered row. - Node labels are NOT capped, and a cap is not the fix for a wide map. Throw labels used to ellipsise
at 52 characters, which shipped
throw: args must include at least { runId, root, target, s…to a published page. Removing it was measured withrender-flows.mjs: +24px on 3 of 9 maps, 6 unchanged, because the widest box on these maps is a ~104-character terminal that nothing caps — the throw boxes were never the binding constraint. The clause cut infirstClausestays (messages run to 289 characters and continue into resume instructions); what survives it is emitted whole. If a map is genuinely too wide, raise the spacing constants or wrap with<br/>. readThrowsreturns TWO forms of each message, and they are not interchangeable.prefixstops at the first${because it is the key a runtime message is matched against (startsWith) — it must stay a literal head.templateis the whole message with values elided toINTERP(...), and it is what a LABEL is built from. Labelling off the key printedthrow: plan id(s) [for a message that goes on to say what is wrong with them. A test that only checks "the label is part of the message" cannot tell the two apart, since the key is itself a prefix of the template — assert the rendered node.- A clause cut must know what it is cutting inside of.
firstClausetreats three spans as atomic, and each was a shipped defect: brackets ((inside{ runId, planPath | plan (markdown string) … }cut to a dangling| plan), double quotes (:inside"## Plan: <id>"ended a node mid-quote), and the elided value (...+ a space reads as the.sentence separator, cuttingargs.runOnly ... matches no plan iddown toargs.runOnly ..). Single quotes are deliberately NOT tracked — the messages are prose full of apostrophes, and one opener leaves the scan unbalanced for the rest of the message. Unbalanced input falls back to the depth-blind cut, never to the whole message.
Solved — every map renders clean (8 as of 2026-09-25). Keep it that way by never putting authored text on a self-loop
or on either edge of a marked node pair. Both shapes are markered now: self-loops carry L<n>
(conditions in the Loops table), the back edge of a boundary+back pair carries E<n> (conditions in
the Edges table), and the boundary edge of a marked pair renders caption-less — mermaid places both
labels of a multi-edge pair at the same path midpoint (measured 39×22px overlap at every one of six
swept spacings, even with a 5-char marker), so a pair can carry at most ONE label; the Edges table's
fixed sentence carries the next-item advance instead. The history is worth knowing, because the
obvious fixes are all wrong:
Mermaid 11.16.0 changed self-loops to a single SVG path through two dummy nodes
(layout-algorithms/dagre/index.js, getSelfLoopSide: "so loops are not always forced above the node"),
tucking the loop into a fixed-width side gutter without ever feeding the label's width into layout.
Bisected: 11.4.1 / 11.8.0 / 11.12.0 / 11.15.0 clean; 11.16.0 broke two maps. render-flows.mjs had
been fetching mermaid@11, a floating tag, so the gate's verdict changed when the CDN moved rather
than when the maps did. It is pinned now, cache keyed by version.
Measured and ruled out — do not re-run these sweeps: RANK_SPACING to 340 changes nothing (the gutter
does not scale with it); shortening a self-loop character budget makes it worse (relayout put a
third map into collision); layout: elk renders byte-identically to no config at all (ELK left mermaid
core in v11 and GitHub has not installed the separate package). defaultRenderer: "elk" is a trap —
it reports zero overlaps and is a false positive: not ELK at all, it reverts to the legacy self-loop path
and scores "clean" by dangling the label in whitespace at the tip of a long teardrop.
The fix was structural, not a constant: self-loops carry a marker and their conditions live in the Loops
table (above). Verified clean on both 11.4.1 (what GitHub was last observed serving) and 11.16.0 (the
strictest layout measured), which is the point — a bounded label cannot regress when a renderer retunes.
The Loops table also carries the full condition list, where the arrow had been truncating to +N more.
8. Before you call a change done
- Grepped the sibling engines for the same defect shape (§1) and fixed each in its own file
node tests/run.mjsgreen, and a new case covering what you changed- Any new agent return is guarded for
null(§3) - Any new exit path parks or changed nothing (§4)
- The workflow's
CLAUDE.mdupdated — a new required arg, return field, written file, or halt condition is a documented behavior change; itsREADME.mdtoo if a human-visible behavior changed metastill a pure literal, still LF-only (the suite checks both)- Prompt text changed?
node tools/gen-prompts.mjsre-run, and its snapshot diff read for variants the change was not meant to reach - Engine edited?
node tools/gen-flows.mjsre-run and the updatedFLOW.mdcommitted (§7); a new agent, guard or terminal state needs a scenario intools/flows/<name>.flow.mjstoo - Root
README.mdchangelog updated if a user would notice
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

