Index of every page on this site: llms.txt
All skills
sandharbor avatar

/cleanup

@62fef7a
Run it yourself

Safely clean up the current worktree after verifying no unmerged work would be lost

Requires /merge
  • 1 file
  • 2.6 KB
  • Updated 7 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/sandharbor/meadow/cleanup

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈23 tokens for metadata: the name and description. ≈625 when used: this file.

Description uses 1.2% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈93 characters, or 1.2%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Clean Up Current Worktree

Safely remove the current worktree and its branch, but only after verifying that no work would be lost.

Step 1: Preflight checks

Run all of these. If any check fails, tell the user why and stop.

  1. Run git rev-parse --git-dir and confirm we are inside a worktree (the git-dir path will contain /worktrees/). If not, stop.
  2. Run git status --porcelain. If there is any output, stop — there are uncommitted changes.
  3. Record the current state for later steps:
    BRANCH=$(git branch --show-current)
    WORKTREE_PATH=$(git rev-parse --show-toplevel)
    MAIN_REPO=$(git rev-parse --path-format=absolute --git-common-dir | sed 's|/\.git$||')

Step 2: Determine if it is safe to delete

There are exactly two safe conditions. Check them in order:

Condition A: No work done — branch is identical to main

git diff main...HEAD --quiet
git rev-list main..HEAD --count   # must be 0

If both pass, the branch has no unique work. It is safe to delete.

Condition B: All work has been merged to main

git rev-list main..HEAD --count   # greater than 0 means there are commits
git branch --contains HEAD main   # if main appears, all commits are merged

If there are commits but main contains HEAD, everything is already merged. It is safe to delete.

Neither condition met

Tell the user:

This branch has commits that are not yet on main. Use /merge to merge first, or confirm you want to discard the work.

Do not delete anything. Stop here.

Step 3: Clean up

First, capture the worktree name for tmux cleanup:

WORKTREE_NAME=$(basename "$WORKTREE_PATH")

Kill any tmux sessions associated with this worktree:

# Kill the dev server session (format: meadow_dev_<worktree-name>)
tmux kill-session -t "meadow_dev_${WORKTREE_NAME}" 2>/dev/null || true

# Kill any other sessions containing the worktree name
tmux list-sessions -F '#{session_name}' 2>/dev/null | grep "$WORKTREE_NAME" | while read -r sess; do
  tmux kill-session -t "$sess" 2>/dev/null || true
done

Navigate out of the worktree, then remove it and the branch:

cd "$MAIN_REPO"
git worktree remove --force "$WORKTREE_PATH"
git branch -D "$BRANCH"
git worktree prune

Step 4: Summary

Print what was cleaned up:

  • Worktree path that was removed
  • Branch that was deleted
  • Tmux sessions that were killed (if any)
  • Which condition applied (no work done, or already merged to main)

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 62fef7a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 weeks ago.

Activeupdated 7 months ago

README badge

README badge for sandharbor/meadow/cleanup