How this command is triggered — by the user, by Claude, or both
Slash command
/on-loop:on-loop-clearThe summary Claude sees in its command listing — used to decide when to auto-load this command
# /on-loop:clear Clean up on-loop worktrees and optionally session logs, then return to a clean main branch state. ## Usage ## What This Does 1. Merges associated PRs (blocks if any PR is not mergeable) 2. Removes all on-loop git worktrees 3. Optionally deletes `.on-loop/` session logs (with `--include-logs`) 4. Switches to `main` (or `master` if `main` doesn't exist) 5. Pulls the latest changes from origin ## Instructions When this command is invoked: 1. **Merge associated PRs before cleanup**: - Read `.on-loop/index.json` (if it exists) - For each session with `status: "act...
Clean up on-loop worktrees and optionally session logs, then return to a clean main branch state.
/on-loop:clear # Clean worktrees only, keep session logs
/on-loop:clear --include-logs # Also delete session logs
.on-loop/ session logs (with --include-logs)main (or master if main doesn't exist)When this command is invoked:
Merge associated PRs before cleanup:
.on-loop/index.json (if it exists)status: "active" or status: "complete" that has a pr_url:
gh pr view <number> --json mergeable,mergeStateStatus,state,title,statusCheckRollup
"MERGED" — already merged, continue with cleanup"CLOSED" — skip (already closed), continue with cleanupmergeable is "MERGEABLE" and all status checks have passed — merge:
gh pr merge <number> --merge --delete-branch
mergeable is "CONFLICTING" / "UNKNOWN"):
Cannot clear: PR #<number> (<title>) is not mergeable.
Reason: <merge state status / failing checks>
Resolve the PR before running /on-loop:clear, or close it manually with:
gh pr close <number>
pr_url that have status: "active", warn the user:
Session <session-name> has no PR. It will be marked as failed during cleanup.
List and remove on-loop worktrees:
git worktree list
.claude/worktrees/git worktree remove .claude/worktrees/<slug> --force
rm -rf .claude/worktrees/
Update session index: If .on-loop/index.json exists, update any "active" sessions to "failed" (they were abandoned by the clear)
Delete session logs (only if --include-logs is passed):
rm -rf .on-loop/
Determine default branch: Check if main or master is the default branch
git rev-parse --verify main 2>/dev/null && echo main || echo master
Switch to default branch:
git checkout <default-branch>
Pull latest:
git pull origin <default-branch>
Confirm to user: Report:
git pull fails (e.g., no remote), warn but don't fail — the cleanup is still successful.npx claudepluginhub joestein/on-loop --plugin on-loop