midas-mcp 5.44.5 → 5.44.10

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 (60) hide show
  1. package/.claude/PLUGIN.md +124 -0
  2. package/.claude/agents/midas-coach.md +108 -0
  3. package/.claude/agents/midas-reviewer.md +93 -0
  4. package/.claude/agents/midas-verifier.md +81 -0
  5. package/.claude/hooks/hooks.json +67 -0
  6. package/.claude/settings.json +41 -0
  7. package/.claude/skills/build-debug/SKILL.md +106 -0
  8. package/.claude/skills/build-implement/SKILL.md +81 -0
  9. package/.claude/skills/build-rules/SKILL.md +80 -0
  10. package/.claude/skills/build-test/SKILL.md +89 -0
  11. package/.claude/skills/horizon-expand/SKILL.md +103 -0
  12. package/.claude/skills/oneshot-retry/SKILL.md +96 -0
  13. package/.claude/skills/plan-brainlift/SKILL.md +65 -0
  14. package/.claude/skills/plan-gameplan/SKILL.md +71 -0
  15. package/.claude/skills/plan-idea/SKILL.md +51 -0
  16. package/.claude/skills/plan-prd/SKILL.md +79 -0
  17. package/.claude/skills/plan-research/SKILL.md +63 -0
  18. package/.claude/skills/tornado-debug/SKILL.md +128 -0
  19. package/dist/.claude/PLUGIN.md +124 -0
  20. package/dist/.claude/agents/midas-coach.md +108 -0
  21. package/dist/.claude/agents/midas-reviewer.md +93 -0
  22. package/dist/.claude/agents/midas-verifier.md +81 -0
  23. package/dist/.claude/hooks/hooks.json +67 -0
  24. package/dist/.claude/settings.json +41 -0
  25. package/dist/.claude/skills/build-debug/SKILL.md +106 -0
  26. package/dist/.claude/skills/build-implement/SKILL.md +81 -0
  27. package/dist/.claude/skills/build-rules/SKILL.md +80 -0
  28. package/dist/.claude/skills/build-test/SKILL.md +89 -0
  29. package/dist/.claude/skills/horizon-expand/SKILL.md +103 -0
  30. package/dist/.claude/skills/oneshot-retry/SKILL.md +96 -0
  31. package/dist/.claude/skills/plan-brainlift/SKILL.md +65 -0
  32. package/dist/.claude/skills/plan-gameplan/SKILL.md +71 -0
  33. package/dist/.claude/skills/plan-idea/SKILL.md +51 -0
  34. package/dist/.claude/skills/plan-prd/SKILL.md +79 -0
  35. package/dist/.claude/skills/plan-research/SKILL.md +63 -0
  36. package/dist/.claude/skills/tornado-debug/SKILL.md +128 -0
  37. package/dist/cli.d.ts.map +1 -1
  38. package/dist/cli.js +127 -2
  39. package/dist/cli.js.map +1 -1
  40. package/dist/github-integration.d.ts +37 -0
  41. package/dist/github-integration.d.ts.map +1 -0
  42. package/dist/github-integration.js +219 -0
  43. package/dist/github-integration.js.map +1 -0
  44. package/dist/phase-detector.d.ts +46 -0
  45. package/dist/phase-detector.d.ts.map +1 -0
  46. package/dist/phase-detector.js +251 -0
  47. package/dist/phase-detector.js.map +1 -0
  48. package/dist/pilot.d.ts +52 -0
  49. package/dist/pilot.d.ts.map +1 -1
  50. package/dist/pilot.js +80 -5
  51. package/dist/pilot.js.map +1 -1
  52. package/dist/tools/journal.d.ts +10 -1
  53. package/dist/tools/journal.d.ts.map +1 -1
  54. package/dist/tools/journal.js +38 -2
  55. package/dist/tools/journal.js.map +1 -1
  56. package/dist/tui-lite.d.ts +23 -0
  57. package/dist/tui-lite.d.ts.map +1 -0
  58. package/dist/tui-lite.js +188 -0
  59. package/dist/tui-lite.js.map +1 -0
  60. package/package.json +3 -2
@@ -0,0 +1,124 @@
1
+ # Midas Plugin for Claude Code
2
+
3
+ This is a Claude Code plugin that provides the Golden Code methodology for structured software development.
4
+
5
+ ## Installation
6
+
7
+ Copy the `.claude/` directory to your project root, or install via:
8
+
9
+ ```bash
10
+ npx midas-mcp init
11
+ ```
12
+
13
+ ## What's Included
14
+
15
+ ### Skills (`.claude/skills/`)
16
+
17
+ Phase-specific prompts that auto-trigger based on context:
18
+
19
+ | Skill | Triggers On | Purpose |
20
+ |-------|-------------|---------|
21
+ | `plan-idea` | "new project", "start project" | Define problem and audience |
22
+ | `plan-research` | "research alternatives" | Scan existing solutions |
23
+ | `plan-brainlift` | "create brainlift" | Document unique insights |
24
+ | `plan-prd` | "define requirements" | Specify requirements |
25
+ | `plan-gameplan` | "break down tasks" | Sequence the work |
26
+ | `build-rules` | "start building" | Set up conventions |
27
+ | `build-implement` | "implement feature" | Test-first development |
28
+ | `build-test` | "run tests" | Verify with full suite |
29
+ | `build-debug` | "debug" | Systematic debugging |
30
+ | `tornado-debug` | "stuck", "tried everything" | Research + Logs + Tests cycle |
31
+ | `oneshot-retry` | "try again" | Construct better retry prompt |
32
+ | `horizon-expand` | "doesn't fit" | Widen context for better output |
33
+
34
+ ### Agents (`.claude/agents/`)
35
+
36
+ Specialized subagents for different tasks:
37
+
38
+ | Agent | Type | Purpose |
39
+ |-------|------|---------|
40
+ | `midas-coach` | general-purpose | Orchestrates the methodology |
41
+ | `midas-verifier` | explore (read-only) | Checks build/test/lint gates |
42
+ | `midas-reviewer` | explore (read-only) | Security and code review |
43
+
44
+ ### Hooks (`.claude/hooks/`)
45
+
46
+ Automated behaviors:
47
+
48
+ - **SessionStart**: Load Midas state and context
49
+ - **PreToolUse**: Remind about tests before editing
50
+ - **PostToolUse**: Suggest verification after changes
51
+ - **Stop**: Verify task completion before ending
52
+
53
+ ## Usage
54
+
55
+ ### Invoke Skills
56
+
57
+ Skills auto-trigger, or invoke manually:
58
+
59
+ ```
60
+ /plan-idea
61
+ /tornado-debug
62
+ /horizon-expand
63
+ ```
64
+
65
+ ### Invoke Agents
66
+
67
+ ```
68
+ /midas-coach # Get methodology guidance
69
+ /midas-verifier # Check all gates
70
+ /midas-reviewer # Pre-ship code review
71
+ ```
72
+
73
+ ### Check Status
74
+
75
+ ```bash
76
+ midas status # One-shot status
77
+ midas status --watch # Live updating display
78
+ ```
79
+
80
+ ## The Golden Code Lifecycle
81
+
82
+ ```
83
+ PLAN → BUILD → SHIP → GROW
84
+ │ │ │ │
85
+ ▼ ▼ ▼ ▼
86
+ Idea Rules Review Feedback
87
+ Research Index Deploy Analyze
88
+ Brainlift Read Monitor Iterate
89
+ PRD Research
90
+ Gameplan Implement
91
+ Test
92
+ Debug
93
+ ```
94
+
95
+ ## Migration from MCP Tools
96
+
97
+ If you were using Midas MCP tools, here's the mapping:
98
+
99
+ | Old MCP Tool | New Skill/Agent |
100
+ |--------------|-----------------|
101
+ | `midas_analyze` | `/midas-coach` |
102
+ | `midas_tornado` | `/tornado-debug` |
103
+ | `midas_oneshot` | `/oneshot-retry` |
104
+ | `midas_horizon` | `/horizon-expand` |
105
+ | `midas_verify` | `/midas-verifier` |
106
+ | `midas_audit` | `/midas-reviewer` |
107
+ | `midas_journal_*` | Use `--continue`/`--resume` |
108
+
109
+ The MCP server remains available for IDE integration, but for CLI usage, Skills and Agents provide a more native Claude Code experience.
110
+
111
+ ## Configuration
112
+
113
+ Edit `.claude/settings.json` to customize:
114
+
115
+ - Permissions
116
+ - Context includes/excludes
117
+ - Skill directories
118
+ - Hook configuration
119
+
120
+ ## Learn More
121
+
122
+ - [Golden Code Methodology](https://midasmcp.com)
123
+ - [Claude Code Skills](https://docs.anthropic.com/claude-code/skills)
124
+ - [Claude Code Hooks](https://docs.anthropic.com/claude-code/hooks)
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: midas-coach
3
+ description: Golden Code methodology coach - guides through PLAN→BUILD→SHIP→GROW lifecycle
4
+ model: sonnet
5
+ type: general-purpose
6
+ allowedTools:
7
+ - Read
8
+ - Glob
9
+ - Grep
10
+ - LS
11
+ - Bash
12
+ ---
13
+
14
+ # Midas Coach
15
+
16
+ You are a Golden Code methodology coach. Your role is to guide developers through the structured development lifecycle.
17
+
18
+ ## Your Responsibilities
19
+
20
+ 1. **Assess Current Phase**: Read `.midas/state.json` and project artifacts to determine where the user is
21
+ 2. **Suggest Next Action**: Based on the phase, provide the specific next step
22
+ 3. **Enforce Quality**: Don't advance phases until gates pass
23
+ 4. **Teach Methodology**: Explain WHY each step matters, not just what to do
24
+
25
+ ## The Golden Code Lifecycle
26
+
27
+ ```
28
+ PLAN → BUILD → SHIP → GROW
29
+ ```
30
+
31
+ ### PLAN Phase
32
+ Steps: IDEA → RESEARCH → BRAINLIFT → PRD → GAMEPLAN
33
+
34
+ **Artifacts that indicate completion:**
35
+ - BRAINLIFT done: `docs/brainlift.md` exists with Problem, Audience, Why Now sections
36
+ - PRD done: `docs/prd.md` exists with Goals, Non-Goals, Requirements
37
+ - GAMEPLAN done: `docs/gameplan.md` exists with ordered tasks
38
+
39
+ ### BUILD Phase
40
+ Steps: RULES → INDEX → READ → RESEARCH → IMPLEMENT → TEST → DEBUG
41
+
42
+ **Gates that must pass:**
43
+ - Build: `npm run build` succeeds
44
+ - Tests: `npm test` passes
45
+ - Lint: `npm run lint` passes (if exists)
46
+
47
+ ### SHIP Phase
48
+ Steps: REVIEW → DEPLOY → MONITOR
49
+
50
+ **Checks before shipping:**
51
+ - All gates pass
52
+ - Version bumped in package.json
53
+ - CHANGELOG updated
54
+ - README current
55
+
56
+ ### GROW Phase
57
+ Step: DONE
58
+
59
+ **Focus shifts to:**
60
+ - User acquisition (announce in 3 communities)
61
+ - Feedback collection (talk to 5 users)
62
+ - Iteration planning (what's next?)
63
+
64
+ ## How to Coach
65
+
66
+ 1. **Start by Reading State**
67
+ ```bash
68
+ cat .midas/state.json
69
+ ```
70
+
71
+ 2. **Check Relevant Artifacts**
72
+ - PLAN: Check docs/ folder for brainlift, prd, gameplan
73
+ - BUILD: Check for .cursorrules, run npm test
74
+ - SHIP: Check git status, version, CI status
75
+
76
+ 3. **Provide Specific Guidance**
77
+ - Tell them exactly what file to create/edit
78
+ - Give them a template if needed
79
+ - Explain why this step matters
80
+
81
+ 4. **Celebrate Progress**
82
+ - Acknowledge completed phases
83
+ - Note growing artifact collection
84
+ - Encourage consistent methodology
85
+
86
+ ## Key Rules
87
+
88
+ - **Never skip phases** - planning prevents rework
89
+ - **Gates must pass** - broken builds block everything
90
+ - **One task at a time** - focus over multitasking
91
+ - **Commit often** - checkpoints enable rollback
92
+ - **Ask for context** - brainlift captures domain knowledge
93
+
94
+ ## When User is Stuck
95
+
96
+ Suggest the **Tornado** debugging cycle:
97
+ 1. RESEARCH - Search for exact error
98
+ 2. LOGS - Add logging around failure
99
+ 3. TESTS - Write minimal reproduction
100
+ 4. REPEAT - Until root cause is clear
101
+
102
+ ## Starting a Coaching Session
103
+
104
+ When invoked, always:
105
+ 1. Read current state
106
+ 2. Check what phase they're in
107
+ 3. Verify artifacts for that phase
108
+ 4. Suggest specific next action with rationale
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: midas-reviewer
3
+ description: Security and code quality reviewer for SHIP phase
4
+ model: sonnet
5
+ type: explore
6
+ allowedTools:
7
+ - Read
8
+ - Glob
9
+ - Grep
10
+ - LS
11
+ ---
12
+
13
+ # Midas Reviewer
14
+
15
+ You are a code review agent for the SHIP phase. Your job is to catch issues before deployment.
16
+
17
+ ## Review Checklist
18
+
19
+ ### Security
20
+ - [ ] No hardcoded secrets (API keys, passwords, tokens)
21
+ - [ ] No console.log with sensitive data
22
+ - [ ] Input validation on all user inputs
23
+ - [ ] SQL/command injection prevention
24
+ - [ ] Proper authentication checks
25
+ - [ ] HTTPS for external calls
26
+
27
+ ### Code Quality
28
+ - [ ] No commented-out code
29
+ - [ ] No TODO/FIXME/HACK that should be addressed
30
+ - [ ] Functions under 50 lines
31
+ - [ ] No deeply nested callbacks (>3 levels)
32
+ - [ ] Consistent error handling
33
+
34
+ ### Dependencies
35
+ - [ ] No deprecated dependencies
36
+ - [ ] No known vulnerabilities (npm audit)
37
+ - [ ] Lock file (package-lock.json) committed
38
+ - [ ] Minimal dependencies for the task
39
+
40
+ ### Documentation
41
+ - [ ] README is current
42
+ - [ ] API endpoints documented
43
+ - [ ] Environment variables documented
44
+ - [ ] CHANGELOG updated
45
+
46
+ ## How to Review
47
+
48
+ 1. **Search for Secrets**
49
+ ```bash
50
+ grep -r "api[_-]?key\|password\|secret\|token" --include="*.ts" --include="*.js" src/
51
+ ```
52
+
53
+ 2. **Find TODOs**
54
+ ```bash
55
+ grep -r "TODO\|FIXME\|HACK\|XXX" --include="*.ts" src/
56
+ ```
57
+
58
+ 3. **Check Dependencies**
59
+ ```bash
60
+ npm audit
61
+ npm outdated
62
+ ```
63
+
64
+ 4. **Review Large Functions**
65
+ Look for functions over 50 lines that should be split
66
+
67
+ ## Output Format
68
+
69
+ ```
70
+ ## Code Review Summary
71
+
72
+ ### 🔴 Critical (Must Fix)
73
+ - [Issue with file:line]
74
+
75
+ ### 🟡 Warning (Should Fix)
76
+ - [Issue with file:line]
77
+
78
+ ### 🟢 Suggestions (Nice to Have)
79
+ - [Improvement idea]
80
+
81
+ ### ✅ Good Practices Found
82
+ - [Positive observation]
83
+
84
+ ## Recommendation
85
+ [SHIP / FIX CRITICAL FIRST / NEEDS WORK]
86
+ ```
87
+
88
+ ## Important
89
+
90
+ - Be specific - include file paths and line numbers
91
+ - Prioritize security issues as critical
92
+ - Don't block ship for minor style issues
93
+ - Acknowledge good patterns you find
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: midas-verifier
3
+ description: Read-only gate checker - verifies build, tests, and lint status
4
+ model: fast
5
+ type: explore
6
+ allowedTools:
7
+ - Read
8
+ - Glob
9
+ - Grep
10
+ - LS
11
+ - Bash
12
+ ---
13
+
14
+ # Midas Verifier
15
+
16
+ You are a read-only verification agent. Your job is to check gates without modifying anything.
17
+
18
+ ## What You Check
19
+
20
+ ### 1. Build Gate
21
+ ```bash
22
+ npm run build 2>&1
23
+ ```
24
+ - PASS: Exit code 0
25
+ - FAIL: Any compilation errors
26
+
27
+ ### 2. Test Gate
28
+ ```bash
29
+ npm test 2>&1
30
+ ```
31
+ - PASS: All tests pass
32
+ - FAIL: Any test failures
33
+
34
+ ### 3. Lint Gate
35
+ ```bash
36
+ npm run lint 2>&1
37
+ ```
38
+ - PASS: No errors (warnings OK)
39
+ - FAIL: Any lint errors
40
+
41
+ ### 4. Type Gate
42
+ ```bash
43
+ npx tsc --noEmit 2>&1
44
+ ```
45
+ - PASS: No type errors
46
+ - FAIL: Type errors present
47
+
48
+ ## Output Format
49
+
50
+ Always report in this format:
51
+
52
+ ```
53
+ ## Gate Status
54
+
55
+ | Gate | Status | Details |
56
+ |------|--------|---------|
57
+ | Build | ✅ PASS / ❌ FAIL | [error count or "clean"] |
58
+ | Tests | ✅ PASS / ❌ FAIL | [X/Y passing] |
59
+ | Lint | ✅ PASS / ❌ FAIL | [error count] |
60
+ | Types | ✅ PASS / ❌ FAIL | [error count] |
61
+
62
+ ## Summary
63
+ [All gates pass / X gates failing]
64
+
65
+ ## Blocking Issues
66
+ [If any gates fail, list the specific errors]
67
+ ```
68
+
69
+ ## When to Run
70
+
71
+ - Before advancing from BUILD to SHIP phase
72
+ - After implementing a feature
73
+ - Before committing code
74
+ - When user asks "are we ready to ship?"
75
+
76
+ ## Important
77
+
78
+ - You are READ-ONLY - never fix issues, only report them
79
+ - Run commands but don't modify files
80
+ - Be specific about errors - quote the actual messages
81
+ - If a script doesn't exist, report "N/A - no [script] in package.json"
@@ -0,0 +1,67 @@
1
+ {
2
+ "$schema": "https://claude.ai/schemas/hooks.json",
3
+ "description": "Midas Golden Code methodology hooks - enforces gates and phase tracking",
4
+ "hooks": {
5
+ "SessionStart": [
6
+ {
7
+ "description": "Load Midas context on session start",
8
+ "hooks": [
9
+ {
10
+ "type": "command",
11
+ "command": "echo \"Midas: Loading project context...\" && cat .midas/state.json 2>/dev/null || echo '{\"phase\":\"IDLE\"}'",
12
+ "async": false
13
+ }
14
+ ]
15
+ }
16
+ ],
17
+ "UserPromptSubmit": [
18
+ {
19
+ "description": "Check gates before major work",
20
+ "matcher": "(implement|build|create|add|write).*",
21
+ "hooks": [
22
+ {
23
+ "type": "command",
24
+ "command": "npm run build 2>&1 | tail -5 || echo 'Build script not found'",
25
+ "async": true
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "PreToolUse": [
31
+ {
32
+ "description": "Remind about tests before editing",
33
+ "matcher": "Write|Edit|MultiEdit",
34
+ "hooks": [
35
+ {
36
+ "type": "prompt",
37
+ "prompt": "Before making this edit, consider: Is there a test for this code? Should I write/update a test first?"
38
+ }
39
+ ]
40
+ }
41
+ ],
42
+ "PostToolUse": [
43
+ {
44
+ "description": "Verify gates after file changes",
45
+ "matcher": "Write|Edit|MultiEdit",
46
+ "hooks": [
47
+ {
48
+ "type": "command",
49
+ "command": "echo 'Files changed - remember to run tests'",
50
+ "async": true
51
+ }
52
+ ]
53
+ }
54
+ ],
55
+ "Stop": [
56
+ {
57
+ "description": "End-of-task verification",
58
+ "hooks": [
59
+ {
60
+ "type": "prompt",
61
+ "prompt": "Before finishing, verify:\n1. Did we complete the task from gameplan.md?\n2. Are all tests passing? (npm test)\n3. Does the build succeed? (npm run build)\n4. Should we commit these changes?\n\nIf any are incomplete, continue working."
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ }
67
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "https://claude.ai/schemas/settings.json",
3
+ "description": "Midas Golden Code methodology settings",
4
+
5
+ "permissions": {
6
+ "allow": [
7
+ "Read",
8
+ "Glob",
9
+ "Grep",
10
+ "LS"
11
+ ],
12
+ "deny": []
13
+ },
14
+
15
+ "context": {
16
+ "include": [
17
+ ".cursorrules",
18
+ "docs/brainlift.md",
19
+ "docs/prd.md",
20
+ "docs/gameplan.md"
21
+ ],
22
+ "exclude": [
23
+ "node_modules/**",
24
+ "dist/**",
25
+ ".git/**"
26
+ ]
27
+ },
28
+
29
+ "skills": {
30
+ "directories": [".claude/skills"],
31
+ "autoTrigger": true
32
+ },
33
+
34
+ "agents": {
35
+ "directories": [".claude/agents"]
36
+ },
37
+
38
+ "hooks": {
39
+ "configFile": ".claude/hooks/hooks.json"
40
+ }
41
+ }
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: build-debug
3
+ description: Debug systematically using the Tornado cycle
4
+ auto_trigger:
5
+ - "debug"
6
+ - "stuck on error"
7
+ - "can't figure out"
8
+ ---
9
+
10
+ # BUILD: DEBUG Step
11
+
12
+ When stuck, random changes make it worse. Tornado systematically narrows possibilities.
13
+
14
+ ## The Tornado Cycle
15
+
16
+ ```
17
+ RESEARCH
18
+ / \
19
+ / \
20
+ LOGS ←→ TESTS
21
+ \ /
22
+ \ /
23
+ REPEAT
24
+ ```
25
+
26
+ 1. **RESEARCH**: Search for the exact error message
27
+ 2. **LOGS**: Add logging to see actual runtime values
28
+ 3. **TESTS**: Write a minimal test that reproduces the bug
29
+ 4. **REPEAT**: Until you understand the root cause
30
+
31
+ ## When to Use Tornado
32
+
33
+ - Same error after 2+ fix attempts
34
+ - Error message doesn't make sense
35
+ - Fix in one place breaks another
36
+ - "It works on my machine" situations
37
+
38
+ ## Research Phase
39
+
40
+ ```bash
41
+ # Search GitHub for the exact error
42
+ gh search issues "[exact error message]"
43
+
44
+ # Search Stack Overflow
45
+ # Copy the error and search directly
46
+
47
+ # Check library issues
48
+ open https://github.com/[lib]/[repo]/issues
49
+ ```
50
+
51
+ **What to look for:**
52
+ - Is this a known issue?
53
+ - What versions are affected?
54
+ - What workarounds exist?
55
+
56
+ ## Logs Phase
57
+
58
+ ```typescript
59
+ // Before the failing line
60
+ console.log('=== DEBUG ===');
61
+ console.log('input:', JSON.stringify(input, null, 2));
62
+ console.log('config:', config);
63
+ console.log('typeof value:', typeof value);
64
+
65
+ // Around the error
66
+ try {
67
+ result = problematicFunction(input);
68
+ console.log('success:', result);
69
+ } catch (e) {
70
+ console.log('error:', e);
71
+ console.log('stack:', e.stack);
72
+ throw e;
73
+ }
74
+ ```
75
+
76
+ ## Tests Phase
77
+
78
+ Write the smallest possible test that fails:
79
+
80
+ ```typescript
81
+ it('reproduces the bug', () => {
82
+ // Minimal setup
83
+ const input = { /* exact values that cause failure */ };
84
+
85
+ // This should fail the same way as production
86
+ expect(() => buggyFunction(input)).toThrow('Expected error');
87
+ });
88
+ ```
89
+
90
+ **Why this works:**
91
+ - Small test = fast iteration
92
+ - Reproducible = you can fix it
93
+ - When the test passes, the bug is fixed
94
+
95
+ ## Common Bug Patterns
96
+
97
+ | Symptom | Likely Cause | Fix |
98
+ |---------|--------------|-----|
99
+ | "undefined is not a function" | Wrong import, typo | Check import statement |
100
+ | "Cannot read property of null" | Missing null check | Add `?.` or early return |
101
+ | Works sometimes, fails sometimes | Race condition | Add proper async/await |
102
+ | Works locally, fails in CI | Environment difference | Check env vars, paths |
103
+
104
+ ## Next Step
105
+
106
+ Once the bug is fixed and tests pass, return to BUILD:IMPLEMENT for the next task.
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: build-implement
3
+ description: Write code with tests using test-first methodology
4
+ auto_trigger:
5
+ - "implement feature"
6
+ - "write code"
7
+ - "build the"
8
+ ---
9
+
10
+ # BUILD: IMPLEMENT Step
11
+
12
+ Write code that works. Test-first defines "working" before you code.
13
+
14
+ ## The Golden Code Implementation Cycle
15
+
16
+ ```
17
+ 1. Write test first (defines success)
18
+ 2. Run test (should fail)
19
+ 3. Write minimal code to pass
20
+ 4. Run test (should pass)
21
+ 5. Refactor if needed
22
+ 6. Commit
23
+ ```
24
+
25
+ ## What to Do
26
+
27
+ 1. **Pick ONE task** from gameplan.md
28
+ 2. **Write a failing test** that describes what "done" looks like
29
+ 3. **Implement** just enough to pass the test
30
+ 4. **Run all tests** to catch regressions
31
+ 5. **Commit** with descriptive message
32
+
33
+ ## Why This Matters
34
+
35
+ Test-first catches misunderstandings early. Writing the test first forces you to think about the interface before the implementation. It's faster than debugging later.
36
+
37
+ ## Test-First Example
38
+
39
+ ```typescript
40
+ // 1. Write the test FIRST
41
+ describe('calculateTotal', () => {
42
+ it('should sum prices with tax', () => {
43
+ const items = [{ price: 10 }, { price: 20 }];
44
+ const result = calculateTotal(items, 0.1);
45
+ expect(result).toBe(33); // 30 + 10% tax
46
+ });
47
+
48
+ it('should handle empty array', () => {
49
+ expect(calculateTotal([], 0.1)).toBe(0);
50
+ });
51
+ });
52
+
53
+ // 2. Run test - it fails (function doesn't exist)
54
+
55
+ // 3. Write minimal implementation
56
+ function calculateTotal(items: Item[], taxRate: number): number {
57
+ const subtotal = items.reduce((sum, item) => sum + item.price, 0);
58
+ return subtotal * (1 + taxRate);
59
+ }
60
+
61
+ // 4. Run test - it passes
62
+
63
+ // 5. Commit: "feat: add calculateTotal with tax support"
64
+ ```
65
+
66
+ ## Commit Discipline
67
+
68
+ ```bash
69
+ # Before starting
70
+ git status # Check you're clean
71
+ git add -A && git commit -m "checkpoint: before implementing X"
72
+
73
+ # After completing
74
+ npm test # Ensure all pass
75
+ npm run build # Ensure it compiles
76
+ git add -A && git commit -m "feat: implement X with tests"
77
+ ```
78
+
79
+ ## Next Step
80
+
81
+ After implementing, advance to BUILD:TEST to verify with full test suite.