From 3c296bfc8e950037112f1a8a649f01c20f3acced Mon Sep 17 00:00:00 2001 From: gntrs <239629917+gntrs@users.noreply.github.com> Date: Fri, 4 Dec 2026 17:12:14 +0200 Subject: [PATCH] workflow: never wait, lanes that talk, one brief shape, the budget check - cook: a blocked question parks with a default and the work moves on; questions reach the user together. reversible calls the agent makes, outward, irreversible or taste calls stay open with the plain version behind a seam - the user owns taste (two or three variations, the pick first), the agent owns execution - lanes ask each other directly, or through the run's asks file, never the user; the coordinator owns contract changes - playbook/references/briefs.md: one shape for asking and for builder briefs, worked examples on an abstract app - the whiteboard as an opt in for looks and inspiration, building goes on while the user marks - tools/limits.mjs: taps the 5h and 7d limits from the statusline, cook reads them at the start, before a fan out and on each wake; a floor and ask or decide in RULES.local.md - installers, install test, npm test, SETUP, README, llms, AGENTS, changelog --- AGENTS.md | 3 +- CHANGELOG.md | 14 +++ README.md | 6 ++ SETUP.md | 6 +- install.ps1 | 6 +- install.sh | 6 +- llms.txt | 2 + package.json | 2 +- scripts/test-install.sh | 2 +- setup/RULES.local.md | 13 +++ skills/cook/SKILL.md | 11 ++- skills/deep/SKILL.md | 4 +- skills/playbook/SKILL.md | 4 +- skills/playbook/references/briefs.md | 56 +++++++++++ tools/limits.mjs | 133 +++++++++++++++++++++++++++ 15 files changed, 251 insertions(+), 17 deletions(-) create mode 100644 skills/playbook/references/briefs.md create mode 100644 tools/limits.mjs diff --git a/AGENTS.md b/AGENTS.md index 3074127..6106522 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,7 +16,7 @@ git clone --depth 1 https://github.com/gntrs/workflow.git ~/.claude/workflow ## you are working on this repo itself -markdown skills, one rules file, two installers, seven scripts (the size probe, its runner, the brand check, the ref reader, the ref check, the recorder, the palette maker) and one small node app (`skills/wrapped`). no build. +markdown skills, one rules file, two installers, eight scripts (the size probe, its runner, the brand check, the ref reader, the ref check, the recorder, the palette maker, the budget check) and one small node app (`skills/wrapped`). no build. - skills live in `skills//SKILL.md`, depth in `skills//references/`. frontmatter `name` matches the folder. - `rules/RULES.md` is always on. a skill never contradicts it. nothing tells the reader to edit an installed file: what is personal goes in `~/.claude/RULES.local.md` (template in `setup/RULES.local.md`). @@ -27,6 +27,7 @@ markdown skills, one rules file, two installers, seven scripts (the size probe, - after changing `tools/brand-check.mjs`, run `node tools/brand-check.mjs --self-test` and show every line passes. - after changing `tools/ref-read.mjs` or `tools/ref-check.mjs`, run their `--self-test` and show every line passes. ref-read's needs playwright like the probe runner. - after changing `skills/palette/palette.mjs`, run `node skills/palette/palette.mjs --self-test` and show every line passes. node only. +- after changing `tools/limits.mjs`, run `node tools/limits.mjs --self-test` and show every line passes. node only. - after changing anything in `skills/wrapped/`, run `node --test skills/wrapped/test/` and show every test passes. node only. - after changing `tools/record.mjs`, run `node tools/record.mjs --self-test` and show every line passes. it needs playwright like the probe runner, and ffmpeg for the mp4 lines (without it, those check the webm fallback). - after changing an installer, run `bash scripts/test-install.sh` (and `bash scripts/test-install.sh ps1` where `pwsh` exists). it installs into throwaway homes: fresh, an upgrade from old commits, with edits, uninstall. a new behavior gets a case there. keep `install.sh` and `install.ps1` doing the same thing. diff --git a/CHANGELOG.md b/CHANGELOG.md index 326aadd..0b989c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ newest first. the installer prints the version it had and the one it wrote. ## unreleased +### workflow: never wait, lanes on a contract, briefs, the budget check + +not benchmarked yet. the bench that measures these against 1.3.0 comes next. + +- **never sit waiting on you.** a question that blocks one piece parks with a default, and the work moves on. the questions reach you together, ordered by what each unblocks. reversible calls the agent makes and reports. outward, irreversible or taste calls stay open, with the plain version behind a seam. +- **you own taste, the agent owns execution.** taste calls come as two or three variations, the pick first. +- **lanes talk to each other, not to you.** a builder that needs something from another lane asks it directly, or through the run's asks file, and keeps building. +- **one brief shape**, for you asking and for cook briefing builders: what, preferences, what is known, research only when unsure, variations, the finish line as numbers. worked examples on an abstract app in `skills/playbook/references/briefs.md`. +- **the whiteboard as a preference.** `whiteboard: yes` in `RULES.local.md` puts a look or an inspiration you name on a board you mark, while everything else keeps building. +- **the budget check.** `tools/limits.mjs` taps the 5 hour and 7 day limits your statusline already receives (an opt in line, SETUP section 3), and cook reads them three times a task: plenty, finish and wait for the 5 hour reset, go full before a weekly reset, or ask once when the week runs low. a floor you set. api keys and plans with no limits change nothing. + +### /wrapped + + `/wrapped` gets five new scenes and a sharper count: - **your top model**, with its share of what claude wrote and the next two. diff --git a/README.md b/README.md index 4f487a4..0775b0f 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,12 @@ these load on their own: - **the coordinator doesn't build,** so its context stays small. - **a new ask gets its own lane,** never queued behind the batch. - **two checks.** a fast one before every preview, the full suite before ship. +- **it never sits waiting on you.** a question parks with a default and the work moves on. your questions arrive together, the taste calls as two or three options. builders that need something from each other ask each other, not you. +- **it can watch your plan's limits,** once you let your statusline hand them over (SETUP has the one line). near the 5 hour limit it finishes what is running and waits for the reset. near the weekly one it asks once: stop, keep going, or go cheaper and slower. + +### how to ask + +say what you want in one line, then what you like and what you never want, the edge cases you already see, and what done looks like in numbers. research only when you are unsure. ask for options when it is a taste call. the agent lists the edge cases you did not see, and decides everything that is not taste. the same shape it uses for its own builders: [briefs.md](skills/playbook/references/briefs.md). ### design that doesn't look generated diff --git a/SETUP.md b/SETUP.md index cc1cd17..108db2f 100644 --- a/SETUP.md +++ b/SETUP.md @@ -63,6 +63,10 @@ one file: `~/.claude/RULES.local.md`. the installer created it, never writes it | voice | per answer 5 | | parallel agents | a lower ceiling, only if they asked. the disk floor (8 gb free before a worktree) stays. already under it: tell them worktrees stay off until they free space | | extra steps | anything they want run before a task, before `/ship` or after a push, and strings that must never leave the machine | +| budget | only on a plan with usage limits: the floor they want left untouched, and whether cook asks or decides when the week runs low | +| how you decide | `whiteboard: yes` if they like picking from a board | + +the budget check needs the statusline to hand over the limits. only with their yes, since it edits their statusline: in the script their `statusLine` setting runs, keep the input once and tap it, `input=$(cat); printf '%s' "$input" | node ~/.claude/tools/limits.mjs --tap >/dev/null 2>&1 || true`, then go on using `$input` where the script read stdin before. no statusline yet: a one line script that taps and prints nothing is enough. the `|| true` keeps the line alive when node is missing or the script runs under `set -e`. pstack on: `~/.claude/skills/pstack/models.md` is theirs too, created once and never written again. it ships with every role on `inherit-parent`. put the same model names there only if they want a role pinned. @@ -78,7 +82,7 @@ say what you ran, not what you read. 1. `ls ~/.claude/skills` lists every skill you installed. 2. `grep -n '@RULES' ~/.claude/CLAUDE.md` shows both imports, `@RULES.md` then `@RULES.local.md`, and `bash ~/.claude/workflow/install.sh --status` says 0 behind. -3. `ls ~/.claude/tools/responsive-probe.js ~/.claude/tools/probe-test.mjs ~/.claude/tools/brand-check.mjs ~/.claude/tools/ref-read.mjs ~/.claude/tools/ref-check.mjs ~/.claude/tools/record.mjs` lists all six. +3. `ls ~/.claude/tools/responsive-probe.js ~/.claude/tools/probe-test.mjs ~/.claude/tools/brand-check.mjs ~/.claude/tools/ref-read.mjs ~/.claude/tools/ref-check.mjs ~/.claude/tools/record.mjs ~/.claude/tools/limits.mjs` lists all seven. 4. pstack yes: `claude plugin list` shows pstack. 5. brain yes: `ls ~/vault` shows `HOME.md`, `now.md`, `projects/`. 6. permissions yes: `grep -n 'git push' ~/.claude/settings.json` shows the ask rule. diff --git a/install.ps1 b/install.ps1 index 761d214..7a2c01e 100644 --- a/install.ps1 +++ b/install.ps1 @@ -192,7 +192,7 @@ function Groups { Get-ChildItem (Join-Path $Src 'skills') -Directory | Sort-Object Name | ForEach-Object { if (Test-Path (Dest "skills/$($_.Name)")) { $all += Pairs $_.FullName "skills/$($_.Name)" } } - foreach ($t in 'responsive-probe.js','probe-test.mjs','brand-check.mjs','ref-read.mjs','ref-check.mjs','record.mjs') { $all += @{ Src = (Join-Path $Src "tools/$t"); Rel = "tools/$t" } } + foreach ($t in 'responsive-probe.js','probe-test.mjs','brand-check.mjs','ref-read.mjs','ref-check.mjs','record.mjs','limits.mjs') { $all += @{ Src = (Join-Path $Src "tools/$t"); Rel = "tools/$t" } } if (Test-Path (Dest 'skills/pstack')) { foreach ($f in 'install.sh','README.md') { $all += @{ Src = (Join-Path $Src "pstack/$f"); Rel = "skills/pstack/$f" } } } return $all } @@ -303,8 +303,8 @@ Get-ChildItem (Join-Path $Src 'skills') -Directory | Sort-Object Name | ForEach- Install-Group "skills/$name" $_.FullName "skills/$name" } -# 4. the size sweep probe, its runner, the brand check, the ref reader and its gate, and the recorder -foreach ($t in 'responsive-probe.js','probe-test.mjs','brand-check.mjs','ref-read.mjs','ref-check.mjs','record.mjs') { +# 4. the size sweep probe, its runner, the brand check, the ref reader and its gate, the recorder, and the budget check +foreach ($t in 'responsive-probe.js','probe-test.mjs','brand-check.mjs','ref-read.mjs','ref-check.mjs','record.mjs','limits.mjs') { Install-Group "tools/$t" (Join-Path $Src "tools/$t") "tools/$t" } diff --git a/install.sh b/install.sh index f3d8e62..62a4fac 100644 --- a/install.sh +++ b/install.sh @@ -169,7 +169,7 @@ groups() { # every "src|rel" the installer keeps up to date and that is installe for dir in "$SRC"/skills/*/; do name="$(basename "$dir")"; [ -d "$CLAUDE_DIR/skills/$name" ] && pairs_of "${dir%/}" "skills/$name" done - for f in responsive-probe.js probe-test.mjs brand-check.mjs ref-read.mjs ref-check.mjs record.mjs; do echo "$SRC/tools/$f|tools/$f"; done + for f in responsive-probe.js probe-test.mjs brand-check.mjs ref-read.mjs ref-check.mjs record.mjs limits.mjs; do echo "$SRC/tools/$f|tools/$f"; done if [ -d "$CLAUDE_DIR/skills/pstack" ]; then for f in install.sh README.md; do echo "$SRC/pstack/$f|skills/pstack/$f"; done; fi [ -e "$CLAUDE_DIR/hooks/ensure-node-modules.sh" ] && echo "$SRC/setup/hooks/ensure-node-modules.sh|hooks/ensure-node-modules.sh" return 0 @@ -288,8 +288,8 @@ for dir in "$SRC"/skills/*/; do install_group "skills/$name" "${dir%/}" "skills/$name" done -# 4. the size sweep probe, its runner, the brand check, the ref reader and its gate, and the recorder -for t in responsive-probe.js probe-test.mjs brand-check.mjs ref-read.mjs ref-check.mjs record.mjs; do +# 4. the size sweep probe, its runner, the brand check, the ref reader and its gate, the recorder, and the budget check +for t in responsive-probe.js probe-test.mjs brand-check.mjs ref-read.mjs ref-check.mjs record.mjs limits.mjs; do install_group "tools/$t" "$SRC/tools/$t" "tools/$t" done diff --git a/llms.txt b/llms.txt index b9b3a2f..9a0d227 100644 --- a/llms.txt +++ b/llms.txt @@ -37,6 +37,8 @@ to install it for someone: `git clone --depth 1 https://github.com/gntrs/workflo - [tools/ref-read.mjs](tools/ref-read.mjs): opens a real product or reads a user's pic, saves screenshots and styles as evidence - [tools/ref-check.mjs](tools/ref-check.mjs): fails a brand.md with no read reference or a kit part with nothing behind it - [tools/record.mjs](tools/record.mjs): records a scroll, wheel or drag walk of a page to a video, and checks it moved +- [tools/limits.mjs](tools/limits.mjs): taps the 5h and 7d plan limits from the statusline, tells cook to go on, go cheaper, ask or stop +- [skills/playbook/references/briefs.md](skills/playbook/references/briefs.md): how to ask an agent and how cook briefs its builders, with worked examples - [brain-template/](brain-template/HOME.md): the vault skeleton - [setup/permissions.json](setup/permissions.json): the ask list `--with-permissions` merges into settings.json - [scripts/test-install.sh](scripts/test-install.sh): the installer's cases, fresh, upgrade, edits, uninstall diff --git a/package.json b/package.json index c5b0ee7..82ad01b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "check": "bash scripts/check.sh", "test:install": "bash scripts/test-install.sh", - "test:tools": "node tools/brand-check.mjs --self-test && node skills/palette/palette.mjs --self-test && node tools/ref-check.mjs --self-test && node tools/probe-test.mjs --self-test && node tools/ref-read.mjs --self-test && node tools/record.mjs --self-test && node --test skills/wrapped/test/", + "test:tools": "node tools/brand-check.mjs --self-test && node skills/palette/palette.mjs --self-test && node tools/ref-check.mjs --self-test && node tools/probe-test.mjs --self-test && node tools/ref-read.mjs --self-test && node tools/record.mjs --self-test && node tools/limits.mjs --self-test && node --test skills/wrapped/test/", "test": "npm run check && npm run test:install && npm run test:tools" }, "devDependencies": { diff --git a/scripts/test-install.sh b/scripts/test-install.sh index e629f12..b15e425 100644 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -46,7 +46,7 @@ matches_source() { # every installed core file equals the source cmp -s "$src/$f" "$h/.claude/$f" || { echo "differs: $f"; return 1; } done cmp -s "$src/rules/RULES.md" "$h/.claude/RULES.md" || { echo "differs: RULES.md"; return 1; } - for f in responsive-probe.js probe-test.mjs brand-check.mjs ref-read.mjs ref-check.mjs record.mjs; do + for f in responsive-probe.js probe-test.mjs brand-check.mjs ref-read.mjs ref-check.mjs record.mjs limits.mjs; do cmp -s "$src/tools/$f" "$h/.claude/tools/$f" || { echo "differs: tools/$f"; return 1; } done } diff --git a/setup/RULES.local.md b/setup/RULES.local.md index e4cc9f0..2974c54 100644 --- a/setup/RULES.local.md +++ b/setup/RULES.local.md @@ -28,6 +28,19 @@ how text should sound, words you never want. empty: the plain style in `skills/w a lower ceiling than cook measures, if you run several sessions or a heavy local stack. empty: cook measures it. +## budget + +for plans with usage limits. empty: a 5% floor, and ask once when the week runs low. + +- floor, the percent of the week left untouched: +- when the week runs low: ask, or decide (cheaper and slower) + +## how you decide + +empty: options in chat. + +- whiteboard: yes or no. yes puts a look or an inspiration you name on a private board you mark right and wrong + ## extra steps things cook and /ship run on top of their own. empty: none. diff --git a/skills/cook/SKILL.md b/skills/cook/SKILL.md index 1223738..7f93880 100644 --- a/skills/cook/SKILL.md +++ b/skills/cook/SKILL.md @@ -19,6 +19,7 @@ one door for every task. size it, run the lane, end it the same way every time. - an open alert from a ram watcher, if you run one, or free memory near zero: the cap is 0, work in the main thread. - `df -h /`, or `Get-PSDrive C` on windows. under 8 gb free: no new worktree. list the stale ones with branch and dirty state and ask which go. - the user may run several sessions at once. the cap is for the machine, not the session. other sessions already building count against it. +6. budget, on build and deep only, when the statusline taps the limits (`tools/limits.mjs` has the wiring): `node ~/.claude/tools/limits.mjs --floor ` at the start, before a fan out and on each wake of a long run, never per agent call. do the move it prints. the floor and whether to ask or decide when the week runs low come from `## budget` in `~/.claude/RULES.local.md`. the user away: never ask, take the cheaper and slower move and say so in the recap. ## 1. size it @@ -69,11 +70,12 @@ the build lane is where most work lands, so it is built for wall clock. the same 1. **one message, everything independent.** the explorers (one per unknown, read only) start in the same message. never one agent, then a wait, then the next. nothing unknown: no explorer. 2. **a plan of ten lines in chat**, written from what they return, not a document: what changes, the files each builder owns, the contract between them (a type, a route, a name), the finish line as numbers. its cold read starts in the same message as the builders on the pieces the plan is sure of. a builder on a piece the plan is unsure of waits for the read. -3. **builders split by files.** two or more independent pieces: one builder each, started together, each brief with the user's words verbatim, its files and no others, the contract, its slice of the finish line. the main thread owns the shared files and the wiring and does not build the pieces. one piece: the main thread builds it. a second agent on a one file job is slower than doing it. +3. **builders split by files.** two or more independent pieces: one builder each, started together, each brief in the shape of `playbook` `references/briefs.md` (what, preferences, what is known, variations, the finish line as numbers), with the user's words verbatim, its files and no others, the contract, its slice of the finish line. the main thread owns the shared files and the wiring and does not build the pieces. one piece: the main thread builds it. a second agent on a one file job is slower than doing it. 4. **effort where it pays.** xhigh and max sit on the plan and the final review. builders and explorers run at their row in the table. a higher effort on every seat doubles the wait and changes nothing. 5. **short reports.** every agent answers in under 200 words: what it did, what runs, what is open. anything longer goes to a file. a coordinator full of pasted reports gets slow and forgets the plan. -6. **review as it lands,** below. findings go back to the builder that owns the files while the others keep going. -7. **verify fast between rounds,** the full tier once before `/ship` (section 5). +6. **lanes talk to each other, never to the user.** a builder that needs something from another lane (a field, a route, a shape) asks that lane directly where the harness lets agents message each other, else writes the ask to the run's asks file (`.claude/run/asks.md`, one line each: from, to, the ask) and keeps building what does not depend on it. the coordinator reads the file between landings, answers there, and owns any change to the contract, telling every lane it touches. +7. **review as it lands,** below. findings go back to the builder that owns the files while the others keep going. +8. **verify fast between rounds,** the full tier once before `/ship` (section 5). pstack, when installed, is used by name for the one tool a job calls for: `tdd` on a bug that reproduces, `architect` when the shape crosses a module boundary or cannot be undone, `interrogate` on a contested diff. its full feature playbook loads poteto-mode (about 1,900 words) and the playbook first, then runs `architect` on the shape, a worktree per delegate, a build, verify and commit per unit, a rebase and its own pr flow, with `interrogate` on top when the design is contested. that weight is why a one feature task takes an hour, so the full playbooks stay out of this lane and out of the deep lane's phase builders. without pstack nothing here changes. say in the lane line when a pstack tool is in play and why. before any pstack playbook that pushes, merges, opens a pr or writes a plan, read the overlay in RULES.md, "pstack runs under these rules". @@ -93,6 +95,9 @@ every reviewer is a fresh subagent per `/review`: the target, the user's words v - **the deep lane:** read `/deep` and follow it. research, a plan with a checkable exit predicate, the cold read, the user's read, the run grant ask, the run, the trail, proof, `/ship`. the main thread coordinates and does not build there. - **a new ask mid build** that is separate from the running work gets its own lane at once: its own branch or worktree, its own builder inside the cap, its own `/ship`. it ships alone, never folded into the running batch. +- **never sit waiting on the user.** a question that blocks one piece parks under `## the user, now` with your default, and the work moves to the next piece. the questions go out together, ordered by what each unblocks. what to decide yourself and what to leave open: `playbook` `references/briefs.md`. +- **the user owns taste, the agent owns execution.** when the user is there and a call is taste, give two or three variations with your pick first, never one answer. everything else, decide. +- **the whiteboard, when the user likes it.** `whiteboard: yes` under `## how you decide` in `~/.claude/RULES.local.md`: a look or an inspiration the user names ("the chat of x, the side preview of y") goes on a board per `design` `references/whiteboard.md`. while the user marks it, build everything that does not depend on the look. other decisions with options, a backend shape or a flow, stay as options in chat. - **one worktree or branch per session.** claim it in the `## cooking` entry (session, branch, folder). before building, check the tbd for another session's open claim. if one holds this tree, start your own worktree and say so in one line. ask only when free disk is under the floor in step 0. ## 5. verify in two tiers diff --git a/skills/deep/SKILL.md b/skills/deep/SKILL.md index 444d9f3..59b25cb 100644 --- a/skills/deep/SKILL.md +++ b/skills/deep/SKILL.md @@ -73,11 +73,11 @@ without pstack: the same loop by hand, with `/loop` to wake. **the run loop.** - the predicate is the plan's, word for word. never relax it to declare victory. a plateau is not a stop. -- wake through `/loop`: a watcher for an event (ci, a build), a 30 minute heartbeat otherwise. every wake checks free memory, a running docker vm and free disk, reads `## cooking`, then the predicate. +- wake through `/loop`: a watcher for an event (ci, a build), a 30 minute heartbeat otherwise. every wake checks free memory, a running docker vm, free disk and the budget (cook step 0.6), reads `## cooking`, then the predicate. - each iteration: the smallest change the evidence justifies, verify it, commit only under the grant, revert what did not help. - a new separate ask arriving mid run gets its own lane per cook and ships alone. it never joins this run's batch. - side discoveries: fix what is local and reversible. "its own pr" becomes a tbd line. -- anything outward, a one way door, or a taste call: park it under `## the user, now` in the tbd with your default, route around it, keep going. +- anything outward, a one way door, or a taste call: park it under `## the user, now` in the tbd with your default, route around it, keep going. the parked questions go to the user together, per cook section 4, never one ping each. ## 5. trail and state diff --git a/skills/playbook/SKILL.md b/skills/playbook/SKILL.md index f720362..e64fb17 100644 --- a/skills/playbook/SKILL.md +++ b/skills/playbook/SKILL.md @@ -83,7 +83,7 @@ swarm shapes, who does what in a big run, and the review-earlier rules: `referen 5. **verify the deploy, not the checkmark.** fetch the live bundle, grep for a marker from this round. 6. **state the fallback loudly.** any failure path surfaces a reason to the user or the log. 7. **no subagent commits, pushes or comments.** only the main thread, only with the user's yes or inside a run grant. -8. **the user's words verbatim** in the brief, not your summary of them. +8. **the user's words verbatim** in the brief, not your summary of them. the rest of the brief follows `references/briefs.md`. 9. **the report goes to a file** the brief names (scratchpad or `.claude/`), with a three line summary back. a long report pasted into the coordinator fills its context. ## speed, without losing the outcome @@ -107,4 +107,4 @@ read `references/mistakes.md` before a build. ## references -one read away: `notes.md` (where plans, log and open items live, with or without the brain), `swarm.md` (shapes, who does what, review earlier), `deploy.md` (branches, commit voice, main, versions, release notes, strip list, PR comments), `debugging.md` (doctrine, browser traps, no-browser verify), `research.md` (research swarm and its sourcing rules), `mistakes.md`. visual work and artifacts: `design`. anything a human reads: `write`. +one read away: `briefs.md` (how to ask, how to brief a builder, what to do when the user is away, worked examples), `notes.md` (where plans, log and open items live, with or without the brain), `swarm.md` (shapes, who does what, review earlier), `deploy.md` (branches, commit voice, main, versions, release notes, strip list, PR comments), `debugging.md` (doctrine, browser traps, no-browser verify), `research.md` (research swarm and its sourcing rules), `mistakes.md`. visual work and artifacts: `design`. anything a human reads: `write`. diff --git a/skills/playbook/references/briefs.md b/skills/playbook/references/briefs.md new file mode 100644 index 0000000..6e0cc97 --- /dev/null +++ b/skills/playbook/references/briefs.md @@ -0,0 +1,56 @@ +# briefs: how to ask, and how cook hands work out + +one shape for both directions: the user asking an agent, and cook briefing a builder. a brief in this shape needs no follow up question, which is most of what makes a run fast. + +## the shape + +1. **what you want,** one line. the outcome, not the steps. +2. **preferences:** do, and do not. a look you like, a library you trust, a thing you never want. +3. **what you know:** the edge cases and bottlenecks you already see. what you do not know, the agent lists in its plan, with an id each, before it builds. +4. **research only when unsure,** or when the project needs it (a new api, a law, a market). never as a ritual. +5. **variations** when a person can pick: two or three for a taste call (ui, flow, the shape of the backend), the agent's pick named first. no person around: the plain one, behind a seam. +6. **the finish line as numbers:** tests and their count, a size with 0 overflow, a bug reproduced then gone. never "works well". + +the user owns taste and direction. the agent owns execution: it decides everything else itself and says what it decided in the recap. + +a builder brief adds, per the hard rules in the playbook: the files it owns and the ones it must not touch, the contract it builds against, the user's words verbatim, the report file. + +## when the user is away + +- a question that blocks one piece parks under `## the user, now` with a default, and the agent moves to the next piece that does not depend on it. it never sits and waits. +- **reversible** (a name, a layout inside a page, a library swap): decide, build, say so in the recap. +- **outward, irreversible or taste** (a push, a delete, a migration on real data, how the product feels): leave it open. build the plain version behind a seam, or skip it and do other work. +- questions batch into one ping, ordered by what each one unblocks. never one ping per question. + +## worked examples + +abstract on purpose, so they carry to any project. the app: a cat feeder, with a phone screen (next feed, feed now, history), a small api (schedules, a feed log, a device that can be offline) and a database of three tables. + +### a bug: "history shows yesterday's feeds as today" + +- lane: build. one unknown, so one explorer reads the history query and the date handling. no builder split: one file area, the main thread fixes it. +- first a failing test that reproduces it (a feed at 23:30 in a timezone ahead of the server). then the fix at the root (store utc, convert at the edge), not a patch in the list view. +- finish line: the repro test fails before and passes after, the suite stays green. + +### a feature over front and back: "add skip next feed" + +- lane: build. two pieces, so a contract first, in the plan: `POST /schedules/:id/skip` returns the next feed time; the screen shows "skipped, next at 18:00". +- two builders start in one message. the api builder owns the routes and the schedule table. the screen builder owns the screen and builds against a fake of the contract. the main thread owns the router, the shared types and the wiring. +- a builder that needs something from the other asks it directly, or through the asks file when agents cannot message each other (cook section 2), never the user. a change to the contract goes through the main thread, which tells both. +- each lane gets its cold read the moment it lands, while the other still runs. +- finish line: 6 tests (skip, skip twice, skip with the device offline, skip the last feed of the day, bad id, no schedule), the screen at 390 and 1440 px with 0 overflow. + +### a research ask: "what is the best way to schedule feeds when the device sleeps" + +- lane: build, no code. two explorers in one message: one reads how the device wakes and what the api already stores, one reads how other scheduled devices handle a missed window. +- the answer: two or three options with what each costs, the pick named first, and the edge cases each one leaves open. no build until the user picks, unless the pick is reversible and the user is away. + +### the same app, built from a one page brief + +- lane: deep. a plan with an edge case register and a checkable finish line, a cold read of the plan before any builder starts. +- a contract for the whole app first: the three tables, the routes, the screen's data. then builders by surface (api, screen, device fake), started together, each on its own files. +- the main thread never builds a piece. it holds the plan, answers the lanes, wires and reviews. + +## one coordinator, two models + +whether a stronger coordinator needs less spelled out than a lighter one is a guess until it is measured. until then, every coordinator writes the full shape above, whichever model it runs on. diff --git a/tools/limits.mjs b/tools/limits.mjs new file mode 100644 index 0000000..89f8674 --- /dev/null +++ b/tools/limits.mjs @@ -0,0 +1,133 @@ +#!/usr/bin/env node +// the budget check. claude code hands the statusline your plan's usage limits (rate_limits.five_hour and +// rate_limits.seven_day, each with used_percentage and, where sent, resets_at). an agent cannot read that input, +// so the statusline taps it into a small file, and cook reads the file at three points: a build or deep task's +// start, before a fan out, each wake of a long run. never per agent call. +// +// tap, from your statusline script (prints nothing, never fails the statusline): +// input=$(cat); printf '%s' "$input" | node ~/.claude/tools/limits.mjs --tap >/dev/null 2>&1 || true +// read, from cook: +// node ~/.claude/tools/limits.mjs [--floor 5] [--json] +// node tools/limits.mjs --self-test +// +// no rate_limits in the input (an api key, another plan): no file, and the read says unknown. nothing changes. +import fs from 'node:fs' +import os from 'node:os' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +export const DEFAULTS = { floor: 5, fiveHourTight: 90, weekTight: 80, resetSoonHours: 36, staleMinutes: 30 } +const USAGE = 'usage: node limits.mjs --tap [--file ]\n node limits.mjs [--floor ] [--json] [--file ]\n node limits.mjs --self-test' +const defaultFile = () => path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), 'usage', 'limits.json') + +// seconds, milliseconds or an iso string, to milliseconds. anything else: null +export function toMs(v) { + if (typeof v === 'number' && Number.isFinite(v) && v > 0) return v < 1e12 ? v * 1000 : v + if (typeof v === 'string' && v.trim()) { const t = Date.parse(v); return Number.isFinite(t) ? t : null } + return null +} + +function window(l) { + if (!l || typeof l !== 'object') return null + const p = l.used_percentage + if (typeof p !== 'number' || !Number.isFinite(p)) return null + return { used: Math.max(0, Math.min(100, p)), resets_at: toMs(l.resets_at) } +} + +// the statusline input to the snapshot. null when there is nothing to keep +export function snapshot(input, now = Date.now()) { + const r = input && typeof input === 'object' ? input.rate_limits : null + if (!r) return null + const five = window(r.five_hour), week = window(r.seven_day) + if (!five && !week) return null + return { written_at: now, five_hour: five, seven_day: week } +} + +const hoursTo = (ms, now) => (ms == null ? null : Math.max(0, (ms - now) / 3600000)) +const fmt = h => (h == null ? 'reset time not sent' : h < 1 ? `resets in ${Math.round(h * 60)} min` : h < 48 ? `resets in ${Math.round(h)} h` : `resets in ${Math.round(h / 24)} days`) + +// the snapshot to one state and the move cook makes +export function decide(snap, { now = Date.now(), ...o } = {}) { + const c = { ...DEFAULTS, ...o } + if (!snap || typeof snap !== 'object') return { state: 'unknown', move: 'as planned', why: 'no snapshot: the statusline does not tap the limits, or the plan has none' } + const age = (now - Number(snap.written_at)) / 60000 + if (!Number.isFinite(age) || age > c.staleMinutes) return { state: 'unknown', move: 'as planned', why: `snapshot is ${Number.isFinite(age) ? Math.round(age) + ' min' : 'of unknown'} old` } + // a window whose reset has passed since the tap is empty again, whatever it said then + const fresh = w => (w && w.resets_at != null && w.resets_at <= now ? { ...w, used: 0 } : w) + const five = fresh(snap.five_hour), week = fresh(snap.seven_day) + const h5 = hoursTo(five?.resets_at, now), h7 = hoursTo(week?.resets_at, now) + if (week && 100 - week.used <= c.floor) return { state: 'week-at-floor', move: 'stop: start nothing new, park the rest in ## cooking, say when it resets', why: `7d ${Math.round(week.used)}% used, floor ${c.floor}%, ${fmt(h7)}` } + if (week && week.used >= c.weekTight) { + if (h7 != null && h7 <= c.resetSoonHours) return { state: 'week-tight-reset-soon', move: `go full on what matters now, stop with ${c.floor}% left`, why: `7d ${Math.round(week.used)}% used, ${fmt(h7)}` } + return { state: 'week-tight-reset-far', move: 'ask once: stop here, continue, or cheaper and slower (lower effort, fewer agents in flight, no second family). user away: cheaper and slower, say so in the recap', why: `7d ${Math.round(week.used)}% used, ${fmt(h7)}` } + } + if (five && five.used >= c.fiveHourTight) return { state: 'five-hour-tight', move: 'finish the lane in flight, park the rest in ## cooking, wake after the reset', why: `5h ${Math.round(five.used)}% used, ${fmt(h5)}` } + return { state: 'plenty', move: 'as planned', why: `5h ${five ? Math.round(five.used) + '%' : 'n/a'}, 7d ${week ? Math.round(week.used) + '%' : 'n/a'}` } +} + +function arg(a, name) { const i = a.indexOf(name); return i < 0 ? undefined : a[i + 1] } + +function selfTest() { + let pass = 0, fail = 0 + const t = (name, ok) => { if (ok) pass++; else fail++; console.log(`${ok ? 'pass' : 'FAIL'} ${name}`) } + const now = Date.parse('2026-12-04T12:00:00Z'), H = 3600000 + const snap = (f, w, extra = {}) => ({ written_at: now, five_hour: f, seven_day: w, ...extra }) + t('seconds, milliseconds and iso all read as milliseconds', toMs(1764849600) === 1764849600000 && toMs(1764849600000) === 1764849600000 && toMs('2026-12-04T12:00:00Z') === now) + t('junk reset times read as null', toMs('soon') === null && toMs(-1) === null && toMs(null) === null && toMs(NaN) === null) + t('no rate_limits keeps nothing', snapshot({ model: {} }, now) === null && snapshot(null, now) === null && snapshot('x', now) === null) + t('a window without a number keeps nothing', snapshot({ rate_limits: { five_hour: { used_percentage: 'a lot' } } }, now) === null) + const s = snapshot({ rate_limits: { five_hour: { used_percentage: 41.6, resets_at: (now + 2 * H) / 1000 }, seven_day: { used_percentage: 12 } } }, now) + t('the tap keeps both windows and the write time', s.written_at === now && s.five_hour.used === 41.6 && s.five_hour.resets_at === now + 2 * H && s.seven_day.resets_at === null) + t('a percent outside 0 to 100 is clamped', snapshot({ rate_limits: { seven_day: { used_percentage: 140 } } }, now).seven_day.used === 100) + t('no snapshot is unknown, as planned', decide(null, { now }).state === 'unknown' && decide(null, { now }).move === 'as planned') + t('a snapshot older than 30 min is unknown', decide({ ...snap({ used: 10 }, { used: 10 }), written_at: now - 31 * 60000 }, { now }).state === 'unknown') + t('a snapshot 29 min old still counts', decide({ ...snap({ used: 10 }, { used: 10 }), written_at: now - 29 * 60000 }, { now }).state === 'plenty') + t('low use is plenty', decide(snap({ used: 20 }, { used: 30 }), { now }).state === 'plenty') + t('5h at 90 is tight, 89 is not', decide(snap({ used: 90 }, { used: 10 }), { now }).state === 'five-hour-tight' && decide(snap({ used: 89 }, { used: 10 }), { now }).state === 'plenty') + t('a window past its reset counts as empty', decide(snap({ used: 95, resets_at: now - 10 * 60000 }, { used: 97, resets_at: now - H }), { now }).state === 'plenty') + t('null, empty, true or a string as the percent keep nothing', [null, '', true, '50'].every(v => snapshot({ rate_limits: { five_hour: { used_percentage: v } } }, now) === null)) + t('week at 80 resetting in 20 h goes full to the floor', decide(snap({ used: 10 }, { used: 80, resets_at: now + 20 * H }), { now }).state === 'week-tight-reset-soon') + t('week at 80 resetting in 3 days asks once', decide(snap({ used: 10 }, { used: 80, resets_at: now + 72 * H }), { now }).state === 'week-tight-reset-far') + t('week tight with no reset time asks once', decide(snap(null, { used: 90, resets_at: null }), { now }).state === 'week-tight-reset-far') + t('week at the floor stops, before the 5h check', decide(snap({ used: 99 }, { used: 95 }), { now }).state === 'week-at-floor' && /start nothing new/.test(decide(snap(null, { used: 96 }), { now }).move)) + t('the floor is configurable', decide(snap(null, { used: 88, resets_at: now + 72 * H }), { now, floor: 15 }).state === 'week-at-floor') + t('the week check wins over a tight 5h', decide(snap({ used: 95 }, { used: 85, resets_at: now + 10 * H }), { now }).state === 'week-tight-reset-soon') + t('only a 5h window still decides', decide(snap({ used: 92 }, null), { now }).state === 'five-hour-tight') + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'limits-test-')), file = path.join(dir, 'u', 'limits.json') + const run = (args, input) => import('node:child_process').then(cp => cp.spawnSync(process.execPath, [fileURLToPath(import.meta.url), ...args], { input, encoding: 'utf8' })) + return (async () => { + let r = await run(['--tap', '--file', file], JSON.stringify({ rate_limits: { five_hour: { used_percentage: 50 }, seven_day: { used_percentage: 90, resets_at: '2099-01-01T00:00:00Z' } } })) + t('the tap writes the file, prints nothing, exits 0', r.status === 0 && r.stdout === '' && JSON.parse(fs.readFileSync(file, 'utf8')).seven_day.used === 90) + r = await run(['--tap', '--file', file], 'not json at all') + t('junk on stdin exits 0 and keeps the old file', r.status === 0 && JSON.parse(fs.readFileSync(file, 'utf8')).seven_day.used === 90) + r = await run(['--file', file, '--json']) + t('the read prints json with a state', r.status === 0 && JSON.parse(r.stdout).state === 'week-tight-reset-far') + r = await run(['--file', path.join(dir, 'none.json')]) + t('the read with no file says unknown, exit 0', r.status === 0 && /unknown/.test(r.stdout)) + r = await run(['--floor', 'lots']) + t('a bad floor exits 2', r.status === 2) + fs.rmSync(dir, { recursive: true, force: true }) + console.log(`${pass} passed, ${fail} failed`) + process.exit(fail ? 1 : 0) + })() +} + +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const a = process.argv.slice(2) + const file = arg(a, '--file') || defaultFile() + if (a.includes('--self-test')) selfTest() + else if (a.includes('--tap')) { + try { + const s = snapshot(JSON.parse(fs.readFileSync(0, 'utf8'))) + if (s) { fs.mkdirSync(path.dirname(file), { recursive: true }); const tmp = file + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(s)); fs.renameSync(tmp, file) } + } catch {} + process.exit(0) + } else { + const f = arg(a, '--floor') + if (f !== undefined && !(Number(f) >= 0 && Number(f) < 100)) { console.error(USAGE); process.exit(2) } + let snap = null + try { snap = JSON.parse(fs.readFileSync(file, 'utf8')) } catch {} + const d = decide(snap, f !== undefined ? { floor: Number(f) } : {}) + console.log(a.includes('--json') ? JSON.stringify(d) : `${d.state}: ${d.move} (${d.why})`) + } +}