cleanup
Clean up after completed or abandoned orc sessions — removes workspace state, registry entry, git worktree, and optionally the merged branch. Destructive; always previews and asks first. Workspace-aware.
- License 许可
- MIT
- 所属仓库
- HigorAlves/orc
- 最近更新
- 2026-11-07
- Stars
- ★ 7
- Forks
- 0
01 前言 Front Matter
- name
- cleanup
- description
- Clean up after completed or abandoned orc sessions — removes workspace state, registry entry, git worktree, and optionally the merged branch. Destructive; always previews and asks first. Workspace-aware.
- allowed-tools
- [ "Bash(orc-state:*)", "Read", "Write", "Edit", "Glob", "Grep", "the available user-question tool (or ask in chat)", "Bash(git worktree:*)", "Bash(git branch:*)", "Bash(git rev-parse:*)", "Bash(git status:*)", "Bash(git log:*)", "Bash(gh pr view:*)", "Bash(rm -rf .orc:*)", "Bash(jq:*)", "Bash(orc-workspace-detect:*)", "Bash(orc-docker-env:*)", "Bash(docker compose:*)", "Bash(kill:*)", "Bash(ps:*)" ]
- argument-hint
- [--auto[=guided|full]] [--dry-run] [--all-completed] [--per-repo] [--down-volumes] [<session-id-or-branch>]
- disable-model-invocation
- true
02 资源文件 7
- 参考文档references/PHASE-1-GUARD.md506 B
- 参考文档references/PHASE-2-REGISTRY.md399 B
- 参考文档references/PHASE-3-CANDIDATES.md825 B
- 参考文档references/PHASE-4-INSPECT.md2.5 KB
- 参考文档references/PHASE-5-PLAN.md2.3 KB
- 参考文档references/PHASE-6-APPLY.md2.8 KB
- 参考文档references/PHASE-7-REPORT.md671 B
03 SKILL.md 正文
$orc-cleanup
Close the loop on finished orc work: remove the workspace state, the worktree and, when safe, the local feature branch.
Arguments
--auto[=guided|full]— autopilot level for this run; overridesinteraction_policy. Ladder and hard-outward exemption:orc-gates§6.<session-id-or-branch>— optional. Clean exactly one session, bysessionId(orc-state sessions, schemaorc-state-protocol) or branch name, sanitized or raw.--all-completed— clean every session whosestatusiscompletedorabandoned. Every safety check still applies per session.--dry-run— print what would happen; change nothing. Recommended for the first run.--per-repo— workspace mode: clean each linked repo as its PR merges. Use only when abandoning some repos (rare).--down-volumes— also remove a torn-down environment's named volumes. Default keeps them: the next boot reuses DB data.
NOTE: at guided or full, the standard plan (state dir, clean worktree, merged branch) auto-applies after printing. Anomalies still gate at every level: partial workspace merges, unmerged branches, a dirty worktree.
Preconditions
🛑 Destructive run
P6 removes state directories, worktrees and local branches. The P5 preview gate is mandatory;
--dry-runnever applies.
- Running from inside a candidate worktree stops the run in P1:
cdto the main repo first. - In workspace mode, an open linked PR refuses the run unless
--per-repoor the session isabandoned. - Typical moments: a shipped PR merged;
$orc-statusshows stalecompletedsessions; an abandoned feature (mark the sessionabandonedfirst).
Phases
Modules live beside this file under references/ (ADR 0008 pilot). Entering a phase, Read exactly its module, per the orc-phases protocol.
| Phase | Module | Skipped when |
|---|---|---|
| 0 Detect context | resident, below | never |
| 1 Guard: not inside a candidate | orc-cleanup/P1 |
never |
| 2 Read the registry | orc-cleanup/P2 |
never |
| 3 Build the candidate list | orc-cleanup/P3 |
never |
| 4 Inspect each candidate | orc-cleanup/P4 |
never |
| 5 Preview the plan, then confirm | orc-cleanup/P5 |
never; --dry-run stops here |
| 6 Apply with safety gates | orc-cleanup/P6 |
--dry-run, Cancel |
| 7 Report | orc-cleanup/P7 |
--dry-run |
Phase 0 — Detect context
Run orc-workspace-detect --banner in the working repository and read its output before continuing.
- Read the banner above; it exports
ORC_*vars. Do not re-run detection. - In workspace mode, note the registry for P2:
${ORC_STATE_DIR}/orc.json. - In workspace mode, before P4, fetch the merge state of each candidate's linked PRs.
- If any linked PR is not
MERGED, refuse and list the open PRs.
for url in $(jq -r '.sessions[] | select(.sessionId == "'$ID'") | .linkedPRs[].url' "$ORC_STATE_DIR/orc.json"); do
gh pr view "$url" --json state -q .state
done
NOTE: workspace sessions carry scope: "workspace" and a repos array. After a refusal the user either waits, passes --per-repo to clean only the merged repos, or marks the session abandoned to bypass the merge check.
Iron rules
- Never pass
--forcetogit worktree remove. A dirty worktree holds user work: skip it and say so. - Never run
git branch -D. Only-d, which refuses unmerged branches. The user runs-Dby hand. - Never delete while running from inside a candidate. Refuse and name where to
cd. .orc/orc.jsonupdates are atomic: Read, modify in memory, Write the whole file. Never partial.--dry-runalways prints the plan and exits, even after a confirming answer in the gate.- A stack member at position N is deletable only when positions 1..N-1 are all
MERGED.--per-repobypasses, with consent. - Never
docker compose downa project without theorc-prefix. Orphans appear in the preview; the user opts into each one. - Named volumes survive by default; only
--down-volumesremoves them. DB data is user work.
Output
.orc/orc.jsonwith the cleaned entries removed..orc/<branch>/directories removed.- Worktrees removed where clean; local branches deleted where merged.
- A plain fenced summary (P7) with everything left undone and why.
04 同仓库更多 Skills
writing-plans
Write a comprehensive implementation plan of bite-sized TDD tasks that an engineer with zero codebase context could execute — exact files, code, tests, and verification steps
writing-for-agents
orc's doctrine layer for writing any document an agent consumes — skills, AGENTS.md/CLAUDE.md, reference docs
workspace-mode
Use when cwd is a parent dir holding multiple sibling git repos — defines repo auto-detection, --repos/--repo/--all-repos/--this-repo precedence, per-repo dispatch, and linked-PR mechanics.
wizard
Generate an interactive bash wizard walking a human through work only they can perform — credentials, secrets, one-off migrations
wait-what
Stop and re-pitch — the last message did not land; say it again simply, in the project's own vocabulary.
vitest
Vitest fast unit testing framework powered by Vite with Jest-compatible API