Skip to content

Commit 5854c1d

Browse files
author
Nick Sullivan
committed
♻️ Update git worktree config to use sibling directories
Change worktree location from .gitworktrees/ (inside repo) to sibling directories (e.g., mcp-hubby-feature-name) to avoid pnpm symlink and ESLint module resolution issues. Why sibling directories: - Avoids pnpm symlink resolution errors with nested worktrees - Prevents ESLint @rushstack/eslint-patch module patching errors - Cleaner separation between main repo and feature work - Standard practice for monorepo tools and shared deps Lesson learned from memory integration PR where pre-commit hooks failed due to ESLint config issues in nested .gitworktrees/ location.
1 parent fc72d33 commit 5854c1d

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

git-worktree-task.mdc

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
description: Autonomous task workflow using git worktrees
3+
alwaysApply: false
4+
---
5+
6+
# Git Worktree Task Workflow
7+
8+
<objective>
9+
Deliver a pull request that passes all checks and merges without back-and-forth. Work in isolated git worktrees to keep the main directory clean and allow context switching.
10+
</objective>
11+
12+
<workspace-setup>
13+
Create git worktree as a sibling directory to avoid pnpm/ESLint module resolution issues:
14+
15+
```bash
16+
# Extract project name from current directory
17+
PROJECT_NAME=$(basename "$(git rev-parse --show-toplevel)")
18+
19+
# Create worktree as sibling directory
20+
git worktree add -b feature/task-name "../${PROJECT_NAME}-task-name" main
21+
cd "../${PROJECT_NAME}-task-name"
22+
```
23+
24+
Example: If working in `/Users/nick/src/mcp-hubby`, worktree will be created at `/Users/nick/src/mcp-hubby-task-name` (sibling directory).
25+
26+
**Why sibling directories?**
27+
- Avoids pnpm symlink resolution issues with nested worktrees
28+
- Prevents ESLint module patching errors (@rushstack/eslint-patch)
29+
- Cleaner separation between main repo and feature work
30+
- Standard practice for monorepo tools and shared dependency trees
31+
32+
**Note:** Do NOT use `.gitworktrees/` inside the repo - this breaks module resolution for pnpm-based projects.
33+
</workspace-setup>
34+
35+
<environment-initialization>
36+
Run /setup-environment to prepare the worktree. This detects project type and sets up dependencies, code generation, and environment files.
37+
38+
If /setup-environment doesn't exist, set up manually based on project type (Node.js: `pnpm install`, Python: `pip install -r requirements.txt`, Ruby: `bundle install`).
39+
40+
Copy environment files from parent directory if needed. After proper setup, all tests (unit + integration) should pass.
41+
</environment-initialization>
42+
43+
<standards-discovery>
44+
Read all cursor rules in .cursor/rules/. If CLAUDE.md or AGENTS.md exist at project root, read those too. Every applicable rule must be followed.
45+
</standards-discovery>
46+
47+
<implementation>
48+
Write code that solves the problem following all cursor rules. Make commits along the way as logical units of work are completed. Follow git commit message guidelines in .cursor/rules/git-commit-message.mdc.
49+
</implementation>
50+
51+
<local-validation>
52+
Run project's pre-push validation before pushing. This catches issues before CI:
53+
- Node.js: `pnpm pre-push` or check package.json scripts
54+
- Python: `pre-commit run --all-files`, `pytest`, `ruff check`, `mypy`
55+
- Ruby: `bundle exec rake test`, `bundle exec rubocop`
56+
- Go: `go test ./...`, `golangci-lint run`
57+
- Rust: `cargo test`, `cargo clippy`
58+
59+
Check .github/workflows/ to see what CI runs - run those steps locally.
60+
61+
All tests should pass after environment setup. If tests fail, it's either incomplete setup or bugs in your code. Fix before pushing.
62+
</local-validation>
63+
64+
<self-review>
65+
Invoke code reviewer agent (Rivera in .claude/agents/rivera.md if available) to review changes before pushing. Address critical issues, consider warnings seriously, evaluate suggestions for merit. Learn from feedback.
66+
</self-review>
67+
68+
<pull-request-creation>
69+
Once local validation passes and code review is addressed, push commits. Create pull request with clear description of what changed and why. Help reviewers understand context and decisions made.
70+
</pull-request-creation>
71+
72+
<ci-validation>
73+
Let all CI jobs run to completion. All must pass. Green checks required before merge. If CI fails, read logs carefully, understand what broke and why, fix and push again.
74+
</ci-validation>
75+
76+
<bot-review-handling>
77+
AI code review bots will analyze the pull request. Evaluate feedback critically - you have full project context, bots don't.
78+
79+
Fix valuable feedback that identifies real issues. Mark as WONTFIX with clear reasoning if feedback is incorrect, not applicable, conflicts with project standards, or would break functionality.
80+
81+
Be discerning. You are smarter than the bots.
82+
</bot-review-handling>
83+
84+
<merge-and-cleanup>
85+
Once CI is green, bot reviews are addressed, and all checks pass, merge the PR.
86+
87+
After merge, clean up worktree:
88+
89+
```bash
90+
# Return to main repo directory
91+
cd "$(git rev-parse --show-toplevel)"
92+
93+
# Remove the sibling worktree
94+
PROJECT_NAME=$(basename "$(git rev-parse --show-toplevel)")
95+
git worktree remove "../${PROJECT_NAME}-task-name"
96+
```
97+
98+
Or use the /clean-up-worktree command if available.
99+
</merge-and-cleanup>
100+
101+
<critical-success-factors>
102+
Environment setup is not optional. After creating worktree, run /setup-environment or manually install dependencies. Type errors and test failures often stem from missing code generation or dependencies.
103+
104+
Local validation saves time. Don't push without running pre-push checks. Local tooling catches issues in seconds vs waiting for CI.
105+
106+
Bot feedback requires judgment. Bots provide suggestions, not mandates. Evaluate each piece based on your context and project standards.
107+
108+
Full test suite must pass. After setup, all tests (unit + integration) should pass. Fix setup or code before pushing.
109+
110+
Successful autonomous task means: original request completed, all automated checks pass, code follows all cursor rules, tests green, code review addressed, bot feedback evaluated intelligently, PR merges without human intervention requesting changes.
111+
</critical-success-factors>

0 commit comments

Comments
 (0)