agentleFS
BlakeemBlakeem/aipromptguide-workflows/tools/CLAUDE.md

aipromptguide-workflows / tools

CLAUDE.md1 starsChanged 2 months agoMITView on GitHub

Plain Node, run directly, zero dependencies. These are NOT Workflow engines: they use real imports, node --check works on them, and they are judged as ordinary code (../tests/CLAUDE.md §2). Most of them build and verify this repo's own artifacts. plan-block.mjs is the exception: it runs DURING a workflow, invoked by agents that develop-cycle and refine-cycle hand a command. Its argv shape, its stdout bytes and its exit codes are a run-time contract two engines depend on — change them and…

The file

We split this CLAUDE.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read it before writing or changing a scenario table.

    line 108

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

tools — repo development machinery (for Claude)

Plain Node, run directly, zero dependencies. These are NOT Workflow engines: they use real imports, node --check works on them, and they are judged as ordinary code (../tests/CLAUDE.md §2).

Most of them build and verify this repo's own artifacts. plan-block.mjs is the exception: it runs DURING a workflow, invoked by agents that develop-cycle and refine-cycle hand a command. Its argv shape, its stdout bytes and its exit codes are a run-time contract two engines depend on — change them and you change what a developer agent receives, so treat it as engine surface, not dev machinery.

FileWhat it does
plan-block.mjsPrints ONE ## Plan: <id> block out of a multi-unit plan file, byte-exact, or --lists the file's control data. It reads the plan-bus metadata grammar. Called by agents at run time (see above). Keeps a multi-unit plan out of every agent's context and makes the block's end a parser's decision rather than an agent's.
plan-edit.mjsWrites plan files, the only tool that does: set upserts one block or issue metadata line, move relocates an issue entry (a cut, never a copy), args folds finished develop runs' statuses into the plans and prints the next launch's args. Operator-invoked between runs, never handed to a run-time agent. It is a separate file from plan-block.mjs because the run-time allowlist rule covers every subcommand of the file it names. Imports plan-block's exported grammar.
plugin-access.mjschecks for, and on the user's yes grants, the Read allow rule in the user settings that lets the Workflow tool launch an installed plugin's engines. A plugin path through a link gets a second rule for the resolved folder. The tool refuses a scriptPath the session cannot already read, and a plugin cannot grant itself its own folder. Run by each skill's first step, operator-side, never by a run-time agent. A cache install is granted the plugin folder above the version folder, so updates keep the rule.
wt.mjsThe batch-worktree lifecycle (init/prep/land/clean) for running several engine runs in parallel, each in its own git worktree. Operator-invoked around the runs — no agent ever calls it, no engine knows it exists. Its header comment is the contract (hook bytes, lock liveness, exit codes — all measured decisions); the operator playbook is ../docs/worktree-batches.md.
gen-flows.mjsGenerates workflows/<x>/FLOW.md — the Mermaid flow map of an engine's complete agent flow. Runs each engine through tests/harness.mjs against a scenario table and draws what it watched, so a diagram can only ever show a path that really executes.
freeze-notes.mjsCopies an engine for a live test of the workflow itself: every agent call is wrapped so its prompt ends with a note asking the agent to record, from its own seat, what in the workflow was unclear, wrong or wasteful, in <notesDir>/<label>.md. The suite cannot test agents, so this is how prompt changes get tested. Put the copy under runs/_engines/<runId>/ (gitignored), since the Workflow tool refuses a scriptPath outside the checkout.
gen-prompts.mjsSnapshots every distinct prompt variant each engine sends to tests/snapshots/<name>.prompts.md, from the same scenario tables. A prompt edit then shows in the git diff under every role, mode and round it reaches. --dump <file> writes every distinct call as JSON, to prove a refactor left the prompts byte-identical.
render-flows.mjsLays every generated map out in real Mermaid (headless Chrome) and reports labels that overlap. Answers "is the picture legible", which gen-flows.mjs cannot.
flows/<name>.flow.mjsOne scenario table per engine: the args + scripted agent replies that drive each distinct path. The only hand-written part of a flow map.
.cache/Gitignored. Downloaded Mermaid + rendered PNGs. Safe to delete.

workflows/debug/gen-units.mjs is the same kind of thing but lives with debug, because you run it as part of that workflow rather than to maintain this repo.

plan-block.mjs

node tools/plan-block.mjs <plan.md|plan-name> <id>            # that block, verbatim, on stdout
node tools/plan-block.mjs <plan.md|plan-name> --list          # { goal, ordered, suite, sweep, blocks: [...] }

It parses the plan-bus metadata grammar: file keys (goal, ordered, suite, synced, sweep), a block preamble (mode, gate, status, plus informational test_selector/depends_on), and ### [<id>] issue entries in fix-mode blocks. --list emits the file keys plus a blocks array of { id, title, mode, gate, status }, defaults applied. Each metadata run is the contiguous key: value lines under its heading, leading blank lines crossed. A blank line above a run is crossed to find it, never to continue one, and body prose never registers as metadata. Every block's gate is its preamble gate: line. A bare plan-name resolves against <CLAUDE_CONFIG_DIR | ~/.claude>/plans/.

Every failure is loud — unknown id, duplicate id (across the block AND issue namespaces), empty body, missing or invalid gate, a gate outside its mode's set, an unknown or illegal metadata key or value, an indented header, a malformed header (colon forgotten, a colon with no id, a space before the colon, or a ### level), an unclosed code fence, no blocks at all. Nothing may resolve to a plausible default, because the consumer is an agent that would build against it. Two silent-wrong-answer classes are guarded and have tests: a header inside a fenced code block is an example (it used to mint a phantom unit and truncate the real one), and the gate is read only from the block preamble (a gate: in prose used to outrank the real one and yield build-only, which makes the engine accept a feature with nothing tested). The last two loud failures share one shape: a block that merges into its predecessor deletes a unit from the control array AND flips the survivor's gate to the merged tail's, in one exit-0 answer.

The engines cannot verify the command ran — the harness has no tools. plan_obtained on develop's developer and acceptance schemas is that signal, and develop halts on an explicit false. The refine editor's plan_parses is the same signal for its re-validation run, and refine halts on false.

plan-edit.mjs

node tools/plan-edit.mjs set <plan.md|plan-name> <id> <key>=<value>          # upsert one metadata line
node tools/plan-edit.mjs move <src> <issue-id> <dest> <block-id>             # relocate one issue entry
node tools/plan-edit.mjs args <plan.md> [<plan.md> ...] [--expect <wf-id>] [--pack <repo> [--loc-cap <n>]]
                                                                             # fold finished runs, print develop's args

The write surface, kept out of plan-block.mjs on purpose: the run-time allowlist rule (Bash(node '<blockTool>':*)) covers every subcommand of the file it names, and an agent must never hold a write path to a plan. set addresses a block or an issue through the file's single id space and rewrites exactly one line, or appends it to the right run. move cuts an entry's bytes verbatim into another fix-mode block, same file or another. Failures are loud and leave every file untouched: unknown id, unrecognized key, illegal value, a gate the target's mode forbids, a duplicate id at the destination, a non-fix destination block. Paths resolve through the same resolveRoadmap as plan-block, so a bare name addresses the same file in both tools. BOM'd and CRLF files round-trip byte-identically, and an appended line inherits the file's dominant line ending.

args is the step before every develop launch, so status bookkeeping cannot be skipped. develop logs each finished block's status edits as one status-sync <json> line. Claude Code writes every Workflow run to <config>/projects/<project>/<session>/workflows/wf_<id>.json when it ends, logs included, for a completed, failed or stopped run alike. args reads every develop record newer than the plan's synced: file key, applies the edits naming that plan oldest first, and moves the key to the newest run applied, so an operator's later edit is never overwritten. The record format is Claude Code's and undocumented. A changed develop record fails args loudly, --expect <wf-id> fails when a known run's record is missing, and tests/plan-bus.test.mjs checks the newest records on the machine on every suite run. Records expire after cleanupPeriodDays (30 by default).

--pack <repo> groups the todo fix blocks into passes, so one set of agents builds several small ones. A block's weight is the line count of each distinct file its open ACTIONABLE issues name: the - loc: line, else the file in <repo>, else 200. Blocks are sorted by the first file they touch and filled up to --loc-cap (default 5000, scaled from resolve's 3000-line batches of about 150-200k tokens). A block over the cap, or one with nothing open and ACTIONABLE, stays its own row. A pass row is { id: <first>-plus-<n>, mode: fix, blocks: [{ id, planPath, issues }] }, and develop writes each member's status and each issue's into the file that holds it. Packing regroups blocks, so an ordered: true file is refused.

gen-flows.mjs

node tools/gen-flows.mjs              # regenerate every map
node tools/gen-flows.mjs develop      # one
node tools/gen-flows.mjs --check      # write nothing; exit 1 naming stale files (what the suite runs)
node tools/gen-flows.mjs develop --json   # the intermediate graph, for rendering elsewhere

Its header comment is the contract — spec shape, terminal identity, and every graph-derivation rule. Read it before writing or changing a scenario table. The short version: node identity, concurrency, loops, loop bounds and unit boundaries are all derived from a trace; only each scenario's when string is authored.

Output is byte-stable (no timestamps), so --check is a meaningful gate. Edit an engine and you must regenerate, or node tests/run.mjs goes red. A map cites each throw site's line number, so an edit that only moves lines stales it too.

It is also dash-free: dedash flattens the finished document to ASCII hyphens (em, en and horizontal bar) because the maps are published on a user-facing site. Presentation only, applied once at the end of generate() — engine prose, --json and terminal identity keep the real characters, and the substitution is 1:1 so no label changes width. Write your prose however you like; only the emitted page is normalized. tests/flow-coverage.test.mjs asserts it over every spec.

render-flows.mjs

node tools/render-flows.mjs           # measure all, report overlaps, exit 1 if any
node tools/render-flows.mjs --png     # also write PNGs to tools/.cache/render/

Drives the Chrome already on the machine via --dump-dom — no puppeteer, no playwright. Mermaid does no collision avoidance on edge labels, and that failure is invisible to every text assertion, so this measures the real bounding boxes instead of guessing.

Deliberately not part of node tests/run.mjs: it needs a browser and, once, the network, and the suite has to stay runnable anywhere. Run it by hand after anything that affects layout. Raise the spacing constants in gen-flows.mjs before shortening label text — room is free, dropped information is not.

The two gates these feed

  • tests/flows.test.mjs — the emitter's own rules (determinism, concurrency, loop counts, escaping).
  • tests/flow-coverage.test.mjs — every role, throw site and terminal state reached by some scenario, meta.phases agreement, and map freshness.

Full working notes, including what the coverage gate structurally cannot see, are in ../tests/CLAUDE.md §7.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.