By sunfmin
A fenced Brain/Hand coding loop: a read-only Brain plans one tiny task, a Hand executes+tests+commits it, and PreToolUse guard hooks block destructive, privileged, and out-of-fence commands.
Planner/reviewer for the Brain/Hand loop. Read-only. Inspects the repo and the Hand's last report, decides the single next task, and judges whether the goal is done. Never edits files.
Executor for the Brain/Hand loop. Performs exactly ONE task from the Brain, runs tests + lint, commits on success, and writes a structured report. Stays inside the project folder.
A Claude Code plugin for the Brain/Hand pattern: one agent plans and reviews (read-only), another executes one tiny task at a time, and a deterministic loop enforces hard stop conditions — so the agent stays a fenced assistant, never "an unsupervised raccoon with terminal access".
Two independent kinds of guardrail, by design:
| Component | Ships via | Role |
|---|---|---|
agents/brain.md | plugin (auto) | Brain — read-only planner/reviewer. Picks ONE next task; judges the last report. No Edit/Write. |
agents/hand.md | plugin (auto) | Hand — executor. Does one task, runs tests/lint, commits on green, reports honestly. |
hooks/guard-bash.sh | plugin (auto) | PreToolUse guard: blocks rm -rf, sudo, force-push, history rewrites, pipe-to-shell, fence escapes. |
hooks/guard-write.sh | plugin (auto) | PreToolUse guard: blocks writes outside the project folder and to secret-like files. |
project-template/workflows/brain-hand-loop.js | manual | The controlled loop with the hard stop conditions. |
project-template/hooks/changed-lines.sh | manual | Single source of truth for the "diff too large" governor (counts hand-written lines, excludes lockfiles). |
project-template/settings.json | manual | Recommended permission allow/deny list. |
Claude Code plugins can ship agents and hooks, but cannot ship
workflows or a permissions list — those are project-scoped by design.
So the plugin auto-installs the reusable agents + safety fence, and the three
project-scoped pieces live in project-template/ for you to drop into your
repo's .claude/.
/plugin marketplace add sunfmin/claude-brain-hand
/plugin install claude-brain-hand@sunfmin-brain-hand --scope project
Use --scope project so the guard hooks apply only in the repo where you
run the loop — not to every session everywhere (they block git push, sudo,
etc., which you don't want fenced during normal work).
From the root of the repo you want to run the loop in:
# the workflow + the diff-size governor script
mkdir -p .claude/workflows .claude/hooks
cp "$(claude plugin path claude-brain-hand)"/project-template/workflows/brain-hand-loop.js .claude/workflows/
cp "$(claude plugin path claude-brain-hand)"/project-template/hooks/changed-lines.sh .claude/hooks/
chmod +x .claude/hooks/changed-lines.sh
Then merge project-template/settings.json into your .claude/settings.json
(the permissions.allow / permissions.deny blocks). Tighten allow to
exactly your project's test/build/lint commands — the narrower the allowlist,
the smaller the attack surface.
Don't have
claude plugin path? Justgit clonethis repo andcpthe two files out ofproject-template/by hand.
Before the first run the repo must be on a feature branch with a clean
git tree, and have real test + lint commands (edit the agents'
instructions / the allow list to match your stack).
The loop is a Claude Code Workflow, which spawns multiple agents, so it needs explicit opt-in. Ask Claude Code, in that repo:
run the brain-hand-loop workflow with the goal "add input validation to parseConfig"
or invoke the Workflow tool with
{ name: "brain-hand-loop", args: "add input validation to parseConfig" }.
The Brain and Hand are ordinary subagents — you can also drive them directly
with the Agent tool.
| Stop condition | Where it lives |
|---|---|
| Stop after N loops | MAX_LOOPS (workflow) |
| Stop if tests fail twice | MAX_TEST_FAILURES (workflow) |
| Stop if the diff gets too large | MAX_DIFF_LINES (workflow) + changed-lines.sh |
| Stop if the Hand is unclear | report.unclear → human |
| No writes outside the project | guard-write.sh |
| No destructive/privileged commands | guard-bash.sh + deny list |
| Clean git + small commits + revertable | git; one task = one commit |
main server-side (branch protection) — the local git push block
is only a courtesy.allow list as narrow as your project's real commands.MIT © Felix Sun
Executes bash commands
Hook triggers when Bash tool is used
Modifies files
Hook triggers on file write and edit operations
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
Uses power tools
Uses Bash, Write, or Edit tools
Uses power tools
Uses Bash, Write, or Edit tools
npx claudepluginhub sunfmin/claude-brain-hand --plugin claude-brain-handBuild and test user journeys from spec.md with screenshot verification, self-improving refinement loop, and design quality checks
Comprehensive feature development workflow with specialized agents for codebase exploration, architecture design, and quality review
Harness-native ECC operator layer - 67 agents, 271 skills, 92 legacy command shims, reusable hooks, rules, selective install profiles, and production-ready workflows for Claude Code, Codex, OpenCode, Cursor, and related agent harnesses
Comprehensive skill pack with 66 specialized skills for full-stack developers: 12 language experts (Python, TypeScript, Go, Rust, C++, Swift, Kotlin, C#, PHP, Java, SQL, JavaScript), 10 backend frameworks, 6 frontend/mobile, plus infrastructure, DevOps, security, and testing. Features progressive disclosure architecture for 50% faster loading.
Tools to maintain and improve CLAUDE.md files - audit quality, capture session learnings, and keep project memory current.
Browser automation and end-to-end testing MCP server by Microsoft. Enables Claude to interact with web pages, take screenshots, fill forms, click elements, and perform automated browser testing workflows.
Develop, test, build, and deploy Godot 4.x games with Claude Code. Includes GdUnit4 testing, web/desktop exports, CI/CD pipelines, and deployment to Vercel/GitHub Pages/itch.io.