changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: using-git-worktrees
|
||||
description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
|
||||
description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with safety verification
|
||||
---
|
||||
|
||||
# Using Git Worktrees
|
||||
@@ -9,68 +9,37 @@ description: Use when starting feature work that needs isolation from current wo
|
||||
|
||||
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
|
||||
|
||||
**Core principle:** Systematic directory selection + safety verification = reliable isolation.
|
||||
**Core principle:** Use repo-root `.worktree/` + safety verification for reliable isolation.
|
||||
|
||||
**Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
|
||||
|
||||
## Directory Selection Process
|
||||
## Directory Rule
|
||||
|
||||
Follow this priority order:
|
||||
Use repo-root `.worktree/` by default.
|
||||
|
||||
### 1. Check Existing Directories
|
||||
Do **not** suggest:
|
||||
- `.worktrees/`
|
||||
- `worktrees/`
|
||||
- `~/.config/superpowers/worktrees/...`
|
||||
|
||||
```bash
|
||||
# Check in priority order
|
||||
ls -d .worktrees 2>/dev/null # Preferred (hidden)
|
||||
ls -d worktrees 2>/dev/null # Alternative
|
||||
```
|
||||
|
||||
**If found:** Use that directory. If both exist, `.worktrees` wins.
|
||||
|
||||
### 2. Check CLAUDE.md
|
||||
|
||||
```bash
|
||||
grep -i "worktree.*director" CLAUDE.md 2>/dev/null
|
||||
```
|
||||
|
||||
**If preference specified:** Use it without asking.
|
||||
|
||||
### 3. Ask User
|
||||
|
||||
If no directory exists and no CLAUDE.md preference:
|
||||
|
||||
```
|
||||
No worktree directory found. Where should I create worktrees?
|
||||
|
||||
1. .worktrees/ (project-local, hidden)
|
||||
2. ~/.config/superpowers/worktrees/<project-name>/ (global location)
|
||||
|
||||
Which would you prefer?
|
||||
```
|
||||
Only deviate if the user explicitly asks for a different location.
|
||||
|
||||
## Safety Verification
|
||||
|
||||
### For Project-Local Directories (.worktrees or worktrees)
|
||||
|
||||
**MUST verify directory is ignored before creating worktree:**
|
||||
**MUST verify `.worktree/` is ignored before creating a worktree:**
|
||||
|
||||
```bash
|
||||
# Check if directory is ignored (respects local, global, and system gitignore)
|
||||
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
||||
git check-ignore -q .worktree/ 2>/dev/null || git check-ignore -q .worktree 2>/dev/null
|
||||
```
|
||||
|
||||
**If NOT ignored:**
|
||||
|
||||
Per Jesse's rule "Fix broken things immediately":
|
||||
1. Add appropriate line to .gitignore
|
||||
1. Add `.worktree/` to `.gitignore`
|
||||
2. Commit the change
|
||||
3. Proceed with worktree creation
|
||||
|
||||
**Why critical:** Prevents accidentally committing worktree contents to repository.
|
||||
|
||||
### For Global Directory (~/.config/superpowers/worktrees)
|
||||
|
||||
No .gitignore verification needed - outside project entirely.
|
||||
**Why critical:** Prevents accidentally committing worktree contents to the repository.
|
||||
|
||||
## Creation Steps
|
||||
|
||||
@@ -83,17 +52,7 @@ project=$(basename "$(git rev-parse --show-toplevel)")
|
||||
### 2. Create Worktree
|
||||
|
||||
```bash
|
||||
# Determine full path
|
||||
case $LOCATION in
|
||||
.worktrees|worktrees)
|
||||
path="$LOCATION/$BRANCH_NAME"
|
||||
;;
|
||||
~/.config/superpowers/worktrees/*)
|
||||
path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create worktree with new branch
|
||||
path=".worktree/$BRANCH_NAME"
|
||||
git worktree add "$path" -b "$BRANCH_NAME"
|
||||
cd "$path"
|
||||
```
|
||||
@@ -145,48 +104,45 @@ Ready to implement <feature-name>
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| `.worktrees/` exists | Use it (verify ignored) |
|
||||
| `worktrees/` exists | Use it (verify ignored) |
|
||||
| Both exist | Use `.worktrees/` |
|
||||
| Neither exists | Check CLAUDE.md → Ask user |
|
||||
| Directory not ignored | Add to .gitignore + commit |
|
||||
| Tests fail during baseline | Report failures + ask |
|
||||
| No package.json/Cargo.toml | Skip dependency install |
|
||||
| Starting feature work | Use `.worktree/<branch-name>` |
|
||||
| `.worktree/` not ignored | Add `.worktree/` to `.gitignore`, commit, continue |
|
||||
| Tests fail during baseline | Report failures and ask |
|
||||
| No package manager/build file | Skip dependency install |
|
||||
| User explicitly wants another location | Follow the user's instruction |
|
||||
|
||||
## Common Mistakes
|
||||
|
||||
### Skipping ignore verification
|
||||
|
||||
- **Problem:** Worktree contents get tracked, pollute git status
|
||||
- **Fix:** Always use `git check-ignore` before creating project-local worktree
|
||||
- **Problem:** Worktree contents get tracked and pollute git status
|
||||
- **Fix:** Always verify `.worktree/` is ignored first
|
||||
|
||||
### Assuming directory location
|
||||
### Using the wrong directory
|
||||
|
||||
- **Problem:** Creates inconsistency, violates project conventions
|
||||
- **Fix:** Follow priority: existing > CLAUDE.md > ask
|
||||
- **Problem:** Inconsistent worktree layout across repositories
|
||||
- **Fix:** Use repo-root `.worktree/` unless the user explicitly overrides it
|
||||
|
||||
### Proceeding with failing tests
|
||||
|
||||
- **Problem:** Can't distinguish new bugs from pre-existing issues
|
||||
- **Fix:** Report failures, get explicit permission to proceed
|
||||
- **Fix:** Report failures and get explicit permission to proceed
|
||||
|
||||
### Hardcoding setup commands
|
||||
|
||||
- **Problem:** Breaks on projects using different tools
|
||||
- **Fix:** Auto-detect from project files (package.json, etc.)
|
||||
- **Fix:** Auto-detect from project files (`package.json`, `Cargo.toml`, etc.)
|
||||
|
||||
## Example Workflow
|
||||
|
||||
```
|
||||
You: I'm using the using-git-worktrees skill to set up an isolated workspace.
|
||||
|
||||
[Check .worktrees/ - exists]
|
||||
[Verify ignored - git check-ignore confirms .worktrees/ is ignored]
|
||||
[Create worktree: git worktree add .worktrees/auth -b feature/auth]
|
||||
[Verify .worktree/ is ignored]
|
||||
[Create worktree: git worktree add .worktree/auth -b feature/auth]
|
||||
[Run npm install]
|
||||
[Run npm test - 47 passing]
|
||||
|
||||
Worktree ready at /Users/jesse/myproject/.worktrees/auth
|
||||
Worktree ready at /Users/jesse/myproject/.worktree/auth
|
||||
Tests passing (47 tests, 0 failures)
|
||||
Ready to implement auth feature
|
||||
```
|
||||
@@ -194,17 +150,16 @@ Ready to implement auth feature
|
||||
## Red Flags
|
||||
|
||||
**Never:**
|
||||
- Create worktree without verifying it's ignored (project-local)
|
||||
- Create a worktree without verifying `.worktree/` is ignored
|
||||
- Skip baseline test verification
|
||||
- Proceed with failing tests without asking
|
||||
- Assume directory location when ambiguous
|
||||
- Skip CLAUDE.md check
|
||||
- Suggest `.worktrees/`, `worktrees/`, or `~/.config/superpowers/worktrees/...` by default
|
||||
|
||||
**Always:**
|
||||
- Follow directory priority: existing > CLAUDE.md > ask
|
||||
- Verify directory is ignored for project-local
|
||||
- Use repo-root `.worktree/` by default
|
||||
- Verify `.worktree/` is ignored
|
||||
- Auto-detect and run project setup
|
||||
- Verify clean test baseline
|
||||
- Verify a clean test baseline
|
||||
|
||||
## Integration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user