git-worktrees
Skill9 starsChanged 7 months agoMITView on GitHub
Creates isolated git worktrees for feature development with safety verification. USE WHEN starting feature work, creating feature branch, isolating development, OR before implementing from plan. Safety: MUST verify project-local dirs (node_modules/, .venv/, etc.) are gitignored before creating worktree. Runs project setup and baseline tests.
- Reads credentials
- Deletes or force-pushes
- Installs packages
12 other projects use a version of this.
Adopted by
Most recently taken up by
- choegyumin/agent-skillstheir own version, first seen Sep 19, 2026
- nafeeur/MaskShifttheir own version, first seen Sep 12, 2026
- KhaledSaeed18/dotclaudetheir own version, first seen Jul 4, 2026
- tomimor/skillstheir own version, first seen Jun 26, 2026
- itallstartedwithaidea/claude-googleadsagenttheir own version, first seen May 21, 2026
- sergeeey/Claude-cod-top-2026their own version, first seen May 13, 2026
Used with
Projects with it also use data-analysis, context-engineering and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
shanggqmSkilldata-analysis
数据分析技能,提供结构化的数据查询、统计分析和报告生成工作流。当用户需要查询数据库、进行数据统计分析、生成分析报告时使用。按规范输出原始数据、计算结果、Markdown报告和HTML可视化报告。
Also in 4 projects that use this
mrgoonieSkillcontext-engineering
Master context engineering for AI agent systems. Use when designing agent architectures, debugging context failures, optimizing token usage, implementing memory systems, building multi-agent coordination, evaluating agent performance, or developing LLM-powered pipelines. Covers context fundamentals, degradation patterns, optimization techniques (compaction, masking, caching), compression strategies, memory architectures, multi-agent patterns, LLM-as-Judge evaluation, tool design, and project development.
Also in 4 projects that use this
ElasticSkillcreate-skill
Interactively create a new Claude Code skill and add it to the elastic-docs-skills catalog. Use when the user wants to generate a new skill, scaffold a slash command, or build automation for docs tasks.
Also in 3 projects that use this
AWSSkillgrill-me
A relentless interview to sharpen a plan or design.
Also in 3 projects that use this
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- NeoLabHQ/context-engineering-kit★ 1.7ksame name
- xenitV1/claude-code-maestro★ 229same name
- jamesrochabrun/skills★ 214same name
- itallstartedwithaidea/agent-skills★ 39same name
- sergeeey/Claude-cod-top-2026★ 9same name
- KhaledSaeed18/dotclaude★ 5same name
- vikisingh23/neuraforge-ai★ 4same name
- itallstartedwithaidea/claude-googleadsagent★ 2same name
- nafeeur/MaskShift★ 2same name
- tomimor/skills★ 2same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository140 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- alex-hormozi-pitchSkill
- AlgorithmSkill
- AnnualReportsSkill
- ArtGeneratorSkill
- artSkill
- autoplanSkill
- autoresearchSkill
- benchmarkSkill
- brainstormingSkill
- brand-guidelinesSkill
- brightdataSkill
- browseSkill
- BugHunterSkill
- CallIntelligenceSkill
- canarySkill
- canvasSkill
- carefulSkill
- ceo-advisorSkill
- cfo-advisorSkill
- cmmcSkill
- codebase-indexerSkill
- codexSkill
- CodingAgentSkill
- company-valuesSkill
- connect-chromeSkill
- CORESkill
- system-createcliSkill
- CreateskillSkill
- csoSkill
- cto-advisorSkill
- CybersecurityPlaybooksSkill
- defuddleSkill
- design-consultationSkill
- design-reviewSkill
- DevTeamSkill
- DiscordAdminSkill
- document-releaseSkill
- document-writerSkill
- doraSkill
- dpdpaSkill
- EmailManagerSkill
- executing-plansSkill
- fabricSkill
- fedrampSkill
- ffuf-web-fuzzingSkill
- find-communitySkill
- first-customersSkill
- FirstPrinciplesSkill
- form-croSkill
- freezeSkill
- gdpr-complianceSkill
- GovernanceSkill
- grow-sustainablySkill
- gstack-upgradeSkill
- guardSkill
- hipaa-complianceSkill
- investigateSkill
- iso27001Skill
- iso27701Skill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 12 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Before executing implementation plans → Clean environment
- Distinctive: line 25
Before starting complex feature → Risk isolation
- Distinctive: line 42
If not ignored, these directories would be tracked by git and shared across worktrees, causing:
- Distinctive: line 57
If tests fail in new worktree, something's wrong with setup.
- Distinctive: line 95
Before creating worktree, verify these directories are gitignored:
- Distinctive: line 421
Create worktree before executing implementation plan.
- Distinctive: line 427
Create worktree before implementing brainstormed design.
- Distinctive: line 436
Before creating worktree, verify:
- Distinctive: line 445
If anything NOT ignored that should be:
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Worktrees
Creates isolated git worktree directories for feature development with automatic safety verification and project setup.
🎯 Load Full CORE Context
read ${PAI_DIR}/skills/CORE/SKILL.mdWhen to Activate This Skill
- "create worktree for feature X" → Isolated feature development
- "set up feature branch" → Before implementation
- "isolate this work" → Separate from main codebase
- Before executing implementation plans → Clean environment
- Before starting complex feature → Risk isolation
Core Philosophy
Isolation Prevents Accidents
Git worktrees create completely separate working directories that:
- Share git history (efficient)
- Have independent branches
- Can't accidentally commit to main
- Enable parallel development
- Simplify cleanup (delete directory = gone)
Safety First: Verify Gitignore
Project-local directories (node_modules/, .venv/, dist/, target/) MUST be gitignored before creating worktrees.
If not ignored, these directories would be tracked by git and shared across worktrees, causing:
- Dependency conflicts
- Build artifacts corruption
- Lock file collisions
- Massive git repository size
CRITICAL: Always verify and fix .gitignore before creating worktree.
Clean Baseline: Setup and Test
New worktree should start with:
- Project dependencies installed
- Project built/compiled if needed
- Tests passing (clean baseline)
If tests fail in new worktree, something's wrong with setup. Fix before implementation.
The Process
Step 1: Directory Selection
Priority order for worktree location:
- Project has
.worktrees/directory → Use it - Project has
worktrees/directory → Use it - CLAUDE.md specifies preference → Follow it
- Ask user where to create
Example:
## Worktree Location
Checking for standard worktree directories...
- `.worktrees/`: Not found
- `worktrees/`: Not found
- CLAUDE.md preference: Not specified
Where should I create the worktree?
Options:
1. `.worktrees/feature-name` (recommended - gitignored by default)
2. `../feature-name` (sibling directory)
3. Specify custom path
What's your preference?Step 2: Safety Verification
CRITICAL: Check .gitignore for project-local directories
Before creating worktree, verify these directories are gitignored:
Node.js/JavaScript:
node_modules/dist/,build/.next/,.nuxt/,.output/
Python:
.venv/,venv/,env/__pycache__/,*.pyc.pytest_cache/,.mypy_cache/
Rust:
target/Cargo.lock(if library)
Go:
vendor/(if using)
General:
.env(secrets)*.log(logs)
Verification Process:
# Check .gitignore
cat .gitignore
# If missing critical entries, CHECK THREE TIMES:
# 1. Are these directories actually local to project?
# 2. Should they be ignored?
# 3. Am I 100% certain?If project-local directories NOT ignored:
⚠️ SAFETY CHECK FAILED
.gitignore is missing critical entries:
Missing:
- node_modules/ (Node.js dependencies)
- dist/ (Build output)
These MUST be gitignored before creating worktree.
Shall I:
1. Add these to .gitignore and commit
2. You'll update .gitignore manually
3. Skip (DANGEROUS - not recommended)
Waiting for confirmation.If adding to .gitignore:
# Add missing entries
cat >> .gitignore << 'EOF'
# Project-local directories (must be ignored for worktrees)
node_modules/
dist/
build/
EOF
# Commit the change
git add .gitignore
git commit -m "Add project-local directories to .gitignore
Required for git worktree safety:
- node_modules/ (dependencies)
- dist/ (build output)
These directories must be local to each worktree."
# THEN proceed with worktree creationStep 3: Create Worktree
After safety verification passes:
- Detect project name (from directory or package.json)
- Create branch name (feature/
<description>) - Create worktree with new branch
- Report location
Commands:
# Detect project name
PROJECT_NAME=$(basename $(git rev-parse --show-toplevel))
# Create worktree with new branch
git worktree add .worktrees/feature-name -b feature/<project>-<description>
# Example:
# git worktree add .worktrees/user-auth -b feature/myapp-user-authReport:
## Worktree Created
**Location:** `.worktrees/user-auth/`
**Branch:** `feature/myapp-user-auth`
**Base:** `main` (current HEAD)
Worktree is ready. Moving to setup...Step 4: Project Setup
Auto-detect project type and run setup:
Node.js (has package.json):
cd .worktrees/user-auth/
npm install # or yarn install, or pnpm install, or bun installPython (has requirements.txt or pyproject.toml):
cd .worktrees/user-auth/
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt # or pip install -e .Rust (has Cargo.toml):
cd .worktrees/user-auth/
cargo buildGo (has go.mod):
cd .worktrees/user-auth/
go mod downloadReport:
## Project Setup
**Project Type:** Node.js (detected package.json)
**Setup Command:**
```bash
$ cd .worktrees/user-auth/
$ npm install
added 234 packages in 12sDependencies installed. Running baseline tests...
### Step 5: Verify Clean Baseline
**Run tests to verify worktree is in good state:**
```bash
# Node.js
npm test
# Python
pytest
# Rust
cargo test
# Go
go test ./...If tests pass:
## Baseline Verification
```bash
$ npm test
PASS tests/example.test.ts
✓ example test (5ms)
Test Files 1 passed (1)
Tests 1 passed (1)
Duration 0.84s✅ Clean baseline - all tests passing
Worktree is ready for development!
Location: .worktrees/user-auth/
Branch: feature/myapp-user-auth
You can now:
- cd .worktrees/user-auth/
- Start implementing
- Tests run independently of main worktree
**If tests fail:**
```markdown
⚠️ BASELINE TESTS FAILING
Tests failed in new worktree:
```bash
$ npm test
FAIL tests/example.test.ts
✗ example test
Expected 2, got 3This indicates a problem with setup or main branch state.
Should I:
- Debug the test failure
- Investigate main branch (is it broken?)
- Skip baseline verification (not recommended)
Waiting for guidance.
## Common Worktree Patterns
### Pattern 1: Feature Branch
```markdown
User: "Create worktree for user authentication feature"
**Steps:**
1. Check .gitignore → OK (node_modules/ ignored)
2. Create `.worktrees/user-auth/`
3. Branch: `feature/myapp-user-auth`
4. Run `npm install`
5. Run `npm test` → All pass ✅
Ready for development!Pattern 2: Parallel Features
User: "Create two worktrees for parallel work"
**Worktree 1:**
- Location: `.worktrees/frontend-ui/`
- Branch: `feature/myapp-frontend-ui`
- Purpose: UI components
**Worktree 2:**
- Location: `.worktrees/backend-api/`
- Branch: `feature/myapp-backend-api`
- Purpose: API endpoints
Both ready for parallel development!Pattern 3: Hotfix
User: "Create worktree for urgent bugfix"
**Steps:**
1. Base off production branch (not main)
2. Create `.worktrees/hotfix-login-crash/`
3. Branch: `hotfix/login-crash`
4. Setup and verify
5. Ready for fix!
**Note:** Hotfix branches typically merge to both production and main.Worktree Management
List Worktrees
git worktree listExample output:
/path/to/project a1b2c3d [main]
/path/to/.worktrees/user-auth e4f5g6h [feature/myapp-user-auth]Remove Worktree
When feature is done and merged:
# 1. Delete worktree directory
rm -rf .worktrees/user-auth/
# 2. Prune worktree from git
git worktree prune
# 3. (Optional) Delete branch if merged
git branch -d feature/myapp-user-authSwitch Between Worktrees
# Just cd to different directory
cd .worktrees/user-auth/ # Work on user-auth feature
cd ../../ # Back to main worktree
cd .worktrees/frontend-ui/ # Work on frontend featureIntegration with Other Skills
GitWorktrees → ExecutingPlans: Create worktree before executing implementation plan.
GitWorktrees → SubagentDrivenDev: Execute subagent-driven development within isolated worktree.
GitWorktrees → Brainstorming: Create worktree before implementing brainstormed design.
Typical flow:
Brainstorming → WritingPlans → GitWorktrees → ExecutingPlansSafety Verification Checklist
Before creating worktree, verify:
- Project-local directories in .gitignore
- Dependencies (node_modules/, .venv/, vendor/)
- Build output (dist/, build/, target/)
- Caches (.next/, .pytest_cache/)
- .env files gitignored (if exist)
- Lock files handling decided (package-lock.json: track or ignore?)
If anything NOT ignored that should be:
- Add to .gitignore
- Commit .gitignore changes
- THEN create worktree
Common Mistakes
| Mistake | Problem | Fix |
| Create worktree without checking .gitignore | node_modules/ shared across worktrees | Verify .gitignore first |
| Forget to run project setup | Missing dependencies, tests fail | Always run install/build |
| Skip baseline test verification | Start with broken tests | Run tests before implementation |
| Create worktree on main branch | Accidental commits to main | Always create new branch |
| Don't remove old worktrees | Disk space waste, confusion | Delete worktree when done |
Quick Reference
Situations and Actions
| Situation | Action |
| Starting new feature | Create worktree with feature branch |
| Need to pause feature | Just leave worktree, switch to main |
| Want to delete feature | Delete worktree directory, prune |
| Feature merged to main | Delete worktree, delete branch |
| Test failing in worktree | Debug in worktree, doesn't affect main |
| Want to switch features | Just cd to different worktree |
| Hotfix needed urgently | Create hotfix worktree from production |
| .gitignore missing entries | Add entries, commit, THEN create worktree |
Project Type Detection
| Project Type | Indicator | Setup Command |
| Node.js | package.json | npm install |
| Python | requirements.txt | pip install -r requirements.txt |
| Python | pyproject.toml | pip install -e . |
| Rust | Cargo.toml | cargo build |
| Go | go.mod | go mod download |
| Ruby | Gemfile | bundle install |
Baseline Test Commands
| Project Type | Test Command |
| Node.js | npm test |
| Python | pytest |
| Rust | cargo test |
| Go | go test ./... |
| Ruby | bundle exec rspec |
Example: Full Worktree Creation
User: "Create worktree for user authentication feature"
## Step 1: Directory Selection
Standard directory `.worktrees/` exists. Using it.
---
## Step 2: Safety Verification
Checking .gitignore for project-local directories...
```bash
$ cat .gitignore
node_modules/
dist/
.env
*.log✅ Safety check passed:
- node_modules/ ignored
- dist/ ignored
- .env ignored
Step 3: Create Worktree
$ git worktree add .worktrees/user-auth -b feature/myapp-user-auth
Preparing worktree (new branch 'feature/myapp-user-auth')
HEAD is now at a1b2c3d Initial commitWorktree Created:
- Location:
.worktrees/user-auth/ - Branch:
feature/myapp-user-auth
Step 4: Project Setup
Detected: Node.js project (package.json)
$ cd .worktrees/user-auth/
$ npm install
added 234 packages, and audited 235 packages in 12sDependencies installed.
Step 5: Verify Clean Baseline
Running tests to verify clean baseline...
$ npm test
RUN v0.34.6
✓ tests/example.test.ts (1)
✓ example test (5ms)
Test Files 1 passed (1)
Tests 1 passed (1)
Duration 0.84s✅ Clean baseline - all tests passing
Worktree Ready! ✅
Location: .worktrees/user-auth/
Branch: feature/myapp-user-auth
Status: Dependencies installed, tests passing
You can now:
cd .worktrees/user-auth/
# Start implementing user authenticationWhen done:
- Merge feature branch to main
- Delete worktree:
rm -rf .worktrees/user-auth/ - Prune:
git worktree prune
---
**This skill creates safe, isolated development environments for feature work with automatic setup and verification.**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.

