Skip to content

Commit 13c7580

Browse files
iHiDclaude
andauthored
Use git worktrees in /fix skill and align pre-commit validation (#8411)
Switch the /fix skill from branch-switching to git worktrees so the main repo stays on its current branch while fixes are developed in isolated worktree directories at ../website-worktrees/fix-<issue-number>. Also align the pre-commit validation step with CLAUDE.md — let the pre-commit hook handle rubocop/brakeman instead of running them manually. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 55859d4 commit 13c7580

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

.claude/skills/fix/SKILL.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: fix
3-
description: Fix a GitHub issue end-to-end — fetches issue, creates branch, plans and implements fix, runs validation, opens PR, returns to main.
3+
description: Fix a GitHub issue end-to-end — fetches issue, creates worktree, plans and implements fix, runs validation, opens PR, cleans up.
44
argument-hint: [issue-number-or-url]
55
disable-model-invocation: true
66
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, WebSearch
@@ -18,21 +18,20 @@ You are fixing a GitHub issue for the exercism/website repository.
1818

1919
Issue number: !`echo "$ARGUMENTS" | grep -oE '[0-9]+$'`
2020

21-
## Critical: Two phase.
21+
## Critical: Two phase.
2222

2323
Your work is split into two phases.
2424

25-
The first phase is purely planning. You must **NOT** make any changes to git state (switching branches, creating branches etc). You should presume that other work is SIMULTANEOUSLY happening WHILE you are planning.
25+
The first phase is purely planning. You must **NOT** make any changes to git state (switching branches, creating branches, creating worktrees, etc). You should presume that other work is SIMULTANEOUSLY happening WHILE you are planning.
2626

2727
Once the plan has been **APPROVED** by the user you should check the current git state:
2828

29-
- Run `git status` to check for uncommitted changes and the current branch.
30-
- If there are **uncommitted or staged changes**, STOP and ask the user how to proceed. Do NOT checkout another branch, stash, or discard anything.
31-
- If you are **not on main**, STOP and ask the user how to proceed. Do NOT switch branches or reset.
29+
- Run `git status` to check for uncommitted changes.
30+
- If there are **uncommitted or staged changes**, STOP and ask the user how to proceed. Do NOT stash or discard anything.
3231

3332
Never destroy or discard existing work.
3433

35-
If the plan has been approved, and you are on a clean main branch, continue with your work.
34+
If the plan has been approved and the working tree is clean, continue with your work.
3635

3736
## Workflow
3837

@@ -50,7 +49,7 @@ Read the relevant `docs/context/` files for the area of the codebase involved.
5049

5150
### Step 2: Plan the fix
5251

53-
**Do NOT create a branch yet.** Stay on the current branch while planning.
52+
**Do NOT create a branch or worktree yet.** Stay on the current branch while planning.
5453

5554
Use /plan to enter plan mode. Explore the codebase thoroughly:
5655

@@ -62,37 +61,40 @@ Use /plan to enter plan mode. Explore the codebase thoroughly:
6261

6362
Design a complete fix before writing any code.
6463

65-
### Step 3: Create a feature branch
64+
### Step 3: Create a worktree
6665

67-
Only create the branch **after the plan is approved**. The issue number has been extracted above (works whether the argument was a full URL like `https://github.com/exercism/website/issues/8370` or just `8370`).
66+
Only create the worktree **after the plan is approved**. The issue number has been extracted above (works whether the argument was a full URL like `https://github.com/exercism/website/issues/8370` or just `8370`).
6867

6968
```bash
70-
git checkout main
7169
git pull --ff-only origin main
72-
git checkout -b fix/<issue-number>
70+
mkdir -p ../website-worktrees
71+
git worktree add ../website-worktrees/fix-<issue-number> -b fix/<issue-number>
72+
cd ../website-worktrees/fix-<issue-number>
7373
```
7474

75+
**Important:** After creating the worktree, `cd` into it immediately. All subsequent work (file edits, bash commands, tests) happens inside the worktree. The main repo stays untouched on its current branch.
76+
7577
### Step 4: Implement the fix
7678

77-
After the plan is approved and the branch is created, implement the changes:
79+
After the plan is approved and the worktree is created, implement the changes:
7880

7981
- Follow existing patterns and conventions in the codebase
8082
- Business logic belongs in `/app/commands/` using the Mandate pattern
8183
- Keep controllers thin — delegate to commands
8284
- Add or update tests as appropriate (Minitest, FactoryBot)
8385
- Keep changes minimal and focused on the issue
8486

85-
### Step 5: Run pre-commit validation
87+
### Step 5: Run tests
8688

87-
Run all three checks. All must pass before committing:
89+
Run the relevant tests for the changes you made:
8890

8991
```bash
90-
bundle exec rubocop --except Metrics
91-
yarn test
92-
bundle exec rails test:zeitwerk
92+
bundle exec rails test <test-file-or-directory>
9393
```
9494

95-
If any check fails, fix the issues and re-run until all pass.
95+
If you made front-end changes, also run `yarn test` before committing.
96+
97+
Rubocop and brakeman will be checked automatically by the pre-commit hook when you commit — you do not need to run them manually.
9698

9799
### Step 6: Commit the changes
98100

@@ -123,10 +125,13 @@ EOF
123125
)"
124126
```
125127

126-
### Step 8: Return to main
128+
### Step 8: Clean up worktree
127129

128130
```bash
129-
git checkout main
131+
cd /Users/iHiD/Code/exercism/website
132+
git worktree remove ../website-worktrees/fix-<issue-number>
130133
```
131134

135+
This removes the worktree directory and returns you to the main repo. The branch remains on the remote for the PR.
136+
132137
Report the PR URL to the user.

0 commit comments

Comments
 (0)