spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / plugin-dev / skills / command-development / examples / simple-commands.md
504 lines · 8.5 KBPreviewCodeRaw
1# Simple Command Examples
2
3Basic slash command patterns for common use cases.
4
5**Important:** All examples below are written as instructions FOR Claude (agent consumption), not messages TO users. Commands tell Claude what to do, not tell users what will happen.
6
7## Example 1: Code Review Command
8
9**File:** `.claude/commands/review.md`
10
11```markdown
12---
13description: Review code for quality and issues
14allowed-tools: Read, Bash(git:*)
15---
16
17Review the code in this repository for:
18
191. **Code Quality:**
20 - Readability and maintainability
21 - Consistent style and formatting
22 - Appropriate abstraction levels
23
242. **Potential Issues:**
25 - Logic errors or bugs
26 - Edge cases not handled
27 - Performance concerns
28
293. **Best Practices:**
30 - Design patterns used correctly
31 - Error handling present
32 - Documentation adequate
33
34Provide specific feedback with file and line references.
35```
36
37**Usage:**
38```
39> /review
40```
41
42---
43
44## Example 2: Security Review Command
45
46**File:** `.claude/commands/security-review.md`
47
48```markdown
49---
50description: Review code for security vulnerabilities
51allowed-tools: Read, Grep
52model: sonnet
53---
54
55Perform comprehensive security review checking for:
56
57**Common Vulnerabilities:**
58- SQL injection risks
59- Cross-site scripting (XSS)
60- Authentication/authorization issues
61- Insecure data handling
62- Hardcoded secrets or credentials
63
64**Security Best Practices:**
65- Input validation present
66- Output encoding correct
67- Secure defaults used
68- Error messages safe
69- Logging appropriate (no sensitive data)
70
71For each issue found:
72- File and line number
73- Severity (Critical/High/Medium/Low)
74- Description of vulnerability
75- Recommended fix
76
77Prioritize issues by severity.
78```
79
80**Usage:**
81```
82> /security-review
83```
84
85---
86
87## Example 3: Test Command with File Argument
88
89**File:** `.claude/commands/test-file.md`
90
91```markdown
92---
93description: Run tests for specific file
94argument-hint: [test-file]
95allowed-tools: Bash(npm:*), Bash(jest:*)
96---
97
98Run tests for $1:
99
100Test execution: !`npm test $1`
101
102Analyze results:
103- Tests passed/failed
104- Code coverage
105- Performance issues
106- Flaky tests
107
108If failures found, suggest fixes based on error messages.
109```
110
111**Usage:**
112```
113> /test-file src/utils/helpers.test.ts
114```
115
116---
117
118## Example 4: Documentation Generator
119
120**File:** `.claude/commands/document.md`
121
122```markdown
123---
124description: Generate documentation for file
125argument-hint: [source-file]
126---
127
128Generate comprehensive documentation for @$1
129
130Include:
131
132**Overview:**
133- Purpose and responsibility
134- Main functionality
135- Dependencies
136
137**API Documentation:**
138- Function/method signatures
139- Parameter descriptions with types
140- Return values with types
141- Exceptions/errors thrown
142
143**Usage Examples:**
144- Basic usage
145- Common patterns
146- Edge cases
147
148**Implementation Notes:**
149- Algorithm complexity
150- Performance considerations
151- Known limitations
152
153Format as Markdown suitable for project documentation.
154```
155
156**Usage:**
157```
158> /document src/api/users.ts
159```
160
161---
162
163## Example 5: Git Status Summary
164
165**File:** `.claude/commands/git-status.md`
166
167```markdown
168---
169description: Summarize Git repository status
170allowed-tools: Bash(git:*)
171---
172
173Repository Status Summary:
174
175**Current Branch:** !`git branch --show-current`
176
177**Status:** !`git status --short`
178
179**Recent Commits:** !`git log --oneline -5`
180
181**Remote Status:** !`git fetch && git status -sb`
182
183Provide:
184- Summary of changes
185- Suggested next actions
186- Any warnings or issues
187```
188
189**Usage:**
190```
191> /git-status
192```
193
194---
195
196## Example 6: Deployment Command
197
198**File:** `.claude/commands/deploy.md`
199
200```markdown
201---
202description: Deploy to specified environment
203argument-hint: [environment] [version]
204allowed-tools: Bash(kubectl:*), Read
205---
206
207Deploy to $1 environment using version $2
208
209**Pre-deployment Checks:**
2101. Verify $1 configuration exists
2112. Check version $2 is valid
2123. Verify cluster accessibility: !`kubectl cluster-info`
213
214**Deployment Steps:**
2151. Update deployment manifest with version $2
2162. Apply configuration to $1
2173. Monitor rollout status
2184. Verify pod health
2195. Run smoke tests
220
221**Rollback Plan:**
222Document current version for rollback if issues occur.
223
224Proceed with deployment? (yes/no)
225```
226
227**Usage:**
228```
229> /deploy staging v1.2.3
230```
231
232---
233
234## Example 7: Comparison Command
235
236**File:** `.claude/commands/compare-files.md`
237
238```markdown
239---
240description: Compare two files
241argument-hint: [file1] [file2]
242---
243
244Compare @$1 with @$2
245
246**Analysis:**
247
2481. **Differences:**
249 - Lines added
250 - Lines removed
251 - Lines modified
252
2532. **Functional Changes:**
254 - Breaking changes
255 - New features
256 - Bug fixes
257 - Refactoring
258
2593. **Impact:**
260 - Affected components
261 - Required updates elsewhere
262 - Migration requirements
263
2644. **Recommendations:**
265 - Code review focus areas
266 - Testing requirements
267 - Documentation updates needed
268
269Present as structured comparison report.
270```
271
272**Usage:**
273```
274> /compare-files src/old-api.ts src/new-api.ts
275```
276
277---
278
279## Example 8: Quick Fix Command
280
281**File:** `.claude/commands/quick-fix.md`
282
283```markdown
284---
285description: Quick fix for common issues
286argument-hint: [issue-description]
287model: haiku
288---
289
290Quickly fix: $ARGUMENTS
291
292**Approach:**
2931. Identify the issue
2942. Find relevant code
2953. Propose fix
2964. Explain solution
297
298Focus on:
299- Simple, direct solution
300- Minimal changes
301- Following existing patterns
302- No breaking changes
303
304Provide code changes with file paths and line numbers.
305```
306
307**Usage:**
308```
309> /quick-fix button not responding to clicks
310> /quick-fix typo in error message
311```
312
313---
314
315## Example 9: Research Command
316
317**File:** `.claude/commands/research.md`
318
319```markdown
320---
321description: Research best practices for topic
322argument-hint: [topic]
323model: sonnet
324---
325
326Research best practices for: $ARGUMENTS
327
328**Coverage:**
329
3301. **Current State:**
331 - How we currently handle this
332 - Existing implementations
333
3342. **Industry Standards:**
335 - Common patterns
336 - Recommended approaches
337 - Tools and libraries
338
3393. **Comparison:**
340 - Our approach vs standards
341 - Gaps or improvements needed
342 - Migration considerations
343
3444. **Recommendations:**
345 - Concrete action items
346 - Priority and effort estimates
347 - Resources for implementation
348
349Provide actionable guidance based on research.
350```
351
352**Usage:**
353```
354> /research error handling in async operations
355> /research API authentication patterns
356```
357
358---
359
360## Example 10: Explain Code Command
361
362**File:** `.claude/commands/explain.md`
363
364```markdown
365---
366description: Explain how code works
367argument-hint: [file-or-function]
368---
369
370Explain @$1 in detail
371
372**Explanation Structure:**
373
3741. **Overview:**
375 - What it does
376 - Why it exists
377 - How it fits in system
378
3792. **Step-by-Step:**
380 - Line-by-line walkthrough
381 - Key algorithms or logic
382 - Important details
383
3843. **Inputs and Outputs:**
385 - Parameters and types
386 - Return values
387 - Side effects
388
3894. **Edge Cases:**
390 - Error handling
391 - Special cases
392 - Limitations
393
3945. **Usage Examples:**
395 - How to call it
396 - Common patterns
397 - Integration points
398
399Explain at level appropriate for junior engineer.
400```
401
402**Usage:**
403```
404> /explain src/utils/cache.ts
405> /explain AuthService.login
406```
407
408---
409
410## Key Patterns
411
412### Pattern 1: Read-Only Analysis
413
414```markdown
415---
416allowed-tools: Read, Grep
417---
418
419Analyze but don't modify...
420```
421
422**Use for:** Code review, documentation, analysis
423
424### Pattern 2: Git Operations
425
426```markdown
427---
428allowed-tools: Bash(git:*)
429---
430
431!`git status`
432Analyze and suggest...
433```
434
435**Use for:** Repository status, commit analysis
436
437### Pattern 3: Single Argument
438
439```markdown
440---
441argument-hint: [target]
442---
443
444Process $1...
445```
446
447**Use for:** File operations, targeted actions
448
449### Pattern 4: Multiple Arguments
450
451```markdown
452---
453argument-hint: [source] [target] [options]
454---
455
456Process $1 to $2 with $3...
457```
458
459**Use for:** Workflows, deployments, comparisons
460
461### Pattern 5: Fast Execution
462
463```markdown
464---
465model: haiku
466---
467
468Quick simple task...
469```
470
471**Use for:** Simple, repetitive commands
472
473### Pattern 6: File Comparison
474
475```markdown
476Compare @$1 with @$2...
477```
478
479**Use for:** Diff analysis, migration planning
480
481### Pattern 7: Context Gathering
482
483```markdown
484---
485allowed-tools: Bash(git:*), Read
486---
487
488Context: !`git status`
489Files: @file1 @file2
490
491Analyze...
492```
493
494**Use for:** Informed decision making
495
496## Tips for Writing Simple Commands
497
4981. **Start basic:** Single responsibility, clear purpose
4992. **Add complexity gradually:** Start without frontmatter
5003. **Test incrementally:** Verify each feature works
5014. **Use descriptive names:** Command name should indicate purpose
5025. **Document arguments:** Always use argument-hint
5036. **Provide examples:** Show usage in comments
5047. **Handle errors:** Consider missing arguments or files