bc-coordinator
Caution
The coordinator never writes code. It validates report files on disk, extracts knowledge entries, updates the Phase Status table in PLAN.md, and generates FINAL.md on completion. Per-phase Status: and Result: fields are managed exclusively by the manager via the Task API — the coordinator never touches them.
Tip
Called automatically by /brewcode:start. You never invoke bc-coordinator directly. The manager calls it after each agent completes, passing the report path as a flat text prompt. On task completion, the manager calls it one final time with mode: finalize.
Quick reference
| Field | Value |
|---|---|
| Agent | bc-coordinator |
| Model | haiku |
| Tools | Read, Write, Edit, Bash |
| Permission mode | acceptEdits |
| Invoked by | /brewcode:start manager (never directly) |
| Modes | initialize, standard, finalize |
When to use
- Phase just completed — manager writes
{AGENT}_output.md, then calls coordinator withmode: standardand the report path - Task starting — manager calls coordinator with
mode: initializeto validate the PLAN.md structure, create the lock file, and transition status frompendingtoin progress - Task finished or failed — manager calls coordinator with
mode: finalizeto write FINAL.md and set the terminal status on line 1 of PLAN.md - KNOWLEDGE.jsonl nearing capacity — coordinator auto-compacts when entry count reaches
maxEntries * 0.8, deduplicating and sorting by priority (❌>✅>ℹ️)
Examples
Initialize at task start:
mode: initialize
taskPath: .claude/tasks/20260417-120000_my-feature_task/PLAN.md
Coordinator validates the task structure, creates the .lock file, and flips line 1 from status: pending to status: in progress.
After an agent completes (standard mode):
mode: standard
taskPath: .claude/tasks/20260417-120000_my-feature_task/PLAN.md
report: artifacts/1-1e/developer_output.md
Coordinator verifies the file exists on disk, reads it, extracts 3–10 KNOWLEDGE entries, and updates the Phase Status table.
Finalize on success:
mode: finalize
taskPath: .claude/tasks/20260417-120000_my-feature_task/PLAN.md
status: finished
Generates FINAL.md from the report template, sets line 1 to status: finished. The stop hook reads this value — any non-terminal status blocks session exit.
Flow
- Receive mode + taskPath
The manager sends a flat text prompt specifying
mode,taskPath, and (in standard mode) thereportpath. Coordinator reads lines 1–3 of PLAN.md for current state. - Verify report on disk
In
standardmode: checks that{AGENT}_output.mdexists at the given path. If missing — returns an error immediately. The manager must write the file before calling coordinator. - Extract knowledge
Reads the report and appends 3–10 genuinely reusable entries to KNOWLEDGE.jsonl using the schema `{"ts":"ISO","t":"❌|✅|ℹ️","txt":"...","src":"agent"}`. Skips phase summaries, vague statements, and progress notes.
- Update Phase Status table
Adds or updates the row for the current phase in the
## Phase Statussection at the bottom of PLAN.md. This is the only PLAN.md body section the coordinator ever writes. - Auto-compact KNOWLEDGE if needed
Counts entries. If count is at or above
maxEntries * 0.8: deduplicates by exacttxtmatch, sorts by priority then timestamp descending, trims tomaxEntries, and atomically rewrites the file. - Return summary
Prints phase number, report verification result, KNOWLEDGE entry count, compaction status, and an explicit next-action recommendation for the manager.
Coordinator protocol & artifact rules
Modes in detail
initialize — called once at /brewcode:start:
- Validates task file exists and has a
## Phase Registrysection - Accepts status
pending,in progress, orhandoff(allows restart after crash) - Writes
.lockfile (always overwrites — enables recovery):{"task_path":"...","started_at":"ISO"} - Sets line 1 to
status: in progress - Validates/updates
.claude/TASK.mdreference (single-line path)
standard — called after each agent:
- Read PLAN.md header (lines 1–3)
- Verify report file exists on disk — error if missing
- Read report, extract 3–10 KNOWLEDGE entries
- Update Phase Status table (add row or update existing)
- Update header lines 2–3 (
current_phase,total_phases) if phase completed - Auto-compact KNOWLEDGE if entry count >= threshold
finalize — called on task completion:
- Generate FINAL.md from
$BC_PLUGIN_ROOT/templates/reports/FINAL.md.template - If
status: failed— include failure summary from KNOWLEDGE.jsonl - Set line 1 to
status: finished(orfailed) - Lock deletion is handled by the stop hook, not coordinator
PLAN.md header format (first 3 lines)
status: in progress
current_phase: 2
total_phases: 5Terminal statuses for line 1: finished, failed, cancelled, error. Any other value blocks session exit via the stop hook.
Phase Status table
## Phase Status
| # | Status | Started | Completed | Iterations |
|---|--------|---------|-----------|------------|
| 1 | completed | 2026-01-26T14:00 | 2026-01-26T14:30 | 1 |
| 1V | completed | 2026-01-26T14:31 | 2026-01-26T14:45 | 1 |
| 2 | in_progress | 2026-01-26T14:46 | - | 1 |If the section does not exist — coordinator creates it at the end of PLAN.md. The Completed column is - while in progress, ISO timestamp when done.
Artifact directory layout
{TS}_{NAME}_task/artifacts/
├── FINAL.md
└── {P}-{N}{T}/ # e.g., 1-1e/ (phase 1, iter 1, exec)
├── {AGENT}_output.md
└── summary.mdWhat coordinator never does
- Implement code
- Fabricate or hallucinate report content
- Create
{AGENT}_output.md— manager writes these before calling coordinator - Edit per-phase
Status:orResult:fields in PLAN.md body (Task API only) - Read files from
phases/directory
brewcode overview
All brewcode skills, agents, and hooks in one place.
/brewcode:start
The skill that drives task execution and calls bc-coordinator at each phase boundary.
GitHub source
Full coordinator protocol and agent definition.
Updating plugins
/brewtools:plugin-update to check and update the brewcode plugin suite in one command.
See the FAQ for details.