@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.
- package/README.md +411 -0
- package/bin/cli.js +99 -0
- package/downloads/with-beads/add-command.md +130 -0
- package/downloads/with-beads/ask.md +134 -0
- package/downloads/with-beads/beepboop.md +54 -0
- package/downloads/with-beads/commit.md +47 -0
- package/downloads/with-beads/cycle.md +89 -0
- package/downloads/with-beads/green.md +89 -0
- package/downloads/with-beads/issue.md +141 -0
- package/downloads/with-beads/plan.md +167 -0
- package/downloads/with-beads/red.md +85 -0
- package/downloads/with-beads/refactor.md +87 -0
- package/downloads/with-beads/ship.md +93 -0
- package/downloads/with-beads/show.md +107 -0
- package/downloads/with-beads/spike.md +89 -0
- package/downloads/with-beads/summarize.md +38 -0
- package/downloads/with-beads/tdd.md +89 -0
- package/downloads/with-beads/worktree-add.md +262 -0
- package/downloads/with-beads/worktree-cleanup.md +226 -0
- package/downloads/without-beads/add-command.md +130 -0
- package/downloads/without-beads/ask.md +126 -0
- package/downloads/without-beads/beepboop.md +46 -0
- package/downloads/without-beads/commit.md +47 -0
- package/downloads/without-beads/cycle.md +89 -0
- package/downloads/without-beads/green.md +89 -0
- package/downloads/without-beads/issue.md +133 -0
- package/downloads/without-beads/plan.md +107 -0
- package/downloads/without-beads/red.md +85 -0
- package/downloads/without-beads/refactor.md +87 -0
- package/downloads/without-beads/ship.md +85 -0
- package/downloads/without-beads/show.md +99 -0
- package/downloads/without-beads/spike.md +89 -0
- package/downloads/without-beads/summarize.md +30 -0
- package/downloads/without-beads/tdd.md +89 -0
- package/downloads/without-beads/worktree-add.md +262 -0
- package/downloads/without-beads/worktree-cleanup.md +226 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# @wbern/claude-instructions
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
_==/ i i \==_
|
|
5
|
+
/XX/ |\___/| \XX\
|
|
6
|
+
/XXXX\ |XXXXX| /XXXX\
|
|
7
|
+
|XXXXXX\_ _XXXXXXX_ _/XXXXXX|
|
|
8
|
+
XXXXXXXXXXXxxxxxxxXXXXXXXXXXXxxxxxxxXXXXXXXXXXX
|
|
9
|
+
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|
|
10
|
+
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
11
|
+
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|
|
12
|
+
XXXXXX/^^^^"\XXXXXXXXXXXXXXXXXXXXX/^^^^^\XXXXXX
|
|
13
|
+
|XXX| \XXX/^^\XXXXX/^^\XXX/ |XXX|
|
|
14
|
+
\XX\ \X/ \XXX/ \X/ /XX/
|
|
15
|
+
"\ " \X/ " /"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
TDD workflow commands for Claude Code CLI.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### Quick Install (Recommended)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx @wbern/claude-instructions
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This interactive installer lets you choose your variant and installation scope.
|
|
29
|
+
|
|
30
|
+
### Manual Installation
|
|
31
|
+
|
|
32
|
+
#### Without Beads Integration (Recommended for Beginners)
|
|
33
|
+
|
|
34
|
+
Standalone TDD workflow commands without dependencies.
|
|
35
|
+
|
|
36
|
+
**User-level (global - available in all projects):**
|
|
37
|
+
```bash
|
|
38
|
+
# Clone the repository
|
|
39
|
+
git clone https://github.com/wbern/claude-instructions.git /tmp/claude-instructions
|
|
40
|
+
|
|
41
|
+
# Copy commands to your user directory
|
|
42
|
+
cp /tmp/claude-instructions/downloads/without-beads/*.md ~/.claude/commands/
|
|
43
|
+
|
|
44
|
+
# Clean up
|
|
45
|
+
rm -rf /tmp/claude-instructions
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Project-level (current repository only):**
|
|
49
|
+
```bash
|
|
50
|
+
# Clone the repository
|
|
51
|
+
git clone https://github.com/wbern/claude-instructions.git /tmp/claude-instructions
|
|
52
|
+
|
|
53
|
+
# Create commands directory and copy files
|
|
54
|
+
mkdir -p .claude/commands
|
|
55
|
+
cp /tmp/claude-instructions/downloads/without-beads/*.md .claude/commands/
|
|
56
|
+
|
|
57
|
+
# Clean up
|
|
58
|
+
rm -rf /tmp/claude-instructions
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### With Beads Integration
|
|
62
|
+
|
|
63
|
+
Supports [Beads MCP](https://github.com/steveyegge/beads) integration for issue tracking and workflow management, installed separately.
|
|
64
|
+
|
|
65
|
+
**Choose this if you:**
|
|
66
|
+
- Are comfortable with TDD workflows
|
|
67
|
+
- Need issue tracking and workflow management
|
|
68
|
+
- Work in a team environment
|
|
69
|
+
- Want integrated project planning with `/plan`
|
|
70
|
+
|
|
71
|
+
**User-level (global - available in all projects):**
|
|
72
|
+
```bash
|
|
73
|
+
# Clone the repository
|
|
74
|
+
git clone https://github.com/wbern/claude-instructions.git /tmp/claude-instructions
|
|
75
|
+
|
|
76
|
+
# Copy commands to your user directory
|
|
77
|
+
cp /tmp/claude-instructions/downloads/with-beads/*.md ~/.claude/commands/
|
|
78
|
+
|
|
79
|
+
# Clean up
|
|
80
|
+
rm -rf /tmp/claude-instructions
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Project-level (current repository only):**
|
|
84
|
+
```bash
|
|
85
|
+
# Clone the repository
|
|
86
|
+
git clone https://github.com/wbern/claude-instructions.git /tmp/claude-instructions
|
|
87
|
+
|
|
88
|
+
# Create commands directory and copy files
|
|
89
|
+
mkdir -p .claude/commands
|
|
90
|
+
cp /tmp/claude-instructions/downloads/with-beads/*.md .claude/commands/
|
|
91
|
+
|
|
92
|
+
# Clean up
|
|
93
|
+
rm -rf /tmp/claude-instructions
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Requirements:**
|
|
97
|
+
- Install [Beads MCP](https://github.com/steveyegge/beads) for full functionality
|
|
98
|
+
- Configure Beads in your project with `bd init`
|
|
99
|
+
|
|
100
|
+
**Note:** User-level installation makes commands available globally in all your projects. Project-level installation only makes them available in the current repository.
|
|
101
|
+
|
|
102
|
+
After installation, restart Claude Code if it's currently running.
|
|
103
|
+
|
|
104
|
+
## Which Command Should I Use?
|
|
105
|
+
|
|
106
|
+
### Main Workflow
|
|
107
|
+
|
|
108
|
+
Follow this workflow from planning to shipping:
|
|
109
|
+
|
|
110
|
+
```mermaid
|
|
111
|
+
flowchart TB
|
|
112
|
+
Start([Start New Work])
|
|
113
|
+
|
|
114
|
+
Start --> Step1[<b>1. PLAN</b>]
|
|
115
|
+
|
|
116
|
+
Step1 --> Issue[📋 /issue<br/>Have GitHub issue<br/><i>Requires: GitHub MCP</i>]
|
|
117
|
+
Step1 --> Plan[📝 /plan<br/>No issue yet<br/><i>Optional: Beads MCP</i>]
|
|
118
|
+
|
|
119
|
+
Issue --> Step2[<b>2. CODE with TDD</b>]
|
|
120
|
+
Plan --> Step2
|
|
121
|
+
|
|
122
|
+
Step2 -->|Manual| Red[🔴 /red<br/>Write failing test]
|
|
123
|
+
Red --> Green[🟢 /green<br/>Make it pass]
|
|
124
|
+
Green --> Refactor[🔵 /refactor<br/>Clean up code]
|
|
125
|
+
Refactor --> MoreTests{More tests?}
|
|
126
|
+
|
|
127
|
+
Step2 -->|Automated| Cycle[🔄 /cycle<br/>Runs red+green+refactor]
|
|
128
|
+
Cycle --> MoreTests
|
|
129
|
+
|
|
130
|
+
MoreTests -->|Yes| Step2
|
|
131
|
+
MoreTests -->|No| Step3
|
|
132
|
+
|
|
133
|
+
Step3[<b>3. SHIP</b>]
|
|
134
|
+
|
|
135
|
+
Step3 --> Commit[📦 /commit<br/>Create commit]
|
|
136
|
+
Commit --> ShipChoice{How to<br/>merge?}
|
|
137
|
+
|
|
138
|
+
ShipChoice -->|Simple change| Ship[🚢 /ship<br/>Direct to main<br/><i>Requires: GitHub MCP</i>]
|
|
139
|
+
ShipChoice -->|Show team| Show[👀 /show<br/>Auto-merge + notify<br/><i>Requires: GitHub MCP</i>]
|
|
140
|
+
ShipChoice -->|Needs review| Ask[💬 /ask<br/>Create PR<br/><i>Requires: GitHub MCP</i>]
|
|
141
|
+
|
|
142
|
+
Ship --> Done([✅ Done])
|
|
143
|
+
Show --> Done
|
|
144
|
+
Ask --> Done
|
|
145
|
+
|
|
146
|
+
style Start fill:#e1f5ff
|
|
147
|
+
style Step1 fill:#fff4e6
|
|
148
|
+
style Step2 fill:#e8f5e9
|
|
149
|
+
style Step3 fill:#fce4ec
|
|
150
|
+
style Done fill:#c8e6c9
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Other Commands
|
|
154
|
+
|
|
155
|
+
Available anytime during your workflow:
|
|
156
|
+
|
|
157
|
+
```mermaid
|
|
158
|
+
flowchart TB
|
|
159
|
+
Utils[<b>UTILITIES</b>]
|
|
160
|
+
Utils --> Spike[🔬 /spike<br/>Exploratory coding before TDD]
|
|
161
|
+
Utils --> TDD[📚 /tdd<br/>Remind agent about TDD]
|
|
162
|
+
Utils --> AddCommand[➕ /add-command<br/>Create custom commands]
|
|
163
|
+
Utils --> Summarize[📄 /summarize<br/>Summarize conversation<br/><i>Optional: Beads MCP</i>]
|
|
164
|
+
Utils --> Beepboop[🤖 /beepboop<br/>AI attribution]
|
|
165
|
+
|
|
166
|
+
Worktree[<b>WORKTREE MANAGEMENT</b>]
|
|
167
|
+
Worktree --> WorktreeAdd[➕ /worktree-add<br/>Create new worktree<br/><i>Requires: GitHub MCP</i>]
|
|
168
|
+
Worktree --> WorktreeCleanup[🧹 /worktree-cleanup<br/>Clean up merged worktrees<br/><i>Requires: GitHub MCP</i>]
|
|
169
|
+
|
|
170
|
+
style Utils fill:#fff9c4
|
|
171
|
+
style Worktree fill:#f3e5f5
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Available Commands
|
|
175
|
+
|
|
176
|
+
### Planning
|
|
177
|
+
|
|
178
|
+
- `/issue` - Analyze GitHub issue and create TDD implementation plan
|
|
179
|
+
- `/plan` - Create implementation plan from feature/requirement with PRD-style discovery and TDD acceptance criteria
|
|
180
|
+
|
|
181
|
+
### TDD Cycle
|
|
182
|
+
|
|
183
|
+
- `/spike` - Execute TDD Spike Phase - exploratory coding to understand problem space before TDD
|
|
184
|
+
- `/red` - Execute TDD Red Phase - write ONE failing test
|
|
185
|
+
- `/green` - Execute TDD Green Phase - write minimal implementation to pass the failing test
|
|
186
|
+
- `/refactor` - Execute TDD Refactor Phase - improve code structure while keeping tests green
|
|
187
|
+
- `/cycle` - Execute complete TDD cycle - Red, Green, and Refactor phases in sequence
|
|
188
|
+
|
|
189
|
+
### Workflow
|
|
190
|
+
|
|
191
|
+
- `/commit` - Create a git commit following project standards
|
|
192
|
+
- `/ship` - Ship code directly to main - for small, obvious changes that don't need review (Cursor's modern alternative to PRs)
|
|
193
|
+
- `/show` - Show code to team with auto-merge - for changes that should be visible but don't need approval (Cursor's modern workflow)
|
|
194
|
+
- `/ask` - Request team review and approval - for complex changes needing discussion (OK fine, traditional PRs still have their place - Cursor)
|
|
195
|
+
- `/summarize` - Summarize conversation progress and next steps
|
|
196
|
+
|
|
197
|
+
### Worktree Management
|
|
198
|
+
|
|
199
|
+
- `/worktree-add` - Add a new git worktree from branch name or GitHub issue URL, copy settings, install deps, and open in current IDE
|
|
200
|
+
- `/worktree-cleanup` - Clean up merged worktrees by verifying PR/issue status, consolidating settings, and removing stale worktrees
|
|
201
|
+
|
|
202
|
+
### Utilities
|
|
203
|
+
|
|
204
|
+
- `/tdd` - Remind agent about TDD approach and continue conversation
|
|
205
|
+
- `/beepboop` - Communicate AI-generated content with transparent attribution
|
|
206
|
+
- `/add-command` - Guide for creating new slash commands
|
|
207
|
+
|
|
208
|
+
## Getting Started
|
|
209
|
+
|
|
210
|
+
### Quick Start: Your First TDD Cycle
|
|
211
|
+
|
|
212
|
+
Here's a simple example to get you started with the TDD workflow:
|
|
213
|
+
|
|
214
|
+
**1. Write a failing test (`/red`)**
|
|
215
|
+
```
|
|
216
|
+
You: /red add a function that validates email addresses
|
|
217
|
+
|
|
218
|
+
Claude: I'll write a failing test for email validation.
|
|
219
|
+
[Creates test file with a test that checks email validation]
|
|
220
|
+
[Runs test - shows it failing because function doesn't exist yet]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**2. Make it pass (`/green`)**
|
|
224
|
+
```
|
|
225
|
+
You: /green
|
|
226
|
+
|
|
227
|
+
Claude: I'll implement the minimal code to pass the test.
|
|
228
|
+
[Creates the email validation function with basic implementation]
|
|
229
|
+
[Runs test - shows it passing]
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**3. Refactor for quality (`/refactor`)**
|
|
233
|
+
```
|
|
234
|
+
You: /refactor extract regex pattern to a constant
|
|
235
|
+
|
|
236
|
+
Claude: I'll refactor while keeping tests green.
|
|
237
|
+
[Extracts magic values, improves code structure]
|
|
238
|
+
[Runs tests - confirms they still pass]
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Complete Workflow Example
|
|
242
|
+
|
|
243
|
+
**Starting from a GitHub issue:**
|
|
244
|
+
```
|
|
245
|
+
/issue 123
|
|
246
|
+
```
|
|
247
|
+
Claude analyzes the GitHub issue and creates a TDD implementation plan showing what tests to write.
|
|
248
|
+
|
|
249
|
+
**Running a full TDD cycle:**
|
|
250
|
+
```
|
|
251
|
+
/cycle implement user authentication with password hashing
|
|
252
|
+
```
|
|
253
|
+
Claude executes the complete red-green-refactor cycle: writes a failing test, implements it, then refactors.
|
|
254
|
+
|
|
255
|
+
**Individual phases for more control:**
|
|
256
|
+
```
|
|
257
|
+
/red test that users can't login with wrong password
|
|
258
|
+
/green
|
|
259
|
+
/refactor move password verification to separate function
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Committing and creating PRs:**
|
|
263
|
+
```
|
|
264
|
+
/commit
|
|
265
|
+
```
|
|
266
|
+
Claude reviews changes, drafts a commit message following project standards, and creates the commit.
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
/pr
|
|
270
|
+
```
|
|
271
|
+
Claude analyzes commits, creates a PR with summary and test plan.
|
|
272
|
+
|
|
273
|
+
### What to Expect
|
|
274
|
+
|
|
275
|
+
- **`/red`** - Claude writes ONE failing test based on your description
|
|
276
|
+
- **`/green`** - Claude writes minimal implementation to pass the current failing test
|
|
277
|
+
- **`/refactor`** - Claude improves code structure without changing behavior
|
|
278
|
+
- **`/cycle`** - Claude runs all three phases in sequence for a complete feature
|
|
279
|
+
|
|
280
|
+
The commands enforce TDD discipline: you can't refactor with failing tests, can't write multiple tests at once, and implementation must match test requirements.
|
|
281
|
+
|
|
282
|
+
## Example Conversations
|
|
283
|
+
|
|
284
|
+
# Conversation: Solving "Find Closest to Zero" Code Challenge
|
|
285
|
+
|
|
286
|
+
**Summary:** User works through solving a code challenge: given a list of integers, find the closest to zero. If there is a tie, choose the positive value. (challenge from [cyber-dojo.org](https://cyber-dojo.org))
|
|
287
|
+
|
|
288
|
+
**Commands:** `/red` `/green` `/refactor`
|
|
289
|
+
**Legend:** 🔴 Red (test fails) | 🟢 Green (test passes) | 🔵 Refactor (cleanup)
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
👤 `/red` single element [1] returns 1
|
|
294
|
+
|
|
295
|
+
🔴 *writes test*
|
|
296
|
+
```typescript
|
|
297
|
+
expect(closestToZero([1])).toBe(1);
|
|
298
|
+
```
|
|
299
|
+
FAIL: closestToZero is not defined
|
|
300
|
+
|
|
301
|
+
👤 `/green`
|
|
302
|
+
|
|
303
|
+
🟢 *returns hardcoded 1*
|
|
304
|
+
```typescript
|
|
305
|
+
function closestToZero(nums: number[]): number {
|
|
306
|
+
return 1; // minimal - only need to pass current test
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
✅ Test passes
|
|
310
|
+
|
|
311
|
+
👤 `/red` two numbers [3, 2] returns 2
|
|
312
|
+
|
|
313
|
+
🔴 *writes test*
|
|
314
|
+
```typescript
|
|
315
|
+
expect(closestToZero([3, 2])).toBe(2);
|
|
316
|
+
```
|
|
317
|
+
FAIL: expected 1 to be 2
|
|
318
|
+
|
|
319
|
+
👤 `/green`
|
|
320
|
+
|
|
321
|
+
🟢 *sorts and returns first*
|
|
322
|
+
```typescript
|
|
323
|
+
function closestToZero(nums: number[]): number {
|
|
324
|
+
return nums.sort((a, b) => a - b)[0]; // minimal
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
✅ 2/2 tests pass
|
|
328
|
+
|
|
329
|
+
👤 `/red` with negative [-3, 2] returns 2
|
|
330
|
+
|
|
331
|
+
🔴 *writes test*
|
|
332
|
+
```typescript
|
|
333
|
+
expect(closestToZero([-3, 2])).toBe(2);
|
|
334
|
+
```
|
|
335
|
+
FAIL: expected -3 to be 2 (regular sort puts -3 first)
|
|
336
|
+
|
|
337
|
+
👤 `/green`
|
|
338
|
+
|
|
339
|
+
🟢 *sorts by absolute value*
|
|
340
|
+
```typescript
|
|
341
|
+
function closestToZero(nums: number[]): number {
|
|
342
|
+
return nums.sort((a, b) => Math.abs(a) - Math.abs(b))[0];
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
✅ 3/3 tests pass
|
|
346
|
+
|
|
347
|
+
👤 `/red` exact tie [-2, 2] returns positive 2
|
|
348
|
+
|
|
349
|
+
🔴 *writes test*
|
|
350
|
+
```typescript
|
|
351
|
+
expect(closestToZero([-2, 2])).toBe(2);
|
|
352
|
+
```
|
|
353
|
+
FAIL: expected -2 to be 2 (returns first when tied)
|
|
354
|
+
|
|
355
|
+
👤 `/green`
|
|
356
|
+
|
|
357
|
+
🟢 *adds tie-breaking: prefer positive*
|
|
358
|
+
```typescript
|
|
359
|
+
function closestToZero(nums: number[]): number {
|
|
360
|
+
return nums.sort((a, b) => {
|
|
361
|
+
const diff = Math.abs(a) - Math.abs(b);
|
|
362
|
+
return diff !== 0 ? diff : b - a;
|
|
363
|
+
})[0];
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
✅ 4/4 tests pass
|
|
367
|
+
|
|
368
|
+
👤 `/refactor` extract helper and use iteration instead of sort
|
|
369
|
+
|
|
370
|
+
🔵 *extracts helper function for comparison logic*
|
|
371
|
+
```typescript
|
|
372
|
+
function isCloser(candidate: number, current: number): boolean {
|
|
373
|
+
const candAbs = Math.abs(candidate);
|
|
374
|
+
const currAbs = Math.abs(current);
|
|
375
|
+
return candAbs < currAbs || (candAbs === currAbs && candidate > current);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function closestToZero(nums: number[]): number {
|
|
379
|
+
if (nums.length === 0) return 0;
|
|
380
|
+
let closest = nums[0];
|
|
381
|
+
for (const num of nums) {
|
|
382
|
+
if (isCloser(num, closest)) {
|
|
383
|
+
closest = num;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return closest;
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
✅ 4/4 tests still pass
|
|
390
|
+
|
|
391
|
+
👤 `/refactor`
|
|
392
|
+
|
|
393
|
+
🔵 *uses reduce for more functional style*
|
|
394
|
+
```typescript
|
|
395
|
+
function closestToZero(nums: number[]): number {
|
|
396
|
+
if (nums.length === 0) return 0;
|
|
397
|
+
return nums.reduce((closest, num) =>
|
|
398
|
+
isCloser(num, closest) ? num : closest
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
✅ 4/4 tests still pass
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
## Contributing
|
|
406
|
+
|
|
407
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow, build system, and fragment management.
|
|
408
|
+
|
|
409
|
+
## Credits
|
|
410
|
+
|
|
411
|
+
TDD workflow instructions adapted from [TDD Guard](https://github.com/nizos/tdd-guard) by Nizar.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// scripts/cli.ts
|
|
4
|
+
import { select, isCancel, intro, outro } from "@clack/prompts";
|
|
5
|
+
|
|
6
|
+
// scripts/cli-generator.ts
|
|
7
|
+
import fs from "fs-extra";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import os from "os";
|
|
11
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
var __dirname = path.dirname(__filename);
|
|
13
|
+
var VARIANTS = {
|
|
14
|
+
WITH_BEADS: "with-beads",
|
|
15
|
+
WITHOUT_BEADS: "without-beads"
|
|
16
|
+
};
|
|
17
|
+
var SCOPES = {
|
|
18
|
+
PROJECT: "project",
|
|
19
|
+
USER: "user"
|
|
20
|
+
};
|
|
21
|
+
var DIRECTORIES = {
|
|
22
|
+
CLAUDE: ".claude",
|
|
23
|
+
COMMANDS: "commands",
|
|
24
|
+
DOWNLOADS: "downloads"
|
|
25
|
+
};
|
|
26
|
+
var VARIANT_OPTIONS = [
|
|
27
|
+
{ value: VARIANTS.WITH_BEADS, label: "With Beads" },
|
|
28
|
+
{ value: VARIANTS.WITHOUT_BEADS, label: "Without Beads" }
|
|
29
|
+
];
|
|
30
|
+
var SCOPE_OPTIONS = [
|
|
31
|
+
{ value: SCOPES.PROJECT, label: "Project/Repository" },
|
|
32
|
+
{ value: SCOPES.USER, label: "User (Global)" }
|
|
33
|
+
];
|
|
34
|
+
function getDestinationPath(outputPath, scope) {
|
|
35
|
+
if (outputPath) {
|
|
36
|
+
return outputPath;
|
|
37
|
+
}
|
|
38
|
+
if (scope === SCOPES.PROJECT) {
|
|
39
|
+
return path.join(process.cwd(), DIRECTORIES.CLAUDE, DIRECTORIES.COMMANDS);
|
|
40
|
+
}
|
|
41
|
+
if (scope === SCOPES.USER) {
|
|
42
|
+
return path.join(os.homedir(), DIRECTORIES.CLAUDE, DIRECTORIES.COMMANDS);
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
async function generateToDirectory(outputPath, variant, scope) {
|
|
47
|
+
const sourcePath = path.join(__dirname, "..", DIRECTORIES.DOWNLOADS, variant || VARIANTS.WITH_BEADS);
|
|
48
|
+
const destinationPath = getDestinationPath(outputPath, scope);
|
|
49
|
+
if (!destinationPath) {
|
|
50
|
+
throw new Error("Either outputPath or scope must be provided");
|
|
51
|
+
}
|
|
52
|
+
const files = await fs.readdir(sourcePath);
|
|
53
|
+
await fs.copy(sourcePath, destinationPath, {});
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
filesGenerated: files.length,
|
|
57
|
+
variant
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// scripts/cli.ts
|
|
62
|
+
var BATMAN_LOGO = `
|
|
63
|
+
_==/ i i \\==_
|
|
64
|
+
/XX/ |\\___/| \\XX\\
|
|
65
|
+
/XXXX\\ |XXXXX| /XXXX\\
|
|
66
|
+
|XXXXXX\\_ _XXXXXXX_ _/XXXXXX|
|
|
67
|
+
XXXXXXXXXXXxxxxxxxXXXXXXXXXXXxxxxxxxXXXXXXXXXXX
|
|
68
|
+
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|
|
69
|
+
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
70
|
+
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|
|
71
|
+
XXXXXX/^^^^"\\XXXXXXXXXXXXXXXXXXXXX/^^^^^\\XXXXXX
|
|
72
|
+
|XXX| \\XXX/^^\\XXXXX/^^\\XXX/ |XXX|
|
|
73
|
+
\\XX\\ \\X/ \\XXX/ \\X/ /XX/
|
|
74
|
+
"\\ " \\X/ " /"
|
|
75
|
+
|
|
76
|
+
@wbern/claude-instructions
|
|
77
|
+
`;
|
|
78
|
+
async function main() {
|
|
79
|
+
intro(BATMAN_LOGO);
|
|
80
|
+
const variant = await select({
|
|
81
|
+
message: "Select variant",
|
|
82
|
+
options: [...VARIANT_OPTIONS]
|
|
83
|
+
});
|
|
84
|
+
if (isCancel(variant)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const scope = await select({
|
|
88
|
+
message: "Select installation scope",
|
|
89
|
+
options: [...SCOPE_OPTIONS]
|
|
90
|
+
});
|
|
91
|
+
if (isCancel(scope)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const result = await generateToDirectory(void 0, variant, scope);
|
|
95
|
+
outro(`Installed ${result.filesGenerated} commands to .claude/commands`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// scripts/bin.ts
|
|
99
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Guide for creating new slash commands
|
|
3
|
+
argument-hint: <command-name> <description>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Slash Command Creator Guide
|
|
7
|
+
|
|
8
|
+
## How This Command Works
|
|
9
|
+
The `/add-command` command shows this guide for creating new slash commands. It includes:
|
|
10
|
+
- Command structure and syntax
|
|
11
|
+
- Common patterns and examples
|
|
12
|
+
- Security restrictions and limitations
|
|
13
|
+
- Frontmatter options
|
|
14
|
+
|
|
15
|
+
**Note for AI**: When creating commands, you CAN use bash tools like `Bash(mkdir:*)`, `Bash(ls:*)`, `Bash(git status:*)` in the `allowed-tools` frontmatter of NEW commands - but ONLY for operations within the current project directory. This command itself doesn't need bash tools since it's just documentation.
|
|
16
|
+
|
|
17
|
+
## Command Locations
|
|
18
|
+
- **Personal**: `~/.claude/commands/` (available across all projects)
|
|
19
|
+
- **Project**: `.claude/commands/` (shared with team, shows "(project)")
|
|
20
|
+
|
|
21
|
+
## Basic Structure
|
|
22
|
+
|
|
23
|
+
```markdown
|
|
24
|
+
---
|
|
25
|
+
allowed-tools: Read, Glob, Grep, Bash(git status:*), Task
|
|
26
|
+
description: Brief description of what this command does
|
|
27
|
+
argument-hint: [required-arg] [optional-arg]
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Command Title
|
|
31
|
+
|
|
32
|
+
Your command instructions here.
|
|
33
|
+
|
|
34
|
+
Arguments: $ARGUMENTS
|
|
35
|
+
|
|
36
|
+
File reference: @path/to/file.js
|
|
37
|
+
|
|
38
|
+
Bash command output: (exclamation)git status(backticks)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## ⚠️ Security Restrictions
|
|
42
|
+
|
|
43
|
+
**Bash Commands (exclamation prefix)**: Limited to current working directory only.
|
|
44
|
+
- ✅ Works: `! + backtick + git status + backtick` (in project dir)
|
|
45
|
+
- ❌ Blocked: `! + backtick + ls /outside/project + backtick` (outside project)
|
|
46
|
+
- ❌ Blocked: `! + backtick + pwd + backtick` (if referencing dirs outside project)
|
|
47
|
+
|
|
48
|
+
**File References (`@` prefix)**: No directory restrictions.
|
|
49
|
+
- ✅ Works: `@/path/to/system/file.md`
|
|
50
|
+
- ✅ Works: `@../other-project/file.js`
|
|
51
|
+
|
|
52
|
+
## Common Patterns
|
|
53
|
+
|
|
54
|
+
### Simple Command
|
|
55
|
+
```bash
|
|
56
|
+
echo "Review this code for bugs and suggest fixes" > ~/.claude/commands/review.md
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Command with Arguments
|
|
60
|
+
```markdown
|
|
61
|
+
Fix issue #$ARGUMENTS following our coding standards
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Command with File References
|
|
65
|
+
```markdown
|
|
66
|
+
Compare @src/old.js with @src/new.js and explain differences
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Command with Bash Output (Project Directory Only)
|
|
70
|
+
```markdown
|
|
71
|
+
---
|
|
72
|
+
allowed-tools: Bash(git status:*), Bash(git branch:*), Bash(git log:*)
|
|
73
|
+
---
|
|
74
|
+
Current status: (!)git status(`)
|
|
75
|
+
Current branch: (!)git branch --show-current(`)
|
|
76
|
+
Recent commits: (!)git log --oneline -5(`)
|
|
77
|
+
|
|
78
|
+
Create commit for these changes.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Note**: Only works with commands in the current project directory.
|
|
82
|
+
|
|
83
|
+
### Namespaced Command
|
|
84
|
+
```bash
|
|
85
|
+
mkdir -p ~/.claude/commands/ai
|
|
86
|
+
echo "Ask GPT-5 about: $ARGUMENTS" > ~/.claude/commands/ai/gpt5.md
|
|
87
|
+
# Creates: /ai:gpt5
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Frontmatter Options
|
|
91
|
+
- `allowed-tools`: Tools this command can use
|
|
92
|
+
- **Important**: Intrusive tools like `Write`, `Edit`, `NotebookEdit` should NEVER be allowed in commands unless the user explicitly requests them. These tools modify files and should only be used when the command's purpose is to make changes.
|
|
93
|
+
- ✅ Safe for most commands: `Read`, `Glob`, `Grep`, `Bash(git status:*)`, `Task`, `AskUserQuestion`
|
|
94
|
+
- `description`: Brief description (shows in /help)
|
|
95
|
+
- `argument-hint`: Help text for arguments
|
|
96
|
+
- `model`: Specific model to use
|
|
97
|
+
|
|
98
|
+
## Best Practices
|
|
99
|
+
|
|
100
|
+
### Safe Commands (No Security Issues)
|
|
101
|
+
```markdown
|
|
102
|
+
# System prompt editor (file reference only)
|
|
103
|
+
(@)path/to/system/prompt.md
|
|
104
|
+
|
|
105
|
+
Edit your system prompt above.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Project-Specific Commands (Bash OK)
|
|
109
|
+
```markdown
|
|
110
|
+
---
|
|
111
|
+
allowed-tools: Bash(git status:*), Bash(npm list:*)
|
|
112
|
+
---
|
|
113
|
+
Current git status: (!)git status(`)
|
|
114
|
+
Package info: (!)npm list --depth=0(`)
|
|
115
|
+
|
|
116
|
+
Review project state and suggest next steps.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Cross-Directory File Access (Use @ not !)
|
|
120
|
+
```markdown
|
|
121
|
+
# Compare config files
|
|
122
|
+
Compare (@)path/to/system.md with (@)project/config.md
|
|
123
|
+
|
|
124
|
+
Show differences and suggest improvements.
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Usage
|
|
128
|
+
After creating: `/<command-name> [arguments]`
|
|
129
|
+
|
|
130
|
+
Example: `/review` or `/ai:gpt5 "explain this code"`
|