Skip to content

deveraux-dev/dream-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dream Worker Discipline

Hook-enforced discipline for LLM coding agents. Seven rules that prevent the common failure modes: runaway token burn, concurrent-agent file conflicts, unverified "I fixed it" claims, and convention drift.

The Problem

LLM coding agents have predictable failure modes. Unleashed, they:

  • Burn tokens re-exploring code they could index once
  • Execute destructive operations without verification gates
  • Spawn parallel agents that conflict on shared files
  • Generate code that does not compile or fails tests
  • Produce output that looks plausible but is wrong

The fix is not a better model. The fix is discipline applied at the dispatch boundary, enforced by hooks at tool-call time.

The Seven Rules

Rule 1: Worktree Isolation

Every implementation agent runs in a dedicated git worktree with its own filesystem. Agents cannot write to the main branch. Merge only happens after verification passes.

Why: parallel agents corrupt each other's edits. Worktrees force physical separation.

Rule 2: Concurrency Cap (max 2)

Never dispatch more than 2 implementation agents simultaneously.

Why: a human supervisor cannot review more than 2 concurrent threads of agent work. Past 2, burn outpaces review.

Rule 3: Tool Call Budget

Implementation agents: 15 tool calls maximum. Research agents: 5 tool calls maximum.

Why: past 15 calls on a single task, the agent is either stuck or duplicating work. Hard cap forces escalation.

Rule 4: Token Cap

Implementation agents: 20,000 output tokens. Research agents: 10,000.

Why: runaway verbosity signals agent confusion. Cap forces concision.

Rule 5: TOML Test Plan Mandatory

No agent dispatches without a TOML plan describing what it must produce and how output will be verified.

Why: "build a feature" without acceptance criteria produces unverifiable output. The plan converts agent output into something testable.

Rule 6: Verification Gate

Every agent output passes a mandatory gate before merge:

  • Compile or type-check passes
  • Test plan assertions pass
  • Visual capture if UI (optional, domain-specific)

Why: verification is non-negotiable. Agent self-reported success is not evidence.

Rule 7: Review Plus Verify Before Merge

Two distinct steps. A code-reviewer validates the diff against plan and conventions. Then the verification gate runs. Both must pass.

Why: review catches convention drift. Verification catches correctness. Both required, neither sufficient.

Additional Principles

Never agent what you already know. If the current session has the answer, use it. Do not dispatch for re-discovery.

Log violations. Every agent dispatch that fails a gate writes to an audit log. Review weekly. Patterns signal where discipline is drifting.

Budget lives in hooks, not in prompts. Telling an agent "do not use more than 15 tool calls" does not work. Hooks that abort at call 16 do.

Reference Implementation

Three hook scripts and one shared library for Claude Code users. Hooks operate on tool-call stdin.

Included

  • hooks/budget-cap.sh: Rule 3 tool-call budget
  • hooks/worktree-guard.sh: Rule 1 worktree isolation
  • hooks/toml-gate.sh: Rule 5 TOML plan mandatory
  • lib/hook-lib.sh: shared stdin parser and JSON output helpers

Setup

See examples/claude-code-setup.md for Claude Code integration.

Anti-Patterns This Eliminates

  1. The parallel dispatch burn: multi-agent orchestrations spawn 7+ concurrent agents. Concurrency cap of 2 stops this.
  2. The self-reported success: agent says "I fixed it." Verification gate requires compile and test evidence, not narration.
  3. The convention drift: agent writes code that works but violates project style. Review step catches it before merge.
  4. The silent token burn: agent retries the same failing approach 5 times. Tool call cap stops the loop and escalates.

When to Use This

LLM coding workflows where:

  • Multiple agents work in parallel
  • Agents touch production or shared code
  • Output quality matters more than speed
  • Token cost is non-trivial

Not worth the overhead for single-prompt code generation, exploratory notebooks, or throwaway prototypes.

License

MIT. Adopt freely.

About

Hook-enforced discipline for LLM coding agents (dream-worker v0.1.0 on crates.io)

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors