@devobsessed/code-captain 0.2.0 → 0.2.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/bin/install.js +40 -10
- package/copilot/agents/Code Captain.agent.md +16 -18
- package/copilot/copilot-instructions.md +64 -0
- package/copilot/prompts/create-adr.prompt.md +18 -106
- package/copilot/prompts/create-spec.prompt.md +26 -113
- package/copilot/prompts/edit-spec.prompt.md +11 -180
- package/copilot/prompts/execute-task.prompt.md +7 -22
- package/copilot/prompts/explain-code.prompt.md +14 -139
- package/copilot/prompts/initialize.prompt.md +9 -12
- package/copilot/prompts/new-command.prompt.md +25 -213
- package/copilot/prompts/plan-product.prompt.md +15 -306
- package/copilot/prompts/research.prompt.md +12 -139
- package/copilot/prompts/status.prompt.md +37 -365
- package/copilot/prompts/swab.prompt.md +9 -135
- package/manifest.json +92 -84
- package/package.json +1 -1
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
---
|
|
2
|
-
agent:
|
|
2
|
+
agent: agent
|
|
3
|
+
description: "Provide comprehensive project status with next actions"
|
|
3
4
|
---
|
|
4
5
|
|
|
5
|
-
# Status
|
|
6
|
+
# You are executing the Status command.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
You MUST follow these instructions exactly. Do NOT describe this process — execute it.
|
|
8
9
|
|
|
9
|
-
Provide
|
|
10
|
+
Your mission: Provide the developer with a comprehensive status report. Analyze the current git state, active work, and project health to orient the developer and suggest next actions.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
### Step 1: Git Status & Context Analysis
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
**Current Position:**
|
|
14
|
+
**Gather current position:**
|
|
15
15
|
- Branch name and relationship to main/origin
|
|
16
16
|
- Commits ahead/behind main branch
|
|
17
17
|
- Last commit message and timestamp
|
|
18
18
|
- Uncommitted changes summary (files modified, added, deleted)
|
|
19
19
|
- Stash status if any
|
|
20
20
|
|
|
21
|
-
**Recent
|
|
21
|
+
**Recent activity:**
|
|
22
22
|
- Last 3-5 commits on current branch
|
|
23
23
|
- Recent activity on main branch that might affect current work
|
|
24
24
|
- Branch age and creation context
|
|
25
25
|
|
|
26
|
-
### 2
|
|
26
|
+
### Step 2: Active Work Detection
|
|
27
|
+
|
|
27
28
|
**Code Captain Integration:**
|
|
28
29
|
- Scan `.code-captain/specs/` for active specifications
|
|
29
|
-
- Parse current task progress from most recent spec's
|
|
30
|
+
- Parse current task progress from most recent spec's user-stories/
|
|
30
31
|
- Identify completed vs pending tasks
|
|
31
32
|
- Determine current user story context
|
|
32
33
|
|
|
@@ -35,7 +36,8 @@ Provide developers with a comprehensive status report when starting work or swit
|
|
|
35
36
|
- Identify obvious next steps based on file changes
|
|
36
37
|
- Check for TODO comments in recently modified files
|
|
37
38
|
|
|
38
|
-
### 3
|
|
39
|
+
### Step 3: Project Health Check
|
|
40
|
+
|
|
39
41
|
**Basic Viability:**
|
|
40
42
|
- Can the project build/compile? (language-specific checks)
|
|
41
43
|
- Are core services startable?
|
|
@@ -47,232 +49,48 @@ Provide developers with a comprehensive status report when starting work or swit
|
|
|
47
49
|
- Missing environment variables or config files
|
|
48
50
|
- Failed builds or critical errors
|
|
49
51
|
|
|
50
|
-
### 4
|
|
51
|
-
**Based on Current State:**
|
|
52
|
-
- If mid-task: Suggest `/execute-task`
|
|
53
|
-
- If no active work: Suggest `/create-spec`
|
|
54
|
-
- If specifications exist: Suggest implementation with `/execute-task`
|
|
55
|
-
- Always suggest `/swab` for code cleanup
|
|
56
|
-
|
|
57
|
-
## Output Format
|
|
52
|
+
### Step 4: Output the Status Report
|
|
58
53
|
|
|
59
|
-
**Important**:
|
|
54
|
+
**Important**: Output the status report as **clean, formatted text** (not wrapped in code blocks) for optimal readability.
|
|
60
55
|
|
|
61
|
-
|
|
56
|
+
**Standard format:**
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
```
|
|
59
|
+
Code Captain Status Report
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
CURRENT POSITION
|
|
67
62
|
Branch: feature/dashboard-websockets (2 commits ahead of main)
|
|
68
63
|
Last commit: "Add WebSocket connection hook" (2 hours ago)
|
|
69
64
|
Uncommitted: 3 modified files in src/components/
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
Spec: Real-time Dashboard with WebSocket Integration
|
|
66
|
+
ACTIVE WORK
|
|
67
|
+
Spec: Real-time Dashboard with WebSocket Integration
|
|
73
68
|
Progress: Story 2 (User receives real-time notifications) - In Progress
|
|
74
69
|
Tasks completed: 3/6 tasks (50%)
|
|
75
|
-
Last completed: 2.3 Create notification display component
|
|
70
|
+
Last completed: 2.3 Create notification display component
|
|
76
71
|
Next task: 2.4 Implement client-side WebSocket connection
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
SUGGESTED ACTIONS
|
|
74
|
+
- Continue with task 2.4 (WebSocket connection management)
|
|
75
|
+
- Commit current changes before switching tasks
|
|
76
|
+
- Review recent main branch changes (3 new commits)
|
|
82
77
|
|
|
83
|
-
|
|
78
|
+
QUICK COMMANDS
|
|
84
79
|
/execute-task # Continue current task
|
|
85
|
-
/commit-wip # Commit work in progress
|
|
86
|
-
/sync-main # Pull latest from main
|
|
87
80
|
/swab # Quick code cleanup
|
|
88
|
-
|
|
89
|
-
### Clean State Example
|
|
90
|
-
|
|
91
|
-
⚓ Code Captain Status Report
|
|
92
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
93
|
-
|
|
94
|
-
📍 CURRENT POSITION
|
|
95
|
-
Branch: main (up to date)
|
|
96
|
-
Last commit: "Fix user authentication bug" (1 day ago)
|
|
97
|
-
Working directory: Clean ✅
|
|
98
|
-
|
|
99
|
-
📋 ACTIVE WORK
|
|
100
|
-
No active specifications found
|
|
101
|
-
Ready to start new work
|
|
102
|
-
|
|
103
|
-
🎯 SUGGESTED ACTIONS
|
|
104
|
-
• Start new feature development
|
|
105
|
-
• Review pending issues or backlog
|
|
106
|
-
• Perform maintenance tasks
|
|
107
|
-
|
|
108
|
-
⚡ QUICK COMMANDS
|
|
109
|
-
/create-spec # Plan new feature
|
|
110
|
-
/swab # Clean up existing code
|
|
111
|
-
/review-specs # Check previous specifications
|
|
112
|
-
|
|
113
|
-
### Problem State Example
|
|
114
|
-
|
|
115
|
-
⚓ Code Captain Status Report
|
|
116
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
117
|
-
|
|
118
|
-
📍 CURRENT POSITION
|
|
119
|
-
Branch: feature/payment-flow (5 commits ahead, 2 behind main)
|
|
120
|
-
Last commit: "WIP: payment validation" (3 days ago)
|
|
121
|
-
Uncommitted: 7 modified files, 2 conflicts
|
|
122
|
-
|
|
123
|
-
⚠️ IMMEDIATE ATTENTION
|
|
124
|
-
• Merge conflicts in src/api/payments.js, package.json
|
|
125
|
-
• Branch is 2 commits behind main (potential conflicts)
|
|
126
|
-
• Stashed changes from 2 days ago
|
|
127
|
-
|
|
128
|
-
📋 ACTIVE WORK
|
|
129
|
-
Spec: Payment Processing Integration
|
|
130
|
-
Progress: Story 1 (User completes payment flow) - In Progress
|
|
131
|
-
Tasks completed: 3/5 tasks (60%)
|
|
132
|
-
Status: Task 1.4 appears incomplete
|
|
133
|
-
Next task: 1.4 Validate payment with external API
|
|
134
|
-
|
|
135
|
-
🎯 SUGGESTED ACTIONS
|
|
136
|
-
• Resolve merge conflicts first
|
|
137
|
-
• Sync with main branch changes
|
|
138
|
-
• Review stashed changes for relevance
|
|
139
|
-
• Continue or restart task 1.4
|
|
140
|
-
|
|
141
|
-
⚡ QUICK COMMANDS
|
|
142
|
-
/execute-task # Continue current task
|
|
143
|
-
/swab # Code cleanup
|
|
144
|
-
|
|
145
|
-
## Implementation Details
|
|
146
|
-
|
|
147
|
-
### Output Presentation
|
|
148
|
-
|
|
149
|
-
**Critical**: When executing the status command, the report should be presented as **clean, formatted text** directly in the chat response, NOT wrapped in code blocks or markdown formatting. This ensures maximum readability and a professional presentation.
|
|
150
|
-
|
|
151
|
-
The status report uses Unicode characters (⚓, 📍, 📋, 🎯, ⚡, ⚠️) and box-drawing characters (━) for visual appeal. These should be output exactly as shown in the examples above.
|
|
152
|
-
|
|
153
|
-
### Git Analysis
|
|
154
|
-
**Commands to Run:**
|
|
155
|
-
```bash
|
|
156
|
-
git status --porcelain # File changes
|
|
157
|
-
git log --oneline -5 # Recent commits
|
|
158
|
-
git log main..HEAD --oneline # Commits ahead
|
|
159
|
-
git log HEAD..main --oneline # Commits behind
|
|
160
|
-
git stash list # Stashed changes
|
|
161
|
-
git branch -v # Branch info
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
**Parsing Logic:**
|
|
165
|
-
- Extract meaningful context from commit messages
|
|
166
|
-
- Detect work patterns (feature vs bug fix vs refactor)
|
|
167
|
-
- Identify if work appears complete or in-progress
|
|
168
|
-
- Calculate time since last activity
|
|
169
|
-
|
|
170
|
-
### Code Captain Integration
|
|
171
|
-
|
|
172
|
-
**Spec Detection:**
|
|
173
|
-
```bash
|
|
174
|
-
# Find most recent spec directory
|
|
175
|
-
LATEST_SPEC=$(ls -t .code-captain/specs/*/spec.md | head -1 | xargs dirname)
|
|
176
|
-
|
|
177
|
-
# Read overall progress from user stories overview
|
|
178
|
-
cat "$LATEST_SPEC/user-stories/README.md"
|
|
179
|
-
|
|
180
|
-
# Find all individual story files
|
|
181
|
-
ls "$LATEST_SPEC/user-stories/story-"*.md
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
**Task Progress Analysis:**
|
|
185
|
-
|
|
186
|
-
For each individual story file (`user-stories/story-N-{name}.md`), parse the Implementation Tasks section:
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
# Count completed tasks (marked with [x])
|
|
190
|
-
grep -c "^\- \[x\].*✅" story-file.md
|
|
191
|
-
|
|
192
|
-
# Count total tasks (any checkbox)
|
|
193
|
-
grep -c "^\- \[[x ]\]" story-file.md
|
|
194
|
-
|
|
195
|
-
# Find next incomplete task
|
|
196
|
-
grep -n "^\- \[ \]" story-file.md | head -1
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
**Story Status Detection:**
|
|
200
|
-
|
|
201
|
-
Parse the story status from the header:
|
|
202
|
-
```bash
|
|
203
|
-
# Extract status from story file header
|
|
204
|
-
grep "^> \*\*Status:\*\*" story-file.md
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Possible statuses:
|
|
208
|
-
- `Not Started` - No tasks completed
|
|
209
|
-
- `In Progress` - Some tasks completed, some remaining
|
|
210
|
-
- `Completed ✅` - All tasks and acceptance criteria completed
|
|
211
|
-
|
|
212
|
-
**Progress Analysis:**
|
|
213
|
-
- Count completed vs total tasks across all stories
|
|
214
|
-
- Identify current active story (has In Progress status)
|
|
215
|
-
- Extract next logical task from current story
|
|
216
|
-
- Detect if entire spec work is complete
|
|
217
|
-
- Parse progress summary from `user-stories/README.md` table
|
|
218
|
-
|
|
219
|
-
**Active Work Prioritization:**
|
|
220
|
-
|
|
221
|
-
1. **Multiple specs exist**: Show the most recently modified spec (based on file timestamps)
|
|
222
|
-
2. **Single spec, multiple stories**: Show the story with "In Progress" status, or first "Not Started" story if none in progress
|
|
223
|
-
3. **All stories complete**: Show overall completion status and suggest next actions
|
|
224
|
-
4. **No specs found**: Indicate no Code Captain specifications exist
|
|
225
|
-
|
|
226
|
-
**Task Parsing Edge Cases:**
|
|
227
|
-
|
|
228
|
-
Handle various task formats that may exist in story files:
|
|
229
|
-
```bash
|
|
230
|
-
# Standard format with checkmark
|
|
231
|
-
- [x] 1.1 Implement authentication ✅
|
|
232
|
-
|
|
233
|
-
# Format without checkmark emoji
|
|
234
|
-
- [x] 1.1 Implement authentication
|
|
235
|
-
|
|
236
|
-
# Incomplete task
|
|
237
|
-
- [ ] 1.2 Add validation logic
|
|
238
|
-
|
|
239
|
-
# Tasks with sub-items (count as single task)
|
|
240
|
-
- [x] 1.3 Database setup
|
|
241
|
-
- Created user table
|
|
242
|
-
- Added indexes
|
|
243
81
|
```
|
|
244
82
|
|
|
245
|
-
|
|
246
|
-
- Only count top-level task items (lines starting with `- [`)
|
|
247
|
-
- Ignore indented sub-items
|
|
248
|
-
- Handle both `[x]` and `[X]` as completed
|
|
249
|
-
- Treat any other character in brackets as incomplete
|
|
250
|
-
|
|
251
|
-
### Project Health Checks
|
|
252
|
-
**Language-Specific:**
|
|
253
|
-
```bash
|
|
254
|
-
# Node.js
|
|
255
|
-
npm run build --if-present
|
|
256
|
-
node -c package.json
|
|
83
|
+
### Step 5: Contextual Command Suggestions
|
|
257
84
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
### Command Suggestion Logic
|
|
268
|
-
**Decision Tree:**
|
|
269
|
-
1. **Is there a merge conflict?** → Suggest conflict resolution
|
|
270
|
-
2. **Is working directory dirty?** → Suggest commit or stash
|
|
271
|
-
3. **Is branch behind main?** → Suggest sync
|
|
272
|
-
4. **Is there an active task?** → Suggest continue task
|
|
273
|
-
5. **Is current task complete?** → Suggest next task
|
|
274
|
-
6. **No active work?** → Suggest create spec
|
|
275
|
-
7. **Always:** → Suggest swab for cleanup
|
|
85
|
+
**Based on current state, suggest relevant next steps:**
|
|
86
|
+
- If mid-task: Suggest `/execute-task`
|
|
87
|
+
- If no active work: Suggest `/create-spec`
|
|
88
|
+
- If specifications exist: Suggest implementation with `/execute-task`
|
|
89
|
+
- If code quality issues: Suggest `/swab`
|
|
90
|
+
- If no specs: Suggest `/create-spec` or `/plan-product`
|
|
91
|
+
- If missing architecture docs: Suggest `/create-adr`
|
|
92
|
+
- If research needed: Suggest `/research`
|
|
93
|
+
- Always suggest `/swab` for code cleanup
|
|
276
94
|
|
|
277
95
|
## Tool Integration
|
|
278
96
|
|
|
@@ -287,149 +105,3 @@ pip check
|
|
|
287
105
|
- Status reports provide real-time project state
|
|
288
106
|
- Integration with existing `.code-captain/specs/` structure
|
|
289
107
|
- Cross-references to active work and suggestions
|
|
290
|
-
|
|
291
|
-
## Usage Patterns
|
|
292
|
-
|
|
293
|
-
### Morning Routine
|
|
294
|
-
```bash
|
|
295
|
-
# Developer starts their day
|
|
296
|
-
$ /status
|
|
297
|
-
|
|
298
|
-
# Gets oriented on yesterday's work
|
|
299
|
-
# Sees exactly what to do next
|
|
300
|
-
# Jumps into flow state quickly
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### Context Switching
|
|
304
|
-
```bash
|
|
305
|
-
# After meetings, interruptions, or breaks
|
|
306
|
-
$ /status
|
|
307
|
-
|
|
308
|
-
# Quick reminder of current state
|
|
309
|
-
# Understand what changed while away
|
|
310
|
-
# Resume work efficiently
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
### Project Handoff
|
|
314
|
-
```bash
|
|
315
|
-
# When picking up someone else's work
|
|
316
|
-
$ /status
|
|
317
|
-
|
|
318
|
-
# Understand current project state
|
|
319
|
-
# See what was being worked on
|
|
320
|
-
# Get oriented without diving into code
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
## Error Handling
|
|
324
|
-
|
|
325
|
-
### Not a Git Repository
|
|
326
|
-
```bash
|
|
327
|
-
❌ Not in a git repository
|
|
328
|
-
Initialize git first: git init
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### No Code Captain Structure
|
|
332
|
-
```bash
|
|
333
|
-
⚓ Code Captain Status Report
|
|
334
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
335
|
-
|
|
336
|
-
📍 CURRENT POSITION
|
|
337
|
-
Branch: main (up to date)
|
|
338
|
-
Last commit: "Initial commit" (1 hour ago)
|
|
339
|
-
Working directory: Clean ✅
|
|
340
|
-
|
|
341
|
-
📋 ACTIVE WORK
|
|
342
|
-
No Code Captain specifications found
|
|
343
|
-
Project structure: Standard git repository
|
|
344
|
-
|
|
345
|
-
🎯 SUGGESTED ACTIONS
|
|
346
|
-
• Set up Code Captain workflow
|
|
347
|
-
• Create first feature specification
|
|
348
|
-
|
|
349
|
-
⚡ QUICK COMMANDS
|
|
350
|
-
/init # Initialize Code Captain
|
|
351
|
-
/create-spec # Create first specification
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### Corrupted Project State
|
|
355
|
-
```bash
|
|
356
|
-
⚠️ PROJECT ISSUES DETECTED
|
|
357
|
-
• package.json syntax error
|
|
358
|
-
• Missing critical dependencies
|
|
359
|
-
• Build process failing
|
|
360
|
-
|
|
361
|
-
🔧 SUGGESTED FIXES
|
|
362
|
-
• Fix package.json syntax
|
|
363
|
-
• Run npm install or equivalent
|
|
364
|
-
• Check build configuration
|
|
365
|
-
|
|
366
|
-
⚡ RECOVERY COMMANDS
|
|
367
|
-
/doctor # Diagnose and fix common issues
|
|
368
|
-
/reset-deps # Reinstall dependencies
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
## Security & Privacy
|
|
372
|
-
|
|
373
|
-
### Local-Only Analysis
|
|
374
|
-
- All analysis happens locally
|
|
375
|
-
- No external API calls or data transmission
|
|
376
|
-
- Git history and file contents remain private
|
|
377
|
-
|
|
378
|
-
### Sensitive Information
|
|
379
|
-
- Avoid displaying sensitive data in commit messages
|
|
380
|
-
- Mask environment variables or config values
|
|
381
|
-
- Sanitize file paths that might contain personal info
|
|
382
|
-
|
|
383
|
-
## Performance Considerations
|
|
384
|
-
|
|
385
|
-
### Fast Execution
|
|
386
|
-
- Target <2 second execution time
|
|
387
|
-
- Cache expensive operations when possible
|
|
388
|
-
- Limit git log queries to reasonable ranges
|
|
389
|
-
|
|
390
|
-
### Incremental Analysis
|
|
391
|
-
- Store last analysis timestamp
|
|
392
|
-
- Only re-analyze changed files/commits
|
|
393
|
-
- Use git's efficient diffing for change detection
|
|
394
|
-
|
|
395
|
-
## Integration Points
|
|
396
|
-
|
|
397
|
-
### Existing Code Captain Commands
|
|
398
|
-
- Status should inform other commands about current state
|
|
399
|
-
- Share analysis results to avoid duplicate work
|
|
400
|
-
- Coordinate with task execution and spec management
|
|
401
|
-
|
|
402
|
-
### Future Enhancements
|
|
403
|
-
- Integration with GitHub/GitLab for PR status
|
|
404
|
-
- Team activity awareness (without external dependencies)
|
|
405
|
-
- Customizable status report sections
|
|
406
|
-
- Export status for external tools or dashboards
|
|
407
|
-
|
|
408
|
-
## Success Metrics
|
|
409
|
-
|
|
410
|
-
### Developer Experience
|
|
411
|
-
- Time to context restoration after interruptions
|
|
412
|
-
- Frequency of "what was I working on?" moments
|
|
413
|
-
- Accuracy of suggested next actions
|
|
414
|
-
- Adoption rate and daily usage patterns
|
|
415
|
-
|
|
416
|
-
### Project Health
|
|
417
|
-
- Early detection of project issues
|
|
418
|
-
- Improved workflow consistency
|
|
419
|
-
- Better task completion rates
|
|
420
|
-
- Reduced context switching overhead
|
|
421
|
-
|
|
422
|
-
---
|
|
423
|
-
|
|
424
|
-
*⚓ Keep your bearings, maintain your heading, and always know where you stand in the code.*
|
|
425
|
-
|
|
426
|
-
## Suggested Next Actions
|
|
427
|
-
|
|
428
|
-
Based on project state analysis, suggest relevant next steps:
|
|
429
|
-
|
|
430
|
-
- **No specs**: Suggest `/create-spec` or `/plan-product`
|
|
431
|
-
- **Specs ready for implementation**: Suggest `/execute-task`
|
|
432
|
-
- **Tasks ready**: Suggest `/execute-task`
|
|
433
|
-
- **Code quality issues**: Suggest `/swab`
|
|
434
|
-
- **Missing architecture**: Suggest `/create-adr`
|
|
435
|
-
- **Research needed**: Suggest `/research`
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
---
|
|
2
|
-
agent:
|
|
2
|
+
agent: agent
|
|
3
|
+
description: "Make one focused code improvement following the Boy Scout Rule"
|
|
3
4
|
---
|
|
4
5
|
|
|
5
|
-
# Swab
|
|
6
|
+
# You are executing the Swab command.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
You MUST follow these instructions exactly. Do NOT describe this process — execute it.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Command Process
|
|
10
|
+
Your mission: Find exactly ONE small, safe improvement opportunity in the codebase and apply it with the developer's approval. Follow the Boy Scout Rule — leave the code cleaner than you found it.
|
|
12
11
|
|
|
13
12
|
### Step 1: Codebase Scanning
|
|
14
13
|
|
|
@@ -38,7 +37,7 @@ A deck-cleaning agent that makes one small, focused improvement to the codebase,
|
|
|
38
37
|
|
|
39
38
|
**Priority Order:**
|
|
40
39
|
1. Variable/function name improvements
|
|
41
|
-
2. Magic number extraction to constants
|
|
40
|
+
2. Magic number extraction to constants
|
|
42
41
|
3. Adding missing error handling
|
|
43
42
|
4. Removing dead code
|
|
44
43
|
5. Formatting consistency fixes
|
|
@@ -47,7 +46,7 @@ A deck-cleaning agent that makes one small, focused improvement to the codebase,
|
|
|
47
46
|
|
|
48
47
|
**Display Format:**
|
|
49
48
|
```
|
|
50
|
-
|
|
49
|
+
Swabbing the deck... found some mess in {filename}
|
|
51
50
|
|
|
52
51
|
=== SUGGESTED CLEANUP ===
|
|
53
52
|
|
|
@@ -65,10 +64,10 @@ Clean this up? [y/N]
|
|
|
65
64
|
**If approved:**
|
|
66
65
|
- Make the exact replacement using search/replace
|
|
67
66
|
- Verify the change was applied correctly
|
|
68
|
-
- Show success message: "
|
|
67
|
+
- Show success message: "Deck swabbed! One less mess aboard."
|
|
69
68
|
|
|
70
69
|
**If declined:**
|
|
71
|
-
- Exit gracefully with: "
|
|
70
|
+
- Exit gracefully with: "Deck inspection complete. No changes made."
|
|
72
71
|
|
|
73
72
|
## Core Rules
|
|
74
73
|
|
|
@@ -79,109 +78,6 @@ Clean this up? [y/N]
|
|
|
79
78
|
5. **Exact replacements** - Surgical precision, no formatting noise
|
|
80
79
|
6. **Conservative approach** - Better to find nothing than break something
|
|
81
80
|
|
|
82
|
-
## AI Implementation Prompt
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
You are a code reviewer cleaning up small messes on the ship.
|
|
86
|
-
|
|
87
|
-
MISSION: Find exactly ONE small, safe cleanup opportunity in the codebase.
|
|
88
|
-
|
|
89
|
-
RULES:
|
|
90
|
-
- Find ONE small cleanup only (1-10 lines max changed)
|
|
91
|
-
- Prioritize clarity and safety over cleverness
|
|
92
|
-
- Preserve all existing functionality exactly
|
|
93
|
-
- Be extremely conservative - if ANY uncertainty, do nothing
|
|
94
|
-
- Provide exact search/replace strings
|
|
95
|
-
- Focus on high-impact, zero-risk improvements
|
|
96
|
-
|
|
97
|
-
SCAN PRIORITIES:
|
|
98
|
-
1. Unclear variable names (single letters, abbreviations)
|
|
99
|
-
2. Magic numbers that should be named constants
|
|
100
|
-
3. Missing error handling (JSON.parse, fetch, etc.)
|
|
101
|
-
4. Dead/commented code removal
|
|
102
|
-
5. Minor formatting consistency
|
|
103
|
-
|
|
104
|
-
CODEBASE CONTEXT: {scanned_files_content}
|
|
105
|
-
|
|
106
|
-
RESPONSE FORMAT:
|
|
107
|
-
If you find a good cleanup opportunity:
|
|
108
|
-
{
|
|
109
|
-
"cleanup": "Brief description of the improvement",
|
|
110
|
-
"filename": "path/to/file.js",
|
|
111
|
-
"searchText": "exact text to find (with proper whitespace)",
|
|
112
|
-
"replaceText": "exact replacement text (with proper whitespace)",
|
|
113
|
-
"reasoning": "Why this specific change helps readability/maintainability",
|
|
114
|
-
"riskLevel": "Low|Medium",
|
|
115
|
-
"linesChanged": number_of_lines_modified
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
If no clear, safe cleanup exists:
|
|
119
|
-
{
|
|
120
|
-
"cleanup": null,
|
|
121
|
-
"message": "No obvious cleanup opportunities found. Codebase looks tidy!"
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
CRITICAL: Only suggest changes you are 100% confident about. When in doubt, suggest nothing.
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Implementation Details
|
|
128
|
-
|
|
129
|
-
### Codebase Scanning Strategy
|
|
130
|
-
|
|
131
|
-
**File Discovery:**
|
|
132
|
-
- Use `codebase` to find code patterns and smells across all source files
|
|
133
|
-
- Use `search` to locate specific patterns and file types
|
|
134
|
-
- Focus on recently modified files first (higher likelihood of improvement opportunities)
|
|
135
|
-
|
|
136
|
-
**Content Analysis:**
|
|
137
|
-
- Read file contents for analysis
|
|
138
|
-
- Use `codebase` for pattern detection
|
|
139
|
-
- Focus on files under 500 lines for simplicity
|
|
140
|
-
- Prioritize recently modified files
|
|
141
|
-
|
|
142
|
-
### Change Application
|
|
143
|
-
|
|
144
|
-
**File Modification:**
|
|
145
|
-
```bash
|
|
146
|
-
# Use editFiles tool for exact string replacement
|
|
147
|
-
editFiles(
|
|
148
|
-
file_path=target_file,
|
|
149
|
-
old_string=exact_match_text,
|
|
150
|
-
new_string=improved_text
|
|
151
|
-
)
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**Verification:**
|
|
155
|
-
- Re-read file to confirm change applied correctly
|
|
156
|
-
- Run basic syntax validation if available
|
|
157
|
-
- Ensure no unintended modifications occurred
|
|
158
|
-
|
|
159
|
-
### Error Handling
|
|
160
|
-
|
|
161
|
-
**No opportunities found:**
|
|
162
|
-
```
|
|
163
|
-
🧽 Deck inspection complete.
|
|
164
|
-
|
|
165
|
-
No obvious cleanup opportunities found in the scanned files.
|
|
166
|
-
Your codebase looks pretty tidy already! ✨
|
|
167
|
-
|
|
168
|
-
Run again later as the code evolves, or try focusing on a specific directory.
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**Multiple opportunities found:**
|
|
172
|
-
- Always pick the highest-impact, lowest-risk option
|
|
173
|
-
- Never present multiple options (causes decision paralysis)
|
|
174
|
-
- Save other opportunities for future runs
|
|
175
|
-
|
|
176
|
-
**Change application failure:**
|
|
177
|
-
```
|
|
178
|
-
❌ Swab attempt failed.
|
|
179
|
-
|
|
180
|
-
The suggested change couldn't be applied safely.
|
|
181
|
-
This might happen if the file was modified since scanning.
|
|
182
|
-
Try running the command again.
|
|
183
|
-
```
|
|
184
|
-
|
|
185
81
|
## Tool Integration
|
|
186
82
|
|
|
187
83
|
**Primary tools:**
|
|
@@ -194,25 +90,3 @@ Try running the command again.
|
|
|
194
90
|
- Single-purpose cleanup tool with no persistent state
|
|
195
91
|
- Focuses on immediate, small improvements
|
|
196
92
|
- Integrates with existing codebase without external dependencies
|
|
197
|
-
|
|
198
|
-
## Integration Notes
|
|
199
|
-
|
|
200
|
-
This command integrates with the existing Code Captain ecosystem by:
|
|
201
|
-
|
|
202
|
-
1. **Following established patterns** - Uses same structure as other commands
|
|
203
|
-
2. **Leveraging existing tools** - Uses GitHub Copilot's native capabilities
|
|
204
|
-
3. **Maintaining simplicity** - No complex configuration or state management
|
|
205
|
-
4. **Respecting user control** - Always asks permission before making changes
|
|
206
|
-
5. **Quality foundation** - Complements specification and implementation commands by maintaining code quality, supporting the overall project foundation alongside `.code-captain` documentation
|
|
207
|
-
|
|
208
|
-
## Future Enhancements
|
|
209
|
-
|
|
210
|
-
Potential future improvements (not in initial version):
|
|
211
|
-
|
|
212
|
-
- **Directory targeting**: `/swab src/components/`
|
|
213
|
-
- **File type filtering**: `/swab --js-only`
|
|
214
|
-
- **Batch mode**: `/swab --batch` (apply multiple small changes)
|
|
215
|
-
- **Learning**: Remember which types of cleanups user prefers
|
|
216
|
-
- **Metrics**: Track improvements made over time
|
|
217
|
-
|
|
218
|
-
But for now: Keep it simple. One command, one small improvement, user approval required.
|