@wbern/claude-instructions 1.20.0 → 2.0.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.
- package/README.md +5 -25
- package/bin/cli.js +345 -196
- package/package.json +2 -3
- package/src/README.md +279 -0
- package/src/fragments/aaa-pattern.md +7 -0
- package/src/fragments/beads-awareness.md +1 -0
- package/src/fragments/beads-integration.md +8 -0
- package/{downloads/without-beads/commit.md → src/fragments/commit-process.md} +0 -17
- package/src/fragments/consistency-check.md +1 -0
- package/src/fragments/discovery-phase.md +22 -0
- package/src/fragments/fallback-arguments-beads.md +3 -0
- package/src/fragments/fallback-arguments.md +1 -0
- package/src/fragments/fullwidth-dollar-note.md +1 -0
- package/src/fragments/gap-beads.md +1 -0
- package/src/fragments/git-host-detection.md +19 -0
- package/src/fragments/github-issue-fetch.md +10 -0
- package/src/fragments/peeping-tom-warning.md +9 -0
- package/src/fragments/plan-beads-context-hint.md +1 -0
- package/src/fragments/plan-beads-details.md +49 -0
- package/src/fragments/plan-beads-integration.md +2 -0
- package/src/fragments/summarize-beads.md +8 -0
- package/{downloads/without-beads/summarize.md → src/fragments/summarize-structure.md} +0 -20
- package/{downloads/without-beads/tdd.md → src/fragments/tdd-fundamentals.md} +0 -21
- package/src/fragments/test-quality-criteria.md +24 -0
- package/src/fragments/universal-guidelines.md +6 -0
- package/{downloads/without-beads → src/sources}/add-command.md +11 -25
- package/{downloads/without-beads → src/sources}/ask.md +11 -6
- package/{downloads/without-beads → src/sources}/beepboop.md +7 -6
- package/{downloads/without-beads → src/sources}/busycommit.md +9 -36
- package/{downloads/without-beads → src/sources}/code-review.md +16 -30
- package/src/sources/commit.md +20 -0
- package/src/sources/cycle.md +23 -0
- package/{downloads/without-beads → src/sources}/gap.md +11 -8
- package/src/sources/green.md +23 -0
- package/src/sources/issue.md +42 -0
- package/{downloads/without-beads → src/sources}/kata.md +10 -9
- package/{downloads/without-beads → src/sources}/plan.md +18 -39
- package/{downloads/without-beads → src/sources}/pr.md +10 -6
- package/src/sources/red.md +26 -0
- package/src/sources/refactor.md +27 -0
- package/{downloads/without-beads → src/sources}/ship.md +11 -6
- package/{downloads/without-beads → src/sources}/show.md +11 -6
- package/src/sources/spike.md +23 -0
- package/src/sources/summarize.md +23 -0
- package/{downloads/without-beads → src/sources}/tdd-review.md +11 -31
- package/src/sources/tdd.md +24 -0
- package/{downloads/without-beads → src/sources}/worktree-add.md +13 -31
- package/{downloads/without-beads → src/sources}/worktree-cleanup.md +9 -27
- package/downloads/with-beads/add-command.md +0 -159
- package/downloads/with-beads/ask.md +0 -144
- package/downloads/with-beads/beepboop.md +0 -47
- package/downloads/with-beads/busycommit.md +0 -78
- package/downloads/with-beads/code-review.md +0 -263
- package/downloads/with-beads/commands-metadata.json +0 -155
- package/downloads/with-beads/commit.md +0 -49
- package/downloads/with-beads/cycle.md +0 -95
- package/downloads/with-beads/gap.md +0 -38
- package/downloads/with-beads/green.md +0 -95
- package/downloads/with-beads/issue.md +0 -152
- package/downloads/with-beads/kata.md +0 -444
- package/downloads/with-beads/plan.md +0 -186
- package/downloads/with-beads/pr.md +0 -82
- package/downloads/with-beads/red.md +0 -103
- package/downloads/with-beads/refactor.md +0 -105
- package/downloads/with-beads/ship.md +0 -98
- package/downloads/with-beads/show.md +0 -114
- package/downloads/with-beads/spike.md +0 -95
- package/downloads/with-beads/summarize.md +0 -54
- package/downloads/with-beads/tdd-review.md +0 -102
- package/downloads/with-beads/tdd.md +0 -94
- package/downloads/with-beads/worktree-add.md +0 -357
- package/downloads/with-beads/worktree-cleanup.md +0 -250
- package/downloads/without-beads/commands-metadata.json +0 -155
- package/downloads/without-beads/cycle.md +0 -90
- package/downloads/without-beads/green.md +0 -90
- package/downloads/without-beads/issue.md +0 -140
- package/downloads/without-beads/red.md +0 -98
- package/downloads/without-beads/refactor.md +0 -100
- package/downloads/without-beads/spike.md +0 -90
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Review test suite quality against FIRST principles and TDD anti-patterns
|
|
3
|
-
argument-hint: [optional test file or directory path]
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
## General Guidelines
|
|
7
|
-
|
|
8
|
-
### Output Style
|
|
9
|
-
|
|
10
|
-
- **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
|
|
11
|
-
- Write natural, descriptive code without meta-commentary about the development process
|
|
12
|
-
- The code should speak for itself - TDD is the process, not the product
|
|
13
|
-
|
|
14
|
-
Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands).
|
|
15
|
-
|
|
16
|
-
(If there was no info above, fallback to:
|
|
17
|
-
|
|
18
|
-
1. Context of the conversation, if there's an immediate thing
|
|
19
|
-
2. `bd ready` to see what to work on next and start from there)
|
|
20
|
-
|
|
21
|
-
# Test Quality Review
|
|
22
|
-
|
|
23
|
-
Analyze test files against FIRST principles and TDD best practices.
|
|
24
|
-
|
|
25
|
-
## Phase 1: Scope
|
|
26
|
-
|
|
27
|
-
| Input | Action |
|
|
28
|
-
|-------|--------|
|
|
29
|
-
| No argument | Find all test files in project |
|
|
30
|
-
| File path | Analyze specific test file |
|
|
31
|
-
| Directory | Analyze tests in directory |
|
|
32
|
-
|
|
33
|
-
Detect test files using common patterns: `*.test.*`, `*.spec.*`, `*.stories.*`, `__tests__/**`
|
|
34
|
-
|
|
35
|
-
Also check for framework-specific patterns based on the project's languages and tools (e.g., `*_test.go`, `*_test.py`, `Test*.java`, `*.feature` for BDD).
|
|
36
|
-
|
|
37
|
-
## Phase 2: Analysis
|
|
38
|
-
|
|
39
|
-
For each test file, check against these criteria:
|
|
40
|
-
|
|
41
|
-
### Quality Criteria
|
|
42
|
-
|
|
43
|
-
#### FIRST Principles
|
|
44
|
-
|
|
45
|
-
| Principle | What to Check |
|
|
46
|
-
|-----------|---------------|
|
|
47
|
-
| **Fast** | Tests complete quickly, no I/O, no network calls, no sleep()/setTimeout delays |
|
|
48
|
-
| **Independent** | No shared mutable state, no execution order dependencies between tests |
|
|
49
|
-
| **Repeatable** | No Date.now(), no Math.random() without seeding, no external service dependencies |
|
|
50
|
-
| **Self-validating** | Meaningful assertions that verify behavior, no manual verification needed |
|
|
51
|
-
|
|
52
|
-
#### TDD Anti-patterns
|
|
53
|
-
|
|
54
|
-
| Anti-pattern | Detection Signals |
|
|
55
|
-
|--------------|-------------------|
|
|
56
|
-
| **The Liar** | `expect(true).toBe(true)`, empty test bodies, tests with no assertions |
|
|
57
|
-
| **Excessive Setup** | >20 lines of arrange code, >5 mocks, deep nested object construction |
|
|
58
|
-
| **The One** | >5 assertions testing unrelated behaviors in a single test |
|
|
59
|
-
| **The Peeping Tom** | Testing private methods, asserting on internal state, tests that break on any refactor |
|
|
60
|
-
| **The Slow Poke** | Real database/network calls, file I/O, hard-coded timeouts |
|
|
61
|
-
|
|
62
|
-
#### Test Structure (AAA Pattern)
|
|
63
|
-
|
|
64
|
-
- **Arrange**: Clear setup with minimal fixtures
|
|
65
|
-
- **Act**: Single action being tested
|
|
66
|
-
- **Assert**: Specific, behavior-focused assertions
|
|
67
|
-
|
|
68
|
-
## Phase 3: Report
|
|
69
|
-
|
|
70
|
-
Output a structured report:
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
## Test Quality Report
|
|
74
|
-
|
|
75
|
-
### Summary
|
|
76
|
-
- Files analyzed: N
|
|
77
|
-
- Tests found: N
|
|
78
|
-
- Issues found: N (X blockers, Y warnings)
|
|
79
|
-
|
|
80
|
-
### By File
|
|
81
|
-
|
|
82
|
-
#### path/to/file.test.ts
|
|
83
|
-
|
|
84
|
-
| Line | Issue | Severity | Description |
|
|
85
|
-
|------|-------|----------|-------------|
|
|
86
|
-
| 15 | The Liar | blocker | Test has no assertions |
|
|
87
|
-
| 42 | Slow Poke | warning | Uses setTimeout(500) |
|
|
88
|
-
|
|
89
|
-
### Recommendations
|
|
90
|
-
- [ ] Fix blockers before merge
|
|
91
|
-
- [ ] Consider refactoring tests with excessive setup
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Severity Levels
|
|
95
|
-
|
|
96
|
-
- **blocker**: Must fix - test provides false confidence (The Liar, no assertions)
|
|
97
|
-
- **warning**: Should fix - test quality issue (Slow Poke, Excessive Setup)
|
|
98
|
-
- **info**: Consider - style or structure suggestion (AAA pattern)
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
Test path (leave empty for all tests): $ARGUMENTS
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Remind agent about TDD approach and continue conversation
|
|
3
|
-
argument-hint: [optional-response-to-last-message]
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# TDD Reminder
|
|
7
|
-
|
|
8
|
-
## General Guidelines
|
|
9
|
-
|
|
10
|
-
### Output Style
|
|
11
|
-
|
|
12
|
-
- **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
|
|
13
|
-
- Write natural, descriptive code without meta-commentary about the development process
|
|
14
|
-
- The code should speak for itself - TDD is the process, not the product
|
|
15
|
-
|
|
16
|
-
Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands).
|
|
17
|
-
|
|
18
|
-
## TDD Fundamentals
|
|
19
|
-
|
|
20
|
-
### The TDD Cycle
|
|
21
|
-
|
|
22
|
-
The foundation of TDD is the Red-Green-Refactor cycle:
|
|
23
|
-
|
|
24
|
-
1. **Red Phase**: Write ONE failing test that describes desired behavior
|
|
25
|
-
|
|
26
|
-
- The test must fail for the RIGHT reason (not syntax/import errors)
|
|
27
|
-
- Only one test at a time - this is critical for TDD discipline
|
|
28
|
-
- Exception: For browser-level tests or expensive setup (e.g., Storybook `*.stories.tsx`), group multiple assertions within a single test block to avoid redundant setup - but only when adding assertions to an existing interaction flow. If new user interactions are required, still create a new test. Split files by category if they exceed ~1000 lines.
|
|
29
|
-
- **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed
|
|
30
|
-
- Starting TDD for a new feature is always valid, even if test output shows unrelated work
|
|
31
|
-
- For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content
|
|
32
|
-
- Avoid hard-coded timeouts both in form of sleep() or timeout: 5000 etc; use proper async patterns (`waitFor`, `findBy*`, event-based sync) instead and rely on global test configs for timeout settings
|
|
33
|
-
|
|
34
|
-
2. **Green Phase**: Write MINIMAL code to make the test pass
|
|
35
|
-
|
|
36
|
-
- Implement only what's needed for the current failing test
|
|
37
|
-
- No anticipatory coding or extra features
|
|
38
|
-
- Address the specific failure message
|
|
39
|
-
|
|
40
|
-
3. **Refactor Phase**: Improve code structure while keeping tests green
|
|
41
|
-
- Only allowed when relevant tests are passing
|
|
42
|
-
- Requires proof that tests have been run and are green
|
|
43
|
-
- Applies to BOTH implementation and test code
|
|
44
|
-
- No refactoring with failing tests - fix them first
|
|
45
|
-
|
|
46
|
-
### Core Violations
|
|
47
|
-
|
|
48
|
-
1. **Multiple Test Addition**
|
|
49
|
-
|
|
50
|
-
- Adding more than one new test at once
|
|
51
|
-
- Exception: Initial test file setup or extracting shared test utilities
|
|
52
|
-
|
|
53
|
-
2. **Over-Implementation**
|
|
54
|
-
|
|
55
|
-
- Code that exceeds what's needed to pass the current failing test
|
|
56
|
-
- Adding untested features, methods, or error handling
|
|
57
|
-
- Implementing multiple methods when test only requires one
|
|
58
|
-
|
|
59
|
-
3. **Premature Implementation**
|
|
60
|
-
- Adding implementation before a test exists and fails properly
|
|
61
|
-
- Adding implementation without running the test first
|
|
62
|
-
- Refactoring when tests haven't been run or are failing
|
|
63
|
-
|
|
64
|
-
### Critical Principle: Incremental Development
|
|
65
|
-
|
|
66
|
-
Each step in TDD should address ONE specific issue:
|
|
67
|
-
|
|
68
|
-
- Test fails "not defined" → Create empty stub/class only
|
|
69
|
-
- Test fails "not a function" → Add method stub only
|
|
70
|
-
- Test fails with assertion → Implement minimal logic only
|
|
71
|
-
|
|
72
|
-
### Optional Pre-Phase: Spike Phase
|
|
73
|
-
|
|
74
|
-
In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.
|
|
75
|
-
This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.
|
|
76
|
-
|
|
77
|
-
- The goal of a Spike is **exploration and learning**, not implementation.
|
|
78
|
-
- The code written during a Spike is **disposable** and **must not** be merged or reused directly.
|
|
79
|
-
- Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.
|
|
80
|
-
- A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
|
|
81
|
-
|
|
82
|
-
### General Information
|
|
83
|
-
|
|
84
|
-
- Sometimes the test output shows as no tests have been run when a new test is failing due to a missing import or constructor. In such cases, allow the agent to create simple stubs. Ask them if they forgot to create a stub if they are stuck.
|
|
85
|
-
- It is never allowed to introduce new logic without evidence of relevant failing tests. However, stubs and simple implementation to make imports and test infrastructure work is fine.
|
|
86
|
-
- In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
|
|
87
|
-
- Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
|
|
88
|
-
- Provide the agent with helpful directions so that they do not get stuck when blocking them.
|
|
89
|
-
|
|
90
|
-
## Continue Conversation
|
|
91
|
-
|
|
92
|
-
User response to the last message: $ARGUMENTS
|
|
93
|
-
|
|
94
|
-
Please continue with TDD approach based on the above response.
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
---
|
|
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
|
-
---
|
|
5
|
-
|
|
6
|
-
# Git Worktree Setup
|
|
7
|
-
|
|
8
|
-
## General Guidelines
|
|
9
|
-
|
|
10
|
-
### Output Style
|
|
11
|
-
|
|
12
|
-
- **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
|
|
13
|
-
- Write natural, descriptive code without meta-commentary about the development process
|
|
14
|
-
- The code should speak for itself - TDD is the process, not the product
|
|
15
|
-
|
|
16
|
-
Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands).
|
|
17
|
-
|
|
18
|
-
Create a new git worktree for branch: $ARGUMENTS
|
|
19
|
-
|
|
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`
|
|
25
|
-
</current_state>
|
|
26
|
-
|
|
27
|
-
<execution_steps>
|
|
28
|
-
<step_0>
|
|
29
|
-
<description>Ask user for setup mode</description>
|
|
30
|
-
<prompt>
|
|
31
|
-
<message>How would you like to set up the worktree?</message>
|
|
32
|
-
<options>
|
|
33
|
-
<option value="quick">
|
|
34
|
-
<label>Quick</label>
|
|
35
|
-
<description>Just create the worktree (skip deps, settings, IDE)</description>
|
|
36
|
-
</option>
|
|
37
|
-
<option value="full">
|
|
38
|
-
<label>Full setup</label>
|
|
39
|
-
<description>Install dependencies, copy settings, open in IDE</description>
|
|
40
|
-
</option>
|
|
41
|
-
</options>
|
|
42
|
-
</prompt>
|
|
43
|
-
<set_variable>$SETUP_MODE = user selection ("quick" or "full")</set_variable>
|
|
44
|
-
<purpose>Allow quick worktree creation when user just needs the branch</purpose>
|
|
45
|
-
</step_0>
|
|
46
|
-
|
|
47
|
-
<step_0b>
|
|
48
|
-
<description>Detect git hosting provider and available tools (only needed if argument is an issue URL)</description>
|
|
49
|
-
<condition>Only run this step if first argument looks like a git hosting URL</condition>
|
|
50
|
-
<detect_provider>
|
|
51
|
-
<check_remote_url>git remote get-url origin</check_remote_url>
|
|
52
|
-
<identify_host>
|
|
53
|
-
- github.com → GitHub
|
|
54
|
-
- gitlab.com → GitLab
|
|
55
|
-
- bitbucket.org → Bitbucket
|
|
56
|
-
- Other → Ask user
|
|
57
|
-
</identify_host>
|
|
58
|
-
</detect_provider>
|
|
59
|
-
<check_available_tools>
|
|
60
|
-
<list_mcp_servers>Check which git-hosting MCP servers are available (github, gitlab, etc.)</list_mcp_servers>
|
|
61
|
-
<check_cli>Check if gh/glab CLI is available as fallback</check_cli>
|
|
62
|
-
</check_available_tools>
|
|
63
|
-
<select_tool>
|
|
64
|
-
<if_single_mcp>If only one relevant MCP available, confirm with user</if_single_mcp>
|
|
65
|
-
<if_multiple>Let user choose which tool to use</if_multiple>
|
|
66
|
-
<if_told_earlier>If user specified tool earlier in conversation, use that without asking again</if_told_earlier>
|
|
67
|
-
<store_as>$GIT_HOST_TOOL (e.g., "github_mcp", "gitlab_mcp", "gh_cli")</store_as>
|
|
68
|
-
</select_tool>
|
|
69
|
-
|
|
70
|
-
<purpose>Detect git hosting provider and select appropriate tool for issue lookup</purpose>
|
|
71
|
-
</step_0b>
|
|
72
|
-
|
|
73
|
-
<step_1>
|
|
74
|
-
<description>Detect current IDE environment</description>
|
|
75
|
-
<condition>Only if $SETUP_MODE is "full"</condition>
|
|
76
|
-
<detection_methods>
|
|
77
|
-
<method_1>
|
|
78
|
-
<tool>mcp__ide__getDiagnostics</tool>
|
|
79
|
-
<vs_code_insiders>Check for paths containing "Code - Insiders"</vs_code_insiders>
|
|
80
|
-
<vs_code>Check for paths containing "Code/" or "Code.app"</vs_code>
|
|
81
|
-
<cursor>Check for paths containing "Cursor"</cursor>
|
|
82
|
-
<zed>Check for paths containing "Zed"</zed>
|
|
83
|
-
</method_1>
|
|
84
|
-
<method_2>
|
|
85
|
-
<fallback_detection>Use which command to find available IDEs</fallback_detection>
|
|
86
|
-
<commands>which code-insiders code zed cursor</commands>
|
|
87
|
-
<priority_order>code-insiders > cursor > zed > code</priority_order>
|
|
88
|
-
</method_2>
|
|
89
|
-
</detection_methods>
|
|
90
|
-
<set_variables>
|
|
91
|
-
<ide_command>Detected command (code-insiders|code|zed|cursor)</ide_command>
|
|
92
|
-
<ide_name>Human-readable name</ide_name>
|
|
93
|
-
<supports_tasks>true for VS Code variants, false for others</supports_tasks>
|
|
94
|
-
</set_variables>
|
|
95
|
-
<purpose>Automatically detect which IDE to use for opening the new worktree</purpose>
|
|
96
|
-
</step_1>
|
|
97
|
-
|
|
98
|
-
<step_2>
|
|
99
|
-
<description>Determine default branch and parse arguments</description>
|
|
100
|
-
<find_default_branch>
|
|
101
|
-
<command>git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'</command>
|
|
102
|
-
<fallback>git remote show origin | grep 'HEAD branch' | cut -d: -f2 | tr -d ' '</fallback>
|
|
103
|
-
<store_as>$DEFAULT_BRANCH (typically "main" or "master")</store_as>
|
|
104
|
-
</find_default_branch>
|
|
105
|
-
<input>The user-provided arguments</input>
|
|
106
|
-
<expected_format>branch-name-or-issue-url [optional-base-branch]</expected_format>
|
|
107
|
-
<example>fix/issue-123-main-content-area-visually-clipped main</example>
|
|
108
|
-
<example_issue_url>https://github.com/owner/project/issues/123 main</example_issue_url>
|
|
109
|
-
<base_branch>Use provided base branch, or $DEFAULT_BRANCH if not specified</base_branch>
|
|
110
|
-
</step_2>
|
|
111
|
-
|
|
112
|
-
<step_2_5>
|
|
113
|
-
<description>Handle issue URLs from git hosting provider</description>
|
|
114
|
-
<condition>If first argument matches issue URL pattern (detected in step_0)</condition>
|
|
115
|
-
<url_detection>
|
|
116
|
-
<github>Check if argument contains "github.com" and "/issues/"</github>
|
|
117
|
-
<gitlab>Check if argument contains "gitlab.com" and "/-/issues/"</gitlab>
|
|
118
|
-
<bitbucket>Check if argument contains "bitbucket.org" and "/issues/"</bitbucket>
|
|
119
|
-
</url_detection>
|
|
120
|
-
<url_parsing>
|
|
121
|
-
<github_pattern><https://github.com/{owner}/{repo}/issues/{issue_number}></github_pattern>
|
|
122
|
-
<gitlab_pattern><https://gitlab.com/{owner}/{repo}/-/issues/{issue_number}></gitlab_pattern>
|
|
123
|
-
<bitbucket_pattern><https://bitbucket.org/{owner}/{repo}/issues/{issue_number}></bitbucket_pattern>
|
|
124
|
-
<extract>owner, repo, issue_number from URL</extract>
|
|
125
|
-
</url_parsing>
|
|
126
|
-
<fetch_issue_details>
|
|
127
|
-
<tool>Use $GIT_HOST_TOOL from step_0</tool>
|
|
128
|
-
<method>get issue details</method>
|
|
129
|
-
<parameters>owner, repo, issue_number</parameters>
|
|
130
|
-
</fetch_issue_details>
|
|
131
|
-
<generate_branch_name>
|
|
132
|
-
<determine_type>Analyze issue title/labels to determine type (feat/fix/refactor/chore)</determine_type>
|
|
133
|
-
<format>{type}/issue-{issue_number}-{kebab-case-title}</format>
|
|
134
|
-
<kebab_case>Convert title to lowercase, replace spaces/special chars with hyphens</kebab_case>
|
|
135
|
-
<sanitization>
|
|
136
|
-
<rule>Always use lowercase for branch names</rule>
|
|
137
|
-
<rule>Replace # with - (hash symbol not allowed in git branch names)</rule>
|
|
138
|
-
<rule>Remove or replace other special characters: @, $, %, ^, &, *, (, ), [, ], {, }, \, |, ;, :, ", ', <, >, ?, /, ~, `</rule>
|
|
139
|
-
<rule>Replace multiple consecutive hyphens with single hyphen</rule>
|
|
140
|
-
<rule>Trim leading/trailing hyphens</rule>
|
|
141
|
-
</sanitization>
|
|
142
|
-
<truncate>Limit total branch name to reasonable length (~60 chars)</truncate>
|
|
143
|
-
</generate_branch_name>
|
|
144
|
-
<user_confirmation>
|
|
145
|
-
<display>Show generated branch name and ask for confirmation</display>
|
|
146
|
-
<options>"Yes, proceed" or "No, exit" or "Edit branch name"</options>
|
|
147
|
-
<if_no>Exit command gracefully</if_no>
|
|
148
|
-
<if_edit>Allow user to modify the branch name</if_edit>
|
|
149
|
-
<if_yes>Continue with generated/modified branch name</if_yes>
|
|
150
|
-
</user_confirmation>
|
|
151
|
-
<examples>
|
|
152
|
-
<input>https://github.com/owner/project/issues/456</input>
|
|
153
|
-
<title>"Fix duplicate items in list view"</title>
|
|
154
|
-
<generated>fix/issue-456-duplicate-items-in-list-view</generated>
|
|
155
|
-
</examples>
|
|
156
|
-
</step_2_5>
|
|
157
|
-
|
|
158
|
-
<step_3>
|
|
159
|
-
<description>Handle uncommitted changes if any exist</description>
|
|
160
|
-
<condition>If git status --short output is not empty (has uncommitted changes)</condition>
|
|
161
|
-
<prompt>
|
|
162
|
-
<message>You have uncommitted changes. Move them to the new branch?</message>
|
|
163
|
-
<options>
|
|
164
|
-
<option value="yes">
|
|
165
|
-
<label>Yes</label>
|
|
166
|
-
<description>Stash changes and apply them in the new worktree</description>
|
|
167
|
-
</option>
|
|
168
|
-
<option value="no">
|
|
169
|
-
<label>No</label>
|
|
170
|
-
<description>Leave changes in current branch</description>
|
|
171
|
-
</option>
|
|
172
|
-
</options>
|
|
173
|
-
</prompt>
|
|
174
|
-
<if_yes>
|
|
175
|
-
<command>git add -A && git stash push -m "Worktree switch: Moving changes to ${branch_name}"</command>
|
|
176
|
-
<set_variable>$STASH_CREATED = true</set_variable>
|
|
177
|
-
</if_yes>
|
|
178
|
-
<if_no>
|
|
179
|
-
<set_variable>$STASH_CREATED = false</set_variable>
|
|
180
|
-
</if_no>
|
|
181
|
-
<purpose>Let user decide whether to move work in progress to new branch</purpose>
|
|
182
|
-
</step_3>
|
|
183
|
-
|
|
184
|
-
<step_4>
|
|
185
|
-
<description>Determine worktree parent directory</description>
|
|
186
|
-
<check_if_in_worktree>git rev-parse --is-inside-work-tree && git worktree list --porcelain | grep "$(git rev-parse --show-toplevel)"</check_if_in_worktree>
|
|
187
|
-
<set_parent_path>
|
|
188
|
-
<if_main_worktree>Set parent_path=".."</if_main_worktree>
|
|
189
|
-
<if_secondary_worktree>Set parent_path="../.." (need to go up two levels)</if_secondary_worktree>
|
|
190
|
-
</set_parent_path>
|
|
191
|
-
<purpose>Correctly determine where to create new worktree regardless of current location</purpose>
|
|
192
|
-
<note>This handles both main worktree and secondary worktree scenarios</note>
|
|
193
|
-
</step_4>
|
|
194
|
-
|
|
195
|
-
<step_5>
|
|
196
|
-
<description>Fetch latest changes from remote</description>
|
|
197
|
-
<command>git fetch origin</command>
|
|
198
|
-
<purpose>Ensure we have the latest remote branches and default branch state</purpose>
|
|
199
|
-
<note>This ensures new worktrees are created from the most recent default branch</note>
|
|
200
|
-
</step_5>
|
|
201
|
-
|
|
202
|
-
<step_6>
|
|
203
|
-
<description>Check if branch exists on remote</description>
|
|
204
|
-
<command>git branch -r | grep "origin/${branch_name}"</command>
|
|
205
|
-
<decision>
|
|
206
|
-
<if_exists>Branch exists on remote - will checkout existing branch</if_exists>
|
|
207
|
-
<if_not_exists>Branch does not exist - will create new branch from base</if_not_exists>
|
|
208
|
-
</decision>
|
|
209
|
-
</step_6>
|
|
210
|
-
|
|
211
|
-
<step_7>
|
|
212
|
-
<description>Create the worktree</description>
|
|
213
|
-
<option_a_new_branch>
|
|
214
|
-
<condition>Remote branch does NOT exist</condition>
|
|
215
|
-
<command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} --no-track ${base_branch}</command>
|
|
216
|
-
<example>git worktree add ../fix/issue-123 -b fix/issue-123 --no-track origin/main</example>
|
|
217
|
-
<note>--no-track prevents git from setting upstream to base_branch (which would make git push target main!)</note>
|
|
218
|
-
</option_a_new_branch>
|
|
219
|
-
<option_b_existing_branch>
|
|
220
|
-
<condition>Remote branch EXISTS</condition>
|
|
221
|
-
<command>git worktree add ${parent_path}/${branch_name} ${branch_name}</command>
|
|
222
|
-
<example>git worktree add ../fix/issue-123-main-content-area-visually-clipped fix/issue-123-main-content-area-visually-clipped</example>
|
|
223
|
-
</option_b_existing_branch>
|
|
224
|
-
</step_7>
|
|
225
|
-
|
|
226
|
-
<step_7b>
|
|
227
|
-
<description>Set up remote tracking for new branch</description>
|
|
228
|
-
<condition>Only if new branch was created (option_a from step_7)</condition>
|
|
229
|
-
<working_directory>${parent_path}/${branch_name}</working_directory>
|
|
230
|
-
<command>cd ${parent_path}/${branch_name} && git push -u origin ${branch_name}</command>
|
|
231
|
-
<purpose>Establish remote tracking so git status shows ahead/behind and git push/pull work without specifying remote</purpose>
|
|
232
|
-
<note>This creates the remote branch and sets upstream tracking in one step</note>
|
|
233
|
-
</step_7b>
|
|
234
|
-
|
|
235
|
-
<step_7c>
|
|
236
|
-
<description>Quick mode completion</description>
|
|
237
|
-
<condition>Only if $SETUP_MODE is "quick"</condition>
|
|
238
|
-
<message>Worktree created at: ${parent_path}/${branch_name}</message>
|
|
239
|
-
<suggested_next_steps>
|
|
240
|
-
<intro>You can now:</intro>
|
|
241
|
-
<suggestion priority="1">Open in VS Code: `code ${parent_path}/${branch_name}`</suggestion>
|
|
242
|
-
<suggestion priority="2">Open in Cursor: `cursor ${parent_path}/${branch_name}`</suggestion>
|
|
243
|
-
<suggestion priority="3">Navigate to it: `cd ${parent_path}/${branch_name}`</suggestion>
|
|
244
|
-
<suggestion priority="4">Install dependencies: `cd ${parent_path}/${branch_name} && pnpm install`</suggestion>
|
|
245
|
-
</suggested_next_steps>
|
|
246
|
-
<action>STOP here - do not continue to remaining steps</action>
|
|
247
|
-
</step_7c>
|
|
248
|
-
|
|
249
|
-
<step_8>
|
|
250
|
-
<description>Copy Claude settings to new worktree</description>
|
|
251
|
-
<condition>Only if $SETUP_MODE is "full"</condition>
|
|
252
|
-
<source>.claude/settings.local.json</source>
|
|
253
|
-
<destination>${parent_path}/${branch_name}/.claude/settings.local.json</destination>
|
|
254
|
-
<command>cp -r .claude/settings.local.json ${parent_path}/${branch_name}/.claude/settings.local.json</command>
|
|
255
|
-
<purpose>Preserve all permission settings and configurations</purpose>
|
|
256
|
-
</step_8>
|
|
257
|
-
|
|
258
|
-
<step_9>
|
|
259
|
-
<description>Copy .env.local files to new worktree</description>
|
|
260
|
-
<condition>Only if $SETUP_MODE is "full"</condition>
|
|
261
|
-
<search_command>find . -name ".env.local" -type f</search_command>
|
|
262
|
-
<copy_logic>For each .env.local file found, copy to corresponding location in new worktree</copy_logic>
|
|
263
|
-
<common_locations>
|
|
264
|
-
- app/.env.local
|
|
265
|
-
- packages/*/.env.local
|
|
266
|
-
- (any other .env.local files found)
|
|
267
|
-
</common_locations>
|
|
268
|
-
<copy_command>find . -name ".env.local" -type f -exec sh -c 'mkdir -p "$(dirname "${parent_path}/${branch_name}/$1")" && cp "$1" "${parent_path}/${branch_name}/$1"'_ {} \;</copy_command>
|
|
269
|
-
<purpose>Preserve local environment configurations for development</purpose>
|
|
270
|
-
<note>Only copies files that exist; ignores missing ones</note>
|
|
271
|
-
</step_9>
|
|
272
|
-
|
|
273
|
-
<step_10>
|
|
274
|
-
<description>Create IDE-specific configuration (conditional)</description>
|
|
275
|
-
<condition>Only if $SETUP_MODE is "full" AND supports_tasks is true (VS Code variants)</condition>
|
|
276
|
-
<vs_code_tasks>
|
|
277
|
-
<create_directory>mkdir -p ${parent_path}/${branch_name}/.vscode</create_directory>
|
|
278
|
-
<create_file_command>cat > ${parent_path}/${branch_name}/.vscode/tasks.json << 'EOF'
|
|
279
|
-
{
|
|
280
|
-
"version": "2.0.0",
|
|
281
|
-
"tasks": [
|
|
282
|
-
{
|
|
283
|
-
"label": "Auto start Claude",
|
|
284
|
-
"type": "shell",
|
|
285
|
-
"command": "claude",
|
|
286
|
-
"runOptions": {
|
|
287
|
-
"runOn": "folderOpen"
|
|
288
|
-
},
|
|
289
|
-
"presentation": {
|
|
290
|
-
"echo": false,
|
|
291
|
-
"reveal": "always",
|
|
292
|
-
"focus": true,
|
|
293
|
-
"panel": "new"
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
]
|
|
297
|
-
}
|
|
298
|
-
EOF</create_file_command>
|
|
299
|
-
</vs_code_tasks>
|
|
300
|
-
<purpose>Create auto-start Claude task for VS Code variants on folder open</purpose>
|
|
301
|
-
<note>Only creates for VS Code variants (code, code-insiders, cursor)</note>
|
|
302
|
-
<skip_message>Skipping IDE-specific config for non-VS Code IDEs</skip_message>
|
|
303
|
-
</step_10>
|
|
304
|
-
|
|
305
|
-
<step_11>
|
|
306
|
-
<description>Install dependencies in new worktree</description>
|
|
307
|
-
<condition>Only if $SETUP_MODE is "full"</condition>
|
|
308
|
-
<working_directory>${parent_path}/${branch_name}</working_directory>
|
|
309
|
-
<command>cd ${parent_path}/${branch_name} && pnpm install</command>
|
|
310
|
-
<purpose>Ensure all node_modules are installed for the new worktree</purpose>
|
|
311
|
-
</step_11>
|
|
312
|
-
|
|
313
|
-
<step_12>
|
|
314
|
-
<description>Apply stashed changes to new worktree (if stash was created)</description>
|
|
315
|
-
<condition>Only if $SETUP_MODE is "full" AND $STASH_CREATED is true</condition>
|
|
316
|
-
<working_directory>${parent_path}/${branch_name}</working_directory>
|
|
317
|
-
<command>cd ${parent_path}/${branch_name} && git stash pop</command>
|
|
318
|
-
<purpose>Restore uncommitted work-in-progress to the new worktree branch</purpose>
|
|
319
|
-
<note>This moves your uncommitted changes to the new branch where you'll continue working</note>
|
|
320
|
-
</step_12>
|
|
321
|
-
|
|
322
|
-
<step_13>
|
|
323
|
-
<description>Open detected IDE in new worktree</description>
|
|
324
|
-
<condition>Only if $SETUP_MODE is "full"</condition>
|
|
325
|
-
<command>${ide_command} ${parent_path}/${branch_name}</command>
|
|
326
|
-
<ide_specific_behavior>
|
|
327
|
-
<vs_code_variants>Opens folder in VS Code/Insiders/Cursor with tasks.json auto-starting Claude</vs_code_variants>
|
|
328
|
-
<zed>Opens folder in Zed editor</zed>
|
|
329
|
-
<other>Uses detected IDE command to open folder</other>
|
|
330
|
-
</ide_specific_behavior>
|
|
331
|
-
<purpose>Launch development environment for the new worktree using detected IDE</purpose>
|
|
332
|
-
<confirmation_message>Opening worktree in ${ide_name}</confirmation_message>
|
|
333
|
-
</step_13>
|
|
334
|
-
</execution_steps>
|
|
335
|
-
|
|
336
|
-
<important_notes>
|
|
337
|
-
|
|
338
|
-
- Offers Quick or Full setup mode - Quick just creates the worktree, Full does everything
|
|
339
|
-
- Automatically detects and uses your current IDE (VS Code, VS Code Insiders, Cursor, Zed, etc.) in Full mode
|
|
340
|
-
- Creates VS Code-specific tasks.json only for VS Code variants (auto-starts Claude on folder open)
|
|
341
|
-
- Branch names with slashes (feat/, fix/, etc.) are fully supported
|
|
342
|
-
- The worktree directory path will match the full branch name including slashes
|
|
343
|
-
- Settings are copied to maintain the same permissions across worktrees
|
|
344
|
-
- Environment files (.env.local) are copied to preserve local configurations
|
|
345
|
-
- Each worktree has its own node_modules installation
|
|
346
|
-
- Uncommitted changes are automatically stashed and moved to the new worktree
|
|
347
|
-
- Your work-in-progress seamlessly transfers to the new branch
|
|
348
|
-
- IDE detection fallback: checks available editors and uses priority order
|
|
349
|
-
- New branches are automatically pushed with `-u` to set up remote tracking
|
|
350
|
-
|
|
351
|
-
Limitations:
|
|
352
|
-
|
|
353
|
-
- Assumes remote is named "origin" (most common convention)
|
|
354
|
-
- Supports macOS and Linux only (no Windows support)
|
|
355
|
-
- Requires MCP server or CLI for git hosting provider when using issue URLs (GitHub, GitLab, etc.)
|
|
356
|
-
- Dependency install command is pnpm (modify for npm/yarn if needed)
|
|
357
|
-
</important_notes>
|