@wbern/claude-instructions 1.0.1

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.
Files changed (37) hide show
  1. package/README.md +411 -0
  2. package/bin/cli.js +99 -0
  3. package/downloads/with-beads/add-command.md +130 -0
  4. package/downloads/with-beads/ask.md +134 -0
  5. package/downloads/with-beads/beepboop.md +54 -0
  6. package/downloads/with-beads/commit.md +47 -0
  7. package/downloads/with-beads/cycle.md +89 -0
  8. package/downloads/with-beads/green.md +89 -0
  9. package/downloads/with-beads/issue.md +141 -0
  10. package/downloads/with-beads/plan.md +167 -0
  11. package/downloads/with-beads/red.md +85 -0
  12. package/downloads/with-beads/refactor.md +87 -0
  13. package/downloads/with-beads/ship.md +93 -0
  14. package/downloads/with-beads/show.md +107 -0
  15. package/downloads/with-beads/spike.md +89 -0
  16. package/downloads/with-beads/summarize.md +38 -0
  17. package/downloads/with-beads/tdd.md +89 -0
  18. package/downloads/with-beads/worktree-add.md +262 -0
  19. package/downloads/with-beads/worktree-cleanup.md +226 -0
  20. package/downloads/without-beads/add-command.md +130 -0
  21. package/downloads/without-beads/ask.md +126 -0
  22. package/downloads/without-beads/beepboop.md +46 -0
  23. package/downloads/without-beads/commit.md +47 -0
  24. package/downloads/without-beads/cycle.md +89 -0
  25. package/downloads/without-beads/green.md +89 -0
  26. package/downloads/without-beads/issue.md +133 -0
  27. package/downloads/without-beads/plan.md +107 -0
  28. package/downloads/without-beads/red.md +85 -0
  29. package/downloads/without-beads/refactor.md +87 -0
  30. package/downloads/without-beads/ship.md +85 -0
  31. package/downloads/without-beads/show.md +99 -0
  32. package/downloads/without-beads/spike.md +89 -0
  33. package/downloads/without-beads/summarize.md +30 -0
  34. package/downloads/without-beads/tdd.md +89 -0
  35. package/downloads/without-beads/worktree-add.md +262 -0
  36. package/downloads/without-beads/worktree-cleanup.md +226 -0
  37. package/package.json +65 -0
@@ -0,0 +1,262 @@
1
+ ---
2
+ allowed-tools: Bash(code-insiders:*), Bash(code:*), Bash(zed:*), Bash(cursor:*), Bash(which:*), Read, mcp__github__issue_read, mcp__ide__getDiagnostics, ListMcpResourcesTool
3
+ description: Add a new git worktree from branch name or GitHub issue URL, copy settings, install deps, and open in current IDE
4
+ argument-hint: <branch-name-or-github-issue-url> [optional-base-branch]
5
+ ---
6
+
7
+ # Git Worktree Setup
8
+
9
+ ## General Guidelines
10
+
11
+ ### Output Style
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
+ Create a new git worktree for branch: $ARGUMENTS
17
+
18
+ <current_state>
19
+ Current branch: !git branch --show-current`
20
+ Current worktrees: !git worktree list`
21
+ Remote branches: !git branch -r`
22
+ Uncommitted changes: !git status --short`
23
+ </current_state>
24
+
25
+ <execution_steps>
26
+ <step_0>
27
+ <description>Validate MCP dependencies</description>
28
+ <check_github_mcp>
29
+ <requirement>GitHub MCP server must be configured</requirement>
30
+ <fallback>If unavailable, use `gh` CLI commands</fallback>
31
+ <validation>
32
+ - Try listing available MCP resources
33
+ - If GitHub MCP not found, switch to CLI fallback
34
+ - Inform user about MCP configuration if needed
35
+ </validation>
36
+ </check_github_mcp>
37
+ <error_handling>
38
+ If MCP validation fails:
39
+ - Show clear error message
40
+ - Provide setup instructions
41
+ - Fallback to CLI if possible
42
+ </error_handling>
43
+ <purpose>Ensure required MCP dependencies are available before proceeding</purpose>
44
+ </step_0>
45
+
46
+ <step_1>
47
+ <description>Detect current IDE environment</description>
48
+ <detection_methods>
49
+ <method_1>
50
+ <tool>mcp__ide__getDiagnostics</tool>
51
+ <vs_code_insiders>Check for paths containing "Code - Insiders"</vs_code_insiders>
52
+ <vs_code>Check for paths containing "Code/" or "Code.app"</vs_code>
53
+ <cursor>Check for paths containing "Cursor"</cursor>
54
+ <zed>Check for paths containing "Zed"</zed>
55
+ </method_1>
56
+ <method_2>
57
+ <fallback_detection>Use which command to find available IDEs</fallback_detection>
58
+ <commands>which code-insiders code zed cursor</commands>
59
+ <priority_order>code-insiders > cursor > zed > code</priority_order>
60
+ </method_2>
61
+ </detection_methods>
62
+ <set_variables>
63
+ <ide_command>Detected command (code-insiders|code|zed|cursor)</ide_command>
64
+ <ide_name>Human-readable name</ide_name>
65
+ <supports_tasks>true for VS Code variants, false for others</supports_tasks>
66
+ </set_variables>
67
+ <purpose>Automatically detect which IDE to use for opening the new worktree</purpose>
68
+ </step_1>
69
+
70
+ <step_2>
71
+ <description>Parse the arguments</description>
72
+ <input>$ARGUMENTS</input>
73
+ <expected_format>branch-name-or-github-url [optional-base-branch]</expected_format>
74
+ <example>fix/issue-123-main-content-area-visually-clipped main</example>
75
+ <example_github_url>https://github.com/owner/project/issues/123 main</example_github_url>
76
+ <default_base_branch>main (if not specified)</default_base_branch>
77
+ </step_1>
78
+
79
+ <step_2_5>
80
+ <description>Handle GitHub issue URLs</description>
81
+ <condition>If first argument matches GitHub issue URL pattern</condition>
82
+ <url_detection>Check if argument contains "github.com" and "/issues/"</url_detection>
83
+ <url_parsing>
84
+ <pattern>https://github.com/{owner}/{repo}/issues/{issue_number}</pattern>
85
+ <extract>owner, repo, issue_number from URL</extract>
86
+ </url_parsing>
87
+ <fetch_issue_details>
88
+ <tool>mcp__github__issue_read</tool>
89
+ <method>get</method>
90
+ <parameters>owner, repo, issue_number</parameters>
91
+ </fetch_issue_details>
92
+ <generate_branch_name>
93
+ <determine_type>Analyze issue title/labels to determine type (feat/fix/refactor/chore)</determine_type>
94
+ <format>{type}/{repo}-{issue_number}-{kebab-case-title}</format>
95
+ <kebab_case>Convert title to lowercase, replace spaces/special chars with hyphens</kebab_case>
96
+ <sanitization>
97
+ <rule>Always use lowercase for branch names</rule>
98
+ <rule>Replace # with - (hash symbol not allowed in git branch names)</rule>
99
+ <rule>Remove or replace other special characters: @, $, %, ^, &, *, (, ), [, ], {, }, \, |, ;, :, ", ', <, >, ?, /, ~, `</rule>
100
+ <rule>Replace multiple consecutive hyphens with single hyphen</rule>
101
+ <rule>Trim leading/trailing hyphens</rule>
102
+ </sanitization>
103
+ <truncate>Limit total branch name to reasonable length (~60 chars)</truncate>
104
+ </generate_branch_name>
105
+ <user_confirmation>
106
+ <display>Show generated branch name and ask for confirmation</display>
107
+ <options>"Yes, proceed" or "No, exit" or "Edit branch name"</options>
108
+ <if_no>Exit command gracefully</if_no>
109
+ <if_edit>Allow user to modify the branch name</if_edit>
110
+ <if_yes>Continue with generated/modified branch name</if_yes>
111
+ </user_confirmation>
112
+ <examples>
113
+ <input>https://github.com/owner/project/issues/456</input>
114
+ <title>"Fix duplicate items in list view"</title>
115
+ <generated>fix/issue-456-duplicate-items-in-list-view</generated>
116
+ </examples>
117
+ </step_1_5>
118
+
119
+ <step_3>
120
+ <description>Add all files and stash uncommitted changes if any exist</description>
121
+ <condition>If output is not empty (has uncommitted changes)</condition>
122
+ <command>git add -A && git stash push -m "Worktree switch: Moving changes to ${branch_name}"</chained_command>
123
+ <purpose>Preserve work in progress before switching worktrees</purpose>
124
+ <note>Remember stash was created for later restoration</note>
125
+ </step_3>
126
+
127
+ <step_4>
128
+ <description>Determine worktree parent directory</description>
129
+ <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>
130
+ <set_parent_path>
131
+ <if_main_worktree>Set parent_path=".."</if_main_worktree>
132
+ <if_secondary_worktree>Set parent_path="../.." (need to go up two levels)</if_secondary_worktree>
133
+ </set_parent_path>
134
+ <purpose>Correctly determine where to create new worktree regardless of current location</purpose>
135
+ <note>This handles both main worktree and secondary worktree scenarios</note>
136
+ </step_4>
137
+
138
+ <step_5>
139
+ <description>Fetch latest changes from remote</description>
140
+ <command>git fetch origin</command>
141
+ <purpose>Ensure we have the latest remote branches and main branch state</purpose>
142
+ <note>This ensures new worktrees are created from the most recent main branch</note>
143
+ </step_6>
144
+
145
+ <step_7>
146
+ <description>Check if branch exists on remote</description>
147
+ <command>git branch -r | grep "origin/${branch_name}"</command>
148
+ <decision>
149
+ <if_exists>Branch exists on remote - will checkout existing branch</if_exists>
150
+ <if_not_exists>Branch does not exist - will create new branch from base</if_not_exists>
151
+ </decision>
152
+ </step_5>
153
+
154
+ <step_6>
155
+ <description>Create the worktree</description>
156
+ <option_a_new_branch>
157
+ <condition>Remote branch does NOT exist</condition>
158
+ <command>git worktree add ${parent_path}/${branch_name} -b ${branch_name} ${base_branch}</command>
159
+ <example>git worktree add ../fix/issue-123-main-content-area-visually-clipped -b fix/issue-123-main-content-area-visually-clipped main</example>
160
+ </option_a_new_branch>
161
+ <option_b_existing_branch>
162
+ <condition>Remote branch EXISTS</condition>
163
+ <command>git worktree add ${parent_path}/${branch_name} ${branch_name}</command>
164
+ <example>git worktree add ../fix/issue-123-main-content-area-visually-clipped fix/issue-123-main-content-area-visually-clipped</example>
165
+ </option_b_existing_branch>
166
+ </step_7>
167
+
168
+ <step_8>
169
+ <description>Copy Claude settings to new worktree</description>
170
+ <source>.claude/settings.local.json</source>
171
+ <destination>${parent_path}/${branch_name}/.claude/settings.local.json</destination>
172
+ <command>cp -r .claude/settings.local.json ${parent_path}/${branch_name}/.claude/settings.local.json</command>
173
+ <purpose>Preserve all permission settings and configurations</purpose>
174
+ </step_8>
175
+
176
+ <step_9>
177
+ <description>Copy .env.local files to new worktree</description>
178
+ <search_command>find . -name ".env.local" -type f</search_command>
179
+ <copy_logic>For each .env.local file found, copy to corresponding location in new worktree</copy_logic>
180
+ <common_locations>
181
+ - app/.env.local
182
+ - packages/*/.env.local
183
+ - (any other .env.local files found)
184
+ </common_locations>
185
+ <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>
186
+ <purpose>Preserve local environment configurations for development</purpose>
187
+ <note>Only copies files that exist; ignores missing ones</note>
188
+ </step_9>
189
+
190
+ <step_10>
191
+ <description>Create IDE-specific configuration (conditional)</description>
192
+ <condition>Only if supports_tasks is true (VS Code variants)</condition>
193
+ <vs_code_tasks>
194
+ <create_directory>mkdir -p ${parent_path}/${branch_name}/.vscode</create_directory>
195
+ <create_file_command>cat > ${parent_path}/${branch_name}/.vscode/tasks.json << 'EOF'
196
+ {
197
+ "version": "2.0.0",
198
+ "tasks": [
199
+ {
200
+ "label": "Auto start Claude",
201
+ "type": "shell",
202
+ "command": "claude",
203
+ "runOptions": {
204
+ "runOn": "folderOpen"
205
+ },
206
+ "presentation": {
207
+ "echo": false,
208
+ "reveal": "always",
209
+ "focus": true,
210
+ "panel": "new"
211
+ }
212
+ }
213
+ ]
214
+ }
215
+ EOF</create_file_command>
216
+ </vs_code_tasks>
217
+ <purpose>Create auto-start Claude task for VS Code variants on folder open</purpose>
218
+ <note>Only creates for VS Code variants (code, code-insiders, cursor)</note>
219
+ <skip_message>Skipping IDE-specific config for non-VS Code IDEs</skip_message>
220
+ </step_10>
221
+
222
+ <step_11>
223
+ <description>Install dependencies in new worktree</description>
224
+ <working_directory>${parent_path}/${branch_name}</working_directory>
225
+ <command>cd ${parent_path}/${branch_name} && pnpm install</command>
226
+ <purpose>Ensure all node_modules are installed for the new worktree</purpose>
227
+ </step_11>
228
+
229
+ <step_12>
230
+ <description>Apply stashed changes to new worktree (if stash was created)</description>
231
+ <condition>Only if stash was created in step_3</condition>
232
+ <working_directory>${parent_path}/${branch_name}</working_directory>
233
+ <command>cd ${parent_path}/${branch_name} && git stash pop</command>
234
+ <purpose>Restore uncommitted work-in-progress to the new worktree branch</purpose>
235
+ <note>This moves your uncommitted changes to the new branch where you'll continue working</note>
236
+ </step_12>
237
+
238
+ <step_13>
239
+ <description>Open detected IDE in new worktree</description>
240
+ <command>${ide_command} ${parent_path}/${branch_name}</command>
241
+ <ide_specific_behavior>
242
+ <vs_code_variants>Opens folder in VS Code/Insiders/Cursor with tasks.json auto-starting Claude</vs_code_variants>
243
+ <zed>Opens folder in Zed editor</zed>
244
+ <other>Uses detected IDE command to open folder</other>
245
+ </ide_specific_behavior>
246
+ <purpose>Launch development environment for the new worktree using detected IDE</purpose>
247
+ <confirmation_message>Opening worktree in ${ide_name}</confirmation_message>
248
+ </step_11>
249
+ </execution_steps>
250
+
251
+ <important_notes>
252
+ - Automatically detects and uses your current IDE (VS Code, VS Code Insiders, Cursor, Zed, etc.)
253
+ - Creates VS Code-specific tasks.json only for VS Code variants (auto-starts Claude on folder open)
254
+ - Branch names with slashes (feat/, fix/, etc.) are fully supported
255
+ - The worktree directory path will match the full branch name including slashes
256
+ - Settings are copied to maintain the same permissions across worktrees
257
+ - Environment files (.env.local) are copied to preserve local configurations
258
+ - Each worktree has its own node_modules installation
259
+ - Uncommitted changes are automatically stashed and moved to the new worktree
260
+ - Your work-in-progress seamlessly transfers to the new branch
261
+ - IDE detection fallback: checks available editors and uses priority order
262
+ </important_notes>
@@ -0,0 +1,226 @@
1
+ ---
2
+ allowed-tools: Read, mcp__mcp-jq__jq_query, mcp__mcp-jq__jq_query_file, mcp__github__search_pull_requests, mcp__github__pull_request_read, mcp__github__issue_read, mcp__github__issue_write, mcp__github__add_issue_comment, ListMcpResourcesTool
3
+ description: Clean up merged worktrees by verifying PR/issue status, consolidating settings, and removing stale worktrees
4
+ argument-hint: (no arguments)
5
+ ---
6
+
7
+ # Worktree Cleanup
8
+
9
+ ## General Guidelines
10
+
11
+ ### Output Style
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
+ Clean up merged worktrees by finding the oldest merged branch, consolidating settings, and removing stale worktrees.
17
+
18
+ <current_state>
19
+ Current branch: !git branch --show-current`
20
+ Current worktrees: !git worktree list`
21
+ </current_state>
22
+
23
+ <execution_steps>
24
+ <step_0>
25
+ <description>Validate MCP dependencies</description>
26
+ <check_github_mcp>
27
+ <requirement>GitHub MCP server must be configured</requirement>
28
+ <fallback>If unavailable, use `gh` CLI commands</fallback>
29
+ <validation>
30
+ - Try listing available MCP resources
31
+ - If GitHub MCP not found, switch to CLI fallback
32
+ - Inform user about MCP configuration if needed
33
+ </validation>
34
+ </check_github_mcp>
35
+ <error_handling>
36
+ If MCP validation fails:
37
+ - Show clear error message
38
+ - Provide setup instructions
39
+ - Fallback to CLI if possible
40
+ </error_handling>
41
+ <purpose>Ensure required MCP dependencies are available before proceeding</purpose>
42
+ </step_0>
43
+
44
+ <step_1>
45
+ <description>Verify we're in main branch</description>
46
+ <check_command>git branch --show-current</check_command>
47
+ <required_branch>main</required_branch>
48
+ <error_if_not_main>Exit with error message: "This command must be run from the main branch"</error_if_not_main>
49
+ <purpose>Ensure we're consolidating to the main worktree</purpose>
50
+ </step_1>
51
+
52
+ <step_2>
53
+ <description>Get list of all worktrees</description>
54
+ <command>git worktree list --porcelain</command>
55
+ <parse_output>Extract worktree paths and branch names</parse_output>
56
+ <exclude_main>Filter out the main worktree from cleanup candidates</exclude_main>
57
+ <purpose>Identify all worktrees that could potentially be cleaned up</purpose>
58
+ </step_2>
59
+
60
+ <step_3>
61
+ <description>Find oldest worktree by directory age</description>
62
+ <get_worktree_ages>
63
+ <command_macos>git worktree list | grep -v "main" | awk '{print $1}' | while read path; do /usr/bin/stat -f "%Sm|%N" -t "%Y-%m-%d %H:%M:%S" "$path" 2>/dev/null; done | sort</command_macos>
64
+ <command_linux>git worktree list | grep -v "main" | awk '{print $1}' | xargs stat -c "%y|%n" | sort</command_linux>
65
+ <purpose>List all worktrees sorted by directory modification time (oldest first)</purpose>
66
+ <note>Use full path /usr/bin/stat on macOS, regular stat on Linux.</note>
67
+ </get_worktree_ages>
68
+ <filter_recent>
69
+ <exclude_new>For worktrees created within the last 24 hours, let user know that this worktree might not be worth cleaning</exclude_new>
70
+ <get_current_time>date +"%Y-%m-%d %H:%M"</get_current_time>
71
+ </filter_recent>
72
+ <select_oldest>
73
+ <extract_branch_name>Parse branch name from oldest worktree path</extract_branch_name>
74
+ <important_note>DO NOT use "git branch --merged" to check merge status - it's unreliable</important_note>
75
+ <proceed_to_pr_check>Move directly to step 4 to verify PR merge status instead</proceed_to_pr_check>
76
+ </select_oldest>
77
+ <purpose>Identify oldest worktree candidate - actual merge verification happens via GitHub PR in next step</purpose>
78
+ </step_3>
79
+
80
+ <step_4>
81
+ <description>Verify GitHub PR merge status (primary merge verification)</description>
82
+ <determine_repo>
83
+ <check_remote>git remote get-url origin</check_remote>
84
+ <parse_repo>Extract owner/repo from GitHub URL</parse_repo>
85
+ <fallback>Use project repository from git remote (owner/repo format)</fallback>
86
+ </determine_repo>
87
+ <search_pr>
88
+ <tool>mcp__github__search_pull_requests</tool>
89
+ <query>repo:owner/repo head:{branch_name} base:main</query>
90
+ <purpose>Find PR for this branch targeting main</purpose>
91
+ <important>This is the PRIMARY way to verify if a branch was merged - NOT git commands</important>
92
+ </search_pr>
93
+ <verify_pr_merged>
94
+ <if_pr_found>
95
+ <get_pr_details>Use mcp__github__pull_request_read to get full PR info</get_pr_details>
96
+ <confirm_merged>Verify PR state is "closed" AND merged_at is not null AND base is "main"</confirm_merged>
97
+ <extract_issue_number>Look for issue references in PR title/body (e.g., #14533, owner/repo#14533)</extract_issue_number>
98
+ <if_merged>Proceed with cleanup - this branch was definitively merged to main</if_merged>
99
+ <if_not_merged>
100
+ <skip_worktree>This worktree is NOT merged - continue to next oldest worktree</skip_worktree>
101
+ <repeat_from_step_3>Go back and find the next oldest worktree to check</repeat_from_step_3>
102
+ </if_not_merged>
103
+ </if_pr_found>
104
+ <if_no_pr>
105
+ <skip_worktree>No PR found - this branch was likely never submitted for review</skip_worktree>
106
+ <continue_to_next>Continue checking next oldest worktree</continue_to_next>
107
+ </if_no_pr>
108
+ </verify_pr_merged>
109
+ <purpose>Use GitHub PR status as the authoritative source for merge verification instead of unreliable git commands</purpose>
110
+ </step_4>
111
+
112
+ <step_4_5>
113
+ <description>Check and close related GitHub issue</description>
114
+ <if_issue_found>
115
+ <get_issue_details>
116
+ <tool>mcp__github__issue_read</tool>
117
+ <method>get</method>
118
+ <extract_repo>From issue reference (main-repo vs cross-repo)</extract_repo>
119
+ </get_issue_details>
120
+ <check_issue_state>
121
+ <if_open>
122
+ <ask_close>Ask user: "Related issue #{number} is still open. Should I close it? (y/N)"</ask_close>
123
+ <if_yes_close>
124
+ <add_closing_comment>
125
+ <tool>mcp__github__add_issue_comment</tool>
126
+ <body_template>Closing this issue as branch {branch_name} was merged to main on {merge_date} via PR #{pr_number}.</body_template>
127
+ <get_merge_date>Extract merge date from PR details</get_merge_date>
128
+ <get_pr_number>Use PR number from search results</get_pr_number>
129
+ </add_closing_comment>
130
+ <close_issue>
131
+ <tool>mcp__github__issue_write</tool>
132
+ <method>update</method>
133
+ <state>closed</state>
134
+ <state_reason>completed</state_reason>
135
+ </close_issue>
136
+ </if_yes_close>
137
+ </if_open>
138
+ <if_closed>Inform user issue is already closed</if_closed>
139
+ </check_issue_state>
140
+ </if_issue_found>
141
+ <if_no_issue>Continue without issue management</if_no_issue>
142
+ <purpose>Ensure proper issue lifecycle management</purpose>
143
+ </step_4_5>
144
+
145
+ <step_5>
146
+ <description>Check if worktree is locked</description>
147
+ <check_command>git worktree list --porcelain | grep -A5 "worktree {path}" | grep "locked"</check_command>
148
+ <if_locked>
149
+ <unlock_command>git worktree unlock {path}</unlock_command>
150
+ <notify_user>Inform user that worktree was unlocked</notify_user>
151
+ </if_locked>
152
+ <purpose>Unlock worktree if it was locked for tracking purposes</purpose>
153
+ </step_5>
154
+
155
+ <step_6>
156
+ <description>Analyze Claude settings differences</description>
157
+ <read_main_settings>.claude/settings.local.json</read_main_settings>
158
+ <read_worktree_settings>{worktree_path}/.claude/settings.local.json</read_worktree_settings>
159
+ <compare_allow_lists>
160
+ <extract_main_allows>Extract "allow" array from main settings</extract_main_allows>
161
+ <extract_worktree_allows>Extract "allow" array from worktree settings</extract_worktree_allows>
162
+ <find_differences>Identify entries in worktree that are not in main</find_differences>
163
+ </compare_allow_lists>
164
+ <filter_suggestions>
165
+ <include_filesystem>Read permissions for filesystem paths</include_filesystem>
166
+ <exclude_intrusive>Exclude bash commands, write permissions, etc.</exclude_intrusive>
167
+ <focus_user_specific>Include only user-specific, non-disruptive entries</focus_user_specific>
168
+ </filter_suggestions>
169
+ <purpose>Identify useful settings to consolidate before cleanup</purpose>
170
+ </step_6>
171
+
172
+ <step_7>
173
+ <description>Suggest settings consolidation</description>
174
+ <if_differences_found>
175
+ <display_suggestions>Show filtered differences to user</display_suggestions>
176
+ <ask_confirmation>Ask user which entries to add to main settings</ask_confirmation>
177
+ <apply_changes>Update main .claude/settings.local.json with selected entries</apply_changes>
178
+ </if_differences_found>
179
+ <if_no_differences>Inform user no settings need consolidation</if_no_differences>
180
+ <purpose>Preserve useful development settings before removing worktree</purpose>
181
+ </step_7>
182
+
183
+ <step_8>
184
+ <description>Final cleanup confirmation</description>
185
+ <summary>
186
+ <display_worktree>Show worktree path and branch name</display_worktree>
187
+ <show_pr_status>Show merged PR details if found</show_pr_status>
188
+ <show_issue_status>Show related issue status if found</show_issue_status>
189
+ <show_last_activity>Display directory creation/modification date</show_last_activity>
190
+ </summary>
191
+ <safety_checks>
192
+ <check_uncommitted>git status --porcelain in worktree directory</check_uncommitted>
193
+ <warn_if_dirty>Alert user if uncommitted changes exist</warn_if_dirty>
194
+ </safety_checks>
195
+ <ask_deletion>Ask user confirmation: "Delete this worktree? (y/N)"</ask_deletion>
196
+ <purpose>Final safety check before irreversible deletion</purpose>
197
+ </step_8>
198
+
199
+ <step_9>
200
+ <description>Delete worktree</description>
201
+ <if_confirmed>
202
+ <remove_worktree>git worktree remove {path} --force</remove_worktree>
203
+ <cleanup_branch>git branch -d {branch_name}</cleanup_branch>
204
+ <success_message>Inform user worktree was successfully removed</success_message>
205
+ <next_steps>Suggest running command again to find next candidate</next_steps>
206
+ </if_confirmed>
207
+ <if_declined>Exit gracefully with no changes</if_declined>
208
+ <purpose>Perform the actual cleanup and guide user for next iteration</purpose>
209
+ </step_9>
210
+ </execution_steps>
211
+
212
+ <important_notes>
213
+ - Uses GitHub PR merge status as the ONLY reliable way to verify if a branch was merged
214
+ - DOES NOT use "git branch --merged" command as it's unreliable for merge verification
215
+ - Only processes branches with PRs that were definitively merged to main
216
+ - Skips worktrees without merged PRs and continues to next oldest candidate
217
+ - Checks and optionally closes related GitHub issues
218
+ - Prioritizes oldest worktrees by directory age first for systematic cleanup
219
+ - Warns about very recent worktrees (created within 24 hours) to avoid cleaning active work
220
+ - Preserves useful development settings before deletion
221
+ - Requires explicit confirmation before any destructive actions
222
+ - Handles locked worktrees automatically
223
+ - Processes one worktree at a time to maintain control
224
+ - Must be run from main branch for safety
225
+ - Works with standard GitHub repository URLs (owner/repo format)
226
+ </important_notes>
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@wbern/claude-instructions",
3
+ "version": "1.0.1",
4
+ "description": "TDD workflow commands for Claude Code CLI",
5
+ "type": "module",
6
+ "bin": "./bin/cli.js",
7
+ "files": [
8
+ "bin",
9
+ "downloads"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/wbern/claude-instructions.git"
14
+ },
15
+ "homepage": "https://github.com/wbern/claude-instructions#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/wbern/claude-instructions/issues"
18
+ },
19
+ "keywords": [
20
+ "claude",
21
+ "claude-code",
22
+ "tdd",
23
+ "test-driven-development",
24
+ "ai",
25
+ "cli"
26
+ ],
27
+ "author": "wbern",
28
+ "license": "MIT",
29
+ "devDependencies": {
30
+ "@types/fs-extra": "^11.0.4",
31
+ "@types/node": "^24.10.1",
32
+ "husky": "^9.1.7",
33
+ "markdown-magic": "^4.0.4",
34
+ "tsup": "^8.5.1",
35
+ "tsx": "^4.20.6",
36
+ "typescript": "^5.9.3",
37
+ "vitest": "^4.0.8"
38
+ },
39
+ "dependencies": {
40
+ "@clack/prompts": "^0.11.0",
41
+ "fs-extra": "^11.3.2"
42
+ },
43
+ "release": {
44
+ "branches": [
45
+ "main"
46
+ ],
47
+ "plugins": [
48
+ "@semantic-release/commit-analyzer",
49
+ "@semantic-release/release-notes-generator",
50
+ "@semantic-release/npm",
51
+ "@semantic-release/github"
52
+ ]
53
+ },
54
+ "scripts": {
55
+ "clean": "rm -rf downloads",
56
+ "clean:dev": "rm -rf .claude/commands",
57
+ "build": "bash scripts/build.sh",
58
+ "build:dev": "bash scripts/build-dev.sh",
59
+ "build:cli": "tsup",
60
+ "generate": "tsx scripts/cli-generator.ts",
61
+ "test": "vitest run",
62
+ "test:watch": "vitest",
63
+ "typecheck": "tsc --noEmit"
64
+ }
65
+ }