Get the FREE Ultimate OpenClaw Setup Guide →

brewcode:start

Scanned
npx machina-cli add skill kochetkov-ma/claude-brewcode/start --openclaw
Files (1)
SKILL.md
6.4 KB

Execute Task — [task-file-path]

<instructions>

How It Works

/brewcode:start -> Load PLAN.md -> Parse Phase Registry
   |
   v
TaskCreate for each row -> TaskUpdate dependencies
   |
   v
Execution Loop: TaskList() -> pending+unblocked -> spawn agents
   |
   v
Per agent: WRITE report -> CALL bc-coordinator (2-step, ALWAYS)
   |
   v
TaskUpdate(completed) -> repeat -> Finalize
   |
   v
After compact: TaskList() -> Read PLAN.md -> continue

Execution Steps

1. Resolve Task Path

  • If $ARGUMENTS has path -> use it
  • If $ARGUMENTS empty -> read .claude/TASK.md (first line = active path)
  • If neither -> STOP: No task path! Run: /brewcode:spec "description" then /brewcode:plan

2. Initialize via Coordinator (REQUIRED)

Task tool:
  subagent_type: "brewcode:bc-coordinator"
  prompt: "Mode: initialize. Task path: {TASK_PATH}"

Coordinator validates, creates lock, updates status -> in progress.

3. Load Context

  • Read PLAN.md (ONLY PLAN.md from the task directory)
  • Read KNOWLEDGE.jsonl if exists
  • Verify artifacts/ directory exists
  • DO NOT read phases/ files -- they are for agents, not the manager

4. Create Tasks from Phase Registry

Parse the ## Phase Registry table in PLAN.md.

FOR each row in Phase Registry:
  TaskCreate(
    subject  = "Phase {#}: {Subject}",
    description = "Phase {#}: {Summary}\n\nFull instructions: phases/{Phase File}\nTask dir: {TASK_DIR}\nArtifacts: artifacts/{Artifact Dir from Phase Registry}/\nKNOWLEDGE: KNOWLEDGE.jsonl",
    activeForm = "{Present continuous of Subject}"
  )

Sub-step 4a: Phase-to-TaskID Map Task IDs are auto-incremented (1,2,3...) and may NOT match Phase # (1,1V,2,3...). Build a map: {phase# -> taskId} during creation. Include phase # explicitly in description.

5. Set Dependencies

FOR each row where "Blocked By" column is non-empty:
  TaskUpdate(taskId, addBlockedBy=[mapped task IDs from Blocked By column])

6. Execution Loop

LOOP while pending tasks remain:
  a. TaskList() -> find tasks: status=pending, blockedBy=[]
  b. Same Parallel group -> spawn in ONE message (parallel Task calls)
  c. Per task:
     i.   TaskUpdate(taskId, status="in_progress")
     ii.  Task(subagent_type="{Agent from Phase Registry}", prompt from description)
     -- If agent FAILED (is_error=true):
        a. TaskUpdate(taskId, status="in_progress") -- keep in progress for retry
        b. Persist failure to KNOWLEDGE.jsonl:
           {"ts":"...","t":"❌","txt":"Phase {N} agent failed: {error_summary}. Attempt {I}/{MAX}.","src":"manager"}
        c. Retry once with same agent
        d. If retry fails: TaskUpdate(taskId, status="failed"), apply Escalation table
        e. Skip steps iii-v (no report to write, no coordinator to call)
     -- If agent SUCCEEDED:
        iii. WRITE report -> artifacts/{P}-{N}{T}/{AGENT}_output.md
        iv.  Task(subagent_type="brewcode:bc-coordinator",
                  prompt="Mode: standard. Task path: {TASK_PATH}. Report: {REPORT_PATH}")
             -- If coordinator FAILED (is_error=true): log warning, proceed to TaskUpdate(completed)
        v.   TaskUpdate(taskId, status="completed")
  d. On verification FAIL:
     i.   Read verification report from artifacts/{P}-{N}{T}/{VERIFY_AGENT}_output.md
          (manager can read artifacts/ — the rule is NEVER read phases/)
          Extract: {ISSUES_TABLE}, {FILES_TO_FIX} from the issues table in the report
          {VERIFY_AGENT} = agent from the verification row in Phase Registry
          {VERIFY_ARTIFACT_DIR} = artifact dir of the verification phase
     ii.  Write phases/{N}F{I}-fix-{name}.md using phase-fix.md.template
          (from .claude/tasks/templates/ or $BC_PLUGIN_ROOT/skills/setup/templates/)
          Fill: {PHASE_NUM}, {ITERATION}, {PHASE_NAME}, {FIX_AGENT}=original agent,
          {ORIGINAL_PHASE_FILE}, {VERIFY_ARTIFACT_DIR}, {VERIFY_AGENT},
          {ISSUES_TABLE} from verification report (step 6.d.i), {FILES_TO_FIX}, {ARTIFACT_DIR}
     iii. TaskCreate(subject="Fix phase {N} issues (iter {I})", ...)
     iv.  TaskCreate(subject="Re-verify phase {N} (iter {I+1})",
               addBlockedBy=[fix task ID])
     v.   Max 3 iterations -> Escalation
  e. Deadlock check after each iteration:
     TaskList() -> categorize:
     - ready = pending + blockedBy=[]
     - blocked = pending + blockedBy non-empty
     - active = in_progress
     If ready=0 AND active=0 AND blocked>0:
       DEADLOCK -> cascade failure to all blocked tasks, BREAK -> Finalize(status="failed")
     If ready=0 AND active=0 AND blocked=0:
       ALL DONE -> BREAK -> Finalize(status="finished")
     Else: continue loop

Escalation after repeated failures:

AfterAction
1 failR&D task: explore root cause
2 failsSplit phase into sub-phases
3 failsUpgrade model, reassign, AskUserQuestion

Failure Cascade

When escalation exhausted (task permanently failed):

  1. TaskUpdate(failedTaskId, status="failed")
  2. Persist to KNOWLEDGE.jsonl: {"ts":"...","t":"❌","txt":"Phase {N} permanently failed: {reason}","src":"manager"}
  3. Cascade: TaskList() -> for each task T where failedTaskId in T.blockedBy (transitive): TaskUpdate(T.id, status="failed")
  4. Log: "Phase {N} permanently failed. Cascaded to {count} dependent tasks."
  5. Independent tasks (no dependency on failed task) continue normally

7. Finalize

Task(subagent_type="brewcode:bc-coordinator",
     prompt="Mode: finalize. Task path: {TASK_PATH}. Status: {finished|failed}")

Status is "finished" when all tasks completed, "failed" when deadlock/cascade occurred.

8. Extract Rules (REQUIRED)

Skill(skill="brewcode:rules", args="{KNOWLEDGE_PATH}")

9. Prune Knowledge (REQUIRED)

Task(subagent_type="brewcode:bc-knowledge-manager",
     prompt="mode: prune-rules\ntaskPath: {TASK_PATH}")

Handoff (After Compact)

  1. TaskList() -- current task state (source of truth)
  2. Read PLAN.md -- protocol and Phase Registry
  3. DO NOT read phases/ -- they are for agents
  4. Continue with current in_progress or next pending task
  5. WRITE report -> CALL coordinator after EVERY agent (ALWAYS)
</instructions>

Source

git clone https://github.com/kochetkov-ma/claude-brewcode/blob/main/brewcode/skills/start/SKILL.mdView on GitHub

Overview

brewcode:start orchestrates multi-phase tasks by loading PLAN.md, creating phase-driven tasks, and handing off execution to agents via a central coordinator. It manages dependencies, enables parallel execution, handles retries, and produces final artifacts and reports for auditing.

How This Skill Works

It resolves the task path, initializes via the bc-coordinator, and loads context from PLAN.md and optional KNOWLEDGE.jsonl. It parses the Phase Registry to create per-phase tasks and their dependencies, then runs an execution loop that spawns agents in parallel, collects reports, and updates statuses until completion.

When to Use It

  • You have a PLAN.md with a Phase Registry defining phases and dependencies.
  • You need automatic handoff of work to specialized agents via a central coordinator.
  • You require parallel task execution within a managed loop and robust retry logic.
  • You want end-to-end traceability with artifacts and KNOWLEDGE.jsonl updates.
  • You need finalization and escalation steps after verification and completion.

Quick Start

  1. Step 1: Point to a task path or ensure .claude/TASK.md is present with the active path as the first line
  2. Step 2: Run the command to start brewcode:start and initialize via the coordinator
  3. Step 3: Monitor execution; review artifacts and reports until all tasks complete

Best Practices

  • Validate PLAN.md Phase Registry formatting before running.
  • Ensure artifacts directories exist for outputs and reports.
  • Map Phase numbers to auto-incremented task IDs and include in descriptions.
  • Keep KNOWLEDGE.jsonl updated with failures for audit trails.
  • Prefer sending a single parallel Task call per execution cycle to optimize throughput.

Example Use Cases

  • Orchestrating a multi-phase software build pipeline with dependency-aware steps.
  • Coordinating data extraction, transformation, and loading tasks with agent-based verification.
  • Managing knowledge discovery phases where each phase produces artifacts for the next.
  • Running long-running optimization tasks with automatic handoffs and retries.
  • Auditing task runs by generating per-phase reports stored in artifacts.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers