Find and safely claim the next Beads task with conflict checking...
Find available work. Verify no conflicts. Claim safely. Announce.
Pattern: This skill uses the orchestrator-subagent pattern. Each phase runs in a fresh context for thorough conflict checking. See
docs/guides/ORCHESTRATOR_SUBAGENT_PATTERN.md.
| Signal | Action |
|---|---|
| User says "next task" or "what's next" | Run discovery + claim |
| Just finished a task | Close out, then discover |
| User says "/next-bead" | Run full protocol |
| Looking for work | Run discovery |
| Tool | Purpose |
|---|---|
fetch_inbox(agent_name) |
Check for messages before claiming |
file_reservation_paths(paths, exclusive) |
Reserve files before editing |
release_file_reservations(agent_name) |
Release files after closing |
send_message(to, subject, body_md, thread_id) |
Announce [CLAIMED]/[CLOSED] |
| Command | Purpose |
|---|---|
bd list --status in_progress --json |
Check for current work |
bd ready --json |
List available tasks |
bd-claim <id> --paths "..." |
PREFERRED: Atomic claim + reserve |
bd update <id> --status in_progress --assignee NAME |
Manual claim (use bd-claim instead) |
bd close <id> --reason "..." |
Close completed bead |
bv --robot-triage |
Get recommendations |
bv --robot-next |
Get single best task |
bv --robot-plan |
Get execution order |
cm context "task description" --json |
Get patterns before starting |
pytest |
Run tests before closing |
ubs --staged |
Security scan (MANDATORY) |
| Pattern | When |
|---|---|
[CLAIMED] bd-XXX - Title |
After claiming task |
[CLOSED] bd-XXX - Title |
After closing task |
ubs --staged.beads/issues.jsonlbd close <id>.1)bd close <id>)āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā NEXT-BEAD ORCHESTRATOR ā
ā - Creates session: sessions/next-bead-{timestamp}/ ā
ā - Manages TodoWrite state ā
ā - Spawns subagents with minimal context ā
ā - Passes verified task to claim phase ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāā
ā ā ā
ā¼ ā¼ ā¼
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā
ā Closeout ā ā Discover ā ā Verify ā
ā agents/ ā ā agents/ ā ā agents/ ā
ā closeout.md ā ā discover.md ā ā verify.md ā
āāāāāāāāāā¬āāāāāāāāā āāāāāāāāāā¬āāāāāāāāā āāāāāāāāāā¬āāāāāāāāā
ā ā ā
01_closeout.md 02_discovery.md 03_verification.md
ā ā ā
ā reservations ā ready_tasks ā can_claim
ā released ā bv_recommendation ā verified_task
āāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Claim ā ā Task claimed
ā agents/ ā
ā claim.md ā
āāāāāāāāāā¬āāāāāāāāā
ā
04_claim.md
| Phase | Agent | Input | Output |
|---|---|---|---|
| 1 | agents/closeout.md |
agent_name | beads_closed, reservations_released |
| 2 | agents/discover.md |
agent_name | ready_tasks, bv_recommendation |
| 3 | agents/verify.md |
target_task, active_agents | can_claim, verified_task |
| 4 | agents/claim.md |
verified_task | task_claimed, files_reserved |
1. Create session directory:
mkdir -p sessions/next-bead-{timestamp}
2. Initialize TodoWrite with phases:
- [ ] Phase 1: Closeout
- [ ] Phase 2: Discover
- [ ] Phase 3: Verify
- [ ] Phase 4: Claim
3. Gather inputs:
- project_path: Absolute path to project
- agent_name: Current agent name
Spawn: agents/closeout.md
Input:
{
"project_path": "/abs/path/to/project",
"session_dir": "sessions/next-bead-{timestamp}",
"agent_name": "BlueLake"
}
Output:
{
"had_in_progress": true,
"beads_closed": ["bd-123", "bd-123.1"],
"reservations_released": true
}
Spawn: agents/discover.md
Input:
{
"project_path": "/abs/path/to/project",
"session_dir": "sessions/next-bead-{timestamp}",
"agent_name": "BlueLake"
}
Output:
{
"ready_tasks": ["bd-125", "bd-126", "bd-127"],
"bv_recommendation": "bd-125",
"active_agents": ["GreenCastle"]
}
Spawn: agents/verify.md
Input:
{
"project_path": "/abs/path/to/project",
"session_dir": "sessions/next-bead-{timestamp}",
"agent_name": "BlueLake",
"target_task": {"id": "bd-125", "files": ["src/auth/**"]},
"active_agents": ["GreenCastle"]
}
Output:
{
"can_claim": true,
"verified_task": "bd-125",
"blocking_reason": null
}
Spawn: agents/claim.md
Input:
{
"project_path": "/abs/path/to/project",
"session_dir": "sessions/next-bead-{timestamp}",
"agent_name": "BlueLake",
"task_to_claim": {"id": "bd-125", "title": "JWT validation"},
"active_agents": ["GreenCastle"]
}
Output:
{
"task_claimed": "bd-125",
"files_reserved": ["src/auth/**"],
"announcement_sent": true
}
Located in .claude/templates/beads/:
verification.md ā Pre-claim checklistclaimed.md ā Claim announcement formatclosed.md ā Completion announcement formatnext-bead-output.md ā Output summary formatParallel agents must coordinate. Before claiming:
Check for in-progress work:
bd list --status in_progress --json
If yes:
ubs --staged.beads/issues.jsonl)bd close <id>.1 --reason "Completed: [summary]"
bd close <id> --reason "Completed: [summary]"
release_file_reservations(project_key=PROJECT_PATH, agent_name=YOUR_NAME)
[CLOSED] announcement (use template)Recommendations:
bv --robot-triage
bv --robot-plan
Ready tasks:
bd ready --json
Active agents:
ReadMcpResourceTool(server="mcp-agent-mail", uri="resource://agents/PROJECT_PATH")
Already claimed:
bd list --status in_progress --json
Your inbox:
fetch_inbox(project_key=PROJECT_PATH, agent_name=YOUR_NAME, include_bodies=true, limit=10)
Address urgent messages before claiming new work.
All must pass before claiming:
readyIf ANY fails ā pick different task or coordinate first.
If uncertain, ask:
send_message(
project_key=PROJECT_PATH,
sender_name=YOUR_NAME,
to=[OTHER_AGENTS],
subject="Claiming task: <task-id>?",
body_md="Planning to pick up **<task-id>**. Files: `app/...`. Conflicts?",
importance="normal"
)
PREFERRED: Use bd-claim for atomic claim + reserve:
bd-claim <id> --paths "app/path/**,tests/**"
This atomically validates, reserves, and claims in one command with automatic rollback on failure.
For sub-beads, claim each:
bd-claim <id>.1 --paths "app/path/**"
bd-claim <id>.2 --paths "tests/**"
ALTERNATIVE: Manual steps (use bd-claim instead):
bd update <id> --status in_progress --assignee YOUR_NAME
bd update <id>.1 --status in_progress --assignee YOUR_NAME
bd update <id>.2 --status in_progress --assignee YOUR_NAME
file_reservation_paths(
project_key=PROJECT_PATH,
agent_name=YOUR_NAME,
paths=["app/path/**", "tests/**"],
ttl_seconds=3600,
exclusive=true,
reason="<task-id>: description"
)
Announce (MANDATORY):
send_message(
project_key=PROJECT_PATH,
sender_name=YOUR_NAME,
to=[ALL_AGENTS],
subject="[CLAIMED] <task-id> - <title>",
body_md=<use claimed template>,
importance="normal",
thread_id="<task-id>"
)
After claiming, get patterns and anti-patterns:
cm context "<task-title>" --json
This returns:
# Recommended next
bv --robot-triage
bv --robot-next # Single best task
# Ready tasks
bd ready --json
# Claimed tasks
bd list --status in_progress --json
# Claim (PREFERRED: atomic claim + reserve)
bd-claim <id> --paths "src/**/*.py"
# Manual claim (use bd-claim instead)
bd update <id> --status in_progress --assignee YOUR_NAME
# Close (sub-beads first)
bd close <id>.1 --reason "Completed: ..."
bd close <id> --reason "Completed: ..."
| Don't | Why |
|---|---|
| Skip file reservation checks | Merge conflicts |
| Claim only parent, not sub-beads | Other agents grab sub-beads |
Skip [CLAIMED] announcement |
Duplicate work |
Skip [CLOSED] announcement |
Stale state |
| Hoard tasks | Claim one, finish it, then next |
| Ignore inbox | Miss coordination messages |
bead-workflow/ ā Full bead lifecycle detailsprime/ ā Session startup.claude/templates/beads/ ā Message templates