@hustle-together/api-dev-tools 3.10.0 → 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 (97) 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 +66 -20
  96. package/bin/cli.js +7 -6
  97. package/package.json +22 -11
@@ -0,0 +1,168 @@
1
+ ---
2
+ description: Create implementation plan from feature/requirement with PRD-style discovery and TDD acceptance criteria
3
+ argument-hint: <feature/requirement description or GitHub issue URL/number>
4
+ ---
5
+
6
+ # Plan: PRD-Informed Task Planning for TDD
7
+
8
+ Create structured implementation plan that bridges product thinking (PRD) with test-driven development.
9
+
10
+ ## General Guidelines
11
+
12
+ ### Output Style
13
+
14
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
15
+ - Write natural, descriptive code without meta-commentary about the development process
16
+ - The code should speak for itself - TDD is the process, not the product
17
+
18
+ ## Input
19
+
20
+ $ARGUMENTS
21
+
22
+ (If no input provided, check conversation context)
23
+
24
+ ## Input Processing
25
+
26
+ The input can be one of:
27
+
28
+ 1. **GitHub Issue URL** (e.g., `https://github.com/owner/repo/issues/123`)
29
+ 2. **GitHub Issue Number** (e.g., `#123` or `123`)
30
+ 3. **Feature Description** (e.g., "Add user authentication")
31
+ 4. **Empty** - use conversation context
32
+
33
+ ### GitHub Issue Integration
34
+
35
+ If input looks like a GitHub issue:
36
+
37
+ **Step 1: Extract Issue Number**
38
+
39
+ - From URL: extract owner/repo/number
40
+ - From number: try to infer repo from git remote
41
+ - From branch name: check patterns like `issue-123`, `123-feature`, `feature/123`
42
+
43
+ **Step 2: Fetch Issue**
44
+ Try GitHub MCP first:
45
+
46
+ - If available: use `mcp__github__issue_read` to fetch issue details
47
+ - If not available: show message and try `gh issue view <number>`
48
+
49
+ ```
50
+ GitHub MCP not configured!
51
+ See: https://github.com/modelcontextprotocol/servers/tree/main/src/github
52
+ Trying GitHub CLI fallback...
53
+ ```
54
+
55
+ **Step 3: Use Issue as Discovery Input**
56
+
57
+ - Title → Feature name
58
+ - Description → Problem statement and context
59
+ - Labels → Type/priority hints
60
+ - Comments → Additional requirements and discussion
61
+ - Linked issues → Dependencies
62
+
63
+ Extract from GitHub issue:
64
+
65
+ - Problem statement and context
66
+ - Acceptance criteria (if present)
67
+ - Technical notes (if present)
68
+ - Related issues/dependencies
69
+
70
+ ## Process
71
+
72
+ ## Discovery Phase
73
+
74
+ Understand the requirement by asking (use AskUserQuestion if needed):
75
+
76
+ **Problem Statement**
77
+
78
+ - What problem does this solve?
79
+ - Who experiences this problem?
80
+ - What's the current pain point?
81
+
82
+ **Desired Outcome**
83
+
84
+ - What should happen after this is built?
85
+ - How will users interact with it?
86
+ - What does success look like?
87
+
88
+ **Scope & Constraints**
89
+
90
+ - What's in scope vs. out of scope?
91
+ - Any technical constraints?
92
+ - Dependencies on other systems/features?
93
+
94
+ **Context Check**
95
+
96
+ - Search codebase for related features/modules
97
+ - Check for existing test files that might be relevant
98
+
99
+ ## Key Principles
100
+
101
+ **From PRD World:**
102
+
103
+ - Start with user problems, not solutions
104
+ - Define success criteria upfront
105
+ - Understand constraints and scope
106
+
107
+ **From TDD World:**
108
+
109
+ - Make acceptance criteria test-ready
110
+ - Break work into small, testable pieces
111
+ - Each task should map to test(s)
112
+
113
+ ## Integration with Other Commands
114
+
115
+ - **Before /plan**: Use `/spike` if you need technical exploration first
116
+ - **After /plan**: Use `/red` to start TDD on first task
117
+
118
+
119
+ ## 🛡 Project Rules (Injected into every command)
120
+
121
+ 1. **NO BROKEN BUILDS:**
122
+ - Run `pnpm test` before every `/commit`
123
+ - Ensure all tests pass
124
+ - Fix any type errors immediately
125
+
126
+ 2. **API DEVELOPMENT:**
127
+ - All new APIs MUST have Zod request/response schemas
128
+ - All APIs MUST be documented in both:
129
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
130
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
131
+ - Test ALL parameters and edge cases
132
+ - Include code examples and real-world outputs
133
+
134
+ 3. **TDD WORKFLOW:**
135
+ - ALWAYS use /red → /green → /refactor cycle
136
+ - NEVER write implementation without failing test first
137
+ - Use /cycle for feature development
138
+ - Use characterization tests for refactoring
139
+
140
+ 4. **API KEY MANAGEMENT:**
141
+ - Support three loading methods:
142
+ - Server environment variables
143
+ - NEXT_PUBLIC_ variables (client-side)
144
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
145
+ - Never hardcode API keys
146
+ - Always validate key availability before use
147
+
148
+ 5. **COMPREHENSIVE TESTING:**
149
+ - When researching APIs, read actual implementation code
150
+ - Discover ALL possible parameters (not just documented ones)
151
+ - Test with various parameter combinations
152
+ - Document custom headers, query params, request/response schemas
153
+ - Include validation rules and testing notes
154
+
155
+ 6. **NO UI BLOAT:**
156
+ - This is an API project with minimal frontend
157
+ - Only keep necessary test/documentation interfaces
158
+ - Delete unused components immediately
159
+ - No unnecessary UI libraries or features
160
+
161
+ 7. **DOCUMENTATION:**
162
+ - If you change an API, you MUST update:
163
+ - OpenAPI spec
164
+ - api-tests-manifest.json
165
+ - Code examples
166
+ - Testing notes
167
+ - Document expected behavior and edge cases
168
+ - Include real-world output examples
@@ -0,0 +1,122 @@
1
+ ---
2
+ description: Creates a pull request using GitHub MCP
3
+ argument-hint: [optional-pr-title-and-description]
4
+ ---
5
+
6
+ # Create Pull Request
7
+
8
+ ## General Guidelines
9
+
10
+ ### Output Style
11
+
12
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
13
+ - Write natural, descriptive code without meta-commentary about the development process
14
+ - The code should speak for itself - TDD is the process, not the product
15
+
16
+ Create a pull request for the current branch using GitHub MCP tools.
17
+
18
+ ## Workflow
19
+
20
+ Current branch status:
21
+ !`git status`
22
+
23
+ Recent commits:
24
+ !`git log --oneline -5`
25
+
26
+ Arguments: $ARGUMENTS
27
+
28
+ **Process:**
29
+
30
+ 1. **Ensure Branch is Ready**:
31
+ !`git status`
32
+ - Commit all changes
33
+ - Push to remote: `git push origin [branch-name]`
34
+
35
+ 2. **Create PR**: Create a well-formatted pull request
36
+
37
+ Title: conventional commits format, like `feat(#123): add user authentication`
38
+
39
+ Description template:
40
+
41
+ ```markdown
42
+ <!--
43
+ Are there any relevant issues / PRs / mailing lists discussions?
44
+ Please reference them here.
45
+ -->
46
+
47
+ ## References
48
+
49
+ - [links to github issues referenced in commit messages]
50
+
51
+ ## Summary
52
+
53
+ [Brief description of changes]
54
+
55
+ ## Test Plan
56
+
57
+ - [ ] Tests pass
58
+ - [ ] Manual testing completed
59
+ ```
60
+
61
+ 3. **Set Base Branch**: Default to main unless specified otherwise
62
+
63
+ 4. **Link Issues**: Reference related issues found in commit messages
64
+
65
+ ## Use GitHub MCP Tools
66
+
67
+ 1. Check current branch and ensure it's pushed
68
+ 2. Create a well-formatted pull request with proper title and description
69
+ 3. Set the base branch (default: main)
70
+ 4. Include relevant issue references if found in commit messages
71
+
72
+
73
+ ## 🛡 Project Rules (Injected into every command)
74
+
75
+ 1. **NO BROKEN BUILDS:**
76
+ - Run `pnpm test` before every `/commit`
77
+ - Ensure all tests pass
78
+ - Fix any type errors immediately
79
+
80
+ 2. **API DEVELOPMENT:**
81
+ - All new APIs MUST have Zod request/response schemas
82
+ - All APIs MUST be documented in both:
83
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
84
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
85
+ - Test ALL parameters and edge cases
86
+ - Include code examples and real-world outputs
87
+
88
+ 3. **TDD WORKFLOW:**
89
+ - ALWAYS use /red → /green → /refactor cycle
90
+ - NEVER write implementation without failing test first
91
+ - Use /cycle for feature development
92
+ - Use characterization tests for refactoring
93
+
94
+ 4. **API KEY MANAGEMENT:**
95
+ - Support three loading methods:
96
+ - Server environment variables
97
+ - NEXT_PUBLIC_ variables (client-side)
98
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
99
+ - Never hardcode API keys
100
+ - Always validate key availability before use
101
+
102
+ 5. **COMPREHENSIVE TESTING:**
103
+ - When researching APIs, read actual implementation code
104
+ - Discover ALL possible parameters (not just documented ones)
105
+ - Test with various parameter combinations
106
+ - Document custom headers, query params, request/response schemas
107
+ - Include validation rules and testing notes
108
+
109
+ 6. **NO UI BLOAT:**
110
+ - This is an API project with minimal frontend
111
+ - Only keep necessary test/documentation interfaces
112
+ - Delete unused components immediately
113
+ - No unnecessary UI libraries or features
114
+
115
+ 7. **DOCUMENTATION:**
116
+ - If you change an API, you MUST update:
117
+ - OpenAPI spec
118
+ - api-tests-manifest.json
119
+ - Code examples
120
+ - Testing notes
121
+ - Document expected behavior and edge cases
122
+ - Include real-world output examples
@@ -0,0 +1,142 @@
1
+ ---
2
+ description: Execute TDD Red Phase - write ONE failing test
3
+ argument-hint: [optional additional info]
4
+ ---
5
+
6
+ RED PHASE! Apply the below to the info given by user input here:
7
+
8
+ $ARGUMENTS
9
+
10
+ ## General Guidelines
11
+
12
+ ### Output Style
13
+
14
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
15
+ - Write natural, descriptive code without meta-commentary about the development process
16
+ - The code should speak for itself - TDD is the process, not the product
17
+
18
+ (If there was no info above, fallback to the context of the conversation)
19
+
20
+ ## TDD Fundamentals
21
+
22
+ ### The TDD Cycle
23
+
24
+ The foundation of TDD is the Red-Green-Refactor cycle:
25
+
26
+ 1. **Red Phase**: Write ONE failing test that describes desired behavior
27
+
28
+ - The test must fail for the RIGHT reason (not syntax/import errors)
29
+ - Only one test at a time - this is critical for TDD discipline
30
+ - 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.
31
+ - **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed
32
+ - Starting TDD for a new feature is always valid, even if test output shows unrelated work
33
+ - For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content
34
+ - 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
35
+
36
+ 2. **Green Phase**: Write MINIMAL code to make the test pass
37
+
38
+ - Implement only what's needed for the current failing test
39
+ - No anticipatory coding or extra features
40
+ - Address the specific failure message
41
+
42
+ 3. **Refactor Phase**: Improve code structure while keeping tests green
43
+ - Only allowed when relevant tests are passing
44
+ - Requires proof that tests have been run and are green
45
+ - Applies to BOTH implementation and test code
46
+ - No refactoring with failing tests - fix them first
47
+
48
+ ### Core Violations
49
+
50
+ 1. **Multiple Test Addition**
51
+
52
+ - Adding more than one new test at once
53
+ - Exception: Initial test file setup or extracting shared test utilities
54
+
55
+ 2. **Over-Implementation**
56
+
57
+ - Code that exceeds what's needed to pass the current failing test
58
+ - Adding untested features, methods, or error handling
59
+ - Implementing multiple methods when test only requires one
60
+
61
+ 3. **Premature Implementation**
62
+ - Adding implementation before a test exists and fails properly
63
+ - Adding implementation without running the test first
64
+ - Refactoring when tests haven't been run or are failing
65
+
66
+ ### Critical Principle: Incremental Development
67
+
68
+ Each step in TDD should address ONE specific issue:
69
+
70
+ - Test fails "not defined" → Create empty stub/class only
71
+ - Test fails "not a function" → Add method stub only
72
+ - Test fails with assertion → Implement minimal logic only
73
+
74
+ ### Optional Pre-Phase: Spike Phase
75
+
76
+ In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.
77
+ This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.
78
+
79
+ - The goal of a Spike is **exploration and learning**, not implementation.
80
+ - The code written during a Spike is **disposable** and **must not** be merged or reused directly.
81
+ - Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.
82
+ - A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
83
+
84
+ ### General Information
85
+
86
+ - 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.
87
+ - 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.
88
+ - 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.
89
+ - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
90
+ - Provide the agent with helpful directions so that they do not get stuck when blocking them.
91
+
92
+
93
+ ## 🛡 Project Rules (Injected into every command)
94
+
95
+ 1. **NO BROKEN BUILDS:**
96
+ - Run `pnpm test` before every `/commit`
97
+ - Ensure all tests pass
98
+ - Fix any type errors immediately
99
+
100
+ 2. **API DEVELOPMENT:**
101
+ - All new APIs MUST have Zod request/response schemas
102
+ - All APIs MUST be documented in both:
103
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
104
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
105
+ - Test ALL parameters and edge cases
106
+ - Include code examples and real-world outputs
107
+
108
+ 3. **TDD WORKFLOW:**
109
+ - ALWAYS use /red → /green → /refactor cycle
110
+ - NEVER write implementation without failing test first
111
+ - Use /cycle for feature development
112
+ - Use characterization tests for refactoring
113
+
114
+ 4. **API KEY MANAGEMENT:**
115
+ - Support three loading methods:
116
+ - Server environment variables
117
+ - NEXT_PUBLIC_ variables (client-side)
118
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
119
+ - Never hardcode API keys
120
+ - Always validate key availability before use
121
+
122
+ 5. **COMPREHENSIVE TESTING:**
123
+ - When researching APIs, read actual implementation code
124
+ - Discover ALL possible parameters (not just documented ones)
125
+ - Test with various parameter combinations
126
+ - Document custom headers, query params, request/response schemas
127
+ - Include validation rules and testing notes
128
+
129
+ 6. **NO UI BLOAT:**
130
+ - This is an API project with minimal frontend
131
+ - Only keep necessary test/documentation interfaces
132
+ - Delete unused components immediately
133
+ - No unnecessary UI libraries or features
134
+
135
+ 7. **DOCUMENTATION:**
136
+ - If you change an API, you MUST update:
137
+ - OpenAPI spec
138
+ - api-tests-manifest.json
139
+ - Code examples
140
+ - Testing notes
141
+ - Document expected behavior and edge cases
142
+ - Include real-world output examples
@@ -0,0 +1,142 @@
1
+ ---
2
+ description: Execute TDD Refactor Phase - improve code structure while keeping tests green
3
+ argument-hint: <refactoring description>
4
+ ---
5
+
6
+ Apply this document (specifically the Refactor phase), to the info given by user input here: $ARGUMENTS
7
+
8
+ ## General Guidelines
9
+
10
+ ### Output Style
11
+
12
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
13
+ - Write natural, descriptive code without meta-commentary about the development process
14
+ - The code should speak for itself - TDD is the process, not the product
15
+
16
+ (If there was no info above, fallback to the context of the conversation)
17
+
18
+ ## TDD Fundamentals
19
+
20
+ ### The TDD Cycle
21
+
22
+ The foundation of TDD is the Red-Green-Refactor cycle:
23
+
24
+ 1. **Red Phase**: Write ONE failing test that describes desired behavior
25
+
26
+ - The test must fail for the RIGHT reason (not syntax/import errors)
27
+ - Only one test at a time - this is critical for TDD discipline
28
+ - 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.
29
+ - **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed
30
+ - Starting TDD for a new feature is always valid, even if test output shows unrelated work
31
+ - For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content
32
+ - 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
33
+
34
+ 2. **Green Phase**: Write MINIMAL code to make the test pass
35
+
36
+ - Implement only what's needed for the current failing test
37
+ - No anticipatory coding or extra features
38
+ - Address the specific failure message
39
+
40
+ 3. **Refactor Phase**: Improve code structure while keeping tests green
41
+ - Only allowed when relevant tests are passing
42
+ - Requires proof that tests have been run and are green
43
+ - Applies to BOTH implementation and test code
44
+ - No refactoring with failing tests - fix them first
45
+
46
+ ### Core Violations
47
+
48
+ 1. **Multiple Test Addition**
49
+
50
+ - Adding more than one new test at once
51
+ - Exception: Initial test file setup or extracting shared test utilities
52
+
53
+ 2. **Over-Implementation**
54
+
55
+ - Code that exceeds what's needed to pass the current failing test
56
+ - Adding untested features, methods, or error handling
57
+ - Implementing multiple methods when test only requires one
58
+
59
+ 3. **Premature Implementation**
60
+ - Adding implementation before a test exists and fails properly
61
+ - Adding implementation without running the test first
62
+ - Refactoring when tests haven't been run or are failing
63
+
64
+ ### Critical Principle: Incremental Development
65
+
66
+ Each step in TDD should address ONE specific issue:
67
+
68
+ - Test fails "not defined" → Create empty stub/class only
69
+ - Test fails "not a function" → Add method stub only
70
+ - Test fails with assertion → Implement minimal logic only
71
+
72
+ ### Optional Pre-Phase: Spike Phase
73
+
74
+ In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.
75
+ This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.
76
+
77
+ - The goal of a Spike is **exploration and learning**, not implementation.
78
+ - The code written during a Spike is **disposable** and **must not** be merged or reused directly.
79
+ - Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.
80
+ - A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
81
+
82
+ ### General Information
83
+
84
+ - 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.
85
+ - 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.
86
+ - 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.
87
+ - Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
88
+ - Provide the agent with helpful directions so that they do not get stuck when blocking them.
89
+
90
+ 1. **Consistency check** - Look for inconsistent patterns, naming conventions, or structure across the codebase
91
+
92
+
93
+ ## 🛡 Project Rules (Injected into every command)
94
+
95
+ 1. **NO BROKEN BUILDS:**
96
+ - Run `pnpm test` before every `/commit`
97
+ - Ensure all tests pass
98
+ - Fix any type errors immediately
99
+
100
+ 2. **API DEVELOPMENT:**
101
+ - All new APIs MUST have Zod request/response schemas
102
+ - All APIs MUST be documented in both:
103
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
104
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
105
+ - Test ALL parameters and edge cases
106
+ - Include code examples and real-world outputs
107
+
108
+ 3. **TDD WORKFLOW:**
109
+ - ALWAYS use /red → /green → /refactor cycle
110
+ - NEVER write implementation without failing test first
111
+ - Use /cycle for feature development
112
+ - Use characterization tests for refactoring
113
+
114
+ 4. **API KEY MANAGEMENT:**
115
+ - Support three loading methods:
116
+ - Server environment variables
117
+ - NEXT_PUBLIC_ variables (client-side)
118
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
119
+ - Never hardcode API keys
120
+ - Always validate key availability before use
121
+
122
+ 5. **COMPREHENSIVE TESTING:**
123
+ - When researching APIs, read actual implementation code
124
+ - Discover ALL possible parameters (not just documented ones)
125
+ - Test with various parameter combinations
126
+ - Document custom headers, query params, request/response schemas
127
+ - Include validation rules and testing notes
128
+
129
+ 6. **NO UI BLOAT:**
130
+ - This is an API project with minimal frontend
131
+ - Only keep necessary test/documentation interfaces
132
+ - Delete unused components immediately
133
+ - No unnecessary UI libraries or features
134
+
135
+ 7. **DOCUMENTATION:**
136
+ - If you change an API, you MUST update:
137
+ - OpenAPI spec
138
+ - api-tests-manifest.json
139
+ - Code examples
140
+ - Testing notes
141
+ - Document expected behavior and edge cases
142
+ - Include real-world output examples