ai-team-library/claude/skills/long-run/SKILL.md
# Skill: Long Run ## Description Puts the Team Lead into autonomous backlog processing mode. The Team Lead reads the bean backlog, selects the best bean to work on, decomposes it into tasks, executes the assigned wave (Developer and Tech-QA are mandatory; other specialists are assigned only when the bean needs them), verifies acceptance criteria, commits the result, and loops to the next bean. Continues until no actionable beans remain or an unrecoverable error occurs. ## Trigger - Invoked b
npx skillsauth add beekeeper-lab/foundry ai-team-library/claude/skills/long-runInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Puts the Team Lead into autonomous backlog processing mode. The Team Lead reads the bean backlog, selects the best bean to work on, decomposes it into tasks, executes the assigned wave (Developer and Tech-QA are mandatory; other specialists are assigned only when the bean needs them), verifies acceptance criteria, commits the result, and loops to the next bean. Continues until no actionable beans remain or an unrecoverable error occurs.
/long-run slash command._index.md with status Approved.| Input | Type | Required | Description |
|-------|------|----------|-------------|
| backlog | Markdown file | Yes | ai/beans/_index.md — master bean index |
| bean_workflow | Markdown file | Yes | ai/context/bean-workflow.md — lifecycle reference |
| bean_files | Markdown files | Yes | Individual bean.md files in ai/beans/BEAN-NNN-<slug>/ |
| fast | Integer | No | Number of parallel workers. When provided, enables parallel mode via tmux. |
| category | String | No | Filter beans by category: App, Process, or Infra. Case-insensitive. When provided, only beans matching this category are processed. |
| tmux_session | Environment | No | $TMUX — required only when fast is provided |
0a. Ensure on main branch — Run git branch --show-current.
main: proceed.main branch. Current branch: <branch>. Please switch to main and retry." Then stop.
0b. Check mode — If fast input is provided, go to Parallel Mode (below). Otherwise, continue with sequential mode (Phase 1).0c. Import sprint backlog from Trello — Invoke /trello-load to pull any
cards from the Trello Sprint_Backlog list into the beans backlog. This runs
non-interactively (auto-selects board, creates beans with Approved status,
moves processed cards to In_Progress on Trello). If the Trello MCP server
is unavailable or Sprint_Backlog is empty, log the result and continue —
this step is best-effort and must not block the run.
ai/beans/_index.md to get all beans and their statuses.Approved. Exclude Done, Deferred, Unapproved, beans blocked by unfinished dependencies, and beans locked by another agent (status In Progress with a different Owner). If category is provided, further filter to only beans whose Category column matches (case-insensitive).bean.md to understand priority, scope, dependencies, and notes..claude/agents/team-lead.md). If a category filter is active, include it in the header: [Category: Process]. This is the first thing visible in the tmux pane.In Progress in bean.md. Update _index.md to set status to In Progress and owner to team-lead. (In sequential mode the orchestrator is also the worker, so both updates happen here.)bean/BEAN-NNN-<slug> (derived from the bean directory name)git checkout -b bean/BEAN-NNN-<slug>main.ai/beans/BEAN-NNN-<slug>/tasks/:
01-<owner>-<slug>.md, 02-<owner>-<slug>.md, etc.> Skipped: BA (default), Architect (default).bean.md with the created tasks.Preferred dispatch: /spawn-task. For each task in the bean's wave,
prefer dispatching with /spawn-task <task-file>. The command auto-detects
tmux and chooses a worktree-isolated worker (in tmux) or a fresh Agent-tool
subagent (not in tmux). The dispatched worker reads only the task's
Inputs: plus its persona context, preserving the supervisor pattern's
context isolation. See claude/skills/spawn-task/SKILL.md and ADR-008.
In-conversation role-switching (you reading the task and playing the persona yourself in this same window) remains a fallback for tiny tasks where dispatch overhead is not justified. Do not use it as the default.
Started timestamp (YYYY-MM-DD HH:MM) in the task file metadata when beginning execution./spawn-task (preferred) or read the task file and execute in-conversation as the assigned persona (fallback)./close-loop telemetry recording: record Completed timestamp, compute Duration, prompt for token self-report, and update the bean's Telemetry per-task table row.Done in the task file and the bean's task table.uv run pytest) and lint (uv run ruff check).Done in bean.md. (The orchestrator updates _index.md after the merge — see step 17.)BEAN-NNN: <bean title>. The commit goes on the bean/BEAN-NNN-<slug> branch./merge-bean skill to merge the feature branch into main:
main, pull latest, merge bean/BEAN-NNN-<slug> with --no-ff, push._index.md to set the bean's status to Done, commit the index update on main, and push.
17b. Move Trello card to Completed — After a successful merge, update the
source Trello card if one exists:
a. Check the bean's Notes section for a "Source: Trello card" reference.
b. If found, call mcp__trello__get_lists to find the In_Progress and
Completed lists (using the same flexible name matching as /trello-load).
c. Call mcp__trello__get_cards_by_list_id on the In_Progress list.
d. Find the card whose name matches the bean title or the card name from
the Notes reference (case-insensitive, flexible matching).
e. Call mcp__trello__move_card to move the card to the Completed list.
f. Log the move: Trello: Moved "[Card Name]" → Completed
g. If no matching card is found, or the Trello MCP is unavailable, log a
warning and continue — this is best-effort and must not block the run.main branch.All work merged to main. Then exit.When fast N is provided, the Team Lead orchestrates N parallel workers instead of processing beans sequentially.
main branch — Same check as Phase 0a above. Must be on main with a clean working tree. Otherwise stop.$TMUX environment variable is set.
/long-run --fast N." Then exit.1b. Import sprint backlog from Trello — Same as sequential Phase 0.5:
invoke /trello-load non-interactively. Best-effort; do not block on
failure.
_index.md, filter actionable beans with status Approved (skip Unapproved, locked beans owned by other agents). Apply category filter if provided.bean.md to understand dependencies._index.md to set status to In Progress and owner to team-lead. Commit this index update on main before spawning workers. (Workers will update their own bean.md independently; they must NOT touch _index.md.)/tmp/agentic-worker-BEAN-NNN.status with status: starting. This allows the dashboard to track the worker immediately. See the Status File Protocol section below for the full file format and status values.WORKTREE_DIR="/tmp/agentic-worktree-BEAN-NNN"
BRANCH_NAME="bean/BEAN-NNN-slug"
# Clean stale worktree from a prior run
git worktree remove --force "$WORKTREE_DIR" 2>/dev/null
# Create feature branch + worktree
if git show-ref --verify --quiet "refs/heads/${BRANCH_NAME}"; then
git worktree add "$WORKTREE_DIR" "$BRANCH_NAME"
else
git worktree add -b "$BRANCH_NAME" "$WORKTREE_DIR" main
fi
LAUNCHER=$(mktemp /tmp/agentic-bean-XXXXXX.sh)
cat > "$LAUNCHER" << 'SCRIPT_EOF'
#!/bin/bash
cd /tmp/agentic-worktree-BEAN-NNN
claude --dangerously-skip-permissions --agent team-lead \
"Process BEAN-NNN-slug through the assigned team wave.
You are running in an ISOLATED GIT WORKTREE. Your feature branch is already checked out.
- Do NOT create or checkout branches.
- Do NOT run /merge-bean — the orchestrator handles merging after you finish.
- Do NOT checkout main — the orchestrator handles merging after you finish.
- Do NOT edit _index.md — the orchestrator is the sole writer of the backlog index.
1. Update bean.md status to In Progress
2. Decompose into tasks
3. Execute the wave (Developer → Tech-QA default; include BA/Architect per activation criteria)
— COMMIT AFTER EACH TASK. Do not wait until the end. If you stall on task 3 of 4,
tasks 1-2 should already be committed and pushed.
4. Verify acceptance criteria
5. Update bean.md status to Done
6. Final commit and push on the feature branch
RELIABILITY RULES:
- COMMIT AND PUSH after completing each task, not just at the end.
- On unrecoverable error: commit any completed work, push, set status file to error with a clear message, then EXIT immediately. Do NOT retry indefinitely or spin in loops.
- If you have been running for more than 30 minutes, commit and push whatever is done, set status appropriately, and exit.
- Update the status file updated timestamp after every task completion as a heartbeat signal.
STATUS FILE PROTOCOL — You MUST update /tmp/agentic-worker-BEAN-NNN.status at every transition.
See the Status File Protocol section in this skill for full status file format and update rules."
SCRIPT_EOF
chmod +x "$LAUNCHER"
tmux new-window -n "bean-NNN" "bash $LAUNCHER; rm -f $LAUNCHER"
The prompt is passed as a positional argument to claude, so it auto-submits immediately. The window auto-closes when claude exits (no bare shell left behind). The launcher script self-deletes after use. No stagger delay needed — worktrees provide full isolation.The main window enters a persistent dashboard loop that monitors workers, merges completed beans, and spawns replacements until the backlog is exhausted. This is the mechanism that keeps assigning beans — it is not just a passive monitor. See /spawn-bean Step 4 for the full specification.
Every iteration of the loop performs these steps:
/tmp/agentic-worker-*.status files and parse key-value pairs. Cross-reference with tmux list-windows to detect closed windows.status: done (or whose tmux window has closed) that has not yet been merged:
a. Remove the worktree: git worktree remove --force /tmp/agentic-worktree-BEAN-NNN
b. Sync before merging: git fetch origin && git pull origin main
c. Merge the bean: run /merge-bean NNN from the main repo.
d. Update _index.md on main: set the bean's status to Done. Commit and push.
e. Move the Trello card to Completed (same logic as sequential step 17b). Best-effort; do not block on failure.
f. Mark this worker as merged in the orchestrator's tracking._index.md fresh (do NOT use a pre-computed queue — the backlog may have changed). For each merged worker slot with no replacement:
a. Find the next bean with status Approved that has no unmet inter-bean dependencies.
b. If found: update _index.md to mark it In Progress, commit and push on main, create a new worktree, write its status file, and spawn a new tmux window using the same launcher script pattern.
c. If no approved unblocked bean exists, leave the slot empty.blocked workers (🔴 with message and window switch shortcut). For stale workers (no status update for 10+ minutes): (a) kill the tmux window: tmux kill-window -t "bean-NNN", (b) remove the worktree: git worktree remove --force /tmp/agentic-worktree-BEAN-NNN, (c) update the status file to status: error, message: Killed by orchestrator (stale for 10+ minutes), (d) log the event. The bean stays In Progress for manual retry._index.md. If either condition is false, continue.The loop runs indefinitely until the backlog is exhausted. There is no maximum bean limit. To force-kill a stuck worker: tmux kill-window -t "bean-NNN", then git worktree remove --force /tmp/agentic-worktree-BEAN-NNN.
- To force-kill a stuck worker: tmux kill-window -t "bean-NNN", then git worktree remove --force /tmp/agentic-worktree-BEAN-NNN
All work merged to main.rm -f /tmp/agentic-worker-*.status. Run git worktree prune to clean up any stale worktree references.git fetch origin && git pull origin main (the orchestrator is already on main)./long-run has current refs when the user resumes work.Workers communicate progress back to the main window via status files in /tmp/. This enables the orchestrator's dashboard to display live state without polling the workers directly. The protocol is shared with /spawn-bean (which is a thin invocation wrapper that uses the same workers and the same files).
Each worker writes to: /tmp/agentic-worker-BEAN-NNN.status
For a single auto-pick worker (e.g., /spawn-bean with no args), the initial filename is /tmp/agentic-worker-auto-1.status. Once the worker picks a bean it renames the file to the real bean ID. When using pre-assigned beans (--fast N or /spawn-bean <ids> or --count N), all status files use the real bean ID from the start.
bean: BEAN-018
title: Library Indexer Service
tasks_total: 4
tasks_done: 2
current_task: 03-developer-implement
status: running
message:
worktree: /tmp/agentic-worktree-BEAN-018
updated: 2026-02-07T14:32:01
| Status | Meaning | Dashboard Color |
|--------|---------|-----------------|
| starting | Worker launched, claude initializing | ⚪ White/dim |
| decomposing | Breaking bean into tasks | 🔵 Blue |
| running | Executing tasks normally | 🟢 Green |
| blocked | Needs human input — see message field | 🔴 Red |
| error | Hit an unrecoverable error — see message | 🟠 Orange |
| done | Bean completed successfully | ✅ Done |
Workers must update their status file at each of these transitions:
status: decomposing, fill in bean, title.status: running, fill in tasks_total, tasks_done: 0, current_task.tasks_done, update current_task to the next task.status: blocked, write explanation in message.status: error, write error details in message.status: done, tasks_done equals tasks_total, clear current_task.Always update the updated timestamp when writing.
╔══════════════════════════════════════════════════════════════════╗
║ Bean Workers — 3 active 14:32:01 ║
╠══════════════════════════════════════════════════════════════════╣
║ ║
║ BEAN-018 Library Indexer Service ████████░░ 50% (2/4) ║
║ 🟢 Running — 03-developer-implement ║
║ ║
║ BEAN-019 Wizard Project Identity ██████████░ 75% (3/4) ║
║ 🟢 Running — 04-tech-qa-tests ║
║ ║
║ BEAN-020 Wizard Persona Selection ███░░░░░░░ 25% (1/4) ║
║ 🔴 FEEDBACK NEEDED — Need clarification on persona filter UX ║
║ → Switch to worker: Alt-3 ║
║ ║
╚══════════════════════════════════════════════════════════════════╝
⚠ 1 worker needs attention — see 🔴 above
Render with simple print() output and Unicode box-drawing characters. The progress bar uses █ (filled) and ░ (empty) with 10 segments. Color indicators use emoji since they render in all terminals.
When a worker has status: blocked:
message text.⚠ N worker(s) need attention.--wide) Mode for /spawn-beanWhen invoked via /spawn-bean --wide, all workers share a single tmux window as tiled panes (instead of separate windows):
# First worker creates the window
tmux new-window -n "workers" "bash $LAUNCHER_1; rm -f $LAUNCHER_1"
# Additional workers split into panes within that window
tmux split-window -t "workers" "bash $LAUNCHER_2; rm -f $LAUNCHER_2"
tmux split-window -t "workers" "bash $LAUNCHER_3; rm -f $LAUNCHER_3"
# Auto-arrange into an even grid
tmux select-layout -t "workers" tiled
The tiled layout automatically arranges panes into a grid: 2 = side-by-side, 4 = 2x2, 6 = 2x3, etc. Each pane auto-closes when its claude exits. To force-kill a pane: switch to the "workers" window, select the pane, and use the kill-pane shortcut. Then also remove the worktree.
The default (non---wide) mode gives each worker its own tmux window — easier to navigate one bean at a time, while --wide is ideal for monitoring all workers on a wide monitor.
| Output | Type | Description |
|--------|------|-------------|
| task_files | Markdown files | Task decompositions in each bean's tasks/ directory |
| persona_outputs | Various files | Work products in ai/outputs/<persona>/ |
| updated_beans | Markdown files | Bean status updated through lifecycle |
| updated_index | Markdown file | _index.md kept in sync with bean statuses |
| git_commits | Git commits | One commit per completed bean |
| progress_reports | Console text | Summary after each bean and at completion |
| Error | Cause | Resolution |
|-------|-------|------------|
| EmptyBacklog | No beans in _index.md | Report and exit cleanly |
| NoActionableBeans | All remaining beans are Done, Deferred, or blocked | Report status summary and exit |
| TaskFailure | A task cannot be completed | Report failure details, leave bean In Progress, stop loop |
| TestFailure | Tests or lint fail | Attempt to fix; if unresolvable, report and stop |
| CommitFailure | Git error during commit | Report error and stop for manual resolution |
| MergeConflict | Merge to main branch fails due to conflicts | Report conflicting files, abort merge, stop loop |
| NotInTmux | --fast used but $TMUX is not set | Instruct user to restart in tmux |
| WorkerFailure | A parallel worker fails on its bean | Report which worker/bean failed; other workers continue |
On error in sequential mode: the current bean stays In Progress and the loop stops. The user can inspect the state, fix the issue, and either re-run /long-run or manually complete the bean.
On error in parallel mode: a single worker failure does not stop other workers. The failed bean stays In Progress. The main window reports the failure and continues monitoring remaining workers.
ai/beans/_index.mdai/context/bean-workflow.mdai/beans/BEAN-NNN-<slug>/bean.md/trello-load sync and card completion; best-effort)/trello-load skill for sprint backlog importdevelopment
# Skill: VDD (Verification-Driven Development) Gate ## Description Runs the programmatic VDD gate for a bean: parses the bean's `## Acceptance Criteria` section, dispatches each criterion's evidence type to the matching runner (test, lint, file, file-contains, or manual), aggregates the results into a pass/fail verdict, and writes a structured markdown report at `ai/outputs/tech-qa/vdd-<NNN>.md` (zero-padded NNN). This is the machine-checkable counterpart to the prose VDD policy in `ai/contex
tools
# Skill: Spawn Task ## Description Dispatches a single specialist persona to execute a single task with only that task's context. Auto-detects the runtime environment and chooses one of two execution paths: - **In tmux** (`$TMUX` set): spawn a worker in a git worktree using a child tmux window. Process-isolated, parallelizable, durable across the calling session's lifetime. Same pattern as `/spawn-bean` but at task granularity. - **Not in tmux**: invoke the `Agent` tool with `subagent_typ
development
# Skill: Orchestration Report ## Description Aggregates the per-bean **Orchestration Telemetry** blocks (BEAN-278) across recent Done beans and produces a markdown report that answers the architecture-aware-evaluation question: **is the orchestration paying for itself?** Distinct from `/telemetry-report` (which aggregates raw cost, duration, and tokens); this skill aggregates the orchestration-quality metrics layered on top — bounces, persona activations, contract violations, escape-hatch usag
development
# Skill: Health Check ## Description Runs all health checks defined in `ai/context/health-checks.md` and produces a table-format report. Can be called standalone or by other skills (e.g., `/long-run`). ## Trigger - Invoked by the `/health-check` slash command. - Called programmatically by `/long-run` at the start of each cycle. ## Inputs | Input | Type | Required | Description | |-------|------|----------|-------------| | health_checks | Markdown file | Yes | `ai/context/health-checks.md`