Skip to content

Builder

Role

The Builder is the primary code-writing agent. It owns the BUILD state. Multiple Builder instances can run in parallel, each taking a different task from the Architect’s plan. Each Builder works in its own git worktree branch.

The Builder takes a single Task from the technical plan and implements it completely: all files, all tests, all inline documentation. When done, it opens a PR and issues a completion certificate.

Responsibilities

  • File implementation — write all files specified in the task, following codebase conventions
  • Test writing — write tests for all new code paths in the same commit (mandate_16)
  • Typecheck — run tsc --noEmit before committing; the certificate fails if typecheck fails
  • Lint — run the project linter; fix all errors before committing
  • Commit — commit with a conventional commit message (feat:, fix:, chore:)
  • PR creation — open a pull request against the main branch with a structured description
  • Certificate — issue a completion certificate: typecheck passed, tests passed, mandate checks passed

Skills

SkillDescription
file.writeCreates or modifies source files
test.writeWrites test files using the project’s test framework
shell.runRuns shell commands (typecheck, lint, tests) in the worktree
git.commitCreates commits with conventional commit messages
pr.openOpens a GitHub pull request via the GitHub API
mandate.checkRuns mandate checks against the working tree

When dispatched

  • BUILD: one instance per task, in parallel

Token budget per task

Each Builder instance has a per-task budget of 200,000 tokens. If a task approaches this limit, the Builder checkpoints its work, commits a WIP commit, and creates an inbox item requesting a budget review.

Inputs (handoff packet)

{
task: Task; // single task from TechnicalPlan
technicalPlan: TechnicalPlan; // full plan for context
uiSpec?: UISpec; // present if task has UI components
workingDirectory: string; // isolated git worktree
mandates: MandateSnapshot;
tokenBudgetRemaining: number;
}

Outputs

  • Committed code in the worktree branch
  • An open GitHub pull request
  • A CompletionCertificate

Conventions enforced

The Builder reads the project’s existing code to infer and match:

  • File structure and naming
  • Import style (named vs. default, path aliases)
  • Component patterns (hooks, context, composition)
  • Test framework and assertion style
  • Error handling patterns
  • Logging patterns (no console.log in production code — mandate_15)

Sample system prompt excerpt

You are a Builder agent for Defiant 2.0.
You are implementing a single task. Do not implement any scope beyond what this
task specifies. Do not modify files outside the task's file list without explicit
justification.
Your task:
<task>{{ task }}</task>
Technical plan (for context):
<plan>{{ technicalPlan }}</plan>
UI specification (if applicable):
<uiSpec>{{ uiSpec }}</uiSpec>
Working directory: {{ workingDirectory }}
Active mandates: {{ mandateList }}
Implementation rules:
- Read existing files before writing to understand conventions.
- Write tests in the same commit as the code. No "I'll add tests later."
- No console.log, TODO comments, or commented-out code in commits (mandate_15).
- Run typecheck and lint before issuing the completion certificate.
- Commit message format: feat(<scope>): <description>
- Open a PR with title matching the task title and body including:
- What was built
- How to test it
- Checklist: [ ] typecheck [ ] tests [ ] lint [ ] mandates

Failure modes

  • Typecheck failure: Builder attempts to fix the error. If it cannot within budget, it commits the WIP, flags the error in the certificate, and moves the sprint to BLOCKED.
  • Test failure: Builder attempts to fix. Same escalation if it cannot.
  • Mandate violation: Builder must resolve it or block the sprint — it cannot ship code that violates a blocking mandate.
  • Budget exhaustion: WIP commit + inbox item. Sprint paused.