claude-mpm 4.15.2__py3-none-any.whl → 4.20.3__py3-none-any.whl

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 (203) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/BASE_ENGINEER.md +286 -0
  3. claude_mpm/agents/BASE_PM.md +255 -23
  4. claude_mpm/agents/PM_INSTRUCTIONS.md +40 -0
  5. claude_mpm/agents/agent_loader.py +4 -4
  6. claude_mpm/agents/templates/agentic-coder-optimizer.json +9 -2
  7. claude_mpm/agents/templates/api_qa.json +7 -1
  8. claude_mpm/agents/templates/clerk-ops.json +8 -1
  9. claude_mpm/agents/templates/code_analyzer.json +4 -1
  10. claude_mpm/agents/templates/dart_engineer.json +11 -1
  11. claude_mpm/agents/templates/data_engineer.json +11 -1
  12. claude_mpm/agents/templates/documentation.json +6 -1
  13. claude_mpm/agents/templates/engineer.json +18 -1
  14. claude_mpm/agents/templates/gcp_ops_agent.json +8 -1
  15. claude_mpm/agents/templates/golang_engineer.json +11 -1
  16. claude_mpm/agents/templates/java_engineer.json +12 -2
  17. claude_mpm/agents/templates/local_ops_agent.json +216 -37
  18. claude_mpm/agents/templates/nextjs_engineer.json +11 -1
  19. claude_mpm/agents/templates/ops.json +8 -1
  20. claude_mpm/agents/templates/php-engineer.json +11 -1
  21. claude_mpm/agents/templates/project_organizer.json +9 -2
  22. claude_mpm/agents/templates/prompt-engineer.json +5 -1
  23. claude_mpm/agents/templates/python_engineer.json +19 -4
  24. claude_mpm/agents/templates/qa.json +7 -1
  25. claude_mpm/agents/templates/react_engineer.json +11 -1
  26. claude_mpm/agents/templates/refactoring_engineer.json +8 -1
  27. claude_mpm/agents/templates/research.json +4 -1
  28. claude_mpm/agents/templates/ruby-engineer.json +11 -1
  29. claude_mpm/agents/templates/rust_engineer.json +23 -8
  30. claude_mpm/agents/templates/security.json +6 -1
  31. claude_mpm/agents/templates/svelte-engineer.json +225 -0
  32. claude_mpm/agents/templates/ticketing.json +6 -1
  33. claude_mpm/agents/templates/typescript_engineer.json +11 -1
  34. claude_mpm/agents/templates/vercel_ops_agent.json +8 -1
  35. claude_mpm/agents/templates/version_control.json +8 -1
  36. claude_mpm/agents/templates/web_qa.json +7 -1
  37. claude_mpm/agents/templates/web_ui.json +11 -1
  38. claude_mpm/cli/commands/__init__.py +2 -0
  39. claude_mpm/cli/commands/configure.py +164 -16
  40. claude_mpm/cli/commands/configure_agent_display.py +6 -6
  41. claude_mpm/cli/commands/configure_behavior_manager.py +8 -8
  42. claude_mpm/cli/commands/configure_navigation.py +20 -18
  43. claude_mpm/cli/commands/configure_startup_manager.py +14 -14
  44. claude_mpm/cli/commands/configure_template_editor.py +8 -8
  45. claude_mpm/cli/commands/mpm_init.py +109 -24
  46. claude_mpm/cli/commands/skills.py +434 -0
  47. claude_mpm/cli/executor.py +2 -0
  48. claude_mpm/cli/interactive/__init__.py +3 -0
  49. claude_mpm/cli/interactive/skills_wizard.py +491 -0
  50. claude_mpm/cli/parsers/base_parser.py +7 -0
  51. claude_mpm/cli/parsers/skills_parser.py +137 -0
  52. claude_mpm/cli/startup.py +83 -0
  53. claude_mpm/commands/mpm-auto-configure.md +52 -0
  54. claude_mpm/commands/mpm-help.md +3 -0
  55. claude_mpm/commands/mpm-init.md +112 -6
  56. claude_mpm/commands/mpm-version.md +113 -0
  57. claude_mpm/commands/mpm.md +1 -0
  58. claude_mpm/config/agent_config.py +2 -2
  59. claude_mpm/constants.py +12 -0
  60. claude_mpm/core/config.py +42 -0
  61. claude_mpm/core/enums.py +18 -0
  62. claude_mpm/core/factories.py +1 -1
  63. claude_mpm/core/optimized_agent_loader.py +3 -3
  64. claude_mpm/core/types.py +2 -9
  65. claude_mpm/dashboard/static/js/dashboard.js +0 -14
  66. claude_mpm/dashboard/templates/index.html +3 -41
  67. claude_mpm/hooks/__init__.py +8 -0
  68. claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
  69. claude_mpm/hooks/session_resume_hook.py +121 -0
  70. claude_mpm/models/resume_log.py +340 -0
  71. claude_mpm/services/agents/auto_config_manager.py +1 -1
  72. claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
  73. claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
  74. claude_mpm/services/agents/deployment/agent_validator.py +17 -1
  75. claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
  76. claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
  77. claude_mpm/services/agents/deployment/validation/__init__.py +3 -1
  78. claude_mpm/services/agents/deployment/validation/validation_result.py +1 -9
  79. claude_mpm/services/agents/local_template_manager.py +1 -1
  80. claude_mpm/services/agents/recommender.py +47 -0
  81. claude_mpm/services/cli/resume_service.py +617 -0
  82. claude_mpm/services/cli/session_manager.py +87 -0
  83. claude_mpm/services/cli/session_resume_helper.py +352 -0
  84. claude_mpm/services/core/models/health.py +1 -28
  85. claude_mpm/services/core/path_resolver.py +1 -1
  86. claude_mpm/services/infrastructure/monitoring/__init__.py +1 -1
  87. claude_mpm/services/infrastructure/monitoring/aggregator.py +12 -12
  88. claude_mpm/services/infrastructure/monitoring/base.py +5 -13
  89. claude_mpm/services/infrastructure/monitoring/network.py +7 -6
  90. claude_mpm/services/infrastructure/monitoring/process.py +13 -12
  91. claude_mpm/services/infrastructure/monitoring/resources.py +7 -6
  92. claude_mpm/services/infrastructure/monitoring/service.py +16 -15
  93. claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
  94. claude_mpm/services/local_ops/__init__.py +1 -1
  95. claude_mpm/services/local_ops/crash_detector.py +1 -1
  96. claude_mpm/services/local_ops/health_checks/http_check.py +2 -1
  97. claude_mpm/services/local_ops/health_checks/process_check.py +2 -1
  98. claude_mpm/services/local_ops/health_checks/resource_check.py +2 -1
  99. claude_mpm/services/local_ops/health_manager.py +1 -1
  100. claude_mpm/services/local_ops/restart_manager.py +1 -1
  101. claude_mpm/services/mcp_config_manager.py +7 -131
  102. claude_mpm/services/session_manager.py +205 -1
  103. claude_mpm/services/shared/async_service_base.py +16 -27
  104. claude_mpm/services/shared/lifecycle_service_base.py +1 -14
  105. claude_mpm/services/socketio/handlers/__init__.py +5 -2
  106. claude_mpm/services/socketio/handlers/hook.py +10 -0
  107. claude_mpm/services/socketio/handlers/registry.py +4 -2
  108. claude_mpm/services/socketio/server/main.py +7 -7
  109. claude_mpm/services/unified/deployment_strategies/local.py +1 -1
  110. claude_mpm/services/version_service.py +104 -1
  111. claude_mpm/skills/__init__.py +42 -0
  112. claude_mpm/skills/agent_skills_injector.py +331 -0
  113. claude_mpm/skills/bundled/LICENSE_ATTRIBUTIONS.md +79 -0
  114. claude_mpm/skills/bundled/__init__.py +6 -0
  115. claude_mpm/skills/bundled/api-documentation.md +393 -0
  116. claude_mpm/skills/bundled/async-testing.md +571 -0
  117. claude_mpm/skills/bundled/code-review.md +143 -0
  118. claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +75 -0
  119. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +184 -0
  120. claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +107 -0
  121. claude_mpm/skills/bundled/collaboration/requesting-code-review/code-reviewer.md +146 -0
  122. claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +118 -0
  123. claude_mpm/skills/bundled/database-migration.md +199 -0
  124. claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +177 -0
  125. claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
  126. claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
  127. claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
  128. claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
  129. claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
  130. claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
  131. claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
  132. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
  133. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
  134. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
  135. claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +175 -0
  136. claude_mpm/skills/bundled/debugging/verification-before-completion/references/common-failures.md +213 -0
  137. claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +314 -0
  138. claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +227 -0
  139. claude_mpm/skills/bundled/docker-containerization.md +194 -0
  140. claude_mpm/skills/bundled/express-local-dev.md +1429 -0
  141. claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
  142. claude_mpm/skills/bundled/git-workflow.md +414 -0
  143. claude_mpm/skills/bundled/imagemagick.md +204 -0
  144. claude_mpm/skills/bundled/json-data-handling.md +223 -0
  145. claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +74 -0
  146. claude_mpm/skills/bundled/main/internal-comms/SKILL.md +32 -0
  147. claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
  148. claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
  149. claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
  150. claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
  151. claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +328 -0
  152. claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
  153. claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
  154. claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
  155. claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
  156. claude_mpm/skills/bundled/main/mcp-builder/scripts/connections.py +150 -0
  157. claude_mpm/skills/bundled/main/mcp-builder/scripts/evaluation.py +372 -0
  158. claude_mpm/skills/bundled/main/skill-creator/SKILL.md +209 -0
  159. claude_mpm/skills/bundled/main/skill-creator/scripts/init_skill.py +302 -0
  160. claude_mpm/skills/bundled/main/skill-creator/scripts/package_skill.py +111 -0
  161. claude_mpm/skills/bundled/main/skill-creator/scripts/quick_validate.py +65 -0
  162. claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
  163. claude_mpm/skills/bundled/pdf.md +141 -0
  164. claude_mpm/skills/bundled/performance-profiling.md +567 -0
  165. claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
  166. claude_mpm/skills/bundled/security-scanning.md +327 -0
  167. claude_mpm/skills/bundled/systematic-debugging.md +473 -0
  168. claude_mpm/skills/bundled/test-driven-development.md +378 -0
  169. claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +123 -0
  170. claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
  171. claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
  172. claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
  173. claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
  174. claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
  175. claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
  176. claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +304 -0
  177. claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +96 -0
  178. claude_mpm/skills/bundled/testing/webapp-testing/examples/console_logging.py +35 -0
  179. claude_mpm/skills/bundled/testing/webapp-testing/examples/element_discovery.py +40 -0
  180. claude_mpm/skills/bundled/testing/webapp-testing/examples/static_html_automation.py +34 -0
  181. claude_mpm/skills/bundled/testing/webapp-testing/scripts/with_server.py +107 -0
  182. claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
  183. claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
  184. claude_mpm/skills/bundled/xlsx.md +157 -0
  185. claude_mpm/skills/registry.py +286 -0
  186. claude_mpm/skills/skill_manager.py +310 -0
  187. claude_mpm/skills/skills_registry.py +351 -0
  188. claude_mpm/skills/skills_service.py +730 -0
  189. claude_mpm/utils/agent_dependency_loader.py +2 -2
  190. {claude_mpm-4.15.2.dist-info → claude_mpm-4.20.3.dist-info}/METADATA +211 -33
  191. {claude_mpm-4.15.2.dist-info → claude_mpm-4.20.3.dist-info}/RECORD +195 -115
  192. claude_mpm/agents/INSTRUCTIONS_OLD_DEPRECATED.md +0 -602
  193. claude_mpm/dashboard/static/css/code-tree.css +0 -1639
  194. claude_mpm/dashboard/static/js/components/code-tree/tree-breadcrumb.js +0 -353
  195. claude_mpm/dashboard/static/js/components/code-tree/tree-constants.js +0 -235
  196. claude_mpm/dashboard/static/js/components/code-tree/tree-search.js +0 -409
  197. claude_mpm/dashboard/static/js/components/code-tree/tree-utils.js +0 -435
  198. claude_mpm/dashboard/static/js/components/code-tree.js +0 -5869
  199. claude_mpm/dashboard/static/js/components/code-viewer.js +0 -1386
  200. {claude_mpm-4.15.2.dist-info → claude_mpm-4.20.3.dist-info}/WHEEL +0 -0
  201. {claude_mpm-4.15.2.dist-info → claude_mpm-4.20.3.dist-info}/entry_points.txt +0 -0
  202. {claude_mpm-4.15.2.dist-info → claude_mpm-4.20.3.dist-info}/licenses/LICENSE +0 -0
  203. {claude_mpm-4.15.2.dist-info → claude_mpm-4.20.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,378 @@
1
+ ---
2
+ skill_id: test-driven-development
3
+ skill_version: 0.1.0
4
+ description: Comprehensive TDD patterns and practices for all programming languages, eliminating redundant testing guidance per agent.
5
+ updated_at: 2025-10-30T17:00:00Z
6
+ tags: [testing, tdd, best-practices, quality-assurance]
7
+ ---
8
+
9
+ # Test-Driven Development (TDD)
10
+
11
+ Comprehensive TDD patterns and practices for all programming languages. This skill eliminates ~500-800 lines of redundant testing guidance per agent.
12
+
13
+ ## When to Use
14
+
15
+ Apply TDD for:
16
+ - New feature implementation
17
+ - Bug fixes (test the bug first)
18
+ - Code refactoring (tests ensure behavior preservation)
19
+ - API development (test contracts)
20
+ - Complex business logic
21
+
22
+ ## TDD Workflow (Red-Green-Refactor)
23
+
24
+ ### 1. Red Phase: Write Failing Test
25
+ ```
26
+ Write a test that:
27
+ - Describes the desired behavior
28
+ - Fails for the right reason (not due to syntax errors)
29
+ - Is focused on a single behavior
30
+ ```
31
+
32
+ ### 2. Green Phase: Make It Pass
33
+ ```
34
+ Write the minimum code to:
35
+ - Pass the test
36
+ - Not introduce regressions
37
+ - Follow existing patterns
38
+ ```
39
+
40
+ ### 3. Refactor Phase: Improve Code
41
+ ```
42
+ While keeping tests green:
43
+ - Remove duplication
44
+ - Improve naming
45
+ - Simplify logic
46
+ - Extract functions/classes
47
+ ```
48
+
49
+ ## Test Structure Patterns
50
+
51
+ ### Arrange-Act-Assert (AAA)
52
+ ```
53
+ // Arrange: Set up test data and conditions
54
+ const user = createTestUser({ role: 'admin' });
55
+
56
+ // Act: Perform the action being tested
57
+ const result = await authenticateUser(user);
58
+
59
+ // Assert: Verify the outcome
60
+ expect(result.isAuthenticated).toBe(true);
61
+ expect(result.permissions).toContain('admin');
62
+ ```
63
+
64
+ ### Given-When-Then (BDD Style)
65
+ ```
66
+ Given: A user with admin privileges
67
+ When: They attempt to access protected resource
68
+ Then: Access is granted with appropriate permissions
69
+ ```
70
+
71
+ ## Test Naming Conventions
72
+
73
+ ### Pattern: `test_should_<expected_behavior>_when_<condition>`
74
+
75
+ **Examples:**
76
+ - `test_should_return_user_when_id_exists()`
77
+ - `test_should_raise_error_when_user_not_found()`
78
+ - `test_should_validate_email_format_when_creating_account()`
79
+
80
+ ### Language-Specific Conventions
81
+
82
+ **Python (pytest):**
83
+ ```python
84
+ def test_should_calculate_total_when_items_added():
85
+ # Arrange
86
+ cart = ShoppingCart()
87
+ cart.add_item(Item("Book", 10.00))
88
+ cart.add_item(Item("Pen", 1.50))
89
+
90
+ # Act
91
+ total = cart.calculate_total()
92
+
93
+ # Assert
94
+ assert total == 11.50
95
+ ```
96
+
97
+ **JavaScript (Jest):**
98
+ ```javascript
99
+ describe('ShoppingCart', () => {
100
+ test('should calculate total when items added', () => {
101
+ const cart = new ShoppingCart();
102
+ cart.addItem({ name: 'Book', price: 10.00 });
103
+ cart.addItem({ name: 'Pen', price: 1.50 });
104
+
105
+ const total = cart.calculateTotal();
106
+
107
+ expect(total).toBe(11.50);
108
+ });
109
+ });
110
+ ```
111
+
112
+ **Go:**
113
+ ```go
114
+ func TestShouldCalculateTotalWhenItemsAdded(t *testing.T) {
115
+ // Arrange
116
+ cart := NewShoppingCart()
117
+ cart.AddItem(Item{Name: "Book", Price: 10.00})
118
+ cart.AddItem(Item{Name: "Pen", Price: 1.50})
119
+
120
+ // Act
121
+ total := cart.CalculateTotal()
122
+
123
+ // Assert
124
+ if total != 11.50 {
125
+ t.Errorf("Expected 11.50, got %f", total)
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## Test Types and Scope
131
+
132
+ ### Unit Tests
133
+ - **Scope:** Single function/method
134
+ - **Dependencies:** Mocked
135
+ - **Speed:** Fast (< 10ms per test)
136
+ - **Coverage:** 80%+ of code paths
137
+
138
+ ### Integration Tests
139
+ - **Scope:** Multiple components
140
+ - **Dependencies:** Real or test doubles
141
+ - **Speed:** Moderate (< 1s per test)
142
+ - **Coverage:** Critical paths and interfaces
143
+
144
+ ### End-to-End Tests
145
+ - **Scope:** Full user workflows
146
+ - **Dependencies:** Real (in test environment)
147
+ - **Speed:** Slow (seconds to minutes)
148
+ - **Coverage:** Core user journeys
149
+
150
+ ## Mocking and Test Doubles
151
+
152
+ ### When to Mock
153
+ - External APIs and services
154
+ - Database operations (for unit tests)
155
+ - File system operations
156
+ - Time-dependent operations
157
+ - Random number generation
158
+
159
+ ### Mock Types
160
+
161
+ **Stub:** Returns predefined data
162
+ ```python
163
+ def get_user_stub(user_id):
164
+ return User(id=user_id, name="Test User")
165
+ ```
166
+
167
+ **Mock:** Verifies interactions
168
+ ```python
169
+ mock_service = Mock()
170
+ service.process_payment(payment_data)
171
+ mock_service.process_payment.assert_called_once_with(payment_data)
172
+ ```
173
+
174
+ **Fake:** Working implementation (simplified)
175
+ ```python
176
+ class FakeDatabase:
177
+ def __init__(self):
178
+ self.data = {}
179
+
180
+ def save(self, key, value):
181
+ self.data[key] = value
182
+
183
+ def get(self, key):
184
+ return self.data.get(key)
185
+ ```
186
+
187
+ ## Test Coverage Guidelines
188
+
189
+ ### Target Coverage Levels
190
+ - **Critical paths:** 100%
191
+ - **Business logic:** 95%+
192
+ - **Overall project:** 80%+
193
+ - **UI components:** 70%+
194
+
195
+ ### What to Test
196
+ - ✅ Business logic and algorithms
197
+ - ✅ Edge cases and boundary conditions
198
+ - ✅ Error handling and validation
199
+ - ✅ State transitions
200
+ - ✅ Public APIs and interfaces
201
+
202
+ ### What NOT to Test
203
+ - ❌ Framework internals
204
+ - ❌ Third-party libraries
205
+ - ❌ Trivial getters/setters
206
+ - ❌ Generated code
207
+ - ❌ Configuration files
208
+
209
+ ## Testing Best Practices
210
+
211
+ ### 1. One Assertion Per Test (When Possible)
212
+ ```python
213
+ # Good: Focused test
214
+ def test_should_validate_email_format():
215
+ assert is_valid_email("user@example.com") is True
216
+
217
+ # Avoid: Multiple unrelated assertions
218
+ def test_validation():
219
+ assert is_valid_email("user@example.com") is True
220
+ assert is_valid_phone("123-456-7890") is True # Different concept
221
+ ```
222
+
223
+ ### 2. Test Independence
224
+ ```python
225
+ # Good: Each test is self-contained
226
+ def test_user_creation():
227
+ user = create_user("test@example.com")
228
+ assert user.email == "test@example.com"
229
+
230
+ # Avoid: Tests depending on execution order
231
+ shared_user = None
232
+
233
+ def test_create_user():
234
+ global shared_user
235
+ shared_user = create_user("test@example.com")
236
+
237
+ def test_update_user(): # Depends on previous test
238
+ shared_user.name = "Updated"
239
+ ```
240
+
241
+ ### 3. Descriptive Test Failures
242
+ ```python
243
+ # Good: Clear failure message
244
+ assert result.status == 200, f"Expected 200, got {result.status}: {result.body}"
245
+
246
+ # Avoid: Unclear failure
247
+ assert result.status == 200
248
+ ```
249
+
250
+ ### 4. Test Data Builders
251
+ ```python
252
+ # Good: Reusable test data creation
253
+ def create_test_user(**overrides):
254
+ defaults = {
255
+ 'email': 'test@example.com',
256
+ 'name': 'Test User',
257
+ 'role': 'user'
258
+ }
259
+ return User(**{**defaults, **overrides})
260
+
261
+ # Usage
262
+ admin = create_test_user(role='admin')
263
+ guest = create_test_user(email='guest@example.com')
264
+ ```
265
+
266
+ ## Testing Anti-Patterns to Avoid
267
+
268
+ ### ❌ Testing Implementation Details
269
+ ```python
270
+ # Bad: Tests internal structure
271
+ def test_user_storage():
272
+ user = User("test@example.com")
273
+ assert user._internal_cache is not None # Implementation detail
274
+ ```
275
+
276
+ ### ❌ Fragile Tests
277
+ ```python
278
+ # Bad: Breaks with harmless changes
279
+ assert user.to_json() == '{"name":"John","email":"john@example.com"}'
280
+
281
+ # Good: Tests behavior, not format
282
+ data = json.loads(user.to_json())
283
+ assert data['name'] == "John"
284
+ assert data['email'] == "john@example.com"
285
+ ```
286
+
287
+ ### ❌ Slow Tests in Unit Test Suite
288
+ ```python
289
+ # Bad: Real HTTP calls in unit tests
290
+ def test_api_integration():
291
+ response = requests.get("https://api.example.com/users") # Slow!
292
+ assert response.status_code == 200
293
+ ```
294
+
295
+ ### ❌ Testing Everything Through UI
296
+ ```python
297
+ # Bad: Testing business logic through UI
298
+ def test_calculation():
299
+ browser.click("#input1")
300
+ browser.type("5")
301
+ browser.click("#input2")
302
+ browser.type("3")
303
+ browser.click("#calculate")
304
+ assert browser.find("#result").text == "8"
305
+
306
+ # Good: Test logic directly
307
+ def test_calculation():
308
+ assert calculate(5, 3) == 8
309
+ ```
310
+
311
+ ## Quick Reference by Language
312
+
313
+ ### Python (pytest)
314
+ ```python
315
+ # Setup/Teardown
316
+ @pytest.fixture
317
+ def database():
318
+ db = create_test_database()
319
+ yield db
320
+ db.cleanup()
321
+
322
+ # Parametrized tests
323
+ @pytest.mark.parametrize("input,expected", [
324
+ ("user@example.com", True),
325
+ ("invalid-email", False),
326
+ ])
327
+ def test_email_validation(input, expected):
328
+ assert is_valid_email(input) == expected
329
+ ```
330
+
331
+ ### JavaScript (Jest)
332
+ ```javascript
333
+ // Setup/Teardown
334
+ beforeEach(() => {
335
+ database = createTestDatabase();
336
+ });
337
+
338
+ afterEach(() => {
339
+ database.cleanup();
340
+ });
341
+
342
+ // Async tests
343
+ test('should fetch user data', async () => {
344
+ const user = await fetchUser(1);
345
+ expect(user.name).toBe('John');
346
+ });
347
+ ```
348
+
349
+ ### Go
350
+ ```go
351
+ // Table-driven tests
352
+ func TestEmailValidation(t *testing.T) {
353
+ tests := []struct {
354
+ input string
355
+ expected bool
356
+ }{
357
+ {"user@example.com", true},
358
+ {"invalid-email", false},
359
+ }
360
+
361
+ for _, tt := range tests {
362
+ result := IsValidEmail(tt.input)
363
+ if result != tt.expected {
364
+ t.Errorf("IsValidEmail(%s) = %v, want %v",
365
+ tt.input, result, tt.expected)
366
+ }
367
+ }
368
+ }
369
+ ```
370
+
371
+ ## TDD Benefits Realized
372
+
373
+ - **Design Improvement:** Tests drive better API design
374
+ - **Documentation:** Tests serve as executable documentation
375
+ - **Confidence:** Refactoring becomes safe
376
+ - **Debugging:** Tests isolate issues quickly
377
+ - **Coverage:** Ensures comprehensive test coverage
378
+ - **Regression Prevention:** Catches bugs before deployment
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: Condition-Based Waiting
3
+ description: Replace arbitrary timeouts with condition polling for reliable async tests
4
+ when_to_use: when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior
5
+ version: 1.1.0
6
+ languages: all
7
+ ---
8
+
9
+ # Condition-Based Waiting
10
+
11
+ ## Overview
12
+
13
+ Flaky tests often guess at timing with arbitrary delays. This creates race conditions where tests pass on fast machines but fail under load or in CI.
14
+
15
+ **Core principle:** Wait for the actual condition you care about, not a guess about how long it takes.
16
+
17
+ ## When to Use
18
+
19
+ ```dot
20
+ digraph when_to_use {
21
+ "Test uses setTimeout/sleep?" [shape=diamond];
22
+ "Testing timing behavior?" [shape=diamond];
23
+ "Document WHY timeout needed" [shape=box];
24
+ "Use condition-based waiting" [shape=box];
25
+
26
+ "Test uses setTimeout/sleep?" -> "Testing timing behavior?" [label="yes"];
27
+ "Testing timing behavior?" -> "Document WHY timeout needed" [label="yes"];
28
+ "Testing timing behavior?" -> "Use condition-based waiting" [label="no"];
29
+ }
30
+ ```
31
+
32
+ **Use when:**
33
+ - Tests have arbitrary delays (`setTimeout`, `sleep`, `time.sleep()`)
34
+ - Tests are flaky (pass sometimes, fail under load)
35
+ - Tests timeout when run in parallel
36
+ - Waiting for async operations to complete
37
+
38
+ **Don't use when:**
39
+ - Testing actual timing behavior (debounce, throttle intervals)
40
+ - Always document WHY if using arbitrary timeout
41
+
42
+ ## Core Pattern
43
+
44
+ ```typescript
45
+ // ❌ BEFORE: Guessing at timing
46
+ await new Promise(r => setTimeout(r, 50));
47
+ const result = getResult();
48
+ expect(result).toBeDefined();
49
+
50
+ // ✅ AFTER: Waiting for condition
51
+ await waitFor(() => getResult() !== undefined);
52
+ const result = getResult();
53
+ expect(result).toBeDefined();
54
+ ```
55
+
56
+ ## Quick Patterns
57
+
58
+ | Scenario | Pattern |
59
+ |----------|---------|
60
+ | Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` |
61
+ | Wait for state | `waitFor(() => machine.state === 'ready')` |
62
+ | Wait for count | `waitFor(() => items.length >= 5)` |
63
+ | Wait for file | `waitFor(() => fs.existsSync(path))` |
64
+ | Complex condition | `waitFor(() => obj.ready && obj.value > 10)` |
65
+
66
+ ## Implementation
67
+
68
+ Generic polling function:
69
+ ```typescript
70
+ async function waitFor<T>(
71
+ condition: () => T | undefined | null | false,
72
+ description: string,
73
+ timeoutMs = 5000
74
+ ): Promise<T> {
75
+ const startTime = Date.now();
76
+
77
+ while (true) {
78
+ const result = condition();
79
+ if (result) return result;
80
+
81
+ if (Date.now() - startTime > timeoutMs) {
82
+ throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);
83
+ }
84
+
85
+ await new Promise(r => setTimeout(r, 10)); // Poll every 10ms
86
+ }
87
+ }
88
+ ```
89
+
90
+ See @example.ts for complete implementation with domain-specific helpers (`waitForEvent`, `waitForEventCount`, `waitForEventMatch`) from actual debugging session.
91
+
92
+ ## Common Mistakes
93
+
94
+ **❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU
95
+ **✅ Fix:** Poll every 10ms
96
+
97
+ **❌ No timeout:** Loop forever if condition never met
98
+ **✅ Fix:** Always include timeout with clear error
99
+
100
+ **❌ Stale data:** Cache state before loop
101
+ **✅ Fix:** Call getter inside loop for fresh data
102
+
103
+ ## When Arbitrary Timeout IS Correct
104
+
105
+ ```typescript
106
+ // Tool ticks every 100ms - need 2 ticks to verify partial output
107
+ await waitForEvent(manager, 'TOOL_STARTED'); // First: wait for condition
108
+ await new Promise(r => setTimeout(r, 200)); // Then: wait for timed behavior
109
+ // 200ms = 2 ticks at 100ms intervals - documented and justified
110
+ ```
111
+
112
+ **Requirements:**
113
+ 1. First wait for triggering condition
114
+ 2. Based on known timing (not guessing)
115
+ 3. Comment explaining WHY
116
+
117
+ ## Real-World Impact
118
+
119
+ From debugging session (2025-10-03):
120
+ - Fixed 15 flaky tests across 3 files
121
+ - Pass rate: 60% → 100%
122
+ - Execution time: 40% faster
123
+ - No more race conditions
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: test-driven-development
3
+ description: Write the test first, watch it fail, write minimal code to pass
4
+ version: 3.2.0
5
+ category: testing
6
+ author: Jesse Vincent
7
+ license: MIT
8
+ source: https://github.com/obra/superpowers-skills/tree/main/skills/testing/test-driven-development
9
+ progressive_disclosure:
10
+ entry_point:
11
+ summary: "Enforce test-first development with strict RED/GREEN/REFACTOR cycle. Never write implementation before failing test."
12
+ when_to_use: "When implementing any feature or bugfix, before writing implementation code. Always for new features, bug fixes, refactoring, and behavior changes."
13
+ quick_start: "1. Write failing test 2. Watch it fail (verify) 3. Write minimal code to pass 4. Watch it pass (verify) 5. Refactor if needed 6. Repeat"
14
+ references:
15
+ - workflow.md
16
+ - examples.md
17
+ - philosophy.md
18
+ - anti-patterns.md
19
+ - integration.md
20
+ context_limit: 800
21
+ tags:
22
+ - tdd
23
+ - testing
24
+ - red-green-refactor
25
+ - test-first
26
+ ---
27
+
28
+ # Test-Driven Development (TDD)
29
+
30
+ ## Overview
31
+
32
+ Write the test first. Watch it fail. Write minimal code to pass.
33
+
34
+ **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
35
+
36
+ This skill enforces strict test-first development following the RED/GREEN/REFACTOR cycle. Violating the letter of the rules is violating the spirit of the rules.
37
+
38
+ ## When to Use This Skill
39
+
40
+ **Always:**
41
+ - New features
42
+ - Bug fixes
43
+ - Refactoring
44
+ - Behavior changes
45
+
46
+ **Exceptions (ask human partner):**
47
+ - Throwaway prototypes
48
+ - Generated code
49
+ - Configuration files
50
+
51
+ Thinking "skip TDD just this once"? Stop. That's rationalization.
52
+
53
+ ## The Iron Law
54
+
55
+ ```
56
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
57
+ ```
58
+
59
+ Write code before the test? Delete it. Start over.
60
+
61
+ **No exceptions:**
62
+ - Don't keep it as "reference"
63
+ - Don't "adapt" it while writing tests
64
+ - Delete means delete
65
+
66
+ ## Core Principles
67
+
68
+ 1. **RED**: Write a failing test first
69
+ 2. **GREEN**: Write minimal code to make test pass
70
+ 3. **REFACTOR**: Improve code while keeping tests green
71
+ 4. **NEVER**: Write implementation before tests
72
+
73
+ ## Quick Start
74
+
75
+ ### The RED/GREEN/REFACTOR Cycle
76
+
77
+ ```
78
+ RED → Verify RED → GREEN → Verify GREEN → REFACTOR → Repeat
79
+ ```
80
+
81
+ 1. **RED**: Write one minimal test showing desired behavior
82
+ 2. **Verify RED**: Run test, confirm it fails for right reason
83
+ 3. **GREEN**: Write simplest code to pass test
84
+ 4. **Verify GREEN**: Run test, confirm it passes
85
+ 5. **REFACTOR**: Clean up while keeping tests green
86
+ 6. **Repeat**: Next test for next feature
87
+
88
+ ## Cycle Details
89
+
90
+ **RED**: Write one minimal test (one behavior, clear name, real code)
91
+ **Verify RED**: MANDATORY - watch it fail for right reason
92
+ **GREEN**: Write simplest code to pass (no extras)
93
+ **Verify GREEN**: MANDATORY - watch it pass, all tests pass
94
+ **REFACTOR**: Clean up while keeping tests green (optional)
95
+
96
+ ## Navigation
97
+
98
+ For detailed information:
99
+ - **[Workflow](references/workflow.md)**: Complete RED/GREEN/REFACTOR workflow with detailed examples
100
+ - **[Examples](references/examples.md)**: Real-world TDD scenarios with step-by-step walkthroughs
101
+ - **[Philosophy](references/philosophy.md)**: Why order matters and why tests-after don't work
102
+ - **[Anti-patterns](references/anti-patterns.md)**: Common mistakes, rationalizations, and red flags
103
+ - **[Integration](references/integration.md)**: Using TDD with debugging and other skills
104
+
105
+ ## Key Reminders
106
+
107
+ - ALWAYS write the test BEFORE implementation
108
+ - Make each test fail FIRST to verify it's testing something
109
+ - Keep implementation minimal - just enough to pass tests
110
+ - Refactor only when tests are green
111
+ - One cycle at a time - small steps
112
+ - If test passes immediately, it's not testing new behavior
113
+
114
+ ## Red Flags - STOP and Start Over
115
+
116
+ If you catch yourself:
117
+ - Writing code before test
118
+ - Test passes immediately
119
+ - Can't explain why test failed
120
+ - "I'll test after"
121
+ - "Keep as reference"
122
+ - "Already spent X hours, deleting is wasteful"
123
+ - "Tests after achieve the same purpose"
124
+
125
+ **ALL of these mean: Delete code. Start over with TDD.**
126
+
127
+ ## Why Order Matters
128
+
129
+ Tests-after pass immediately (proves nothing), test-first fail then pass (proves it works). See [Philosophy](references/philosophy.md) for detailed explanation.
130
+
131
+ ## Integration with Other Skills
132
+
133
+ - **systematic-debugging**: Create failing test in Phase 4 (bug reproduction)
134
+ - **verification-before-completion**: Verify tests exist and watched them fail
135
+ - **defense-in-depth**: Add validation tests after implementing feature
136
+
137
+ ## Real-World Impact
138
+
139
+ From TDD practice:
140
+ - Test-first: 95%+ first-time correctness
141
+ - Test-after: 40% first-time correctness
142
+ - TDD time: 25-45 minutes per feature (including tests)
143
+ - Non-TDD time: 15 minutes coding + 60-120 minutes debugging
144
+
145
+ **TDD is pragmatic** - finds bugs before commit, prevents regressions, documents behavior, enables refactoring.