@hustle-together/api-dev-tools 3.10.1 → 3.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/.claude/api-dev-state.json +159 -0
  2. package/.claude/commands/README.md +185 -0
  3. package/.claude/commands/add-command.md +209 -0
  4. package/.claude/commands/api-create.md +499 -0
  5. package/.claude/commands/api-env.md +50 -0
  6. package/.claude/commands/api-interview.md +331 -0
  7. package/.claude/commands/api-research.md +331 -0
  8. package/.claude/commands/api-status.md +259 -0
  9. package/.claude/commands/api-verify.md +231 -0
  10. package/.claude/commands/beepboop.md +97 -0
  11. package/.claude/commands/busycommit.md +112 -0
  12. package/.claude/commands/commit.md +83 -0
  13. package/.claude/commands/cycle.md +142 -0
  14. package/.claude/commands/gap.md +86 -0
  15. package/.claude/commands/green.md +142 -0
  16. package/.claude/commands/issue.md +192 -0
  17. package/.claude/commands/plan.md +168 -0
  18. package/.claude/commands/pr.md +122 -0
  19. package/.claude/commands/red.md +142 -0
  20. package/.claude/commands/refactor.md +142 -0
  21. package/.claude/commands/spike.md +142 -0
  22. package/.claude/commands/summarize.md +94 -0
  23. package/.claude/commands/tdd.md +144 -0
  24. package/.claude/commands/worktree-add.md +315 -0
  25. package/.claude/commands/worktree-cleanup.md +281 -0
  26. package/.claude/hooks/api-workflow-check.py +227 -0
  27. package/.claude/hooks/enforce-deep-research.py +185 -0
  28. package/.claude/hooks/enforce-disambiguation.py +155 -0
  29. package/.claude/hooks/enforce-documentation.py +192 -0
  30. package/.claude/hooks/enforce-environment.py +253 -0
  31. package/.claude/hooks/enforce-external-research.py +328 -0
  32. package/.claude/hooks/enforce-interview.py +421 -0
  33. package/.claude/hooks/enforce-refactor.py +189 -0
  34. package/.claude/hooks/enforce-research.py +159 -0
  35. package/.claude/hooks/enforce-schema.py +186 -0
  36. package/.claude/hooks/enforce-scope.py +160 -0
  37. package/.claude/hooks/enforce-tdd-red.py +250 -0
  38. package/.claude/hooks/enforce-verify.py +186 -0
  39. package/.claude/hooks/periodic-reground.py +154 -0
  40. package/.claude/hooks/session-startup.py +151 -0
  41. package/.claude/hooks/track-tool-use.py +626 -0
  42. package/.claude/hooks/verify-after-green.py +282 -0
  43. package/.claude/hooks/verify-implementation.py +225 -0
  44. package/.claude/research/index.json +6 -0
  45. package/.claude/settings.json +93 -0
  46. package/.claude/settings.local.json +11 -0
  47. package/.claude-plugin/marketplace.json +112 -0
  48. package/.skills/README.md +291 -0
  49. package/.skills/_shared/convert-commands.py +192 -0
  50. package/.skills/_shared/hooks/api-workflow-check.py +227 -0
  51. package/.skills/_shared/hooks/enforce-deep-research.py +185 -0
  52. package/.skills/_shared/hooks/enforce-disambiguation.py +155 -0
  53. package/.skills/_shared/hooks/enforce-documentation.py +192 -0
  54. package/.skills/_shared/hooks/enforce-environment.py +253 -0
  55. package/.skills/_shared/hooks/enforce-external-research.py +328 -0
  56. package/.skills/_shared/hooks/enforce-interview.py +421 -0
  57. package/.skills/_shared/hooks/enforce-refactor.py +189 -0
  58. package/.skills/_shared/hooks/enforce-research.py +159 -0
  59. package/.skills/_shared/hooks/enforce-schema.py +186 -0
  60. package/.skills/_shared/hooks/enforce-scope.py +160 -0
  61. package/.skills/_shared/hooks/enforce-tdd-red.py +250 -0
  62. package/.skills/_shared/hooks/enforce-verify.py +186 -0
  63. package/.skills/_shared/hooks/periodic-reground.py +154 -0
  64. package/.skills/_shared/hooks/session-startup.py +151 -0
  65. package/.skills/_shared/hooks/track-tool-use.py +626 -0
  66. package/.skills/_shared/hooks/verify-after-green.py +282 -0
  67. package/.skills/_shared/hooks/verify-implementation.py +225 -0
  68. package/.skills/_shared/install.sh +114 -0
  69. package/.skills/_shared/settings.json +93 -0
  70. package/.skills/add-command/SKILL.md +222 -0
  71. package/.skills/api-create/SKILL.md +512 -0
  72. package/.skills/api-env/SKILL.md +63 -0
  73. package/.skills/api-interview/SKILL.md +344 -0
  74. package/.skills/api-research/SKILL.md +344 -0
  75. package/.skills/api-status/SKILL.md +272 -0
  76. package/.skills/api-verify/SKILL.md +244 -0
  77. package/.skills/beepboop/SKILL.md +110 -0
  78. package/.skills/busycommit/SKILL.md +125 -0
  79. package/.skills/commit/SKILL.md +96 -0
  80. package/.skills/cycle/SKILL.md +155 -0
  81. package/.skills/gap/SKILL.md +99 -0
  82. package/.skills/green/SKILL.md +155 -0
  83. package/.skills/issue/SKILL.md +205 -0
  84. package/.skills/plan/SKILL.md +181 -0
  85. package/.skills/pr/SKILL.md +135 -0
  86. package/.skills/red/SKILL.md +155 -0
  87. package/.skills/refactor/SKILL.md +155 -0
  88. package/.skills/spike/SKILL.md +155 -0
  89. package/.skills/summarize/SKILL.md +107 -0
  90. package/.skills/tdd/SKILL.md +157 -0
  91. package/.skills/update-todos/SKILL.md +228 -0
  92. package/.skills/worktree-add/SKILL.md +328 -0
  93. package/.skills/worktree-cleanup/SKILL.md +294 -0
  94. package/CHANGELOG.md +97 -0
  95. package/README.md +58 -17
  96. package/package.json +22 -11
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: refactor
3
+ description: TDD Refactor Phase - improve code structure, readability, and performance while keeping all tests green. Use after tests pass to clean up code. Keywords: tdd, refactoring, cleanup, optimization, quality
4
+ license: MIT
5
+ compatibility: Requires Claude Code with MCP servers (Context7, GitHub), Python 3.9+ for hooks, pnpm 10.11.0+
6
+ metadata:
7
+ version: "3.0.0"
8
+ category: "testing"
9
+ tags: ['tdd', 'refactoring', 'cleanup', 'optimization']
10
+ author: "Hustle Together"
11
+ allowed-tools: WebSearch WebFetch mcp__context7 mcp__github AskUserQuestion Read Write Edit Bash TodoWrite
12
+ ---
13
+
14
+ ---
15
+ description: Execute TDD Refactor Phase - improve code structure while keeping tests green
16
+ argument-hint: <refactoring description>
17
+ ---
18
+
19
+ Apply this document (specifically the Refactor phase), to the info given by user input here: $ARGUMENTS
20
+
21
+ ## General Guidelines
22
+
23
+ ### Output Style
24
+
25
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
26
+ - Write natural, descriptive code without meta-commentary about the development process
27
+ - The code should speak for itself - TDD is the process, not the product
28
+
29
+ (If there was no info above, fallback to the context of the conversation)
30
+
31
+ ## TDD Fundamentals
32
+
33
+ ### The TDD Cycle
34
+
35
+ The foundation of TDD is the Red-Green-Refactor cycle:
36
+
37
+ 1. **Red Phase**: Write ONE failing test that describes desired behavior
38
+
39
+ - The test must fail for the RIGHT reason (not syntax/import errors)
40
+ - Only one test at a time - this is critical for TDD discipline
41
+ - Exception: For browser-level tests or expensive setup (e.g., Storybook `*.stories.tsx`), group multiple assertions within a single test block to avoid redundant setup - but only when adding assertions to an existing interaction flow. If new user interactions are required, still create a new test. Split files by category if they exceed ~1000 lines.
42
+ - **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed
43
+ - Starting TDD for a new feature is always valid, even if test output shows unrelated work
44
+ - For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content
45
+ - Avoid hard-coded timeouts both in form of sleep() or timeout: 5000 etc; use proper async patterns (`waitFor`, `findBy*`, event-based sync) instead and rely on global test configs for timeout settings
46
+
47
+ 2. **Green Phase**: Write MINIMAL code to make the test pass
48
+
49
+ - Implement only what's needed for the current failing test
50
+ - No anticipatory coding or extra features
51
+ - Address the specific failure message
52
+
53
+ 3. **Refactor Phase**: Improve code structure while keeping tests green
54
+ - Only allowed when relevant tests are passing
55
+ - Requires proof that tests have been run and are green
56
+ - Applies to BOTH implementation and test code
57
+ - No refactoring with failing tests - fix them first
58
+
59
+ ### Core Violations
60
+
61
+ 1. **Multiple Test Addition**
62
+
63
+ - Adding more than one new test at once
64
+ - Exception: Initial test file setup or extracting shared test utilities
65
+
66
+ 2. **Over-Implementation**
67
+
68
+ - Code that exceeds what's needed to pass the current failing test
69
+ - Adding untested features, methods, or error handling
70
+ - Implementing multiple methods when test only requires one
71
+
72
+ 3. **Premature Implementation**
73
+ - Adding implementation before a test exists and fails properly
74
+ - Adding implementation without running the test first
75
+ - Refactoring when tests haven't been run or are failing
76
+
77
+ ### Critical Principle: Incremental Development
78
+
79
+ Each step in TDD should address ONE specific issue:
80
+
81
+ - Test fails "not defined" → Create empty stub/class only
82
+ - Test fails "not a function" → Add method stub only
83
+ - Test fails with assertion → Implement minimal logic only
84
+
85
+ ### Optional Pre-Phase: Spike Phase
86
+
87
+ In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.
88
+ This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.
89
+
90
+ - The goal of a Spike is **exploration and learning**, not implementation.
91
+ - The code written during a Spike is **disposable** and **must not** be merged or reused directly.
92
+ - Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.
93
+ - A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
94
+
95
+ ### General Information
96
+
97
+ - Sometimes the test output shows as no tests have been run when a new test is failing due to a missing import or constructor. In such cases, allow the agent to create simple stubs. Ask them if they forgot to create a stub if they are stuck.
98
+ - It is never allowed to introduce new logic without evidence of relevant failing tests. However, stubs and simple implementation to make imports and test infrastructure work is fine.
99
+ - In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
100
+ - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
101
+ - Provide the agent with helpful directions so that they do not get stuck when blocking them.
102
+
103
+ 1. **Consistency check** - Look for inconsistent patterns, naming conventions, or structure across the codebase
104
+
105
+
106
+ ## 🛡 Project Rules (Injected into every command)
107
+
108
+ 1. **NO BROKEN BUILDS:**
109
+ - Run `pnpm test` before every `/commit`
110
+ - Ensure all tests pass
111
+ - Fix any type errors immediately
112
+
113
+ 2. **API DEVELOPMENT:**
114
+ - All new APIs MUST have Zod request/response schemas
115
+ - All APIs MUST be documented in both:
116
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
117
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
118
+ - Test ALL parameters and edge cases
119
+ - Include code examples and real-world outputs
120
+
121
+ 3. **TDD WORKFLOW:**
122
+ - ALWAYS use /red → /green → /refactor cycle
123
+ - NEVER write implementation without failing test first
124
+ - Use /cycle for feature development
125
+ - Use characterization tests for refactoring
126
+
127
+ 4. **API KEY MANAGEMENT:**
128
+ - Support three loading methods:
129
+ - Server environment variables
130
+ - NEXT_PUBLIC_ variables (client-side)
131
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
132
+ - Never hardcode API keys
133
+ - Always validate key availability before use
134
+
135
+ 5. **COMPREHENSIVE TESTING:**
136
+ - When researching APIs, read actual implementation code
137
+ - Discover ALL possible parameters (not just documented ones)
138
+ - Test with various parameter combinations
139
+ - Document custom headers, query params, request/response schemas
140
+ - Include validation rules and testing notes
141
+
142
+ 6. **NO UI BLOAT:**
143
+ - This is an API project with minimal frontend
144
+ - Only keep necessary test/documentation interfaces
145
+ - Delete unused components immediately
146
+ - No unnecessary UI libraries or features
147
+
148
+ 7. **DOCUMENTATION:**
149
+ - If you change an API, you MUST update:
150
+ - OpenAPI spec
151
+ - api-tests-manifest.json
152
+ - Code examples
153
+ - Testing notes
154
+ - Document expected behavior and edge cases
155
+ - Include real-world output examples
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: spike
3
+ description: Execute TDD Spike Phase - exploratory coding to understand problem space before formal TDD. Use when requirements are unclear or architecture needs exploration. Keywords: spike, exploration, prototyping, learning, architecture
4
+ license: MIT
5
+ compatibility: Requires Claude Code with MCP servers (Context7, GitHub), Python 3.9+ for hooks, pnpm 10.11.0+
6
+ metadata:
7
+ version: "3.0.0"
8
+ category: "workflow"
9
+ tags: ['spike', 'exploration', 'prototyping', 'learning']
10
+ author: "Hustle Together"
11
+ allowed-tools: WebSearch WebFetch mcp__context7 mcp__github AskUserQuestion Read Write Edit Bash TodoWrite
12
+ ---
13
+
14
+ ---
15
+ description: Execute TDD Spike Phase - exploratory coding to understand problem space before TDD
16
+ argument-hint: <exploration description>
17
+ ---
18
+
19
+ SPIKE PHASE! Apply the below to the info given by user input here:
20
+
21
+ $ARGUMENTS
22
+
23
+ ## General Guidelines
24
+
25
+ ### Output Style
26
+
27
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
28
+ - Write natural, descriptive code without meta-commentary about the development process
29
+ - The code should speak for itself - TDD is the process, not the product
30
+
31
+ (If there was no info above, fallback to the context of the conversation)
32
+
33
+ ## TDD Fundamentals
34
+
35
+ ### The TDD Cycle
36
+
37
+ The foundation of TDD is the Red-Green-Refactor cycle:
38
+
39
+ 1. **Red Phase**: Write ONE failing test that describes desired behavior
40
+
41
+ - The test must fail for the RIGHT reason (not syntax/import errors)
42
+ - Only one test at a time - this is critical for TDD discipline
43
+ - Exception: For browser-level tests or expensive setup (e.g., Storybook `*.stories.tsx`), group multiple assertions within a single test block to avoid redundant setup - but only when adding assertions to an existing interaction flow. If new user interactions are required, still create a new test. Split files by category if they exceed ~1000 lines.
44
+ - **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed
45
+ - Starting TDD for a new feature is always valid, even if test output shows unrelated work
46
+ - For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content
47
+ - Avoid hard-coded timeouts both in form of sleep() or timeout: 5000 etc; use proper async patterns (`waitFor`, `findBy*`, event-based sync) instead and rely on global test configs for timeout settings
48
+
49
+ 2. **Green Phase**: Write MINIMAL code to make the test pass
50
+
51
+ - Implement only what's needed for the current failing test
52
+ - No anticipatory coding or extra features
53
+ - Address the specific failure message
54
+
55
+ 3. **Refactor Phase**: Improve code structure while keeping tests green
56
+ - Only allowed when relevant tests are passing
57
+ - Requires proof that tests have been run and are green
58
+ - Applies to BOTH implementation and test code
59
+ - No refactoring with failing tests - fix them first
60
+
61
+ ### Core Violations
62
+
63
+ 1. **Multiple Test Addition**
64
+
65
+ - Adding more than one new test at once
66
+ - Exception: Initial test file setup or extracting shared test utilities
67
+
68
+ 2. **Over-Implementation**
69
+
70
+ - Code that exceeds what's needed to pass the current failing test
71
+ - Adding untested features, methods, or error handling
72
+ - Implementing multiple methods when test only requires one
73
+
74
+ 3. **Premature Implementation**
75
+ - Adding implementation before a test exists and fails properly
76
+ - Adding implementation without running the test first
77
+ - Refactoring when tests haven't been run or are failing
78
+
79
+ ### Critical Principle: Incremental Development
80
+
81
+ Each step in TDD should address ONE specific issue:
82
+
83
+ - Test fails "not defined" → Create empty stub/class only
84
+ - Test fails "not a function" → Add method stub only
85
+ - Test fails with assertion → Implement minimal logic only
86
+
87
+ ### Optional Pre-Phase: Spike Phase
88
+
89
+ In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.
90
+ This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.
91
+
92
+ - The goal of a Spike is **exploration and learning**, not implementation.
93
+ - The code written during a Spike is **disposable** and **must not** be merged or reused directly.
94
+ - Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.
95
+ - A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
96
+
97
+ ### General Information
98
+
99
+ - Sometimes the test output shows as no tests have been run when a new test is failing due to a missing import or constructor. In such cases, allow the agent to create simple stubs. Ask them if they forgot to create a stub if they are stuck.
100
+ - It is never allowed to introduce new logic without evidence of relevant failing tests. However, stubs and simple implementation to make imports and test infrastructure work is fine.
101
+ - In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
102
+ - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
103
+ - Provide the agent with helpful directions so that they do not get stuck when blocking them.
104
+
105
+
106
+ ## 🛡 Project Rules (Injected into every command)
107
+
108
+ 1. **NO BROKEN BUILDS:**
109
+ - Run `pnpm test` before every `/commit`
110
+ - Ensure all tests pass
111
+ - Fix any type errors immediately
112
+
113
+ 2. **API DEVELOPMENT:**
114
+ - All new APIs MUST have Zod request/response schemas
115
+ - All APIs MUST be documented in both:
116
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
117
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
118
+ - Test ALL parameters and edge cases
119
+ - Include code examples and real-world outputs
120
+
121
+ 3. **TDD WORKFLOW:**
122
+ - ALWAYS use /red → /green → /refactor cycle
123
+ - NEVER write implementation without failing test first
124
+ - Use /cycle for feature development
125
+ - Use characterization tests for refactoring
126
+
127
+ 4. **API KEY MANAGEMENT:**
128
+ - Support three loading methods:
129
+ - Server environment variables
130
+ - NEXT_PUBLIC_ variables (client-side)
131
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
132
+ - Never hardcode API keys
133
+ - Always validate key availability before use
134
+
135
+ 5. **COMPREHENSIVE TESTING:**
136
+ - When researching APIs, read actual implementation code
137
+ - Discover ALL possible parameters (not just documented ones)
138
+ - Test with various parameter combinations
139
+ - Document custom headers, query params, request/response schemas
140
+ - Include validation rules and testing notes
141
+
142
+ 6. **NO UI BLOAT:**
143
+ - This is an API project with minimal frontend
144
+ - Only keep necessary test/documentation interfaces
145
+ - Delete unused components immediately
146
+ - No unnecessary UI libraries or features
147
+
148
+ 7. **DOCUMENTATION:**
149
+ - If you change an API, you MUST update:
150
+ - OpenAPI spec
151
+ - api-tests-manifest.json
152
+ - Code examples
153
+ - Testing notes
154
+ - Document expected behavior and edge cases
155
+ - Include real-world output examples
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: summarize
3
+ description: Summarize conversation progress and next steps. Provides overview of completed work and remaining tasks. Use at end of sessions or before breaks. Keywords: summary, progress, overview, tracking, communication
4
+ license: MIT
5
+ compatibility: Requires Claude Code with MCP servers (Context7, GitHub), Python 3.9+ for hooks, pnpm 10.11.0+
6
+ metadata:
7
+ version: "3.0.0"
8
+ category: "workflow"
9
+ tags: ['summary', 'progress', 'overview', 'tracking']
10
+ author: "Hustle Together"
11
+ allowed-tools: WebSearch WebFetch mcp__context7 mcp__github AskUserQuestion Read Write Edit Bash TodoWrite
12
+ ---
13
+
14
+ ---
15
+ description: Summarize conversation progress and next steps
16
+ argument-hint: [optional additional info]
17
+ ---
18
+
19
+ ## General Guidelines
20
+
21
+ ### Output Style
22
+
23
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
24
+ - Write natural, descriptive code without meta-commentary about the development process
25
+ - The code should speak for itself - TDD is the process, not the product
26
+
27
+ Create a concise summary of the current conversation suitable for transferring context to a new conversation.
28
+
29
+ Additional info: $ARGUMENTS
30
+
31
+ ## Summary Structure
32
+
33
+ Provide a summary with these sections:
34
+
35
+ ### What We Did
36
+
37
+ - Key accomplishments and changes made
38
+ - Important decisions or discoveries
39
+ - Files created, modified, or analyzed
40
+
41
+ ### What We're Doing Next
42
+
43
+ - Immediate next steps
44
+ - Pending tasks or work in progress
45
+ - Goals or objectives to continue
46
+
47
+ ### Blockers & User Input Needed
48
+
49
+ - Any issues requiring user intervention
50
+ - Decisions that need to be made
51
+ - Missing information or clarifications needed
52
+
53
+ ## Output Format
54
+
55
+ Keep the summary concise and actionable - suitable for pasting into a new conversation to quickly restore context without needing the full conversation history.
56
+
57
+
58
+ ## 🛡 Project Rules (Injected into every command)
59
+
60
+ 1. **NO BROKEN BUILDS:**
61
+ - Run `pnpm test` before every `/commit`
62
+ - Ensure all tests pass
63
+ - Fix any type errors immediately
64
+
65
+ 2. **API DEVELOPMENT:**
66
+ - All new APIs MUST have Zod request/response schemas
67
+ - All APIs MUST be documented in both:
68
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
69
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
70
+ - Test ALL parameters and edge cases
71
+ - Include code examples and real-world outputs
72
+
73
+ 3. **TDD WORKFLOW:**
74
+ - ALWAYS use /red → /green → /refactor cycle
75
+ - NEVER write implementation without failing test first
76
+ - Use /cycle for feature development
77
+ - Use characterization tests for refactoring
78
+
79
+ 4. **API KEY MANAGEMENT:**
80
+ - Support three loading methods:
81
+ - Server environment variables
82
+ - NEXT_PUBLIC_ variables (client-side)
83
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
84
+ - Never hardcode API keys
85
+ - Always validate key availability before use
86
+
87
+ 5. **COMPREHENSIVE TESTING:**
88
+ - When researching APIs, read actual implementation code
89
+ - Discover ALL possible parameters (not just documented ones)
90
+ - Test with various parameter combinations
91
+ - Document custom headers, query params, request/response schemas
92
+ - Include validation rules and testing notes
93
+
94
+ 6. **NO UI BLOAT:**
95
+ - This is an API project with minimal frontend
96
+ - Only keep necessary test/documentation interfaces
97
+ - Delete unused components immediately
98
+ - No unnecessary UI libraries or features
99
+
100
+ 7. **DOCUMENTATION:**
101
+ - If you change an API, you MUST update:
102
+ - OpenAPI spec
103
+ - api-tests-manifest.json
104
+ - Code examples
105
+ - Testing notes
106
+ - Document expected behavior and edge cases
107
+ - Include real-world output examples
@@ -0,0 +1,157 @@
1
+ ---
2
+ name: tdd
3
+ description: Remind agent about TDD approach and continue conversation. Reinforces test-first methodology. Use when agent deviates from TDD practices. Keywords: tdd, reminder, methodology, testing, practices
4
+ license: MIT
5
+ compatibility: Requires Claude Code with MCP servers (Context7, GitHub), Python 3.9+ for hooks, pnpm 10.11.0+
6
+ metadata:
7
+ version: "3.0.0"
8
+ category: "workflow"
9
+ tags: ['tdd', 'reminder', 'methodology', 'testing']
10
+ author: "Hustle Together"
11
+ allowed-tools: WebSearch WebFetch mcp__context7 mcp__github AskUserQuestion Read Write Edit Bash TodoWrite
12
+ ---
13
+
14
+ ---
15
+ description: Remind agent about TDD approach and continue conversation
16
+ argument-hint: [optional-response-to-last-message]
17
+ ---
18
+
19
+ # TDD Reminder
20
+
21
+ ## General Guidelines
22
+
23
+ ### Output Style
24
+
25
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
26
+ - Write natural, descriptive code without meta-commentary about the development process
27
+ - The code should speak for itself - TDD is the process, not the product
28
+
29
+ ## TDD Fundamentals
30
+
31
+ ### The TDD Cycle
32
+
33
+ The foundation of TDD is the Red-Green-Refactor cycle:
34
+
35
+ 1. **Red Phase**: Write ONE failing test that describes desired behavior
36
+
37
+ - The test must fail for the RIGHT reason (not syntax/import errors)
38
+ - Only one test at a time - this is critical for TDD discipline
39
+ - Exception: For browser-level tests or expensive setup (e.g., Storybook `*.stories.tsx`), group multiple assertions within a single test block to avoid redundant setup - but only when adding assertions to an existing interaction flow. If new user interactions are required, still create a new test. Split files by category if they exceed ~1000 lines.
40
+ - **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed
41
+ - Starting TDD for a new feature is always valid, even if test output shows unrelated work
42
+ - For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content
43
+ - Avoid hard-coded timeouts both in form of sleep() or timeout: 5000 etc; use proper async patterns (`waitFor`, `findBy*`, event-based sync) instead and rely on global test configs for timeout settings
44
+
45
+ 2. **Green Phase**: Write MINIMAL code to make the test pass
46
+
47
+ - Implement only what's needed for the current failing test
48
+ - No anticipatory coding or extra features
49
+ - Address the specific failure message
50
+
51
+ 3. **Refactor Phase**: Improve code structure while keeping tests green
52
+ - Only allowed when relevant tests are passing
53
+ - Requires proof that tests have been run and are green
54
+ - Applies to BOTH implementation and test code
55
+ - No refactoring with failing tests - fix them first
56
+
57
+ ### Core Violations
58
+
59
+ 1. **Multiple Test Addition**
60
+
61
+ - Adding more than one new test at once
62
+ - Exception: Initial test file setup or extracting shared test utilities
63
+
64
+ 2. **Over-Implementation**
65
+
66
+ - Code that exceeds what's needed to pass the current failing test
67
+ - Adding untested features, methods, or error handling
68
+ - Implementing multiple methods when test only requires one
69
+
70
+ 3. **Premature Implementation**
71
+ - Adding implementation before a test exists and fails properly
72
+ - Adding implementation without running the test first
73
+ - Refactoring when tests haven't been run or are failing
74
+
75
+ ### Critical Principle: Incremental Development
76
+
77
+ Each step in TDD should address ONE specific issue:
78
+
79
+ - Test fails "not defined" → Create empty stub/class only
80
+ - Test fails "not a function" → Add method stub only
81
+ - Test fails with assertion → Implement minimal logic only
82
+
83
+ ### Optional Pre-Phase: Spike Phase
84
+
85
+ In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.
86
+ This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.
87
+
88
+ - The goal of a Spike is **exploration and learning**, not implementation.
89
+ - The code written during a Spike is **disposable** and **must not** be merged or reused directly.
90
+ - Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.
91
+ - A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
92
+
93
+ ### General Information
94
+
95
+ - Sometimes the test output shows as no tests have been run when a new test is failing due to a missing import or constructor. In such cases, allow the agent to create simple stubs. Ask them if they forgot to create a stub if they are stuck.
96
+ - It is never allowed to introduce new logic without evidence of relevant failing tests. However, stubs and simple implementation to make imports and test infrastructure work is fine.
97
+ - In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
98
+ - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
99
+ - Provide the agent with helpful directions so that they do not get stuck when blocking them.
100
+
101
+ ## Continue Conversation
102
+
103
+ User response to the last message: $ARGUMENTS
104
+
105
+ Please continue with TDD approach based on the above response.
106
+
107
+
108
+ ## 🛡 Project Rules (Injected into every command)
109
+
110
+ 1. **NO BROKEN BUILDS:**
111
+ - Run `pnpm test` before every `/commit`
112
+ - Ensure all tests pass
113
+ - Fix any type errors immediately
114
+
115
+ 2. **API DEVELOPMENT:**
116
+ - All new APIs MUST have Zod request/response schemas
117
+ - All APIs MUST be documented in both:
118
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
119
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
120
+ - Test ALL parameters and edge cases
121
+ - Include code examples and real-world outputs
122
+
123
+ 3. **TDD WORKFLOW:**
124
+ - ALWAYS use /red → /green → /refactor cycle
125
+ - NEVER write implementation without failing test first
126
+ - Use /cycle for feature development
127
+ - Use characterization tests for refactoring
128
+
129
+ 4. **API KEY MANAGEMENT:**
130
+ - Support three loading methods:
131
+ - Server environment variables
132
+ - NEXT_PUBLIC_ variables (client-side)
133
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
134
+ - Never hardcode API keys
135
+ - Always validate key availability before use
136
+
137
+ 5. **COMPREHENSIVE TESTING:**
138
+ - When researching APIs, read actual implementation code
139
+ - Discover ALL possible parameters (not just documented ones)
140
+ - Test with various parameter combinations
141
+ - Document custom headers, query params, request/response schemas
142
+ - Include validation rules and testing notes
143
+
144
+ 6. **NO UI BLOAT:**
145
+ - This is an API project with minimal frontend
146
+ - Only keep necessary test/documentation interfaces
147
+ - Delete unused components immediately
148
+ - No unnecessary UI libraries or features
149
+
150
+ 7. **DOCUMENTATION:**
151
+ - If you change an API, you MUST update:
152
+ - OpenAPI spec
153
+ - api-tests-manifest.json
154
+ - Code examples
155
+ - Testing notes
156
+ - Document expected behavior and edge cases
157
+ - Include real-world output examples