Rehorse
CLAUDE.md1 starsChanged 2 months agoMITView on GitHub
Rehorse is a Claude Code plugin that runs "auto mode you can walk away from": every task rehearses on a git worktree, must go red-then-green on tests, is checked by an independent verifier subagent, and stops with a report. Nothing touches the user's real branch until they run /rehorse:merge. There is no production code yet. SPEC.md is the full build spec and the source of truth; read it before doing anything. Work proceeds in numbered milestones (SPEC.md, bottom). Milestone 1…
- Deletes or force-pushes
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 4 are distinctive, and 5 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.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Read it before wiring any hook.
- Distinctive: line 28
Every safety guarantee lives in a hook script, never in a skill's prose.
- Very specific: line 30
Only merge.py and discard.py may modify the user's real branch.
- Distinctive: line 32
Before writing any plugin, hook, or skill code, fetch the current docs and copy the JSON schemas exactly (do not write hook output formats …
- Distinctive: line 37
If Claude Code behaves differently from SPEC.md, trust the docs and tell the user what changed.
- Very specific: line 38
Never widen scope. Missing feature ideas go in IDEAS.md.
- Distinctive: line 40
Write the failing pytest for a hook script before the script itself.
- Very specific: line 41
After each milestone, update README.md and DECISIONS.md (one line per decision, with reason).
- Very specific: line 60
Test the plugin end to end by loading it from the local path in a toy repo with a tiny pytest suite, including a forced /compact and a …
≈ “Common” is an estimate: at least 1 in 5 of the 27,641 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
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project status
Rehorse is a Claude Code plugin that runs "auto mode you can walk away from": every task
rehearses on a git worktree, must go red-then-green on tests, is checked by an independent
verifier subagent, and stops with a report. Nothing touches the user's real branch until they
run /rehorse:merge.
There is no production code yet. SPEC.md is the full build spec and the source of truth;
read it before doing anything. Work proceeds in numbered milestones (SPEC.md, bottom).
Milestone 1 (the Day-1 spikes) is complete: all 11 passed on 2026-09-03. DECISIONS.md holds
the evidence and three design changes the spikes forced (PostToolUseFailure for failing test
runs, SessionStart(compact) for post-compaction injection, SubagentStop filtering by agent_type).
Read it before wiring any hook. Real hook inputs captured from those runs are in
tests/fixtures/hook_inputs/; use them as pytest fixtures rather than inventing JSON.
Hard constraints (from the spec; do not relax)
- Zero cost: no API keys, no external services. Runs on the user's Claude Code subscription, git, and Python 3 stdlib only.
- Hook scripts are plain Python 3, stdlib only, invoked as
python3 script.py. Read JSON on stdin, write JSON on stdout, exit 0. No jq, no bash-isms. The 150-line cap binds the hook entry script (the filehooks/hooks.jsonnames); shared logic it imports lives inscripts/rehorse_lib/(stdlib only, no install).tests/test_line_cap.pyenforces both. Move code out to fit the cap; never drop a guarantee to fit it. - Every safety guarantee lives in a hook script, never in a skill's prose. Prose guides; hooks enforce.
- Phases advance only via
scripts/state.py, never by the model editingstate.jsondirectly. - Only
merge.pyanddiscard.pymay modify the user's real branch.guard_bash.pydenies branch-mutating git commands unlessREHORSE_MERGE_TOKENmatches the state file. - Before writing any plugin, hook, or skill code, fetch the current docs and copy the JSON
schemas exactly (do not write hook output formats from memory):
- https://code.claude.com/docs/en/plugins
- https://code.claude.com/docs/en/hooks
- https://code.claude.com/docs/en/skills If Claude Code behaves differently from SPEC.md, trust the docs and tell the user what changed.
- Never widen scope. Missing feature ideas go in
IDEAS.md. Out of scope for v1: model routing, knowledge graph, any UI, non-git repos, multi-task parallelism. - Write the failing pytest for a hook script before the script itself.
- After each milestone, update
README.mdandDECISIONS.md(one line per decision, with reason).
Commands
Planned layout has scripts/ (hook and helper scripts), tests/ (pytest), tests/fixtures/
(sample hook JSON), and eval/. Once these exist:
python3 -m pytest tests/ -q # all tests
python3 -m pytest tests/test_guard_edit.py -q # one file
python3 -m pytest tests/test_guard_edit.py -k name # one test
# Manually exercise a hook the way Claude Code will: pipe sample JSON through it
python3 scripts/guard_edit.py < tests/fixtures/edit_in_tests_phase.json
# Eval harness (milestone 6+): clones each task repo, runs `claude -p "/rehorse:build ..."`
python3 eval/run_eval.pyTest the plugin end to end by loading it from the local path in a toy repo with a tiny pytest
suite, including a forced /compact and a resume from a fresh session.
Architecture (big picture)
Plugin shape. .claude-plugin/plugin.json manifest; skills/rehorse-{build,status,merge,discard}/SKILL.md
are the user-facing commands (/rehorse:build "<task>" etc.); agents/rehorse-verifier.md is the
adversarial verifier subagent; hooks/hooks.json wires events to scripts/*.py.
State is the single source of truth. <repo>/.rehorse/state.json (gitignored) holds every
task: phase, worktree path, branch, base_sha, test command, baseline/red/green counts,
edit_seq, and last_test_run.after_edit_seq. Task IDs are t-<YYYYMMDD>-<slug> and name the
branch (rehorse/<id>), worktree (.rehorse/worktrees/<id>/), and report consistently.
Human-readable artifacts in <repo>/rehorse-reports/ are committed as the evidence trail:
PROGRESS.md (regenerated by progress.py from state, never free-formed), one report per task,
and verifier/ for long findings.
Phase machine: spec → tests → implement → verify → report → (merged | discarded).
tests: model may edit test paths only;red_checkrequires at least one new failing test or the phase does not advance.implement: test paths are locked; each plan step runs as a fresh subagent that returns a two-line summary; the orchestrator never reads the transcript.verify: verifier gets only the spec,git diff base_sha..HEAD, and last test output.report:report.pyrenders the report, then the agent's turn ends. It never merges.
Hooks are the guarantees. guard_edit.py (PreToolUse Edit/Write/MultiEdit: worktree
isolation, phase-based path lock, bumps edit_seq), guard_bash.py (PreToolUse Bash: no
branch mutation, no rm -rf on repo/.rehorse, no --no-verify), on_bash_done.py
(PostToolUse Bash: records test runs against current edit_seq), guard_stop.py (Stop: block
if edits happened since the last test run during implement), state.py --summary
(SessionStart), handoff.py (PreCompact: snapshot + injected summary), progress.py --step-done
(SubagentStop). Every deny must return a reason telling the model what it may do instead.
Context is managed by delegation, not clearing. The main session is an orchestrator holding
only the spec, the active PROGRESS.md section, and the state summary. Every phase and step is
a fresh subagent handed artifacts, not transcripts. Hooks cannot distinguish subagent tool calls
from the main session's, so "orchestrator never edits" is prose-guided only; say so in the README.
The hook-enforced guarantees (isolation, test-path lock, red-before-green, no merge) hold regardless.
Eval grades by the upstream PR's tests, never by Rehorse's own tests. Target repos: rich,
fastapi, zod, ten tasks each.
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.

