worktree

A Git worktree manager for creating separate working folders and branches from the same repository.

In plain words
What is it for?
Use it to prepare the experiment area, create and remove auto-improvement worktrees, and merge winning experiment branches into the main branch.
Why use it?
It protects the main working folder while experiments are run and makes it easier to clean up failed attempts or merge successful ones.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/benmarte/autoimprove/worktree
Any agent
npx skills add benmarte/autoimprove --skill worktree
Clone the repo
git clone --depth 1 https://github.com/benmarte/autoimprove

Made for: Claude Code, Codex.

Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,118 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00039 $0.01118
Opus 5 $0.00019 $0.00559
Sonnet 5 $0.00008 $0.00224
Haiku 4.5 $0.00004 $0.00112

Measured 2d ago against content hash 07ba682ec06b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade D, and why

worktree scanned grade D with 2 findings 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 2d 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

grep -q ".claude/autoimprove/worktrees" .gitignore 2>/dev/null || echo ".claude/autoimprove/worktrees" >> .gitignore

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf .claude/autoimprove/worktrees
skills/worktree/SKILL.md · 159 lines

How it starts

The opening of the file, as written. The whole thing — 159 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Worktree Management Skill

Every autoimprove experiment runs in an isolated git worktree — a separate directory linked to the same repo but on its own branch. The main working directory is never modified. Only winning experiments get merged back.

your-project/          ← main worktree (never touched during experiments)
.claude/autoimprove/worktrees/       ← experiment worktrees live here
  experiment-001/      ← branch: autoimprove/experiment-001
  experiment-002/      ← branch: autoimprove/experiment-002

Setup worktree environment

Run once before the first experiment in a session:

# 1. Make sure we're on a clean main branch
git status
git branch --show-current

# 2. Create the worktree container directory (gitignored)
mkdir -p .claude/autoimprove/worktrees

# 3. Add it to .gitignore if not already there
grep -q ".claude/autoimprove/worktrees" .gitignore 2>/dev/null || echo ".claude/autoimprove/worktrees" >> .gitignore

# 4. Record the base commit so all experiments branch from the same point
BASE_COMMIT=$(git rev-parse HEAD)
echo "Base commit: $BASE_COMMIT"

Create a new experiment worktree

Run at the start of each iteration:

EXPERIMENT_ID=$(printf "%03d" $ITERATION_NUMBER)
BRANCH="autoimprove/experiment-$EXPERIMENT_ID"
WORKTREE_PATH=".claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID"

# Create a new branch and worktree from current HEAD
git worktree add -b "$BRANCH" "$WORKTREE_PATH"

echo "Created worktree: $WORKTREE_PATH"
echo "Branch: $BRANCH"

Now switch all subsequent file edits and commands to run inside $WORKTREE_PATH. The main directory is untouched.


Run measurement in a worktree

All measurement commands must be run from inside the worktree path:

cd .claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID

# Run the measurement suite from .claude/autoimprove/config.md
# (same commands, different working directory)

Winning experiment — merge back to main

If AFTER score > BEFORE score:

Read the full file on GitHub · 159 lines

Changes

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.

  1. 2d ago First seen · 159 lines · 39 tokens per session scan D 07ba682ec06b

Subscribe to this mod's changes

worktree is a skill published in the GitHub repository benmarte/autoimprove (5 stars, last pushed 5mo ago), licensed MIT. It adds 39 tokens to every session and 1,118 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it D with 2 findings (reads agent configuration directories, recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

srt-whiteboard-animation

将 SRT 字幕做成暖米黄纸张底的白板手绘动画:读字幕→输出配图策略→确认后生成统一风格线稿→按叙事语义标注分区→预览台调整→渲染 MP4。编排沿用分区遮罩揭示(annotation.json / sequence / startMs / protectedRegions),但每个区域内的落墨换成 stream 的连续笔迹(骨架/网格 ink→color)。当用户提供 SRT 字幕并要求"字幕做成白板手绘/流式笔迹视频""SRT 生成白板动画""按字幕分镜画手绘"时触发。.

geeklee/srt-whiteboard-animation · 156 tokens

user-research-cookiy

End-to-end user research assistant — qualitative and quantitative. Use this skill whenever the user mentions user research, user interviews, discussion guides, interview guides, research plans, qualitative research, quantitative research, user surveys, survey design, usability studies, participant recruitment…

cookiy-ai/user-research-skill · 154 tokens

seo

Deterministic LLM-first SEO audits for websites, blog posts, and GitHub repositories. Use this when the user asks to "perform SEO analysis", "run SEO audit", "analyze SEO", "check technical SEO", "review schema", "Core Web Vitals", "E-E-A-T", "hreflang", "GEO", "AEO", or GitHub repository SEO optimization. For…

Bhanunamikaze/Agentic-SEO-Skill · 105 tokens

playwright-best-practices

Use when writing Playwright tests, fixing flaky tests, debugging failures, implementing Page Object Model, configuring CI/CD, optimizing performance, mocking APIs, handling authentication or OAuth, testing accessibility (axe-core), file uploads/downloads, date/time mocking, WebSockets, geolocation, permissions…

currents-dev/playwright-best-practices-skill · 214 tokens

open-map-stack

Use textual agent instructions for GIS and geospatial work: source discovery and provenance, vector/raster/point-cloud pipelines, CRS and metric analysis, spatial SQL, routing and isochrones, QGIS projects, tile generation, and web maps. Use advanced tools and formats such as OSM, Overture, STAC, Sentinel/Landsat…

jaakla/openmapstack · 169 tokens

globalpercent

GlobalPercent — build a global-macro-probability panel for an investment research system. Merges public probability data from prediction markets (Polymarket + Kalshi), classifies every market into macro modules (monetary policy / macro economy / AI / etc.), and shows the whole market's expected-probability state at a…

simonlin1212/globalpercent · 134 tokens