Bd Grind

Autonomously work through all ready beads tasks without stopping to ask. Keeps going until the backlog is empty or a blocking err…

srmccray updated 5mo ago
Claude CodeGeneric
View source ↗
# Grind Beads Backlog

Autonomously work through all ready beads tasks without stopping to ask. Keeps going until the backlog is empty or a blocking error occurs.

## Scope (optional)
$ARGUMENTS

## Instructions

**You are the ORCHESTRATOR.** Your job is to continuously pull ready tasks from beads and delegate them to subagents until nothing remains. Do NOT ask the user for confirmation between tasks — just keep going.

---

## Phase 1: Survey the Backlog (YOU do this directly)

```bash
bd ready
bd list --status=open
bd stats

If $ARGUMENTS provided (scope filter):

  • If it looks like a beads ID (e.g. hacking-game-abc), filter to tasks under that feature
  • If it looks like a keyword, use bd search "KEYWORD" to find matching issues
  • Only work on tasks matching the scope

If no arguments:

  • Work through ALL ready tasks across all features, ordered by priority then ID

Show the user what you found:

## Grind Session Starting

**Ready tasks:** [N]
**Scope:** [all | feature: id | search: keyword]

| # | Beads ID | Title | Priority |
|---|----------|-------|----------|
| 1 | [id] | [title] | [priority] |
| 2 | [id] | [title] | [priority] |
| ... | | | |

Starting work...

If no ready tasks exist, inform the user and suggest /bd-plan to create some.


Phase 2: Grind Loop (REPEAT until backlog empty)

For each iteration:

Step 1: Pick the next task

bd ready

Pick the highest-priority unblocked task. If multiple tasks share the same priority, pick the lowest ID (oldest first). If scoped to a feature, only pick tasks under that feature.

If bd ready returns nothing, go to Phase 3 (Wrap Up).

Step 2: Claim it

bd show <task-id>
bd update <task-id> --status=in_progress

Step 3: Delegate to subagent

Use the Task tool to invoke the appropriate implementation agent:

Task tool parameters:
  subagent_type: "[agent-from-table-below]"
  prompt: |
    Implement this task:

    BEADS_TASK_ID: [beads task ID]
    BEADS_FEATURE_ID: [parent feature ID]
    TITLE: [task title]
    DESCRIPTION: [full task description from bd show]
    CONTEXT: [any relevant context — FRD location, previous task outputs, etc.]

    After implementation, include in your output:
    1. A "Completion Status" section (Complete or Partial with explanation)
    2. List of files created/modified
    3. A "New Tasks Discovered" section listing any follow-up work needed

Agent Routing (this project)

Domain Agent
Core game (TypeScript, state, resources) backend-implementation
UI (PixiJS, rendering, HUD, scenes) frontend-implementation
Build, deployment infrastructure-implementation
Tests test-coverage
Security security-review
Documentation documentation-writer

Step 4: Process implementation output

Check "Completion Status":

  • Partial → keep task open, log what remains, and continue to next task:
    bd update <task-id> --notes="Partial: [what remains]"
    
    Skip validation — proceed to Step 7.
  • Complete → proceed to Step 5 (Validation).

Check "New Tasks Discovered":

  • Create beads issues for any follow-up work:
    bd create "New task title" --type=task|bug --priority=N --description="..."
    bd dep add <new-id> <blocking-id>   # if dependency needed
    

Step 5: Validate (INVOKE SUBAGENT)

Use the Task tool to invoke the task-validator agent:

Task tool parameters:
  subagent_type: "task-validator"
  prompt: |
    Validate that this task has been completed successfully.

    BEADS_TASK_ID: [beads task ID]
    BEADS_FEATURE_ID: [parent feature ID]
    TASK_TITLE: [title]
    TASK_DESCRIPTION: [full description from bd show]
    ACCEPTANCE_CRITERIA: [paste acceptance criteria from task description or FRD]
    FILES_MODIFIED: [list from implementation agent output]
    IMPLEMENTATION_SUMMARY: [what the implementation agent said it did]

    Run all validation checks (TypeScript, lint, build, unit tests, e2e tests)
    and verify each acceptance criterion against the actual code.

Process the validator's output:

  • VERDICT: PASS → close the task and proceed to Step 6:

    bd close <task-id> --reason="Validated: [summary]"
    
  • VERDICT: FAIL → enter retry loop (Step 5a)

Step 5a: Retry Loop (max 2 retries)

Track retry count per task. On FAIL:

  1. Re-invoke the implementation agent with the validator's failure context:

    Task tool parameters:
      subagent_type: "[same agent as Step 3]"
      prompt: |
        RETRY: Fix validation failures for this task.
    
        BEADS_TASK_ID: [beads task ID]
        BEADS_FEATURE_ID: [parent feature ID]
        TITLE: [title]
        DESCRIPTION: [full description]
        RETRY_ATTEMPT: [1 or 2]
    
        VALIDATION FAILURES:
        [paste the "Context for retry" section from the validator output]
    
        Fix these specific issues. After fixing, include in your output:
        1. A "Completion Status" section
        2. List of files created/modified
        3. A "New Tasks Discovered" section
    
  2. Re-invoke the task-validator with the same parameters as Step 5.

  3. If PASS → close task, continue to Step 6.

  4. If FAIL again and retries exhausted (2 retries used):

    • Do NOT close the task
    • Log the persistent failure:
      bd update <task-id> --status=open --notes="Validation failed after 2 retries: [summary of failures]"
      
    • Skip this task and continue to Step 7

Step 6: Post-task housekeeping

Periodic commit — after every 3 validated tasks (or after any task that produced significant changes):

git add <files modified in recent tasks>
git commit -m "Implement: [brief summary of recent tasks]"

Check if feature is done — after closing a task, check if all tasks for its parent feature are now closed:

bd list --status=open | grep <feature-related-prefix>

If ```

Maintain Bd Grind?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Bd Grind on getagentictools](https://getagentictools.com/loops/srmccray-grind-beads-backlog?ref=badge)