@devobsessed/code-captain 0.0.3

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 (55) hide show
  1. package/README.md +214 -0
  2. package/bin/install.js +1048 -0
  3. package/claude-code/README.md +276 -0
  4. package/claude-code/agents/code-captain.md +121 -0
  5. package/claude-code/agents/spec-generator.md +271 -0
  6. package/claude-code/agents/story-creator.md +309 -0
  7. package/claude-code/agents/tech-spec.md +440 -0
  8. package/claude-code/commands/cc-initialize.md +520 -0
  9. package/copilot/README.md +210 -0
  10. package/copilot/chatmodes/Code Captain.chatmode.md +60 -0
  11. package/copilot/docs/best-practices.md +74 -0
  12. package/copilot/prompts/create-adr.prompt.md +468 -0
  13. package/copilot/prompts/create-spec.prompt.md +430 -0
  14. package/copilot/prompts/edit-spec.prompt.md +396 -0
  15. package/copilot/prompts/execute-task.prompt.md +144 -0
  16. package/copilot/prompts/explain-code.prompt.md +292 -0
  17. package/copilot/prompts/initialize.prompt.md +65 -0
  18. package/copilot/prompts/new-command.prompt.md +310 -0
  19. package/copilot/prompts/plan-product.prompt.md +450 -0
  20. package/copilot/prompts/research.prompt.md +329 -0
  21. package/copilot/prompts/status.prompt.md +424 -0
  22. package/copilot/prompts/swab.prompt.md +217 -0
  23. package/cursor/README.md +224 -0
  24. package/cursor/cc.md +183 -0
  25. package/cursor/cc.mdc +69 -0
  26. package/cursor/commands/create-adr.md +504 -0
  27. package/cursor/commands/create-spec.md +430 -0
  28. package/cursor/commands/edit-spec.md +405 -0
  29. package/cursor/commands/execute-task.md +514 -0
  30. package/cursor/commands/explain-code.md +289 -0
  31. package/cursor/commands/initialize.md +397 -0
  32. package/cursor/commands/new-command.md +312 -0
  33. package/cursor/commands/plan-product.md +466 -0
  34. package/cursor/commands/research.md +317 -0
  35. package/cursor/commands/status.md +413 -0
  36. package/cursor/commands/swab.md +209 -0
  37. package/cursor/docs/best-practices.md +74 -0
  38. package/cursor/integrations/azure-devops/create-azure-work-items.md +403 -0
  39. package/cursor/integrations/azure-devops/sync-azure-work-items.md +486 -0
  40. package/cursor/integrations/github/create-github-issues.md +765 -0
  41. package/cursor/integrations/github/scripts/create-issues-batch.sh +272 -0
  42. package/cursor/integrations/github/sync-github-issues.md +237 -0
  43. package/cursor/integrations/github/sync.md +305 -0
  44. package/manifest.json +381 -0
  45. package/package.json +58 -0
  46. package/windsurf/README.md +254 -0
  47. package/windsurf/rules/cc.md +5 -0
  48. package/windsurf/workflows/create-adr.md +331 -0
  49. package/windsurf/workflows/create-spec.md +280 -0
  50. package/windsurf/workflows/edit-spec.md +273 -0
  51. package/windsurf/workflows/execute-task.md +276 -0
  52. package/windsurf/workflows/explain-code.md +292 -0
  53. package/windsurf/workflows/initialize.md +298 -0
  54. package/windsurf/workflows/new-command.md +321 -0
  55. package/windsurf/workflows/status.md +213 -0
@@ -0,0 +1,276 @@
1
+ ---
2
+ description: Execute specific tasks systematically following Test-Driven Development workflow with comprehensive testing
3
+ ---
4
+
5
+ # Execute Task Workflow
6
+
7
+ ## Overview
8
+ Execute specific tasks and sub-tasks systematically following a Test-Driven Development (TDD) workflow. Reads task specifications from `.code-captain/specs/` directories and implements features with comprehensive testing, following established code standards and best practices.
9
+
10
+ ## CRITICAL REQUIREMENT: 100% Test Pass Rate
11
+
12
+ **⚠️ ZERO TOLERANCE FOR FAILING TESTS ⚠️**
13
+
14
+ This workflow enforces strict test validation:
15
+ - **NO story can be marked "COMPLETED" with ANY failing tests**
16
+ - **100% test pass rate is MANDATORY before completion**
17
+ - **"Edge case" or "minor" test failures are NOT acceptable**
18
+ - **Implementation is considered incomplete until all tests pass**
19
+
20
+ If tests fail, the story remains "IN PROGRESS" until all failures are resolved.
21
+
22
+ ## Command Process
23
+
24
+ ### Step 1: Task Discovery & Selection
25
+
26
+ **Scan for available specifications:**
27
+
28
+ - Use `find_by_name` to search `.code-captain/specs/` for dated specification folders
29
+ - Use `view_file` to load user stories from `user-stories/` folders in each spec
30
+ - Use `view_file` to read `user-stories/README.md` for story overview and progress
31
+ - Use `view_file` to parse individual `story-N-{name}.md` files for available tasks
32
+ - Present available stories and tasks organized by specification
33
+
34
+ **Story selection process:**
35
+
36
+ 1. **If multiple specs exist**: Present selection menu with spec dates and story summaries
37
+ 2. **If single spec exists**: Show available stories and their tasks within that specification
38
+ 3. **If story/task specified**: Validate story exists and select specific task for execution
39
+ 4. **If no specs exist**: Guide user to run create-spec workflow first
40
+
41
+ **Selection format:**
42
+ ```
43
+ Available specifications:
44
+ ├── 2024-01-15-user-auth/ (3 stories, 12 total tasks)
45
+ │ ├── Story 1: User Registration (5 tasks) - Not Started
46
+ │ ├── Story 2: User Login (4 tasks) - Not Started
47
+ │ └── Story 3: Password Reset (3 tasks) - Not Started
48
+ └── 2024-01-20-payment-system/ (2 stories, 8 total tasks)
49
+ ├── Story 1: Payment Processing (5 tasks) - In Progress (2/5)
50
+ └── Story 2: Refund Management (3 tasks) - Not Started
51
+ ```
52
+
53
+ ### Step 2: Context Gathering & Analysis
54
+
55
+ **Load specification context:**
56
+
57
+ - Use `view_file` to read primary spec document: `spec.md`
58
+ - Use `view_file` to load user stories overview: `user-stories/README.md`
59
+ - Use `view_file` to read selected story file: `user-stories/story-N-{name}.md`
60
+ - Use `view_file` to review technical specifications: `sub-specs/technical-spec.md`
61
+ - Parse task breakdown from individual story file
62
+
63
+ **Analyze current codebase:**
64
+
65
+ Use `codebase_search` to understand:
66
+ - Current architecture and patterns
67
+ - Related existing functionality
68
+ - Integration points for new features
69
+ - Testing frameworks and conventions
70
+
71
+ **Load project standards:**
72
+ - Code style guide: `.code-captain/docs/code-style.md`
73
+ - Technology stack: `.code-captain/docs/tech-stack.md`
74
+ - Best practices: `.code-captain/docs/best-practices.md`
75
+
76
+ ### Step 3: Story & Task Analysis
77
+
78
+ **Parse selected story structure:**
79
+
80
+ - Use `view_file` to load complete story file: `user-stories/story-N-{name}.md`
81
+ - Extract user story, acceptance criteria, and implementation tasks
82
+ - Analyze task dependencies and execution order within the story
83
+ - Understand test requirements (first task typically writes tests)
84
+ - Plan implementation approach based on story's task breakdown
85
+
86
+ **Validate TDD approach within story:**
87
+
88
+ - **First task**: Should write tests for the story functionality
89
+ - **Middle tasks**: Implement functionality to pass tests (max 5-7 tasks total)
90
+ - **Final task**: Verify all tests pass and acceptance criteria are met
91
+ - **Integration considerations**: Update adjacent/related tests as needed
92
+
93
+ **Story structure:** User story → Acceptance criteria → Implementation tasks (max 5-7 tasks, first task writes tests, final task verifies 100% pass rate)
94
+
95
+ ### Step 4: Pre-Implementation Preparation
96
+
97
+ **Validate testing setup:**
98
+ - Use `codebase_search` to confirm testing framework is configured
99
+ - Use `find_by_name` to verify test directories and naming conventions
100
+ - Use `view_file` to check existing test patterns and utilities
101
+ - Use `run_command` to ensure test runner is functional
102
+
103
+ ### Step 5: Story Task Execution (TDD Workflow)
104
+
105
+ **Execute story tasks in sequential order:**
106
+
107
+ #### Task 1: Write Tests (Test-First Approach)
108
+
109
+ **Actions:**
110
+ - Write comprehensive test cases for the entire feature using `write_to_file`
111
+ - Include unit tests, integration tests, and edge cases
112
+ - Cover happy path, error conditions, and boundary cases
113
+ - Ensure tests fail appropriately (red phase)
114
+
115
+ **Test categories to include:**
116
+ - **Unit tests**: Individual function/method testing
117
+ - **Integration tests**: Component interaction testing
118
+ - **Edge cases**: Boundary conditions and error scenarios
119
+ - **Acceptance tests**: User story validation
120
+
121
+ #### Tasks 2-N: Implementation (Green Phase)
122
+
123
+ **For each implementation task within the story:**
124
+
125
+ 1. **Focus on specific functionality**: Implement only what's needed for current task
126
+ 2. **Make tests pass**: Write minimal code to satisfy failing tests using `replace_file_content`
127
+ 3. **Update related tests**: Modify adjacent tests if behavior changes
128
+ 4. **Maintain compatibility**: Ensure no regressions in existing functionality
129
+ 5. **Refactor when green**: Improve code quality while tests remain passing
130
+
131
+ **Implementation approach:**
132
+ - Start with simplest implementation that passes tests
133
+ - Add complexity incrementally as required by test cases
134
+ - Keep tests passing at each step using `run_command` to verify
135
+ - Refactor for clarity and maintainability
136
+
137
+ #### Final Task: Test & Acceptance Verification
138
+
139
+ **CRITICAL: 100% Test Pass Rate Required**
140
+
141
+ **Mandatory Actions (ALL must succeed before story completion):**
142
+
143
+ 1. **Run complete test suite for this story** using `run_command`
144
+ 2. **Achieve 100% pass rate for ALL tests** - NO EXCEPTIONS
145
+ 3. **Verify no regressions in existing test suites**
146
+ 4. **Validate all acceptance criteria are met for the user story**
147
+ 5. **Confirm story delivers the specified user value**
148
+
149
+ **⚠️ STORY CANNOT BE MARKED COMPLETE WITH ANY FAILING TESTS ⚠️**
150
+
151
+ If ANY tests fail:
152
+ - **STOP IMMEDIATELY** - Do not mark story as complete
153
+ - Debug and fix each failing test
154
+ - Re-run test suite until 100% pass rate achieved
155
+ - Only then proceed to mark story as complete
156
+
157
+ ### Step 6: Story-Specific Test Validation
158
+
159
+ **Run targeted test validation:**
160
+
161
+ Use `run_command` to verify:
162
+ - All tests written in first task are passing
163
+ - New functionality works as specified in user story
164
+ - All acceptance criteria are satisfied
165
+ - No regressions introduced to existing features
166
+ - Performance requirements are met (if specified)
167
+
168
+ **Test execution strategy:**
169
+ - **First**: Run only tests for current story/feature
170
+ - **Then**: Run related test suites to check for regressions
171
+ - **Finally**: Consider full test suite if significant changes made
172
+ - **Acceptance**: Validate user story acceptance criteria are met
173
+
174
+ **Failure handling:**
175
+
176
+ **ZERO TOLERANCE FOR FAILING TESTS:**
177
+ - **If ANY tests fail**: Story CANNOT be marked complete
178
+ - **Required action**: Debug and fix ALL failing tests before proceeding
179
+ - **No exceptions**: "Edge case" or "minor" failing tests are NOT acceptable
180
+ - **If performance issues**: Optimize implementation until all tests pass
181
+ - **If regressions found**: Fix regressions - story completion is blocked until resolved
182
+
183
+ **Failure Resolution Process:**
184
+ 1. Identify root cause of each failing test
185
+ 2. Fix implementation to make test pass using `replace_file_content`
186
+ 3. Re-run ALL tests using `run_command` to ensure 100% pass rate
187
+ 4. Repeat until NO tests fail
188
+ 5. Only then mark story as complete
189
+
190
+ ### Step 7: Story Completion & Status Updates
191
+
192
+ **Update story file status:**
193
+
194
+ Use `replace_file_content` to mark completed tasks in story file:
195
+ - Change status from "Not Started" to "Completed ✅"
196
+ - Mark all tasks as [x] with ✅
197
+ - Mark all acceptance criteria as [x] with ✅
198
+ - Update Definition of Done with **ALL tests passing (100% pass rate)** ✅ **MANDATORY**
199
+ - Add note: "Story CANNOT be marked complete without 100% test pass rate"
200
+
201
+ **Update stories overview:**
202
+
203
+ Use `replace_file_content` to update progress tracking in `user-stories/README.md`:
204
+
205
+ ```markdown
206
+ | Story | Title | Status | Tasks | Progress |
207
+ |-------|-------|--------|-------|----------|
208
+ | 1 | User Authentication | Completed ✅ | 5 | 5/5 ✅ |
209
+ | 2 | Password Reset | Not Started | 4 | 0/4 |
210
+ | 3 | Profile Management | Not Started | 6 | 0/6 |
211
+
212
+ **Total Progress:** 5/15 tasks (33%)
213
+ ```
214
+
215
+ **Document completion:**
216
+ - Update spec status if all stories in the specification are complete
217
+ - Note any deviations from original plan in story notes
218
+ - Document lessons learned or improvements made
219
+ - Identify any follow-up tasks or technical debt
220
+
221
+ **Present completion summary:**
222
+
223
+ **If ALL tests pass (100%):** "Story completed successfully: [Story name] - Tasks: X/X ✅ - Tests: X/X (100%) ✅ - Next stories available"
224
+
225
+ **If ANY tests fail:** "Story INCOMPLETE - Tests failing: [Story name] - Tests: X/Y (Z%) ❌ COMPLETION BLOCKED - Must fix all failing tests before completion"
226
+
227
+ ### Step 8: Create Memory of Completed Story (Optional)
228
+ After successful story completion, ask Cascade:
229
+ "Please create a memory of this completed story: [story name and key implementation approach, noting 100% test pass achievement]"
230
+
231
+ ## Integration with Code Captain Ecosystem
232
+
233
+ **Specification dependency:**
234
+ - Requires existing spec created by create-spec workflow
235
+ - Uses story breakdown from `user-stories/` folder in spec directories
236
+ - Loads individual story files: `user-stories/story-N-{name}.md`
237
+ - Tracks progress in `user-stories/README.md`
238
+ - Follows technical approach from `sub-specs/technical-spec.md`
239
+
240
+ **Code style compliance:**
241
+ - Adheres to patterns in `.code-captain/docs/code-style.md`
242
+ - Uses technology stack from `.code-captain/docs/tech-stack.md`
243
+ - Follows best practices from `.code-captain/docs/best-practices.md`
244
+
245
+ ## Quality Standards
246
+
247
+ **TDD:** Tests before implementation, **100% pass rate MANDATORY**, ZERO TOLERANCE for failures, comprehensive coverage, regression testing, failed tests = incomplete implementation.
248
+
249
+ **Code quality:** Follow project patterns, maintain compatibility, proper error handling, appropriate logging.
250
+
251
+ ## Error Handling & Best Practices
252
+
253
+ **Common failures:** No specs (→ create-spec), test framework issues (→ setup guidance), implementation conflicts (→ resolution strategies), performance issues (→ optimization)
254
+
255
+ **Blocking issues:** Document as `⚠️ Blocking issue: [DESCRIPTION]` in story notes. Try alternatives, research solutions, break down tasks. Max 3 attempts before escalating.
256
+
257
+ **TDD adherence:** Start with failing tests, minimal code to pass, refactor when green. **MANDATORY: 100% test pass rate before completion. NO EXCEPTIONS.**
258
+
259
+ **Development:** Sequential tasks, verify each step with `run_command`, test early, validate incrementally, update status immediately, document decisions.
260
+
261
+ ## Windsurf Tools Used
262
+
263
+ - `find_by_name`: Locate specifications, story files, and test directories
264
+ - `view_file`: Read specification documents, story files, and existing code
265
+ - `write_to_file`: Create test files and new implementation files
266
+ - `replace_file_content`: Update existing code and story status files
267
+ - `codebase_search`: Understand current architecture and patterns
268
+ - `run_command`: Execute tests, verify functionality, and run build processes
269
+
270
+ ## Windsurf Features Used
271
+
272
+ - **Memories**: After completion, optionally create memory of completed story and implementation approach
273
+
274
+ ---
275
+
276
+ *🧪 Tests first, code second, success always. No compromises on quality.*
@@ -0,0 +1,292 @@
1
+ ---
2
+ description: Provide comprehensive AI-powered explanations of code segments, functions, classes, or files with visual diagrams
3
+ ---
4
+
5
+ # Explain Code Workflow
6
+
7
+ ## Overview
8
+ Provides comprehensive, AI-powered explanations of code segments, functions, classes, or entire files. Combines natural language explanations with visual diagrams to help developers understand complex code quickly and thoroughly.
9
+
10
+ ## Command Targets
11
+
12
+ **Target types:**
13
+ - `[function-name]` - Specific function to explain
14
+ - `[class-name]` - Entire class explanation
15
+ - `[file-path]` - Explain entire file
16
+ - `[line-range]` - Explain specific lines (e.g., "125-150")
17
+ - `current-selection` - Explain currently selected code in IDE
18
+
19
+ **Automatically includes:**
20
+ - Visual diagrams (flowcharts, sequence diagrams, class diagrams)
21
+ - Intermediate complexity level (technical but accessible)
22
+ - Full context (includes dependencies and related components)
23
+ - Saves explanations to `.code-captain/explanations/` for future reference
24
+
25
+ ## Examples
26
+
27
+ ```bash
28
+ # Explain a specific function
29
+ /explain-code calculateUserDiscount
30
+
31
+ # Explain a class
32
+ /explain-code PaymentProcessor
33
+
34
+ # Explain entire file
35
+ /explain-code src/auth/AuthService.js
36
+
37
+ # Explain specific line range
38
+ /explain-code "src/utils/helpers.js:45-78"
39
+
40
+ # Explain currently selected code
41
+ /explain-code current-selection
42
+ ```
43
+
44
+ ## Workflow Process
45
+
46
+ ### Step 1: Target Identification & Location
47
+
48
+ **Locate the target code:**
49
+
50
+ - Use `find_by_name` to search for files matching the target
51
+ - Use `view_code_item` to locate specific functions or classes
52
+ - Use `grep_search` to find function/class definitions by name
53
+ - Use `view_file` to read file contents for line ranges or full files
54
+
55
+ **Target validation:**
56
+ - Confirm target exists and is accessible
57
+ - If ambiguous, present multiple options for user selection
58
+ - If not found, provide suggestions for similar names
59
+
60
+ ### Step 2: Context Gathering & Analysis
61
+
62
+ **Gather comprehensive context:**
63
+
64
+ - Use `codebase_search` to understand architectural context
65
+ - Use `view_file` to read related files and dependencies
66
+ - Use `grep_search` to find all usages of the target code
67
+ - Use `view_code_item` to analyze related classes/functions
68
+
69
+ **Analyze code characteristics:**
70
+ - Parse syntax and identify patterns
71
+ - Measure complexity and performance characteristics
72
+ - Understand dependencies and integration points
73
+ - Identify design patterns and architectural decisions
74
+
75
+ ### Step 3: Explanation Generation
76
+
77
+ **Create structured explanation:**
78
+
79
+ **📋 Code Overview**
80
+ - Purpose: What this code does
81
+ - Parameters: Input expectations and validation
82
+ - Return Value: What it outputs and formats
83
+ - Key Logic: Step-by-step breakdown of main functionality
84
+
85
+ **🔄 Execution Flow**
86
+ - Control flow through the code
87
+ - Decision points and branching logic
88
+ - Error handling paths and edge cases
89
+ - Performance characteristics and bottlenecks
90
+
91
+ **🏗️ Architecture Context**
92
+ - Where this fits in the overall system
93
+ - Dependencies and related components
94
+ - Design patterns and architectural decisions
95
+ - Integration points with other modules
96
+
97
+ **⚡ Technical Details**
98
+ - Time and space complexity analysis
99
+ - Memory usage patterns
100
+ - Potential issues and gotchas
101
+ - Optimization opportunities
102
+
103
+ ### Step 4: Visual Diagram Creation
104
+
105
+ **Generate appropriate diagrams using Mermaid syntax:**
106
+
107
+ **Flowcharts:**
108
+ - Control flow through functions
109
+ - Decision trees for complex logic
110
+ - Error handling paths
111
+
112
+ **Sequence Diagrams:**
113
+ - Function call sequences
114
+ - API interaction flows
115
+ - Database transaction flows
116
+
117
+ **Class Diagrams:**
118
+ - Object relationships
119
+ - Inheritance hierarchies
120
+ - Dependency structures
121
+
122
+ **Example Mermaid flowchart:**
123
+ ```mermaid
124
+ graph TD
125
+ A[Input Validation] --> B{Valid Input?}
126
+ B -->|Yes| C[Process Data]
127
+ B -->|No| D[Return Error]
128
+ C --> E[Apply Business Logic]
129
+ E --> F[Return Result]
130
+ D --> G[Log Error]
131
+ ```
132
+
133
+ ### Step 5: Documentation & Auto-Save
134
+
135
+ **Save explanation with date prefix:**
136
+
137
+ Use `write_to_file` to create explanation file in `.code-captain/explanations/[DATE]-[target-name].md`
138
+
139
+ **File format:**
140
+ ```markdown
141
+ # Code Explanation: [Target Name]
142
+
143
+ _Generated on [DATE]_
144
+
145
+ ## Overview
146
+ [Natural language summary of purpose and functionality]
147
+
148
+ ## Execution Flow
149
+ ```mermaid
150
+ [Generated diagram showing control flow]
151
+ ```
152
+
153
+ ## Detailed Breakdown
154
+ [Step-by-step explanation of key logic and decision points]
155
+
156
+ ## Architecture Context
157
+ [How this code fits within the broader system architecture]
158
+
159
+ ## Usage Examples
160
+ [Practical examples of how to use this code]
161
+
162
+ ## Related Components
163
+ [Links to other explanations and dependencies]
164
+
165
+ ## Technical Analysis
166
+ [Performance characteristics, complexity, and optimization notes]
167
+
168
+ ---
169
+ _Generated by Code Captain on [timestamp]_
170
+ ```
171
+
172
+ ### Step 6: Date Determination
173
+
174
+ **Primary method - File system timestamp:**
175
+ 1. Create directory if not exists: `.code-captain/explanations/`
176
+ 2. Create temporary file: `.code-captain/explanations/.date-check`
177
+ 3. Read file creation timestamp from filesystem
178
+ 4. Extract date in YYYY-MM-DD format
179
+ 5. Delete temporary file
180
+ 6. Store date for file naming
181
+
182
+ **Fallback method - User confirmation:**
183
+ If file system method fails:
184
+ 1. Ask user: "What is today's date? (YYYY-MM-DD format)"
185
+ 2. Validate format matches `^\d{4}-\d{2}-\d{2}$`
186
+ 3. Store date for file naming
187
+
188
+ ### Step 7: Present Results
189
+
190
+ **Display structured explanation in chat:**
191
+ - Overview with purpose and key functionality
192
+ - Visual diagram showing execution flow
193
+ - Detailed breakdown of logic and decision points
194
+ - Architecture context and system integration
195
+ - Technical analysis with performance notes
196
+ - Usage examples and related components
197
+
198
+ **Confirm auto-save:**
199
+ - Notify user that explanation saved to `.code-captain/explanations/[DATE]-[target-name].md`
200
+ - Provide file path for future reference
201
+ - Mention integration with other Code Captain commands
202
+
203
+ ## Output Characteristics
204
+
205
+ **Technical level:** Intermediate complexity balancing accessibility with depth
206
+ **Context:** Always includes related functions, dependencies, and architectural context
207
+ **Visual elements:** Every explanation includes appropriate diagrams
208
+ **Comprehensive:** Shows how code fits in the entire system
209
+ **Saved format:** Markdown with Mermaid diagrams for future reference
210
+
211
+ ## Integration with Code Captain Ecosystem
212
+
213
+ **Cross-command integration:**
214
+ - Saved explanations accessible by `/research` workflow for context
215
+ - Referenced by `/create-spec` workflow for understanding existing patterns
216
+ - Used by `/execute-task` workflow for implementation guidance
217
+ - Integrated with other workflows for comprehensive codebase understanding
218
+
219
+ **File organization:**
220
+ ```
221
+ .code-captain/
222
+ └── explanations/
223
+ ├── 2024-01-15-AuthenticationFlow.md
224
+ ├── 2024-01-16-PaymentProcessor.md
225
+ ├── 2024-01-16-UserService.md
226
+ └── 2024-01-17-SearchAlgorithm.md
227
+ ```
228
+
229
+ Files named: `[DATE]-[target-name].md` (YYYY-MM-DD format)
230
+
231
+ ## Error Handling
232
+
233
+ **Common issues and responses:**
234
+ - **Code not found**: "Could not locate [target]. Please check the path/name." Use `find_by_name` to suggest alternatives
235
+ - **Too complex**: "This code is very complex. Consider breaking into smaller explanations."
236
+ - **Limited context**: "Some context may be missing. Ensure related files are accessible."
237
+
238
+ **Fallback behaviors:**
239
+ - If diagrams fail to generate, provide text-based flow description
240
+ - If target is ambiguous, offer multiple options using `grep_search` results
241
+ - If code is too large, suggest breaking into smaller segments
242
+
243
+ **Resolution strategies:**
244
+ 1. Use `codebase_search` to find alternative approaches
245
+ 2. Break complex code into logical segments
246
+ 3. Provide partial explanations with clear boundaries
247
+ 4. Suggest related files or functions for additional context
248
+
249
+ ## Diagram Types
250
+
251
+ **Flowcharts:** Control flow, decision trees, error handling paths
252
+ **Sequence diagrams:** Function calls, API interactions, database transactions
253
+ **Class diagrams:** Object relationships, inheritance, dependencies
254
+ **Architecture diagrams:** Component interactions, data flow, service communication
255
+
256
+ ## Management Features
257
+
258
+ **Explanation discovery:**
259
+ - Use `find_by_name` to list all saved explanations
260
+ - Use `grep_search` to search explanation content
261
+ - Use `view_file` to read previous explanations for context
262
+
263
+ **Update detection:**
264
+ - Compare file modification times with explanation dates
265
+ - Suggest refreshing explanations for changed code
266
+ - Maintain explanation history and versioning
267
+
268
+ ## Quality Standards
269
+
270
+ **Clarity:** Explanations understandable to developers at intermediate level
271
+ **Completeness:** Cover purpose, logic, context, and technical details
272
+ **Accuracy:** Reflect actual code behavior and architectural patterns
273
+ **Visual:** Include appropriate diagrams for better understanding
274
+ **Consistency:** Use standard format and terminology across explanations
275
+
276
+ ## Windsurf Tools Used
277
+
278
+ - `find_by_name`: Locate target files, functions, and classes
279
+ - `view_file`: Read file contents and related code
280
+ - `view_code_item`: Examine specific code elements (classes, functions)
281
+ - `codebase_search`: Understand architectural context and dependencies
282
+ - `grep_search`: Find function definitions, usages, and patterns
283
+ - `write_to_file`: Save explanations to dated files
284
+ - `list_dir`: Explore directory structure for context
285
+
286
+ ## Windsurf Features Used
287
+
288
+ - **Memories**: After explaining complex architectural patterns, ask Cascade to "create a memory of this architectural pattern and its usage"
289
+
290
+ ---
291
+
292
+ *🧠 Understanding code through comprehensive explanation and visual insight.*