agentleFS
palpenpalpen/claude-skills/teardown/SKILL.md

teardown

Skill0 starsChanged 7 months agoMITView on GitHub

Remove a feature clone after its work is merged. Verifies the branch was merged into main before deleting. Can target a specific clone or list all clones for selection. Use when asked to "teardown", "remove clone", "delete workspace", "clean up clone", or "prune workspaces".

  • Reads credentials
  • Deletes or force-pushes
  • Commits and pushes

6 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions6 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 6

    1. jakubkrehel/skills★ 12ksame name
    2. elvarofficial/teardown★ 538same name
    3. Scino/fstack★ 18same name
    4. mik2win/foureyes★ 2same name
    5. blueclover22/mw_agent_kit★ 1same name
    6. OlegTestov/prove-it-mini★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository10 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. 0 are common, 7 are distinctive, and 9 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run these in parallel:

    line 26
  2. Very specific:

    If it doesn't exist, try BASE_DIR/<base-repo-name>--<name> with common variations (with/without feat- prefix, etc.)

    line 38
  3. Distinctive:

    If still not found, list available clones and ask.

    line 39
  4. Very specific:

    If the target has no -- suffix (it's the base/main clone), refuse immediately: "Cannot teardown the base clone.

    line 52
  5. Very specific:

    If CURRENT_DIR matches the target path, refuse: "You're inside this clone.

    line 57
  6. Very specific:

    If gh is not available or returns nothing, fall back to git:

    line 69
  7. Very specific:

    Use AskUserQuestion to confirm.

    line 116
  8. Very specific:

    Delete the clone: rm -rf <target-clone-path>

    line 127
  9. Distinctive:

    Check if any remaining clone's AGENTS.md has a port table with a row for the deleted clone.

    line 131
  10. Very specific:

    If found, use AskUserQuestion: "Remove the row for --<name> from AGENTS.md?

    line 133
  11. Distinctive:

    If yes, edit the table in the appropriate clone.

    line 135
  12. Very specific:

    NEVER delete the base clone (the one without a -- suffix).

    line 152
  13. Distinctive:

    NEVER delete without explicit confirmation from the user.

    line 153
  14. Distinctive:

    NEVER delete if the user is inside the target clone.

    line 154
  15. Distinctive:

    Always check merge status before deleting — this is the primary safety check.

    line 156
  16. Very specific:

    If gh is not installed, fall back to git-only merge detection.

    line 158

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Teardown — Remove a Merged Clone

Safely remove a feature clone after its branch has been merged.

Steps

1. Orient — Identify the base repo

Run these in parallel:

  • git rev-parse --show-toplevel — repo root path
  • basename $(git rev-parse --show-toplevel) — directory name

Derive the base repo name by stripping any --<suffix> from the directory name. Set BASE_DIR to the parent directory of the repo root. Set CURRENT_DIR to the repo root.

2. Identify the target

If the user specified a clone name (e.g., /teardown backend):

  • Set target to BASE_DIR/<base-repo-name>--<name>
  • If it doesn't exist, try BASE_DIR/<base-repo-name>--<name> with common variations (with/without feat- prefix, etc.)
  • If still not found, list available clones and ask.

If no name specified:

  • List all sibling clones: ls -d BASE_DIR/<base-repo-name>--* 2>/dev/null
  • For each clone, gather in parallel: branch name, merge status, port, uncommitted changes
  • Present a numbered list and use AskUserQuestion to ask which to tear down (allow multiple selection)

3. Pre-flight checks

For each target clone, run these checks:

3a. Refuse to delete base clone

If the target has no -- suffix (it's the base/main clone), refuse immediately: "Cannot teardown the base clone. Only feature clones (--<name>) can be removed."

3b. Refuse if user is inside the target

If CURRENT_DIR matches the target path, refuse: "You're inside this clone. Open a different session first, then run /teardown."

3c. Check merge status

Try gh first (more reliable):

cd <target-clone>
BRANCH=$(git branch --show-current)
gh pr list --head "$BRANCH" --state merged --json number,title,url --limit 1

If gh is not available or returns nothing, fall back to git:

git fetch origin main
git branch -r --merged origin/main | grep "$BRANCH"

Classify as:

  • Merged — safe to delete
  • Open PR — warn, show PR URL
  • Unmerged, no PR — warn strongly

3d. Check for uncommitted work

cd <target-clone>
git status --porcelain
git log --oneline @{upstream}..HEAD 2>/dev/null  # unpushed commits

Report uncommitted changes and unpushed commits if any.

3e. Check dev server

PORT=$(grep '^PORT=' <target-clone>/.env.local <target-clone>/web/.env.local 2>/dev/null | head -1 | cut -d= -f2)
lsof -ti:$PORT 2>/dev/null

4. Confirm deletion

Present a clear summary:

Teardown: <base-repo-name>--<name>

  Branch:       feat/<name>
  Merge status: Merged (PR #42)
  Uncommitted:  none
  Unpushed:     none
  Dev server:   not running
  Port:         3005

  This will permanently delete <full-path>

  Proceed? (yes/no)

Use AskUserQuestion to confirm.

If the branch IS merged: Require "yes".

If the branch is NOT merged: Require the user to type the clone suffix name as confirmation: "This branch has NOT been merged. Type the clone name '<name>' to confirm deletion:"

5. Delete

  1. Kill any running dev server: kill $(lsof -ti:<port>) 2>/dev/null
  2. Optionally delete the remote branch (ask first): git push origin --delete feat/<name> 2>/dev/null
  3. Delete the clone: rm -rf <target-clone-path>

6. Update project docs (optional)

Check if any remaining clone's AGENTS.md has a port table with a row for the deleted clone.

If found, use AskUserQuestion: "Remove the row for --<name> from AGENTS.md? (y/n)"

If yes, edit the table in the appropriate clone.

7. Report

Torn down: <base-repo-name>--<name>
  Deleted: <full-path>
  Branch:  feat/<name> (remote branch deleted)
  Port <port> is now free.

  Remaining clones:
    --frontend-ui  feat/frontend-ui  port 3001
    --infra        feat/infra        port 3003

Rules

  • NEVER delete the base clone (the one without a -- suffix).
  • NEVER delete without explicit confirmation from the user.
  • NEVER delete if the user is inside the target clone.
  • For unmerged branches, require typing the clone name as confirmation (not just "yes").
  • Always check merge status before deleting — this is the primary safety check.
  • Offer to delete the remote branch but don't require it.
  • If gh is not installed, fall back to git-only merge detection.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.