@wbern/claude-instructions 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,248 @@
1
+ ---
2
+ description: Code review using dynamic category detection and domain-specific analysis
3
+ argument-hint: (optional) [branch, PR#, or PR URL] - defaults to current branch
4
+ - Bash(git diff:*)
5
+ - Bash(git status:*)
6
+ - Bash(git log:*)
7
+ - Bash(git rev-parse:*)
8
+ - Bash(git merge-base:*)
9
+ - Bash(git branch:*)
10
+ ---
11
+
12
+ ## General Guidelines
13
+
14
+ ### Output Style
15
+
16
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
17
+ - Write natural, descriptive code without meta-commentary about the development process
18
+ - The code should speak for itself - TDD is the process, not the product
19
+
20
+ Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands).
21
+
22
+ # Code Review
23
+
24
+ Perform a code review using dynamic category detection.
25
+
26
+ ## Phase 0: Setup & Categorization
27
+
28
+ ### Determine What to Review
29
+
30
+ Parse the argument to determine the review target:
31
+
32
+ | Input | Action |
33
+ |-------|--------|
34
+ | No argument | Detect divergence point, confirm scope with user |
35
+ | Branch name | Use specified branch as base |
36
+ | PR number (e.g., `123`) | Fetch PR diff from GitHub |
37
+ | PR URL (e.g., `https://github.com/owner/repo/pull/123`) | Extract PR number and fetch diff |
38
+
39
+ **For GitHub PRs:**
40
+
41
+ 1. Try GitHub MCP first: `mcp__github__pull_request_read` with `method: "get_diff"`
42
+ 2. Fall back to `gh` CLI: `gh pr diff <number>`
43
+ 3. If neither works, report error and stop
44
+
45
+ **For local branches (no argument or branch name provided):**
46
+
47
+ 1. **Get current branch**: `git rev-parse --abbrev-ref HEAD`
48
+
49
+ 2. **Check for uncommitted changes**: `git status --porcelain`
50
+ - If output is non-empty, note that uncommitted changes exist
51
+
52
+ 3. **Detect divergence point** (skip if branch name was provided as argument):
53
+ - Get all local branches except current: `git branch --format='%(refname:short)'`
54
+ - For each branch, find merge-base: `git merge-base HEAD <branch>`
55
+ - Count commits from merge-base to HEAD: `git rev-list --count <merge-base>..HEAD`
56
+ - The branch with the **fewest commits back** (closest merge-base) is the likely parent
57
+ - If no other branches exist, fall back to `main`, `master`, or `develop` if they exist as remote tracking branches
58
+
59
+ 4. **Confirm scope with user** using `AskUserQuestion`:
60
+
61
+ **Question 1 - "Review scope"** (header: "Base branch"):
62
+ - Option A: `From <detected-branch>` — "Review N commits since diverging from <branch>"
63
+ - Option B: `Different branch` — "Specify another branch to compare against"
64
+ - Option C: `Uncommitted only` — "Review only staged/unstaged changes, skip committed work"
65
+
66
+ **Question 2 - "Include uncommitted?"** (header: "Uncommitted", only ask if uncommitted changes exist AND user didn't pick option C):
67
+ - Option A: `Yes` — "Include N staged/unstaged files in review"
68
+ - Option B: `No` — "Review only committed changes"
69
+
70
+ 5. **Collect changed files** based on user selection:
71
+ - From branch: `git diff --name-only <base>...HEAD`
72
+ - Uncommitted unstaged: `git diff --name-only`
73
+ - Uncommitted staged: `git diff --name-only --cached`
74
+ - Combine and deduplicate the file list
75
+
76
+ 6. **If no changes**: Report "Nothing to review" and stop
77
+
78
+ ### Categorize Files
79
+
80
+ Check for CLAUDE.md - if it exists, note any project-specific review patterns.
81
+
82
+ Categorize each changed file into ONE primary category based on these patterns:
83
+
84
+ | Category | File Patterns |
85
+ |----------|---------------|
86
+ | Frontend/UI | `*.tsx`, `*.jsx`, `components/`, `pages/`, `views/`, `*.vue` |
87
+ | Frontend/Styling | `*.css`, `*.scss`, `*.less`, `styles/`, `*.tailwind*`, `*.styled.*` |
88
+ | Backend/API | `routes/`, `api/`, `controllers/`, `services/`, `*.controller.*`, `*.service.*`, `*.resolver.*` |
89
+ | Backend/Data | `migrations/`, `models/`, `prisma/`, `schema.*`, `*.model.*`, `*.entity.*` |
90
+ | Tooling/Config | `scripts/`, `*.config.*`, `package.json`, `tsconfig.*`, `vite.*`, `webpack.*`, `eslint.*` |
91
+ | CI/CD | `.github/`, `.gitlab-ci.*`, `Dockerfile`, `docker-compose.*`, `*.yml` in CI paths |
92
+ | Tests | `*.test.*`, `*.spec.*`, `__tests__/`, `__mocks__/`, `*.stories.*` |
93
+ | Docs | `*.md`, `docs/`, `README*`, `CHANGELOG*` |
94
+
95
+ Output the categorization:
96
+
97
+ ```
98
+ ## Categorization
99
+
100
+ Base branch: <branch>
101
+ Total files changed: <n>
102
+
103
+ | Category | Files |
104
+ |----------|-------|
105
+ | <category> | <count> |
106
+ ...
107
+ ```
108
+
109
+ ## Phase 1: Branch Brief
110
+
111
+ From the diff and recent commit messages (`git log <base>...HEAD --oneline`), infer:
112
+
113
+ - **Goal**: What this branch accomplishes (1-3 sentences)
114
+ - **Constraints**: Any implied requirements (security, performance, backwards compatibility)
115
+ - **Success checklist**: What must work after this change, what must not break
116
+
117
+ ```
118
+ ## Branch Brief
119
+
120
+ **Goal**: ...
121
+ **Constraints**: ...
122
+ **Checklist**:
123
+ - [ ] ...
124
+ ```
125
+
126
+ ## Phase 2: Category Reviews
127
+
128
+ For each detected category with changes, run a targeted review. Skip categories with no changes.
129
+
130
+ ### Frontend/UI Review Criteria
131
+
132
+ - Accessibility: ARIA attributes, keyboard navigation, screen reader support
133
+ - Component patterns: Composition, prop drilling, context usage
134
+ - State management: Unnecessary re-renders, stale closures
135
+ - Performance: memo/useMemo/useCallback usage, lazy loading, bundle impact
136
+
137
+ ### Frontend/Styling Review Criteria
138
+
139
+ - Responsive design: Breakpoints, mobile-first
140
+ - Design system: Token usage, consistent spacing/colors
141
+ - CSS specificity: Overly specific selectors, !important usage
142
+ - Theme support: Dark mode, CSS variables
143
+
144
+ ### Backend/API Review Criteria
145
+
146
+ - Input validation: Sanitization, type checking, bounds
147
+ - Security: Authentication checks, authorization, injection risks
148
+ - Error handling: Proper status codes, meaningful messages, logging
149
+ - Performance: N+1 queries, missing indexes, pagination
150
+
151
+ ### Backend/Data Review Criteria
152
+
153
+ - Migration safety: Reversibility, data preservation
154
+ - Data integrity: Constraints, foreign keys, nullability
155
+ - Index usage: Queries have appropriate indexes
156
+ - Backwards compatibility: Existing data still works
157
+
158
+ ### Tooling/Config Review Criteria
159
+
160
+ - Breaking changes: Does this affect developer workflow?
161
+ - Dependency compatibility: Version conflicts, peer deps
162
+ - Build performance: Added build time, bundle size
163
+
164
+ ### CI/CD Review Criteria
165
+
166
+ - Secrets exposure: Credentials in logs, env vars
167
+ - Pipeline efficiency: Caching, parallelization
168
+ - Failure handling: Notifications, rollback strategy
169
+
170
+ ### Tests Review Criteria
171
+
172
+ - Coverage: Edge cases, error paths, boundaries
173
+ - Assertion quality: Specific assertions, not just "no error"
174
+ - Flaky patterns: Timing dependencies, order dependencies, shared state
175
+
176
+ ### Docs Review Criteria
177
+
178
+ - Technical accuracy: Code examples work, APIs documented correctly
179
+ - Completeness: All new features documented
180
+ - Clarity: Easy to follow, good examples
181
+
182
+ **Output format per category:**
183
+
184
+ ```
185
+ ## <Category> Review (<n> files)
186
+
187
+ ### file:line - [blocker|risky|nit] Title
188
+ Description of the issue and why it matters.
189
+ Suggested fix or question to investigate.
190
+
191
+ ...
192
+ ```
193
+
194
+ ## Phase 3: Cross-Cutting Analysis
195
+
196
+ After reviewing all categories, check for cross-cutting issues:
197
+
198
+ - API changed but tests didn't update?
199
+ - New feature but no documentation?
200
+ - Migration added but no rollback tested?
201
+ - Config changed but README not updated?
202
+ - Security-sensitive code without corresponding test?
203
+
204
+ ```
205
+ ## Cross-Cutting Issues
206
+
207
+ - [ ] <issue description>
208
+ ...
209
+ ```
210
+
211
+ ## Phase 4: Summary
212
+
213
+ ### PR Description (draft)
214
+
215
+ Provide a ready-to-paste PR description:
216
+
217
+ ```
218
+ ## What changed
219
+ - <by category, 1-2 bullets each>
220
+
221
+ ## Why
222
+ - <motivation>
223
+
224
+ ## Testing
225
+ - <how to verify>
226
+
227
+ ## Notes
228
+ - <migration steps, breaking changes, etc.>
229
+ ```
230
+
231
+ ### Review Checklist
232
+
233
+ ```
234
+ ## Before Merge
235
+
236
+ ### Blockers (must fix)
237
+ - [ ] ...
238
+
239
+ ### Risky (highlight to reviewers)
240
+ - [ ] ...
241
+
242
+ ### Follow-ups (can defer)
243
+ - [ ] ...
244
+ ```
245
+
246
+ ---
247
+
248
+ Review target (branch name, PR number, or PR URL - leave empty for current branch): $ARGUMENTS
@@ -24,6 +24,20 @@
24
24
  "category": "Workflow",
25
25
  "order": 2
26
26
  },
27
+ "code-review.md": {
28
+ "description": "Code review using dynamic category detection and domain-specific analysis",
29
+ "hint": "Review code",
30
+ "category": "Workflow",
31
+ "order": 35,
32
+ "_requested-tools": [
33
+ "Bash(git diff:*)",
34
+ "Bash(git status:*)",
35
+ "Bash(git log:*)",
36
+ "Bash(git rev-parse:*)",
37
+ "Bash(git merge-base:*)",
38
+ "Bash(git branch:*)"
39
+ ]
40
+ },
27
41
  "commit.md": {
28
42
  "description": "Create a git commit following project standards",
29
43
  "hint": "Git commit",
@@ -111,7 +125,7 @@
111
125
  "order": 1
112
126
  },
113
127
  "worktree-add.md": {
114
- "description": "Add a new git worktree from branch name or GitHub issue URL, copy settings, install deps, and open in current IDE",
128
+ "description": "Add a new git worktree from branch name or issue URL, copy settings, install deps, and open in current IDE",
115
129
  "hint": "Add worktree",
116
130
  "category": "Worktree Management",
117
131
  "order": 1
@@ -17,6 +17,22 @@ Create a git commit following project standards
17
17
 
18
18
  Include any of the following info if specified: $ARGUMENTS
19
19
 
20
+ ## Commit Message Rules
21
+
22
+ Follows [Conventional Commits](https://www.conventionalcommits.org/) standard.
23
+
24
+ 1. **Format**: `type(#issue): description`
25
+ - Use `#123` for local repo issues
26
+ - Use `owner/repo#123` for cross-repo issues
27
+ - Common types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`
28
+
29
+ 2. **AI Credits**: **NEVER include AI credits in commit messages**
30
+ - No "Generated with Claude Code"
31
+ - No "Co-Authored-By: Claude" or "Co-Authored-By: Happy"
32
+ - Focus on the actual changes made, not conversation history
33
+
34
+ 3. **Content**: Write clear, concise commit messages describing what changed and why
35
+
20
36
  ## Process
21
37
 
22
38
  1. Run `git status` and `git diff` to review changes
@@ -19,6 +19,7 @@ Analyze the current conversation context and identify things that have not yet b
19
19
  2. **Unused variables/results** - Values that were captured but never used
20
20
  3. **Missing tests** - Functionality without test coverage
21
21
  4. **Open issues** - Beads issues that are still open or in progress
22
+
22
23
  5. **User requests** - Things the user asked for that weren't fully completed
23
24
  6. **TODO comments** - Any TODOs mentioned in conversation
24
25
  7. **Error handling gaps** - Missing error cases or edge cases
@@ -21,8 +21,7 @@ Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues
21
21
 
22
22
  $ARGUMENTS
23
23
 
24
- (If no input provided, check conversation context or run `bd ready` to see existing work
25
- )
24
+ (If no input provided, check conversation context or run `bd ready` to see existing work)
26
25
 
27
26
  ## Input Processing
28
27
 
@@ -1,6 +1,6 @@
1
1
  ---
2
- description: Add a new git worktree from branch name or GitHub issue URL, copy settings, install deps, and open in current IDE
3
- argument-hint: <branch-name-or-github-issue-url> [optional-base-branch]
2
+ description: Add a new git worktree from branch name or issue URL, copy settings, install deps, and open in current IDE
3
+ argument-hint: <branch-name-or-issue-url> [optional-base-branch]
4
4
  ---
5
5
 
6
6
  # Git Worktree Setup
@@ -18,31 +18,37 @@ Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues
18
18
  Create a new git worktree for branch: $ARGUMENTS
19
19
 
20
20
  <current_state>
21
- Current branch: !git branch --show-current`
22
- Current worktrees: !git worktree list`
23
- Remote branches: !git branch -r`
24
- Uncommitted changes: !git status --short`
21
+ Current branch: `git branch --show-current`
22
+ Current worktrees: `git worktree list`
23
+ Remote branches: `git branch -r`
24
+ Uncommitted changes: `git status --short`
25
25
  </current_state>
26
26
 
27
27
  <execution_steps>
28
28
  <step_0>
29
- <description>Validate MCP dependencies</description>
30
- <check_github_mcp>
31
- <requirement>GitHub MCP server must be configured</requirement>
32
- <fallback>If unavailable, use `gh` CLI commands</fallback>
33
- <validation>
34
- - Try listing available MCP resources
35
- - If GitHub MCP not found, switch to CLI fallback
36
- - Inform user about MCP configuration if needed
37
- </validation>
38
- </check_github_mcp>
39
- <error_handling>
40
- If MCP validation fails:
41
- - Show clear error message
42
- - Provide setup instructions
43
- - Fallback to CLI if possible
44
- </error_handling>
45
- <purpose>Ensure required MCP dependencies are available before proceeding</purpose>
29
+ <description>Detect git hosting provider and available tools (only needed if argument is an issue URL)</description>
30
+ <condition>Only run this step if first argument looks like a git hosting URL</condition>
31
+ <detect_provider>
32
+ <check_remote_url>git remote get-url origin</check_remote_url>
33
+ <identify_host>
34
+ - github.com GitHub
35
+ - gitlab.com GitLab
36
+ - bitbucket.org Bitbucket
37
+ - Other → Ask user
38
+ </identify_host>
39
+ </detect_provider>
40
+ <check_available_tools>
41
+ <list_mcp_servers>Check which git-hosting MCP servers are available (github, gitlab, etc.)</list_mcp_servers>
42
+ <check_cli>Check if gh/glab CLI is available as fallback</check_cli>
43
+ </check_available_tools>
44
+ <select_tool>
45
+ <if_single_mcp>If only one relevant MCP available, confirm with user</if_single_mcp>
46
+ <if_multiple>Let user choose which tool to use</if_multiple>
47
+ <if_told_earlier>If user specified tool earlier in conversation, use that without asking again</if_told_earlier>
48
+ <store_as>$GIT_HOST_TOOL (e.g., "github_mcp", "gitlab_mcp", "gh_cli")</store_as>
49
+ </select_tool>
50
+
51
+ <purpose>Detect git hosting provider and select appropriate tool for issue lookup</purpose>
46
52
  </step_0>
47
53
 
48
54
  <step_1>
@@ -70,30 +76,41 @@ Uncommitted changes: !git status --short`
70
76
  </step_1>
71
77
 
72
78
  <step_2>
73
- <description>Parse the arguments</description>
79
+ <description>Determine default branch and parse arguments</description>
80
+ <find_default_branch>
81
+ <command>git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'</command>
82
+ <fallback>git remote show origin | grep 'HEAD branch' | cut -d: -f2 | tr -d ' '</fallback>
83
+ <store_as>$DEFAULT_BRANCH (typically "main" or "master")</store_as>
84
+ </find_default_branch>
74
85
  <input>The user-provided arguments</input>
75
- <expected_format>branch-name-or-github-url [optional-base-branch]</expected_format>
86
+ <expected_format>branch-name-or-issue-url [optional-base-branch]</expected_format>
76
87
  <example>fix/issue-123-main-content-area-visually-clipped main</example>
77
- <example_github_url><https://github.com/owner/project/issues/123> main</example_github_url>
78
- <default_base_branch>main (if not specified)</default_base_branch>
79
- </step_1>
88
+ <example_issue_url>https://github.com/owner/project/issues/123 main</example_issue_url>
89
+ <base_branch>Use provided base branch, or $DEFAULT_BRANCH if not specified</base_branch>
90
+ </step_2>
80
91
 
81
92
  <step_2_5>
82
- <description>Handle GitHub issue URLs</description>
83
- <condition>If first argument matches GitHub issue URL pattern</condition>
84
- <url_detection>Check if argument contains "github.com" and "/issues/"</url_detection>
93
+ <description>Handle issue URLs from git hosting provider</description>
94
+ <condition>If first argument matches issue URL pattern (detected in step_0)</condition>
95
+ <url_detection>
96
+ <github>Check if argument contains "github.com" and "/issues/"</github>
97
+ <gitlab>Check if argument contains "gitlab.com" and "/-/issues/"</gitlab>
98
+ <bitbucket>Check if argument contains "bitbucket.org" and "/issues/"</bitbucket>
99
+ </url_detection>
85
100
  <url_parsing>
86
- <pattern>https://github.com/{owner}/{repo}/issues/{issue_number}</pattern>
101
+ <github_pattern><https://github.com/{owner}/{repo}/issues/{issue_number}></github_pattern>
102
+ <gitlab_pattern><https://gitlab.com/{owner}/{repo}/-/issues/{issue_number}></gitlab_pattern>
103
+ <bitbucket_pattern><https://bitbucket.org/{owner}/{repo}/issues/{issue_number}></bitbucket_pattern>
87
104
  <extract>owner, repo, issue_number from URL</extract>
88
105
  </url_parsing>
89
106
  <fetch_issue_details>
90
- <tool>mcp__github__issue_read</tool>
91
- <method>get</method>
107
+ <tool>Use $GIT_HOST_TOOL from step_0</tool>
108
+ <method>get issue details</method>
92
109
  <parameters>owner, repo, issue_number</parameters>
93
110
  </fetch_issue_details>
94
111
  <generate_branch_name>
95
112
  <determine_type>Analyze issue title/labels to determine type (feat/fix/refactor/chore)</determine_type>
96
- <format>{type}/{repo}-{issue_number}-{kebab-case-title}</format>
113
+ <format>{type}/issue-{issue_number}-{kebab-case-title}</format>
97
114
  <kebab_case>Convert title to lowercase, replace spaces/special chars with hyphens</kebab_case>
98
115
  <sanitization>
99
116
  <rule>Always use lowercase for branch names</rule>
@@ -116,12 +133,12 @@ Uncommitted changes: !git status --short`
116
133
  <title>"Fix duplicate items in list view"</title>
117
134
  <generated>fix/issue-456-duplicate-items-in-list-view</generated>
118
135
  </examples>
119
- </step_1_5>
136
+ </step_2_5>
120
137
 
121
138
  <step_3>
122
139
  <description>Add all files and stash uncommitted changes if any exist</description>
123
140
  <condition>If output is not empty (has uncommitted changes)</condition>
124
- <command>git add -A && git stash push -m "Worktree switch: Moving changes to ${branch_name}"</chained_command>
141
+ <command>git add -A && git stash push -m "Worktree switch: Moving changes to ${branch_name}"</command>
125
142
  <purpose>Preserve work in progress before switching worktrees</purpose>
126
143
  <note>Remember stash was created for later restoration</note>
127
144
  </step_3>
@@ -140,20 +157,20 @@ Uncommitted changes: !git status --short`
140
157
  <step_5>
141
158
  <description>Fetch latest changes from remote</description>
142
159
  <command>git fetch origin</command>
143
- <purpose>Ensure we have the latest remote branches and main branch state</purpose>
144
- <note>This ensures new worktrees are created from the most recent main branch</note>
145
- </step_6>
160
+ <purpose>Ensure we have the latest remote branches and default branch state</purpose>
161
+ <note>This ensures new worktrees are created from the most recent default branch</note>
162
+ </step_5>
146
163
 
147
- <step_7>
164
+ <step_6>
148
165
  <description>Check if branch exists on remote</description>
149
166
  <command>git branch -r | grep "origin/${branch_name}"</command>
150
167
  <decision>
151
168
  <if_exists>Branch exists on remote - will checkout existing branch</if_exists>
152
169
  <if_not_exists>Branch does not exist - will create new branch from base</if_not_exists>
153
170
  </decision>
154
- </step_5>
171
+ </step_6>
155
172
 
156
- <step_6>
173
+ <step_7>
157
174
  <description>Create the worktree</description>
158
175
  <option_a_new_branch>
159
176
  <condition>Remote branch does NOT exist</condition>
@@ -247,7 +264,7 @@ EOF</create_file_command>
247
264
  </ide_specific_behavior>
248
265
  <purpose>Launch development environment for the new worktree using detected IDE</purpose>
249
266
  <confirmation_message>Opening worktree in ${ide_name}</confirmation_message>
250
- </step_11>
267
+ </step_13>
251
268
  </execution_steps>
252
269
 
253
270
  <important_notes>
@@ -262,4 +279,11 @@ EOF</create_file_command>
262
279
  - Uncommitted changes are automatically stashed and moved to the new worktree
263
280
  - Your work-in-progress seamlessly transfers to the new branch
264
281
  - IDE detection fallback: checks available editors and uses priority order
282
+
283
+ Limitations:
284
+
285
+ - Assumes remote is named "origin" (most common convention)
286
+ - Supports macOS and Linux only (no Windows support)
287
+ - Requires MCP server or CLI for git hosting provider when using issue URLs (GitHub, GitLab, etc.)
288
+ - Dependency install command is pnpm (modify for npm/yarn if needed)
265
289
  </important_notes>