beads-cleanup
Use when a Beads coordinator needs to reconcile stale worker state, PR-review bookkeeping, or orphaned worktrees before dispatching new work.
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- beads-cleanup
- metadata
- { "owner": "tze", "status": "active", "authors": [ "tze", "OpenAI Codex", "Claude Opus 5.5" ], "last_reviewed": "2026-10-27" }
- description
- Use when a Beads coordinator needs to reconcile stale worker state, PR-review bookkeeping, or orphaned worktrees before dispatching new work.
- compatibility
- Requires a Beads-backed git repository with `bd`, `git`, `gh`, `jq`, and git worktree support. Authenticated GitHub access is required for report-only PR reconciliation.
02 资源文件 7
- 参考文档agents/openai.yaml280 B
- 参考文档references/local-state-reconciliation.md4.3 KB
- 参考文档references/pr-review-reconciliation.md5.2 KB
- 参考文档references/reporting.md3.3 KB
- 脚本scripts/cleanup_scan.py50.3 KB
- 脚本tests/test_cleanup_scan.py89.3 KB
- 脚本tests/test_skill_package.py6.2 KB
03 SKILL.md 正文
Beads Cleanup
Run this skill before a beads-coordinator loop when stale worker state may
have been left behind by crashes, compaction, out-of-token exits, or missed
handoffs.
This skill is a read-only reconciliation pass. It reports Beads and Git evidence for the coordinator; it does not implement code, dispatch workers, or mutate lifecycle state.
Use This Skill When
- starting or resuming a
beads-coordinatorloop - recovering after a crashed coordinator or killed worker
- auditing stuck
in_progress,blocked,pr-review, orreview-runningstate - reporting orphaned coordinator worktrees or branches tied to Beads issues
- sizing build-artifact directories (
--artifact-root) whose bead is closed or whose PR merged, so the coordinator can reclaim disk
Do Not Use This Skill When
- implementing the assigned issue itself
- performing normal ready-work selection or worker dispatch
- creating new beads for discovered work
- repairing GitHub review threads inside an active PR review worker
Source Of Truth
This skill is a routing layer over the existing Beads operating model.
- Repository workflow and ownership model:
../../../../../README.md - Coordinator mutation authority, atomic claim, and stall-heartbeat rules:
../beads-coordinator/references/runtime-and-safety.md - Coordinator loop and PR-review lane behavior:
../beads-coordinator/references/coordinator-loop.md - PR-review worker closure boundary and review-lock vocabulary:
../beads-pr-reviewer-worker/SKILL.md
If these sources disagree with this skill, fix this skill. Do not let cleanup become a competing doctrine.
Non-Negotiable Boundaries
- Never implement code.
- The coordinator is the sole mutation authority. Cleanup never claims, releases, creates, closes, relabels, unblocks, removes a worktree, deletes a branch, or repairs Dolt. It reports evidence and recommendations only.
- Never mutate a bead held by a live actor. A holder is live when its bead
heartbeat is fresh or its assignee is a live registered coordinator (peers
sleeping between wakes let bead heartbeats lapse), per
../beads-coordinator/references/runtime-and-safety.md→ "Parallel Coordinators". Another coordinator's claims, worktrees, and PRs are not orphans while it is live. - Never mutate PR-review bead state from PR outcome. Cleanup inspects PR state and reports the finding plus a recommended action; the coordinator's Step 0 is the sole PR-state mutator.
- Never create new beads from cleanup. Missing wiring should be reported for the coordinator loop to self-heal.
- Never touch
.beads/dolt/manually. - Inspect token-efficiently (
../../references/token-efficiency.md): project everybd/ghlisting throughjqto the fields the pass needs, batch related checks into one composite command, and keep the final report to findings and recommendations — not raw command output.
Load Only The Reference You Need
references/local-state-reconciliation.mdLoad for stalein_progressclaims, dependency unblocking, Dolt/worktree health, and stalereview-runninglabels.references/pr-review-reconciliation.mdLoad for blocked originalpr-reviewbeads and blockedpr-review-taskreview beads.references/reporting.mdLoad for the cleanup report shape, rig-routing notes, command quick reference, and coordinator handoff summary.scripts/cleanup_scan.pyRun first for one compactbeads-cleanup-scan/v1read model covering claims, dependencies, Dolt, worktrees/branches, review locks, and nested PR findings. It is report-only: it has no apply mode and never replaces fresh verification before a coordinator-owned mutation.
Workflow
- Read
../beads-coordinator/references/runtime-and-safety.mdif you need the exact claim, stall-heartbeat, and mutation-authority rules before handing a finding to the coordinator. - From the cleanup package directory, run
uv run scripts/cleanup_scan.py --repo-root "${REPO_ROOT}"(plus one--artifact-root <dir>per artifact root the repo'sAGENTS.mdnames) to collect compact read-only findings. Treatpartialandfatalas manual-triage reports; do not forward command output or infer a mutation from them. - Use the relevant passes from the reference files to interpret the report. When evidence is incomplete or a bead is held by a live actor (fresh heartbeat), report manual triage. For PR-review beads, report findings only.
- Keep canonical PR metadata on the original implementation bead only; review
beads must not invent their own
external_ref. - Report worktrees and branches conservatively. Preserve anything that may still contain useful unpublished work.
- Produce the structured report from
references/reporting.mdso the coordinator has a clear evidence ledger before dispatch begins.
04 同仓库更多 Skills
user-run
Use when a step needs privileges this session lacks (docker, sudo, another user's checkout or secrets, host access) and the owner must run it as tze. Writes a reviewable /home/orca/.tmp/<slug>/run.sh that impersonates tze (USER_TO_IMPERSONATE overrides), tees timestamped logs plus latest.log and collects artifacts there; Claude presents it with a risk and time brief, then continues from the logs. Triggers: "I'll run it for you", "permission denied on docker.sock", "needs sudo", "sudo: a password is required", "run as tze", "/user-run".
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
receiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
executing-plans
Use when you have a written implementation plan to execute in a separate session with review checkpoints
dispatching-parallel-agents
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies