@devobsessed/code-captain 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -27
- package/bin/install.js +1165 -978
- package/claude-code/agents/code-captain.md +15 -3
- package/copilot/chatmodes/Code Captain.chatmode.md +30 -9
- package/copilot/prompts/create-adr.prompt.md +6 -4
- package/copilot/prompts/create-spec.prompt.md +60 -40
- package/copilot/prompts/explain-code.prompt.md +7 -20
- package/copilot/prompts/research.prompt.md +14 -27
- package/cursor/README.md +72 -68
- package/cursor/cc.mdc +54 -31
- package/cursor/commands/create-adr.md +6 -12
- package/cursor/commands/create-spec.md +66 -54
- package/cursor/commands/edit-spec.md +2 -15
- package/cursor/commands/execute-task.md +7 -15
- package/cursor/commands/explain-code.md +16 -32
- package/cursor/commands/initialize.md +18 -17
- package/cursor/commands/new-command.md +168 -77
- package/cursor/commands/plan-product.md +7 -13
- package/cursor/commands/research.md +4 -23
- package/cursor/commands/status.md +28 -28
- package/cursor/commands/swab.md +4 -12
- package/manifest.json +104 -207
- package/package.json +2 -3
- package/cursor/cc.md +0 -156
- package/windsurf/README.md +0 -254
- package/windsurf/rules/cc.md +0 -5
- package/windsurf/workflows/create-adr.md +0 -331
- package/windsurf/workflows/create-spec.md +0 -280
- package/windsurf/workflows/edit-spec.md +0 -273
- package/windsurf/workflows/execute-task.md +0 -276
- package/windsurf/workflows/explain-code.md +0 -288
- package/windsurf/workflows/initialize.md +0 -298
- package/windsurf/workflows/new-command.md +0 -321
- package/windsurf/workflows/plan-product.md +0 -330
- package/windsurf/workflows/research.md +0 -240
- package/windsurf/workflows/status.md +0 -213
- package/windsurf/workflows/swab.md +0 -212
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "Conduct systematic research using structured phases with web search capabilities and actionable todos"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Research Workflow
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
Conduct systematic research using structured phases with web search capabilities and actionable todos.
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
/research "topic description"
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Process
|
|
18
|
-
|
|
19
|
-
### Phase 1: Define Research Scope
|
|
20
|
-
|
|
21
|
-
**Create research todos:**
|
|
22
|
-
|
|
23
|
-
Use memory feature to track progress:
|
|
24
|
-
```
|
|
25
|
-
- Phase 1: Define scope and questions [in_progress]
|
|
26
|
-
- Phase 2: Initial discovery [pending]
|
|
27
|
-
- Phase 3: Deep dive analysis [pending]
|
|
28
|
-
- Phase 4: Synthesis and recommendations [pending]
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**Actions:**
|
|
32
|
-
1. Define primary research question(s)
|
|
33
|
-
2. Identify key stakeholders and information needs
|
|
34
|
-
3. Set success criteria for research
|
|
35
|
-
|
|
36
|
-
### Phase 2: Initial Discovery
|
|
37
|
-
|
|
38
|
-
**Objective:** Gather broad understanding of topic landscape
|
|
39
|
-
|
|
40
|
-
**Actions:**
|
|
41
|
-
1. Use `search_web` with broad search terms
|
|
42
|
-
2. Search for:
|
|
43
|
-
- Overview articles and introductory content
|
|
44
|
-
- Current trends and recent developments
|
|
45
|
-
- Key players and thought leaders
|
|
46
|
-
- Common terminology and concepts
|
|
47
|
-
3. Document initial findings and themes
|
|
48
|
-
4. Identify knowledge gaps for deeper investigation
|
|
49
|
-
|
|
50
|
-
**Search Strategy:**
|
|
51
|
-
- Start with general terms: "[topic] overview", "[topic] 2024", "[topic] trends"
|
|
52
|
-
- Look for authoritative sources: documentation, whitepapers, industry reports
|
|
53
|
-
- Note recurring themes for Phase 3
|
|
54
|
-
|
|
55
|
-
### Phase 3: Deep Dive Analysis
|
|
56
|
-
|
|
57
|
-
**Objective:** Investigate specific aspects identified in Phase 2
|
|
58
|
-
|
|
59
|
-
**Actions:**
|
|
60
|
-
1. Use `search_web` with targeted queries from Phase 2 findings
|
|
61
|
-
2. Research specific sub-topics:
|
|
62
|
-
- Technical implementation details
|
|
63
|
-
- Pros and cons of different approaches
|
|
64
|
-
- Real-world case studies and examples
|
|
65
|
-
- Performance metrics and benchmarks
|
|
66
|
-
3. Compare alternatives and trade-offs
|
|
67
|
-
4. Validate claims from multiple sources
|
|
68
|
-
|
|
69
|
-
**Search Strategy:**
|
|
70
|
-
- Use specific terminology from Phase 2
|
|
71
|
-
- Search for: "[approach] vs [alternative]", "[topic] case study", "[topic] performance"
|
|
72
|
-
- Look for criticism and limitations, not just benefits
|
|
73
|
-
|
|
74
|
-
### Phase 4: Synthesis and Recommendations
|
|
75
|
-
|
|
76
|
-
**Objective:** Transform research into actionable insights
|
|
77
|
-
|
|
78
|
-
**Actions:**
|
|
79
|
-
1. Synthesize findings into key insights
|
|
80
|
-
2. Create recommendations based on research
|
|
81
|
-
3. Identify next steps or further investigation needs
|
|
82
|
-
4. Document sources and evidence
|
|
83
|
-
5. Create research document in `.code-captain/research/` folder
|
|
84
|
-
|
|
85
|
-
**Deliverables:**
|
|
86
|
-
- Executive summary of key findings
|
|
87
|
-
- Pros/cons analysis of options
|
|
88
|
-
- Specific recommendations with rationale
|
|
89
|
-
- Risk assessment and mitigation strategies
|
|
90
|
-
- Research document: `.code-captain/research/[DATE]-[topic-name]-research.md`
|
|
91
|
-
|
|
92
|
-
## Date Determination
|
|
93
|
-
|
|
94
|
-
### Primary Method: System Clock
|
|
95
|
-
|
|
96
|
-
1. Read the current UTC date from the system clock and format as `YYYY-MM-DD`.
|
|
97
|
-
2. Store it for naming:
|
|
98
|
-
`.code-captain/research/[DATE]-[topic-name]-research.md`
|
|
99
|
-
|
|
100
|
-
### Fallback Method
|
|
101
|
-
|
|
102
|
-
If system clock access isn't available:
|
|
103
|
-
1. Prompt: "What is today's date? (YYYY-MM-DD)"
|
|
104
|
-
2. Validate against `^\d{4}-\d{2}-\d{2}$`
|
|
105
|
-
3. Store the date for naming
|
|
106
|
-
|
|
107
|
-
## Research Document Template
|
|
108
|
-
|
|
109
|
-
Create: `.code-captain/research/[DATE]-[topic-name]-research.md`
|
|
110
|
-
|
|
111
|
-
```markdown
|
|
112
|
-
# [Topic Name] Research
|
|
113
|
-
|
|
114
|
-
**Date:** [Current date]
|
|
115
|
-
**Researcher:** [Name]
|
|
116
|
-
**Status:** [In Progress/Complete]
|
|
117
|
-
|
|
118
|
-
## Research Question(s)
|
|
119
|
-
|
|
120
|
-
[Primary questions this research aimed to answer]
|
|
121
|
-
|
|
122
|
-
## Executive Summary
|
|
123
|
-
|
|
124
|
-
[2-3 paragraph overview of key findings and recommendations]
|
|
125
|
-
|
|
126
|
-
## Background & Context
|
|
127
|
-
|
|
128
|
-
[Why research was needed, current situation, stakeholders]
|
|
129
|
-
|
|
130
|
-
## Methodology
|
|
131
|
-
|
|
132
|
-
[How research was conducted, sources used, timeframe]
|
|
133
|
-
|
|
134
|
-
## Key Findings
|
|
135
|
-
|
|
136
|
-
### Finding 1: [Title]
|
|
137
|
-
|
|
138
|
-
- **Evidence:** [Supporting data/sources]
|
|
139
|
-
- **Implications:** [What this means for project/decision]
|
|
140
|
-
|
|
141
|
-
### Finding 2: [Title]
|
|
142
|
-
|
|
143
|
-
- **Evidence:** [Supporting data/sources]
|
|
144
|
-
- **Implications:** [What this means for project/decision]
|
|
145
|
-
|
|
146
|
-
## Options Analysis
|
|
147
|
-
|
|
148
|
-
### Option 1: [Name]
|
|
149
|
-
|
|
150
|
-
- **Pros:** [Benefits and advantages]
|
|
151
|
-
- **Cons:** [Drawbacks and limitations]
|
|
152
|
-
- **Cost/Effort:** [Implementation requirements]
|
|
153
|
-
- **Risk Level:** [High/Medium/Low with explanation]
|
|
154
|
-
|
|
155
|
-
### Option 2: [Name]
|
|
156
|
-
|
|
157
|
-
- **Pros:** [Benefits and advantages]
|
|
158
|
-
- **Cons:** [Drawbacks and limitations]
|
|
159
|
-
- **Cost/Effort:** [Implementation requirements]
|
|
160
|
-
- **Risk Level:** [High/Medium/Low with explanation]
|
|
161
|
-
|
|
162
|
-
## Recommendations
|
|
163
|
-
|
|
164
|
-
### Primary Recommendation
|
|
165
|
-
|
|
166
|
-
[Specific recommended course of action with rationale]
|
|
167
|
-
|
|
168
|
-
### Alternative Approaches
|
|
169
|
-
|
|
170
|
-
[Secondary options if primary isn't feasible]
|
|
171
|
-
|
|
172
|
-
### Implementation Considerations
|
|
173
|
-
|
|
174
|
-
[Key factors to consider when moving forward]
|
|
175
|
-
|
|
176
|
-
## Risks & Mitigation
|
|
177
|
-
|
|
178
|
-
- **Risk 1:** [Description] → **Mitigation:** [How to address]
|
|
179
|
-
- **Risk 2:** [Description] → **Mitigation:** [How to address]
|
|
180
|
-
|
|
181
|
-
## Further Research Needed
|
|
182
|
-
|
|
183
|
-
- [Questions/areas needing additional investigation]
|
|
184
|
-
|
|
185
|
-
## Sources
|
|
186
|
-
|
|
187
|
-
- [Source 1 with URL and access date]
|
|
188
|
-
- [Source 2 with URL and access date]
|
|
189
|
-
|
|
190
|
-
## Appendix
|
|
191
|
-
|
|
192
|
-
[Additional detailed information, raw data, extended quotes]
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Best Practices
|
|
196
|
-
|
|
197
|
-
### Search Strategy
|
|
198
|
-
- Start broad, then narrow down
|
|
199
|
-
- Use multiple search terms and phrasings
|
|
200
|
-
- Look for recent content (last 1-2 years) for evolving topics
|
|
201
|
-
- Cross-reference information from multiple sources
|
|
202
|
-
- Search for both benefits AND criticisms
|
|
203
|
-
|
|
204
|
-
### Critical Thinking
|
|
205
|
-
- Question assumptions and biases in sources
|
|
206
|
-
- Look for evidence, not just opinions
|
|
207
|
-
- Consider source credibility and potential conflicts
|
|
208
|
-
- Distinguish between correlation and causation
|
|
209
|
-
- Identify missing information
|
|
210
|
-
|
|
211
|
-
### Documentation
|
|
212
|
-
- Keep track of sources for all claims
|
|
213
|
-
- Note information dates (especially for fast-moving topics)
|
|
214
|
-
- Document search process for reproducibility
|
|
215
|
-
- Save important quotes with proper attribution
|
|
216
|
-
|
|
217
|
-
## Common Pitfalls to Avoid
|
|
218
|
-
|
|
219
|
-
- Confirmation bias (only seeking supporting information)
|
|
220
|
-
- Stopping research too early when findings seem obvious
|
|
221
|
-
- Not considering implementation challenges
|
|
222
|
-
- Ignoring edge cases or limitations
|
|
223
|
-
- Failing to consider stakeholder perspectives beyond your own
|
|
224
|
-
|
|
225
|
-
## Implementation with Windsurf Tools
|
|
226
|
-
|
|
227
|
-
**File Operations:**
|
|
228
|
-
- Use `write_to_file` to create research documents
|
|
229
|
-
- Use `view_file` to review existing research
|
|
230
|
-
- Use `find_by_name` to locate related files
|
|
231
|
-
|
|
232
|
-
**Research Tools:**
|
|
233
|
-
- Use `search_web` for all web research phases
|
|
234
|
-
- Use `codebase_search` for understanding current implementation
|
|
235
|
-
- Use memory feature to track research progress and key findings
|
|
236
|
-
|
|
237
|
-
**Integration:**
|
|
238
|
-
- Works with existing `.code-captain/research/` directory structure
|
|
239
|
-
- Feeds into Architecture Decision Records (ADRs)
|
|
240
|
-
- Supports product planning and feature specification workflows
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Code Captain status report for project orientation and next actions
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Code Captain Status Workflow
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
Provides comprehensive status report when starting work or switching context. Analyzes git state, active work, and project health to orient developers and suggest next actions.
|
|
9
|
-
|
|
10
|
-
## Core Functionality
|
|
11
|
-
|
|
12
|
-
### 1. Git Status & Context Analysis
|
|
13
|
-
Use `run_command` to gather git information:
|
|
14
|
-
- Current branch and relationship to main/origin
|
|
15
|
-
- Commits ahead/behind main branch
|
|
16
|
-
- Last commit message and timestamp
|
|
17
|
-
- Uncommitted changes summary
|
|
18
|
-
- Stash status
|
|
19
|
-
|
|
20
|
-
### 2. Active Work Detection
|
|
21
|
-
Use `codebase_search` and `view_file` to find:
|
|
22
|
-
- Code Captain specs in `.code-captain/specs/`
|
|
23
|
-
- Current task progress from most recent spec
|
|
24
|
-
- Completed vs pending tasks
|
|
25
|
-
- Current user story context
|
|
26
|
-
|
|
27
|
-
### 3. Project Health Check
|
|
28
|
-
Use `run_command` for language-specific checks:
|
|
29
|
-
- Can the project build/compile?
|
|
30
|
-
- Dependencies status (package.json, requirements.txt, etc.)
|
|
31
|
-
- Configuration issues
|
|
32
|
-
- Missing environment variables
|
|
33
|
-
|
|
34
|
-
### 4. Contextual Suggestions
|
|
35
|
-
Based on current state, suggest appropriate next commands.
|
|
36
|
-
|
|
37
|
-
## Implementation Steps
|
|
38
|
-
|
|
39
|
-
### Step 1: Git Analysis
|
|
40
|
-
```bash
|
|
41
|
-
# Use run_command for these git operations:
|
|
42
|
-
git status --porcelain # File changes
|
|
43
|
-
git log --oneline -5 # Recent commits
|
|
44
|
-
git log main..HEAD --oneline # Commits ahead
|
|
45
|
-
git log HEAD..main --oneline # Commits behind
|
|
46
|
-
git stash list # Stashed changes
|
|
47
|
-
git branch -v # Branch info
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Step 2: Code Captain Integration
|
|
51
|
-
Use `find_by_name` to locate specs:
|
|
52
|
-
```bash
|
|
53
|
-
# Find most recent spec directory
|
|
54
|
-
find .code-captain/specs -name "spec.md" -type f
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Use `view_file` to read spec content and task progress:
|
|
58
|
-
- Read overall progress from user stories overview
|
|
59
|
-
- Parse individual story files for task completion
|
|
60
|
-
- Count completed tasks (marked with [x])
|
|
61
|
-
- Find next incomplete task
|
|
62
|
-
|
|
63
|
-
### Step 3: Project Health
|
|
64
|
-
Use `run_command` for health checks:
|
|
65
|
-
```bash
|
|
66
|
-
# Node.js
|
|
67
|
-
npm run build --if-present
|
|
68
|
-
node -c package.json
|
|
69
|
-
|
|
70
|
-
# Python
|
|
71
|
-
python -m py_compile main.py
|
|
72
|
-
pip check
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Step 4: Generate Status Report
|
|
76
|
-
|
|
77
|
-
**Output Format** (clean formatted text, not code blocks):
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
⚓ Code Captain Status Report
|
|
81
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
82
|
-
|
|
83
|
-
📍 CURRENT POSITION
|
|
84
|
-
Branch: feature/dashboard-websockets (2 commits ahead of main)
|
|
85
|
-
Last commit: "Add WebSocket connection hook" (2 hours ago)
|
|
86
|
-
Uncommitted: 3 modified files in src/components/
|
|
87
|
-
|
|
88
|
-
📋 ACTIVE WORK
|
|
89
|
-
Spec: Real-time Dashboard with WebSocket Integration
|
|
90
|
-
Progress: Story 2 (User receives real-time notifications) - In Progress
|
|
91
|
-
Tasks completed: 3/6 tasks (50%)
|
|
92
|
-
Next task: 2.4 Implement client-side WebSocket connection
|
|
93
|
-
|
|
94
|
-
🎯 SUGGESTED ACTIONS
|
|
95
|
-
• Continue with task 2.4 (WebSocket connection management)
|
|
96
|
-
• Commit current changes before switching tasks
|
|
97
|
-
• Review recent main branch changes
|
|
98
|
-
|
|
99
|
-
⚡ QUICK COMMANDS
|
|
100
|
-
Execute task workflow # Continue current task
|
|
101
|
-
Code cleanup workflow # Quick code improvements
|
|
102
|
-
Sync main workflow # Pull latest from main
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Task Progress Analysis
|
|
106
|
-
|
|
107
|
-
### Parsing Logic
|
|
108
|
-
For each story file in `user-stories/story-N-{name}.md`:
|
|
109
|
-
|
|
110
|
-
1. **Count completed tasks**:
|
|
111
|
-
```bash
|
|
112
|
-
grep -c "^\- \[x\].*✅" story-file.md
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
2. **Count total tasks**:
|
|
116
|
-
```bash
|
|
117
|
-
grep -c "^\- \[[x ]\]" story-file.md
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
3. **Find next incomplete task**:
|
|
121
|
-
```bash
|
|
122
|
-
grep -n "^\- \[ \]" story-file.md | head -1
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
4. **Extract status from story header**:
|
|
126
|
-
```bash
|
|
127
|
-
grep "^> \*\*Status:\*\*" story-file.md
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Status Detection
|
|
131
|
-
- `Not Started` - No tasks completed
|
|
132
|
-
- `In Progress` - Some tasks completed, some remaining
|
|
133
|
-
- `Completed ✅` - All tasks and acceptance criteria completed
|
|
134
|
-
|
|
135
|
-
## Error Handling
|
|
136
|
-
|
|
137
|
-
### Not a Git Repository
|
|
138
|
-
```
|
|
139
|
-
❌ Not in a git repository
|
|
140
|
-
Initialize git first: git init
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### No Code Captain Structure
|
|
144
|
-
```
|
|
145
|
-
📋 ACTIVE WORK
|
|
146
|
-
No Code Captain specifications found
|
|
147
|
-
Project structure: Standard git repository
|
|
148
|
-
|
|
149
|
-
🎯 SUGGESTED ACTIONS
|
|
150
|
-
• Set up Code Captain workflow
|
|
151
|
-
• Create first feature specification
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Project Issues
|
|
155
|
-
```
|
|
156
|
-
⚠️ PROJECT ISSUES DETECTED
|
|
157
|
-
• package.json syntax error
|
|
158
|
-
• Missing critical dependencies
|
|
159
|
-
• Build process failing
|
|
160
|
-
|
|
161
|
-
🔧 SUGGESTED FIXES
|
|
162
|
-
• Fix package.json syntax
|
|
163
|
-
• Run npm install or equivalent
|
|
164
|
-
• Check build configuration
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Decision Tree for Suggestions
|
|
168
|
-
|
|
169
|
-
1. **Merge conflict?** → Suggest conflict resolution
|
|
170
|
-
2. **Working directory dirty?** → Suggest commit or stash
|
|
171
|
-
3. **Branch behind main?** → Suggest sync
|
|
172
|
-
4. **Active task?** → Suggest continue task
|
|
173
|
-
5. **Current task complete?** → Suggest next task
|
|
174
|
-
6. **No active work?** → Suggest create spec
|
|
175
|
-
7. **Always** → Suggest code cleanup
|
|
176
|
-
|
|
177
|
-
## Usage Patterns
|
|
178
|
-
|
|
179
|
-
### Morning Routine
|
|
180
|
-
Developer starts day, gets oriented on yesterday's work, sees exactly what to do next.
|
|
181
|
-
|
|
182
|
-
### Context Switching
|
|
183
|
-
After meetings or interruptions, quick reminder of current state, resume work efficiently.
|
|
184
|
-
|
|
185
|
-
### Project Handoff
|
|
186
|
-
When picking up someone else's work, understand current project state without diving into code.
|
|
187
|
-
|
|
188
|
-
## Performance Considerations
|
|
189
|
-
|
|
190
|
-
- Target <2 second execution time
|
|
191
|
-
- Limit git log queries to reasonable ranges
|
|
192
|
-
- Cache expensive operations when possible
|
|
193
|
-
- Use efficient file scanning with `find_by_name`
|
|
194
|
-
|
|
195
|
-
## Windsurf Tools Used
|
|
196
|
-
|
|
197
|
-
- `run_command`: Git operations, build checks
|
|
198
|
-
- `codebase_search`: Find specs and project structure
|
|
199
|
-
- `view_file`: Read spec content and progress
|
|
200
|
-
- `find_by_name`: Locate Code Captain files
|
|
201
|
-
- `grep_search`: Parse task completion status
|
|
202
|
-
- `list_dir`: Directory structure analysis
|
|
203
|
-
|
|
204
|
-
## Security & Privacy
|
|
205
|
-
|
|
206
|
-
- All analysis happens locally
|
|
207
|
-
- No external API calls or data transmission
|
|
208
|
-
- Git history and file contents remain private
|
|
209
|
-
- Sanitize sensitive information in output
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
*⚓ Keep your bearings, maintain your heading, and always know where you stand in the code.*
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "A deck-cleaning workflow that makes one small, focused improvement to the codebase following the Boy Scout Rule"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Swab Workflow
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
A deck-cleaning workflow that makes one small, focused improvement to the codebase, following the "Boy Scout Rule" - leave the code cleaner than you found it. Identifies the single best small cleanup opportunity and applies it with your approval.
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
/swab
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
**Note:** No options, no flags, no complexity. Just simple deck cleaning.
|
|
18
|
-
|
|
19
|
-
## Process
|
|
20
|
-
|
|
21
|
-
### Step 1: Codebase Scanning
|
|
22
|
-
|
|
23
|
-
**Scan for improvement opportunities:**
|
|
24
|
-
|
|
25
|
-
- Search project files for common code smells
|
|
26
|
-
- Analyze file patterns and naming conventions
|
|
27
|
-
- Identify low-risk, high-impact improvements
|
|
28
|
-
- Focus on clarity and maintainability wins
|
|
29
|
-
|
|
30
|
-
**Target Areas:**
|
|
31
|
-
- Unclear variable names (`d`, `temp`, `data`, single letters)
|
|
32
|
-
- Magic numbers that should be constants
|
|
33
|
-
- Missing error handling on JSON.parse, API calls
|
|
34
|
-
- Commented-out code blocks
|
|
35
|
-
- Inconsistent formatting patterns
|
|
36
|
-
- Overly abbreviated names
|
|
37
|
-
- Unused imports or variables
|
|
38
|
-
|
|
39
|
-
### Step 2: Opportunity Prioritization
|
|
40
|
-
|
|
41
|
-
**Selection Criteria:**
|
|
42
|
-
1. **Clarity Impact** - How much clearer will the code be?
|
|
43
|
-
2. **Risk Level** - How certain are we this won't break anything?
|
|
44
|
-
3. **Scope** - Prefer 1-10 line changes maximum
|
|
45
|
-
4. **Confidence** - Only suggest changes we're 100% certain about
|
|
46
|
-
|
|
47
|
-
**Priority Order:**
|
|
48
|
-
1. Variable/function name improvements
|
|
49
|
-
2. Magic number extraction to constants
|
|
50
|
-
3. Adding missing error handling
|
|
51
|
-
4. Removing dead code
|
|
52
|
-
5. Formatting consistency fixes
|
|
53
|
-
|
|
54
|
-
### Step 3: Present Single Best Option
|
|
55
|
-
|
|
56
|
-
**Display Format:**
|
|
57
|
-
```
|
|
58
|
-
🧽 Swabbing the deck... found some mess in {filename}
|
|
59
|
-
|
|
60
|
-
=== SUGGESTED CLEANUP ===
|
|
61
|
-
|
|
62
|
-
- {before_code}
|
|
63
|
-
+ {after_code}
|
|
64
|
-
|
|
65
|
-
Reason: {clear_explanation}
|
|
66
|
-
Risk: {Low|Medium}
|
|
67
|
-
|
|
68
|
-
Clean this up? [y/N]
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Step 4: Apply Change
|
|
72
|
-
|
|
73
|
-
**If approved:**
|
|
74
|
-
- Make the exact replacement using search/replace
|
|
75
|
-
- Verify the change was applied correctly
|
|
76
|
-
- Show success message: "✅ Deck swabbed! One less mess aboard."
|
|
77
|
-
|
|
78
|
-
**If declined:**
|
|
79
|
-
- Exit gracefully with: "🧽 Deck inspection complete. No changes made."
|
|
80
|
-
|
|
81
|
-
## Core Rules
|
|
82
|
-
|
|
83
|
-
1. **One change only** - Never fix multiple things at once
|
|
84
|
-
2. **Small changes** - Maximum 10 lines modified
|
|
85
|
-
3. **Safe changes** - If uncertain, do nothing
|
|
86
|
-
4. **Your approval required** - Always ask before applying
|
|
87
|
-
5. **Exact replacements** - Surgical precision, no formatting noise
|
|
88
|
-
6. **Conservative approach** - Better to find nothing than break something
|
|
89
|
-
|
|
90
|
-
## Implementation with Windsurf Tools
|
|
91
|
-
|
|
92
|
-
### Codebase Scanning Strategy
|
|
93
|
-
|
|
94
|
-
**File Discovery:**
|
|
95
|
-
- Use `codebase_search` to find code patterns and smells across source files
|
|
96
|
-
- Use `find_by_name` to locate relevant files and directories
|
|
97
|
-
- Use `view_file` to inspect file contents when needed
|
|
98
|
-
- Focus on recently modified files first (higher likelihood of improvement opportunities)
|
|
99
|
-
|
|
100
|
-
**Content Analysis:**
|
|
101
|
-
- Use `view_file` for reading file contents for analysis
|
|
102
|
-
- Use `codebase_search` for pattern detection
|
|
103
|
-
- Focus on files under 500 lines for simplicity
|
|
104
|
-
- Prioritize recently modified files
|
|
105
|
-
|
|
106
|
-
### Change Application
|
|
107
|
-
|
|
108
|
-
**File Modification:**
|
|
109
|
-
```bash
|
|
110
|
-
# Use replace_file_content for exact string replacement
|
|
111
|
-
replace_file_content(
|
|
112
|
-
file_path=target_file,
|
|
113
|
-
old_content=exact_match_text,
|
|
114
|
-
new_content=improved_text
|
|
115
|
-
)
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**Verification:**
|
|
119
|
-
- Re-read file with `view_file` to confirm change applied correctly
|
|
120
|
-
- Run basic syntax validation if available
|
|
121
|
-
- Ensure no unintended modifications occurred
|
|
122
|
-
|
|
123
|
-
### Error Handling
|
|
124
|
-
|
|
125
|
-
**No opportunities found:**
|
|
126
|
-
```
|
|
127
|
-
🧽 Deck inspection complete.
|
|
128
|
-
|
|
129
|
-
No obvious cleanup opportunities found in the scanned files.
|
|
130
|
-
Your codebase looks pretty tidy already! ✨
|
|
131
|
-
|
|
132
|
-
Run again later as the code evolves, or try focusing on a specific directory.
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**Multiple opportunities found:**
|
|
136
|
-
- Always pick the highest-impact, lowest-risk option
|
|
137
|
-
- Never present multiple options (causes decision paralysis)
|
|
138
|
-
- Save other opportunities for future runs
|
|
139
|
-
|
|
140
|
-
**Change application failure:**
|
|
141
|
-
```
|
|
142
|
-
❌ Swab attempt failed.
|
|
143
|
-
|
|
144
|
-
The suggested change couldn't be applied safely.
|
|
145
|
-
This might happen if the file was modified since scanning.
|
|
146
|
-
Try running the workflow again.
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Analysis Prompt for AI
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
You are a code reviewer cleaning up small messes.
|
|
153
|
-
|
|
154
|
-
MISSION: Find exactly ONE small, safe cleanup opportunity in the codebase.
|
|
155
|
-
|
|
156
|
-
RULES:
|
|
157
|
-
- Find ONE small cleanup only (1-10 lines max changed)
|
|
158
|
-
- Prioritize clarity and safety over cleverness
|
|
159
|
-
- Preserve all existing functionality exactly
|
|
160
|
-
- Be extremely conservative - if ANY uncertainty, do nothing
|
|
161
|
-
- Provide exact search/replace strings
|
|
162
|
-
- Focus on high-impact, zero-risk improvements
|
|
163
|
-
|
|
164
|
-
SCAN PRIORITIES:
|
|
165
|
-
1. Unclear variable names (single letters, abbreviations)
|
|
166
|
-
2. Magic numbers that should be named constants
|
|
167
|
-
3. Missing error handling (JSON.parse, fetch, etc.)
|
|
168
|
-
4. Dead/commented code removal
|
|
169
|
-
5. Minor formatting consistency
|
|
170
|
-
|
|
171
|
-
RESPONSE FORMAT:
|
|
172
|
-
If you find a good cleanup opportunity:
|
|
173
|
-
{
|
|
174
|
-
"cleanup": "Brief description of the improvement",
|
|
175
|
-
"filename": "path/to/file.js",
|
|
176
|
-
"searchText": "exact text to find (with proper whitespace)",
|
|
177
|
-
"replaceText": "exact replacement text (with proper whitespace)",
|
|
178
|
-
"reasoning": "Why this specific change helps readability/maintainability",
|
|
179
|
-
"riskLevel": "Low|Medium",
|
|
180
|
-
"linesChanged": number_of_lines_modified
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
If no clear, safe cleanup exists:
|
|
184
|
-
{
|
|
185
|
-
"cleanup": null,
|
|
186
|
-
"message": "No obvious cleanup opportunities found. Codebase looks tidy!"
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
CRITICAL: Only suggest changes you are 100% confident about. When in doubt, suggest nothing.
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## Integration Notes
|
|
193
|
-
|
|
194
|
-
This workflow integrates with the existing Code Captain ecosystem by:
|
|
195
|
-
|
|
196
|
-
1. **Following established patterns** - Uses same markdown structure as other workflows
|
|
197
|
-
2. **Leveraging Windsurf tools** - Uses `codebase_search`, `view_file`, `replace_file_content`
|
|
198
|
-
3. **Maintaining simplicity** - No complex configuration or state management
|
|
199
|
-
4. **Respecting user control** - Always asks permission before making changes
|
|
200
|
-
5. **Quality foundation** - Complements specification and implementation commands by maintaining code quality, supporting the overall project foundation alongside `.code-captain` documentation
|
|
201
|
-
|
|
202
|
-
## Future Enhancements
|
|
203
|
-
|
|
204
|
-
Potential future improvements (not in initial version):
|
|
205
|
-
|
|
206
|
-
- **Directory targeting**: `/swab src/components/`
|
|
207
|
-
- **File type filtering**: `/swab --js-only`
|
|
208
|
-
- **Batch mode**: `/swab --batch` (apply multiple small changes)
|
|
209
|
-
- **Learning**: Remember which types of cleanups user prefers
|
|
210
|
-
- **Metrics**: Track improvements made over time
|
|
211
|
-
|
|
212
|
-
But for now: Keep it simple. One workflow, one small improvement, user approval required.
|