@devobsessed/code-captain 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +1 -10
  2. package/bin/install.js +178 -182
  3. package/claude-code/agents/code-captain.md +17 -20
  4. package/copilot/README.md +26 -16
  5. package/copilot/chatmodes/Code Captain.chatmode.md +11 -16
  6. package/copilot/prompts/create-spec.prompt.md +5 -8
  7. package/copilot/prompts/explain-code.prompt.md +5 -8
  8. package/copilot/prompts/new-command.prompt.md +60 -21
  9. package/copilot/prompts/research.prompt.md +5 -8
  10. package/copilot/prompts/status.prompt.md +13 -2
  11. package/copilot/prompts/swab.prompt.md +1 -0
  12. package/cursor/README.md +8 -23
  13. package/cursor/cc.md +2 -29
  14. package/cursor/cc.mdc +3 -10
  15. package/cursor/commands/create-adr.md +1 -1
  16. package/cursor/commands/create-spec.md +9 -12
  17. package/cursor/commands/explain-code.md +5 -8
  18. package/cursor/commands/initialize.md +1 -1
  19. package/cursor/commands/new-command.md +5 -4
  20. package/cursor/commands/research.md +6 -9
  21. package/cursor/commands/status.md +13 -2
  22. package/cursor/commands/swab.md +61 -2
  23. package/manifest.json +150 -166
  24. package/package.json +12 -2
  25. package/windsurf/workflows/explain-code.md +4 -8
  26. package/windsurf/workflows/plan-product.md +330 -0
  27. package/windsurf/workflows/research.md +240 -0
  28. package/windsurf/workflows/swab.md +212 -0
  29. package/cursor/integrations/azure-devops/create-azure-work-items.md +0 -403
  30. package/cursor/integrations/azure-devops/sync-azure-work-items.md +0 -486
  31. package/cursor/integrations/github/create-github-issues.md +0 -765
  32. package/cursor/integrations/github/scripts/create-issues-batch.sh +0 -272
  33. package/cursor/integrations/github/sync-github-issues.md +0 -237
  34. package/cursor/integrations/github/sync.md +0 -305
@@ -0,0 +1,212 @@
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.
@@ -1,403 +0,0 @@
1
- # Create Azure DevOps Work Items Command (cc: create-azure-work-items)
2
-
3
- ## Overview
4
-
5
- Automatically create Azure DevOps work items from existing user stories and tasks, establishing parent-child relationships through hierarchical work item types and updating source documents with work item IDs for traceability.
6
-
7
- ## Usage
8
-
9
- ```bash
10
- cc: create-azure-work-items [spec-folder-path]
11
- ```
12
-
13
- **Examples:**
14
-
15
- ```bash
16
- cc: create-azure-work-items .code-captain/specs/2024-12-28-user-profile-dashboard/
17
- cc: create-azure-work-items # Auto-detect latest spec folder
18
- ```
19
-
20
- ## Command Process
21
-
22
- ### Step 1: Context Discovery & Validation
23
-
24
- **Auto-detect spec folder (if no path provided):**
25
-
26
- - Search `.code-captain/specs/` for most recent dated folder
27
- - Validate folder contains required files: `user-stories.md` and `tasks.md`
28
- - Confirm Azure DevOps project context is available
29
-
30
- **Validate required files exist:**
31
-
32
- - `user-stories.md` - Source for User Story work items
33
- - `tasks.md` - Source for Task and Sub-task work items
34
- - Optional: `spec.md` for additional context
35
-
36
- **Azure DevOps project detection:**
37
-
38
- - Check if current directory is a git repository with Azure DevOps remote
39
- - Extract organization and project from remote origin
40
- - Validate Azure DevOps access permissions and PAT configuration
41
-
42
- ### Step 2: Create Todo Tracking
43
-
44
- **Use `todo_write` to track the work item creation process:**
45
-
46
- ```json
47
- {
48
- "todos": [
49
- {
50
- "id": "azure-workitems-parse",
51
- "content": "Parse user stories and tasks from spec documents",
52
- "status": "in_progress"
53
- },
54
- {
55
- "id": "azure-workitems-create-stories",
56
- "content": "Create User Story work items from user stories",
57
- "status": "pending"
58
- },
59
- {
60
- "id": "azure-workitems-create-tasks",
61
- "content": "Create Task work items linked to User Stories",
62
- "status": "pending"
63
- },
64
- {
65
- "id": "azure-workitems-update-docs",
66
- "content": "Update user-stories.md and tasks.md with work item IDs",
67
- "status": "pending"
68
- },
69
- {
70
- "id": "azure-workitems-verify",
71
- "content": "Verify all work items created and documents updated",
72
- "status": "pending"
73
- }
74
- ]
75
- }
76
- ```
77
-
78
- ### Step 3: Parse Spec Documents
79
-
80
- **Read and parse user-stories.md:**
81
-
82
- - Extract each user story with its structure:
83
- - Title
84
- - "As a/I want to/So that" format
85
- - Acceptance criteria list
86
- - Definition of done checklist
87
-
88
- **Read and parse tasks.md:**
89
-
90
- - Extract main tasks and their subtasks
91
- - Identify task hierarchy (1.0, 1.1, 1.2, etc.)
92
- - Preserve task descriptions and checkboxes
93
-
94
- **Create mapping structure:**
95
-
96
- ```javascript
97
- {
98
- userStories: [
99
- {
100
- title: "Story Title",
101
- description: "As a user...",
102
- acceptanceCriteria: ["Given...", "When...", "Then..."],
103
- definitionOfDone: ["Testable requirement 1", "..."],
104
- originalLineRange: [25, 45]
105
- }
106
- ],
107
- tasks: [
108
- {
109
- title: "Main Task Title",
110
- subtasks: [
111
- { title: "Subtask 1", description: "...", originalLineRange: [10, 12] },
112
- { title: "Subtask 2", description: "...", originalLineRange: [13, 15] }
113
- ],
114
- originalLineRange: [8, 20]
115
- }
116
- ]
117
- }
118
- ```
119
-
120
- ### Step 4: Create User Story Work Items
121
-
122
- **For each user story:**
123
-
124
- **Work item title format:**
125
-
126
- ```
127
- {Story Title}
128
- ```
129
-
130
- **Work item fields:**
131
-
132
- - **Work Item Type:** User Story
133
- - **Title:** Story title
134
- - **Description:** Full user story with acceptance criteria
135
- - **State:** New
136
- - **Area Path:** Current project area
137
- - **Iteration Path:** Current iteration
138
- - **Tags:** user-story, code-captain
139
-
140
- **Description template:**
141
-
142
- ```markdown
143
- ## User Story
144
-
145
- {User Story Description - "As a ... I want to ... So that ..."}
146
-
147
- ## Acceptance Criteria
148
-
149
- {Acceptance Criteria formatted as checklist}
150
-
151
- - [ ] Given [context], when [action], then [outcome]
152
- - [ ] Given [context], when [action], then [outcome]
153
-
154
- ## Definition of Done
155
-
156
- {Definition of Done formatted as checklist}
157
-
158
- - [ ] [Testable requirement]
159
- - [ ] [Testable requirement]
160
-
161
- ---
162
-
163
- _Generated from spec: {spec-folder-name}_
164
- _Source: user-stories.md_
165
- ```
166
-
167
- **Create work items using Azure DevOps REST API:**
168
-
169
- - Use Azure DevOps REST API to create User Story work items
170
- - Store returned work item IDs with user story mapping
171
-
172
- ### Step 5: Create Task Work Items
173
-
174
- **For each main task:**
175
-
176
- **Main task work item:**
177
-
178
- - **Work Item Type:** Task
179
- - **Title:** Main task title
180
- - **Parent Link:** Link to related User Story (if applicable)
181
- - **Description:** Task overview with subtask list
182
- - **State:** New
183
- - **Tags:** task, code-captain
184
-
185
- **For each subtask:**
186
-
187
- **Subtask work item:**
188
-
189
- - **Work Item Type:** Task
190
- - **Title:** Subtask title
191
- - **Parent Link:** Link to main task
192
- - **Description:** Subtask details
193
- - **State:** New
194
- - **Tags:** subtask, code-captain
195
-
196
- **Description template for main tasks:**
197
-
198
- ```markdown
199
- ## Task Overview
200
-
201
- {Main Task Description}
202
-
203
- ## Sub-Tasks
204
-
205
- This task includes the following sub-tasks:
206
-
207
- {List of subtask work items with links - populated after creation}
208
-
209
- ---
210
-
211
- _Generated from spec: {spec-folder-name}_
212
- _Source: tasks.md_
213
- ```
214
-
215
- **Description template for subtasks:**
216
-
217
- ```markdown
218
- ## Subtask Details
219
-
220
- {Subtask Description}
221
-
222
- ## Parent Task
223
-
224
- This subtask belongs to: {parent-task-work-item-link}
225
-
226
- ---
227
-
228
- _Generated from spec: {spec-folder-name}_
229
- _Source: tasks.md_
230
- ```
231
-
232
- ### Step 6: Update Source Documents with Work Item IDs
233
-
234
- **Update user-stories.md:**
235
-
236
- For each user story, add work item ID reference:
237
-
238
- ```markdown
239
- ## Story 1: User Profile Creation [#123]
240
-
241
- **As a** new user
242
- **I want to** create a profile with basic information
243
- **So that** I can personalize my experience
244
-
245
- ### Work Item: [123](https://dev.azure.com/org/project/_workitems/edit/123)
246
-
247
- ### Acceptance Criteria
248
-
249
- ...
250
- ```
251
-
252
- **Update tasks.md:**
253
-
254
- For each task and subtask, add work item ID references:
255
-
256
- ```markdown
257
- ## Tasks
258
-
259
- - [ ] 1. User Authentication System [#124]
260
-
261
- - [ ] 1.1 Write tests for authentication middleware [#125]
262
- - [ ] 1.2 Implement JWT token generation [#126]
263
- - [ ] 1.3 Create password hashing utilities [#127]
264
-
265
- ### Task Work Items:
266
-
267
- - Main Task: [124](https://dev.azure.com/org/project/_workitems/edit/124)
268
- - Subtasks: [125](https://dev.azure.com/org/project/_workitems/edit/125), [126](https://dev.azure.com/org/project/_workitems/edit/126), [127](https://dev.azure.com/org/project/_workitems/edit/127)
269
- ```
270
-
271
- ### Step 7: Create Work Item Relationship Mapping
272
-
273
- **Generate mapping document:**
274
-
275
- Create `.code-captain/specs/{spec-folder}/azure-workitems-mapping.md`:
276
-
277
- ```markdown
278
- # Azure DevOps Work Items Mapping
279
-
280
- > Generated: {current-date}
281
- > Spec: {spec-folder-name}
282
- > Organization: {org-name}
283
- > Project: {project-name}
284
-
285
- ## User Story Work Items
286
-
287
- | Story Title | Work Item # | Azure DevOps Link |
288
- | ------------- | ----------- | ------------------------------------------------------------- |
289
- | Story 1 Title | 123 | [Link](https://dev.azure.com/org/project/_workitems/edit/123) |
290
- | Story 2 Title | 124 | [Link](https://dev.azure.com/org/project/_workitems/edit/124) |
291
-
292
- ## Task Work Items
293
-
294
- | Task Title | Main Work Item | Sub Work Items |
295
- | ------------ | -------------- | ------------------------ |
296
- | Task 1 Title | [125](link) | [126](link), [127](link) |
297
- | Task 2 Title | [128](link) | [129](link), [130](link) |
298
-
299
- ## Summary
300
-
301
- - **Total Work Items Created:** {count}
302
- - **User Stories:** {count}
303
- - **Main Tasks:** {count}
304
- - **Subtasks:** {count}
305
-
306
- ## Source Files Updated
307
-
308
- - ✅ user-stories.md - Added work item references
309
- - ✅ tasks.md - Added work item references and links
310
- - ✅ azure-workitems-mapping.md - Created mapping document
311
- ```
312
-
313
- ### Step 8: Verification & Summary
314
-
315
- **Verify all work items created:**
316
-
317
- - Check each returned work item ID is valid
318
- - Verify Azure DevOps links are accessible
319
- - Confirm parent-child relationships established
320
-
321
- **Present completion summary:**
322
-
323
- ```
324
- ✅ Azure DevOps Work Items Creation Complete
325
-
326
- 📊 Summary:
327
- - User Stories: {count} work items created
328
- - Main Tasks: {count} work items created
329
- - Subtasks: {count} work items created
330
- - Total: {total-count} work items
331
-
332
- 📁 Updated Files:
333
- - user-stories.md - Added work item references
334
- - tasks.md - Added work item references and task links
335
- - azure-workitems-mapping.md - Created mapping document
336
-
337
- 🔗 Organization: {org-name}
338
- 📋 Project: {project-name}
339
- 📋 All work items available at: https://dev.azure.com/{org}/{project}/_workitems
340
- ```
341
-
342
- ## Configuration Requirements
343
-
344
- **Azure DevOps Access:**
345
-
346
- - Personal Access Token (PAT) with Work Items (read, write) permissions
347
- - Organization and project access
348
- - Environment variable: `AZURE_DEVOPS_PAT`
349
-
350
- **Project Configuration:**
351
-
352
- - Extract organization and project from git remote URL
353
- - Support both SSH and HTTPS Azure DevOps remotes
354
- - Validate access to target project
355
-
356
- ## Error Handling & Edge Cases
357
-
358
- **Missing configuration:**
359
-
360
- - If PAT not configured: Provide setup instructions
361
- - If not an Azure DevOps repository: Error with guidance
362
- - If project access denied: Clear permission error message
363
-
364
- **API limitations:**
365
-
366
- - Handle rate limiting with appropriate delays
367
- - Retry failed work item creation attempts
368
- - Validate work item field requirements
369
-
370
- **Document parsing errors:**
371
-
372
- - Handle malformed user story structures gracefully
373
- - Skip invalid task hierarchies with warnings
374
- - Continue processing valid entries when possible
375
-
376
- ## Integration with Existing Commands
377
-
378
- **Works with create-spec:**
379
-
380
- - Automatically detects create-spec output format
381
- - Reads user-stories.md and tasks.md generated by create-spec
382
- - Maintains consistency with spec folder structure
383
-
384
- **Azure DevOps specific features:**
385
-
386
- - Utilizes Azure DevOps work item hierarchy (User Story > Task)
387
- - Creates proper parent-child relationships
388
- - Applies Azure DevOps specific tags and fields
389
- - Integrates with Azure DevOps iterations and areas
390
-
391
- ## Usage Notes
392
-
393
- **Prerequisites:**
394
-
395
- - Existing spec folder with user-stories.md and tasks.md
396
- - Azure DevOps project with appropriate permissions
397
- - Azure DevOps PAT configured in environment
398
-
399
- **Best practices:**
400
-
401
- - Run after completing spec creation and review
402
- - Ensure spec documents are finalized before creating work items
403
- - Use consistent area and iteration paths for better organization