rtk is a command-line proxy that filters and compresses output from development commands before it reaches an LLM's context. It is used with coding agents to reduce the tokens consumed by commands such as Git operations. The catalogue includes skills, commands, agents, and instructions for using rtk in agent workflows.
Borrowing it
Nothing to install: this file belongs to rtk-ai/rtk. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/rtk-ai/rtk/develop/.claude/commands/tech/remove-worktree.mdgit clone --depth 1 https://github.com/rtk-ai/rtkWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/rtk-ai/rtk/remove-worktree)<a href="https://agentmods.dev/commands/rtk-ai/rtk/remove-worktree"><img src="https://agentmods.dev/badge/commands/rtk-ai/rtk/remove-worktree.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00013 | $0.01115 |
| Opus 5 | $0.00006 | $0.00558 |
| Sonnet 5 | $0.00003 | $0.00223 |
| Haiku 4.5 | $0.00001 | $0.00112 |
Grade C, and why
remove-worktree scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Recursive force deletehighDestructive command
rm -rf with a variable or a broad path is one typo away from removing the wrong tree.
rm -rf "$WORKTREE_FULL_PATH" How it starts
The opening of the file, as written. The whole thing — 156 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Remove Worktree
Remove a specific worktree, cleaning up directory, git references, and optionally the branch.
Usage
/tech:remove-worktree feature/new-filter
/tech:remove-worktree fix/session-bug
Implementation
Execute this script with branch name from $ARGUMENTS:
#!/bin/bash
set -euo pipefail
BRANCH_NAME="$ARGUMENTS"
if [ -z "$BRANCH_NAME" ]; then
echo "❌ Usage: /tech:remove-worktree <branch-name>"
echo ""
echo "Example:"
echo " /tech:remove-worktree feature/new-filter"
exit 1
fi
echo "🔍 Checking worktree: $BRANCH_NAME"
echo ""
# Check if worktree exists in git
if ! git worktree list | grep -q "$BRANCH_NAME"; then
echo "❌ Worktree not found: $BRANCH_NAME"
echo ""
echo "Available worktrees:"
git worktree list
exit 1
fi
# Get worktree path from git
WORKTREE_FULL_PATH=$(git worktree list | grep "$BRANCH_NAME" | awk '{print $1}')
# Safety check: never remove main repo
if [ "$WORKTREE_FULL_PATH" = "$(pwd)" ]; then
echo "❌ Cannot remove main repository worktree"
exit 1
fi
# Safety check: never remove master or main
if [ "$BRANCH_NAME" = "master" ] || [ "$BRANCH_NAME" = "main" ]; then
echo "❌ Cannot remove $BRANCH_NAME (protected branch)"
exit 1
fi
echo "📂 Worktree path: $WORKTREE_FULL_PATH"
echo "🌿 Branch: $BRANCH_NAME"
echo ""
# Check if branch is merged
IS_MERGED=false
if git branch --merged master | grep -q "^[* ] ${BRANCH_NAME}$"; then
IS_MERGED=true
echo "✅ Branch is merged into master (safe to delete)"
else
echo "⚠️ Branch is NOT merged into master"
fi
echo ""
# Ask confirmation if not merged
if [ "$IS_MERGED" = false ]; then
echo "⚠️ This will DELETE unmerged work. Continue? [y/N]"
read -r confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo "Aborted."
exit 0
fi
fi
# Remove worktree
echo "🗑️ Removing worktree..."
if git worktree remove "$WORKTREE_FULL_PATH" 2>/dev/null; then
echo "✅ Worktree removed: $WORKTREE_FULL_PATH"
else
echo "⚠️ Git remove failed, forcing removal..."
rm -rf "$WORKTREE_FULL_PATH"
git worktree prune
echo "✅ Worktree forcefully removed"
fi
# Delete branch
echo ""
echo "🌿 Deleting branch..."
if [ "$IS_MERGED" = true ]; then
if git branch -d "$BRANCH_NAME" 2>/dev/null; then
echo "✅ Branch deleted (local): $BRANCH_NAME"
else
echo "⚠️ Local branch already deleted or not found"
fi
else
if git branch -D "$BRANCH_NAME" 2>/dev/null; then
echo "✅ Branch force-deleted (local): $BRANCH_NAME"
else
echo "⚠️ Local branch already deleted or not found"
fi
fi
# Delete remote branch (if exists)
echo ""
echo "🌐 Checking remote branch..."
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
echo "⚠️ Remote branch exists. Delete it? [y/N]"
read -r confirm_remote
if [ "$confirm_remote" = "y" ] || [ "$confirm_remote" = "Y" ]; then
if git push origin --delete "$BRANCH_NAME" --no-verify 2>/dev/null; then
echo "✅ Remote branch deleted: $BRANCH_NAME"
else
echo "❌ Failed to delete remote branch (may require permissions)"
fi
else
echo "⏭️ Skipped remote branch deletion"
fi
else
echo "ℹ️ No remote branch found"
fi
echo ""
echo "✅ Cleanup complete!"
echo ""
echo "📊 Remaining worktrees:"
git worktree list
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 156 lines · 13 tokens per session scan C 30827642947b
remove-worktree is a command published in the GitHub repository rtk-ai/rtk (79,139 stars, last pushed today), licensed Apache-2.0. It adds 13 tokens to every session and 1,115 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
worktree
Create a git worktree for isolated feature/fix work.
watch-ci
Spawn a background Haiku-backed subagent to watch CI for the current branch (or specified target). Provider-agnostic — the subagent inspects project signals to identify the CI system (GitHub Actions, GitLab CI, CircleCI, etc.) and picks the right CLI. Returns immediately; reports back when CI reaches a terminal state.
undo-commit
Soft-undo the last commit. Restores its changes as staged, leaves working tree intact. Refuses if HEAD is already pushed to a tracked remote.
changelog
View recent CHANGELOG entries.
pr
Open a pull request from the current branch with a generated title and summary.
session-report
Capture what changed this session and why, scoped to the current branch. Read by ship verbs when synthesizing the commit message; deleted after a successful commit.