worktree-story
Skill0 starsChanged 36 days agoMITView on GitHub
Create an isolated git worktree and branch for the current task before changing any files. Use at the start of implementation work in a git repository, features, fixes, refactors, especially when the main checkout must stay clean or other work may run in parallel. Not needed for read-only tasks.
- Reads credentials
In this repository2 other files it gives its agents.
- pr-per-storySkill
- spec-firstSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Before changing anything, move the work into a dedicated git worktree on its own branch.
- Distinctive: line 19
If the main checkout has uncommitted changes, do not drag them into the feature, tell the user and ask how to proceed.
- Distinctive: line 40
Run git worktree list, then either continue there or choose a new branch name.
- Very specific: line 58
If git worktree remove refuses because of modified files, show the user what is dirty instead of reaching for --force.
- Distinctive: line 75
Never modify files, commit, or switch branches in the main checkout while a feature worktree exists for this task.
- Very specific: line 77
Never use --force variants of worktree or branch commands to bypass an error you have not explained to the user.
- Distinctive: line 79
Never delete a worktree or branch containing unmerged work without explicit confirmation.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Worktree Per Feature (User Story): One Task, One Isolated Checkout
Before changing anything, move the work into a dedicated git worktree on its own branch. The main checkout stays untouched, and parallel work stays possible.
Workflow
Confirm the repo and check its state.
git rev-parse --show-toplevel git status --porcelainIf the main checkout has uncommitted changes, do not drag them into the feature, tell the user and ask how to proceed.
- Name the branch after the feature:
feature/<slug>(e.g.feature/rate-limit-login). If a spec exists (see the spec-first skill), reuse its slug so branch, spec, and PR line up. Create the worktree as a sibling folder, never nested inside the repo:
git worktree add ../<repo-name>-<slug> -b feature/<slug>Example, repo
shop, featurerate-limit-login:git worktree add ../shop-rate-limit-login -b feature/rate-limit-login- Handle errors, never force through them.
- "branch already exists": attach to it without
-b:git worktree add ../<dir> feature/<slug>, or pick a new slug if that branch belongs to other work. Never-B(force-reset) an existing branch. - "already checked out in another worktree": that feature is live elsewhere.
Run
git worktree list, then either continue there or choose a new branch name. - Target directory already exists: choose another path. Never delete a directory you did not create.
- "branch already exists": attach to it without
- Work only inside the worktree.
cdinto it and stay there: every edit, build, and test run happens under the worktree path. Commit to the feature branch as you go. The main checkout is read-only for you from now on. - Report the path. Tell the user the absolute worktree path and branch name as soon as they exist, and repeat both in your final summary.
Cleanup (after the branch is merged, not before)
git worktree remove ../<repo-name>-<slug>
git branch -d feature/<slug> # -d refuses unmerged work; that is the point
git worktree pruneIf git worktree remove refuses because of modified files, show the user
what is dirty instead of reaching for --force.
Edge cases
- Not a git repo: say so and ask whether to
git initor proceed without isolation, never pretend the isolation exists. - Dependencies do not follow:
node_modules, virtualenvs, and ignored.env*files are not copied into a new worktree. Re-run the installer (npm install,uv sync, ...) and copy env files only with the user's consent. - Shared state is still shared: databases, dev-server ports, and global caches are not isolated between worktrees. Flag collisions (two servers on one port) instead of silently debugging them.
Boundaries
- Never modify files, commit, or switch branches in the main checkout while a feature worktree exists for this task.
- Never use
--forcevariants of worktree or branch commands to bypass an error you have not explained to the user. - Never delete a worktree or branch containing unmerged work without explicit confirmation.
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
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.

