summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Harrison <mycarrysun@users.noreply.github.com>2025-12-23 14:26:33 -0500
committerGitHub <noreply@github.com>2025-12-23 11:26:33 -0800
commitc037dcbf4ba74a3e7a63f7f2910baf1f13513d05 (patch)
tree593aa367424424d13b2d5f729a7e0637887198e7
parenta7a8c08c02d1f20409048ceafc49ed309d570ebf (diff)
fix: use git check-ignore for worktree gitignore verification (#160)
* fix: use git check-ignore for worktree gitignore verification The using-git-worktrees skill previously used grep to check only the local .gitignore file, missing patterns in global gitignore configurations (core.excludesfile). This caused unnecessary modifications to local .gitignore when the directory was already globally ignored. Changed verification from grep to git check-ignore, which respects Git's full ignore hierarchy (local, global, and system gitignore files). Fixes obra/superpowers#101 Tested with: Subagent pressure scenarios verifying correct behavior with global gitignore configuration. Baseline test confirmed the bug, post-fix test confirmed correct behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * style: convert bold emphasis to headings in Common Mistakes section Convert **Title** patterns to ### Title headings for markdown lint compliance (MD036 - no emphasis as heading). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
-rw-r--r--skills/using-git-worktrees/SKILL.md34
1 files changed, 19 insertions, 15 deletions
diff --git a/skills/using-git-worktrees/SKILL.md b/skills/using-git-worktrees/SKILL.md
index 40b9ff9..9d52d80 100644
--- a/skills/using-git-worktrees/SKILL.md
+++ b/skills/using-git-worktrees/SKILL.md
@@ -52,14 +52,14 @@ Which would you prefer?
### For Project-Local Directories (.worktrees or worktrees)
-**MUST verify .gitignore before creating worktree:**
+**MUST verify directory is ignored before creating worktree:**
```bash
-# Check if directory pattern in .gitignore
-grep -q "^\.worktrees/$" .gitignore || grep -q "^worktrees/$" .gitignore
+# 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
```
-**If NOT in .gitignore:**
+**If NOT ignored:**
Per Jesse's rule "Fix broken things immediately":
1. Add appropriate line to .gitignore
@@ -145,29 +145,33 @@ Ready to implement <feature-name>
| Situation | Action |
|-----------|--------|
-| `.worktrees/` exists | Use it (verify .gitignore) |
-| `worktrees/` exists | Use it (verify .gitignore) |
+| `.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 in .gitignore | Add it immediately + commit |
+| Directory not ignored | Add to .gitignore + commit |
| Tests fail during baseline | Report failures + ask |
| No package.json/Cargo.toml | Skip dependency install |
## Common Mistakes
-**Skipping .gitignore verification**
+### Skipping ignore verification
+
- **Problem:** Worktree contents get tracked, pollute git status
-- **Fix:** Always grep .gitignore before creating project-local worktree
+- **Fix:** Always use `git check-ignore` before creating project-local worktree
+
+### Assuming directory location
-**Assuming directory location**
- **Problem:** Creates inconsistency, violates project conventions
- **Fix:** Follow priority: existing > CLAUDE.md > ask
-**Proceeding with failing tests**
+### Proceeding with failing tests
+
- **Problem:** Can't distinguish new bugs from pre-existing issues
- **Fix:** Report failures, get explicit permission to proceed
-**Hardcoding setup commands**
+### Hardcoding setup commands
+
- **Problem:** Breaks on projects using different tools
- **Fix:** Auto-detect from project files (package.json, etc.)
@@ -177,7 +181,7 @@ Ready to implement <feature-name>
You: I'm using the using-git-worktrees skill to set up an isolated workspace.
[Check .worktrees/ - exists]
-[Verify .gitignore - contains .worktrees/]
+[Verify ignored - git check-ignore confirms .worktrees/ is ignored]
[Create worktree: git worktree add .worktrees/auth -b feature/auth]
[Run npm install]
[Run npm test - 47 passing]
@@ -190,7 +194,7 @@ Ready to implement auth feature
## Red Flags
**Never:**
-- Create worktree without .gitignore verification (project-local)
+- Create worktree without verifying it's ignored (project-local)
- Skip baseline test verification
- Proceed with failing tests without asking
- Assume directory location when ambiguous
@@ -198,7 +202,7 @@ Ready to implement auth feature
**Always:**
- Follow directory priority: existing > CLAUDE.md > ask
-- Verify .gitignore for project-local
+- Verify directory is ignored for project-local
- Auto-detect and run project setup
- Verify clean test baseline