Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add commands/madappgang/claude-code/worktreegit clone --depth 1 https://github.com/MadAppGang/claude-codeWrote 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/madappgang/claude-code/worktree)<a href="https://agentmods.dev/commands/madappgang/claude-code/worktree"><img src="https://agentmods.dev/badge/commands/madappgang/claude-code/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 | $0.00021 | $0.01770 |
| Opus 5 | $0.00010 | $0.00885 |
| Sonnet 5 | $0.00004 | $0.00354 |
| Haiku 4.5 | $0.00002 | $0.00177 |
Grade C, and why
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 yesterday.
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.
- NEVER use `rm -rf` on worktree directories How it starts
The opening of the file, as written. The whole thing — 256 lines — stays where its author put it; the contents beside it link to each section on GitHub.
<user_request> $ARGUMENTS </user_request>
Create a new worktree following the dev:worktree-lifecycle skill phases 1-5.
Steps:
1. If branch-name not provided, ask user for branch name
2. Use AskUserQuestion to ask for worktree directory (or use .worktrees/ default)
3. Execute Phase 1: Pre-flight Checks
- Verify git repository
- Check branch availability
- Check path availability
4. Execute Phase 2: Directory Selection (use provided or ask)
5. Execute Phase 3: Creation
- Verify .gitignore
- Create worktree with `git worktree add`
- Store original CWD
6. Execute Phase 4: Setup
- Detect stacks (nodejs, rust, golang, python, ruby)
- Install dependencies for each stack
- Run baseline tests
7. Execute Phase 5: Handoff
- Display worktree information
- Show path, branch, stacks, test results
8. Write worktree context marker for statusline persistence
- Get Claude Code session ID (if available from environment or session context)
- Write marker file to `~/.claude/.statusline-worktree-{SESSION_ID}`:
```json
{
"worktree_path": ".worktrees/{slug}",
"branch": "{branch-name}",
"worktree_name": "{slug}"
}
```
- This marker survives context compaction and ensures the statusline
continues showing worktree info after long-running operations
Output format:
```
Worktree created successfully!
Path: .worktrees/{slug}
Branch: {branch-name}
Stacks: {detected-stacks}
Tests: {passing} passing, {failing} failing
To work in this worktree:
cd .worktrees/{slug}
To clean up later:
/dev:worktree cleanup .worktrees/{slug}
```
Show all active worktrees in this repository.
Steps:
1. Run `git worktree list --porcelain`
2. Parse output to extract:
- Worktree path
- Branch name
- HEAD commit
- Locked status
3. Format as table:
```
Active Worktrees:
Path Branch Commit
────────────────────────────────────────────────────────────
/path/to/project main abc1234
/path/to/.worktrees/feature feature/auth def5678
/path/to/.worktrees/hotfix hotfix/login ghi9012
```
If no worktrees besides main:
```
No additional worktrees found.
Only main worktree is active.
Create a worktree with: /dev:worktree create [branch-name]
```
Remove a worktree following dev:worktree-lifecycle Phase 6.
Steps:
1. If path not provided, list available worktrees and ask which to clean up
2. Execute Phase 6 cleanup:
- Return to original CWD if currently in worktree
- Check for uncommitted changes
- If uncommitted changes:
Use AskUserQuestion:
question: "Uncommitted changes found. How to proceed?"
options:
- Commit now
- Stash changes
- Discard changes
- Abort cleanup
- Remove worktree with `git worktree remove`
- Remove statusline worktree marker: `rm -f ~/.claude/.statusline-worktree-*`
(clean all markers for this project to avoid stale files)
- Optionally delete branch (only if merged)
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.
- yesterday First seen · 256 lines · 21 tokens per session scan C 310488fb6600
worktree is a command published in the GitHub repository MadAppGang/claude-code (279 stars, last pushed 5mo ago), licensed MIT. It adds 21 tokens to every session and 1,770 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-09-03.
Other commands, from other repositories
checklist
Generate a custom checklist for the current feature based on user requirements.
clarify
Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec.
specify
Create or update the feature specification from a natural language feature description.
analyze
Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation.
converge
Assess the current codebase against the feature's spec, plan, and tasks, then append any remaining unbuilt work as new tasks to tasks.md so implement can complete it.
implement
Execute the implementation plan by processing and executing all tasks defined in tasks.md.