Skip to content
Agentmart
Submit a tool

clean

End-of-work cleanup sweep for a multi-agent repo — safely land genuine unpushed commits, squash open PRs, prune merged branches and worktrees, clean the…

Skill by thunter009

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/thunter009-clean

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

End-of-work cleanup sweep for a multi-agent repo — safely land genuine unpushed commits, squash open PRs, prune merged branches and worktrees, clean the remote dev box, and dedup session follow-ups. A /clean wrapper that orchestrates the squash-pr, prune-branches, devbox-cleanup, and followup-dedup skills.

Use cases: agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Shell scripts

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/clean

What's inside

Skill name
clean
Description
End-of-work cleanup sweep for a multi-agent repo — safely land genuine unpushed commits, squash open PRs, prune merged branches and worktrees, clean the remote dev box, and dedup session follow-ups. A /clean wrapper that orchestrates the squash-pr, prune-branches, devbox-cleanup, and followup-dedup skills.
License
MIT
Instructions
214 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts
  • Instructions read files in your home folder (~/.ssh, ~/.aws…)

Files (2)

  • SKILL.md
  • check-dirty-beads.sh · scripts/

SKILL.md (first lines)

# /clean — repo hygiene sweep

A five-phase end-of-work sweep. Each phase is a checkpoint: run it, report, move on.
`/clean` is the wrapper — the heavy lifting is delegated to focused skills.

## Before you start

- Identify the repo's integration branch (`dev` / `main`) from the contributor docs
  (CLAUDE.md, AGENTS.md).
- **Shared-checkout check.** Are other Claude sessions sharing this working tree? This
  changes Phase 1's path.

  ```bash
  pgrep -fa claude | awk '{print $1}' | sort -u | while read pid; do
    lsof -p "$pid" 2>/dev/null | awk '/cwd/{print $NF}' | grep -qx "$(pwd)" \
      && echo "sister Claude shares this checkout: PID $pid"
  done
  ```

  If sisters are present, never move a shared branch pointer and never run
  `checkout` / `reset` / `rebase` in the canonical checkout — do branch-mutating
  work in a `git worktree`.

- Register with Agent Mail if the repo uses it — mutating ops follow.

## Phase 0 — Bead state, in every repo this session touched

A `br close` reaches origin only if the resulting `.beads/issues.jsonl` change is both
committed and pushed. Two ways it silently is not (bd-1x5s, 3+ occurrences): it is never
committed — sitting in `git status` beside foreign modified files while closeout attention
goes to a different repo — or it is committed onto a local integration branch that has
diverged from its upstream and never leaves the machine.

```bash
bash ~/.claude/skills/clean/scripts/check-dirty-beads.sh <repo> [<repo> ...]
```

Pass every repo the session touched, not only the current one — the 2026-08-05 loss was in
the second repo. Non-zero exit names the repo and the reason. **Never `br close` and commit
onto a stale local `dev`** — close in a fresh worktree off the integration branch instead:

```bash
git worktree add .ntm/worktrees/close-beads -b chore/close-beads origin/dev
cd .ntm/worktrees/close-beads && br close <ids> && br sync --flush-only
git diff -- .beads/            # ONLY the intended beads
git add .beads/ && git commit -m 'chore(beads): close <ids>'
git push -u origin HEAD && gh pr create --base dev   # then merge
```

## Phase 1 — Land genuine unpushed work

The path depends on the shared-checkout check above.

### Single-agent repo (no sisters)

A dirty working tree IS unlanded work; an "ahead" branch IS your unpushed commits.
Stage, commit, and `git push`. Skip the classifier below — it is just friction here.

### Multi-agent shared checkout (sisters present)

Do **not** assume a dirty working tree or an "ahead" branch is unlanded work. A sister
may have already committed your "modification" and pushed it; your "ahead" commits may
be content-equivalent duplicates of commits already on `origin`. Classify first:

1. **Working-tree changes.** For each modified file, compare its blob to the integration
   branch on the remote:

   ```bash
   git fetch origin <branch> --quiet
   git hash-object <file>                  # working-tree blob
   git rev-parse origin/<branch>:<file>    # remote blob
   ```

   A file whose blob equals `origin/<branch>`'s is already shipped — a sister committed
   it. It is stale residue, not new work. Do not re-commit it.

2. **"Ahead" commits.** For each commit in `origin/<branch>..<branch>`, classify:
   - **Duplicate** — same `git patch-id` as a commit already on `origin`. Drop it.
   - **Already-shipped** — `git cherry origin/<branch> <commit>` prints a `-` prefix,
     meaning its patch-id matches one on the upstream. Drop it.
   - **Genuinely unpushed** — real work not on `origin`. Land it.

3. **Land genuine commits without disturbing a shared branch.** Create an isolated
   worktree at the remote tip, cherry-pick the genuine commits oldest-first, and
   fast-forward push. Never force-push a shared branch; never move the local branch
   pointer that sister sessions share:

   ```bash
   git worktree add --detach <tmp-worktree> origin/<branch>
   git -C <tmp-worktree> cherry-pick <genuine-commit> ...
   git -C <tmp-worktree> push origin HEAD:<branch>
   git worktree remove <tmp-worktree>
   ```

   Resolve `.beads/issues.jsonl` conflicts as positional only — keep both sides' beads,
   never drop a bead another commit added.

If there is genuinely nothing to land, say so and move on — do not manufacture a commit.

## Phase 2 — Squash open PRs

Invoke the **`squash-pr`** skill. It lists open PRs, presents them for triage, and
squash-merges the approved ones through GitHub's merge path. No open PRs → no-op; report
and continue.

## Phase 3 — Prune branches and worktrees

Two passes — remote first, then local. They use different tools because their skills do.

### Remote branches

Invoke the **`prune-branches`** skill. It cross-references GitHub PR state to find
merged and squash-merged branches on `origin`, categorizes the rest, and proposes an
explicit delete command for approval. `prune-branches` is remote-only — it does not
touch local refs.

### Local branches and worktrees

`prune-branches` does not handle these; inline the logic here. Enumerate candidates:

From thunter009/skills, MIT.

More from thunter009/skills

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Aug 19, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from thunter009

Cite this page

clean skill. Agent Mart. https://agentmart.dev/skills/thunter009-clean (last updated 2026-10-24)