done-when
Skill8 starsChanged 8 days agoMITView on GitHub
Use when a command can decide that a task is finished (tests pass, a build succeeds, a type
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- after-merge-checkSkill
- agent-rolesSkill
- clarify-with-ownerSkill
- decide-before-buildSkill
- delegate-briefSkill
- findings-logSkill
- hold-for-ownerSkill
- latest-checkSkill
- link-checkSkill
- merge-resultsSkill
- plan-to-issuesSkill
- read-the-contractSkill
- repo-setupSkill
- review-queueSkill
- secret-scopeSkill
- session-recallSkill
- shorten-safelySkill
- show-it-worksSkill
- tool-contractSkill
- unattended-batchSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
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
- Distinctive: line 16
Before starting, and before calling done, any task a command can judge.
- Distinctive: line 24
Keep it local, repeatable and free of side effects: No deploy, no sending, no writes outside the project: it runs at every stop attempt.
- Very specific: line 36
The owner's "stop" wins at once: Run scripts/done-when.mjs halt, then stop.
- Distinctive: line 80
No command can decide the finish, or the owner has not agreed the condition.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill 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
done-when
A command the owner approved decides when you may stop; your sense of being finished does not.
When to use
Before starting, and before calling done, any task a command can judge; and when wiring the hook or loop that enforces it.
Rules
- Agree the check first. State the completion condition as a command, get a yes, then save it as
the executable
./done-when.shat the project root. Ask your questions before creating it. A check invented after the work fits whatever was built. - Keep it local, repeatable and free of side effects. No deploy, no sending, no writes outside the project: it runs at every stop attempt.
- The owner approves the exact file. Show the whole file and ask the owner to run
scripts/done-when.mjs approvein their own terminal. It runs with no permission prompt, so the gate refuses it unless its content matches that approval. A commit is not approval, you never approve, and any edit voids it. - Run the gate before stopping. Pass means finished; anything else means work on what it reports.
- Fix the work, never the check. Changing the condition, or an existing check, needs the owner's yes and a new approval.
- Honour the round limit. The owner sets it at approval (default 5). A limit named in the task goes
in
.done-when/limitand can only lower it. Running out is not success: say the work is not done and quote the check. - The owner's "stop" wins at once. Run
scripts/done-when.mjs halt, then stop. Never run it otherwise. - An unapproved check does not run. Show the file, ask for approval, stop, and call the work unverified.
- The owner installs the hook, per project. User-wide, it would run checks from unknown repositories.
What to produce
./done-when.sh, the approval record (kept outside the project), one line per stop in
.done-when/outcomes.log, and a final message naming the outcome: passed, attempts-exhausted,
owner-halted or not-approved.
#!/bin/sh
# done when the importer's tests pass and the type check is clean
npm test -- importer && npx tsc --noEmit{"at":"2026-11-25T09:14:02Z","outcome":"passed","session":"7c1e","rounds":2,"limit":5}The helper script
Needs Node 18+. Run from the project root, with the full path to the script (see "Script paths" below); see --help.
node scripts/done-when.mjs approve [--max N]: owner only, in an interactive terminal.node scripts/done-when.mjs gate: the stop hook. Exit 0 lets you stop, exit 2 sends you back with the reason. Without a hook, rungate --manualyourself before every stop; it counts rounds and writes the log.node scripts/done-when.mjs run -- <agent command>: the loop for harnesses with no stop hook; the failure report becomes the command's last argument.
For Claude Code, the owner merges stop-hook.settings.json into .claude/settings.local.json and fixes
the script path. As of late 2026, check your version: the hook gets JSON on stdin (session_id, cwd),
exit code 2 with a reason on stderr keeps the agent working, and the harness ends the turn itself after
eight blocks in a row with no tool call.
What the script cannot stop: an agent with a shell writing the approval store or the halt marker. The snippet's deny rule covers the edit tool only; rules 3 and 7 cover the rest.
Stop and ask
- No command can decide the finish, or the owner has not agreed the condition.
- The check looks wrong, flaky or impossible: report it, do not edit it.
- The check would need network, credentials or writes outside the project.
Not for
Timers and recurring prompts, batches with no model, sandboxing what the check runs, or test design.
Script paths
scripts/... in this file means the scripts/ folder of this skill, wherever the skill is installed. From a project root that is usually .claude/skills/done-when/scripts/, so the full form of a command is node .claude/skills/done-when/scripts/<file>.mjs ....
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.

