claude-mpm 4.15.6__py3-none-any.whl → 4.21.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.

Potentially problematic release.


This version of claude-mpm might be problematic. Click here for more details.

Files changed (209) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/BASE_ENGINEER.md +286 -0
  3. claude_mpm/agents/BASE_PM.md +272 -23
  4. claude_mpm/agents/PM_INSTRUCTIONS.md +49 -0
  5. claude_mpm/agents/agent_loader.py +4 -4
  6. claude_mpm/agents/templates/engineer.json +5 -1
  7. claude_mpm/agents/templates/php-engineer.json +10 -4
  8. claude_mpm/agents/templates/python_engineer.json +8 -3
  9. claude_mpm/agents/templates/rust_engineer.json +12 -7
  10. claude_mpm/agents/templates/svelte-engineer.json +225 -0
  11. claude_mpm/cli/commands/__init__.py +2 -0
  12. claude_mpm/cli/commands/mpm_init/__init__.py +73 -0
  13. claude_mpm/cli/commands/mpm_init/core.py +525 -0
  14. claude_mpm/cli/commands/mpm_init/display.py +341 -0
  15. claude_mpm/cli/commands/mpm_init/git_activity.py +427 -0
  16. claude_mpm/cli/commands/mpm_init/modes.py +397 -0
  17. claude_mpm/cli/commands/mpm_init/prompts.py +442 -0
  18. claude_mpm/cli/commands/mpm_init_cli.py +396 -0
  19. claude_mpm/cli/commands/mpm_init_handler.py +67 -1
  20. claude_mpm/cli/commands/skills.py +488 -0
  21. claude_mpm/cli/executor.py +2 -0
  22. claude_mpm/cli/parsers/base_parser.py +7 -0
  23. claude_mpm/cli/parsers/mpm_init_parser.py +42 -0
  24. claude_mpm/cli/parsers/skills_parser.py +137 -0
  25. claude_mpm/cli/startup.py +57 -0
  26. claude_mpm/commands/mpm-auto-configure.md +52 -0
  27. claude_mpm/commands/mpm-help.md +6 -0
  28. claude_mpm/commands/mpm-init.md +112 -6
  29. claude_mpm/commands/mpm-resume.md +372 -0
  30. claude_mpm/commands/mpm-version.md +113 -0
  31. claude_mpm/commands/mpm.md +2 -0
  32. claude_mpm/config/agent_config.py +2 -2
  33. claude_mpm/constants.py +12 -0
  34. claude_mpm/core/config.py +42 -0
  35. claude_mpm/core/factories.py +1 -1
  36. claude_mpm/core/interfaces.py +56 -1
  37. claude_mpm/core/optimized_agent_loader.py +3 -3
  38. claude_mpm/hooks/__init__.py +8 -0
  39. claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
  40. claude_mpm/hooks/session_resume_hook.py +121 -0
  41. claude_mpm/models/resume_log.py +340 -0
  42. claude_mpm/services/agents/auto_config_manager.py +1 -1
  43. claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
  44. claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
  45. claude_mpm/services/agents/deployment/agent_validator.py +17 -1
  46. claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
  47. claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
  48. claude_mpm/services/agents/local_template_manager.py +1 -1
  49. claude_mpm/services/agents/recommender.py +47 -0
  50. claude_mpm/services/cli/resume_service.py +617 -0
  51. claude_mpm/services/cli/session_manager.py +87 -0
  52. claude_mpm/services/cli/session_pause_manager.py +504 -0
  53. claude_mpm/services/cli/session_resume_helper.py +372 -0
  54. claude_mpm/services/core/base.py +26 -11
  55. claude_mpm/services/core/interfaces.py +56 -1
  56. claude_mpm/services/core/models/agent_config.py +3 -0
  57. claude_mpm/services/core/models/process.py +4 -0
  58. claude_mpm/services/core/path_resolver.py +1 -1
  59. claude_mpm/services/diagnostics/models.py +21 -0
  60. claude_mpm/services/event_bus/relay.py +23 -7
  61. claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
  62. claude_mpm/services/local_ops/__init__.py +2 -0
  63. claude_mpm/services/mcp_config_manager.py +7 -131
  64. claude_mpm/services/mcp_gateway/auto_configure.py +31 -25
  65. claude_mpm/services/mcp_gateway/core/process_pool.py +19 -10
  66. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +26 -21
  67. claude_mpm/services/memory/failure_tracker.py +19 -4
  68. claude_mpm/services/session_manager.py +205 -1
  69. claude_mpm/services/unified/deployment_strategies/local.py +1 -1
  70. claude_mpm/services/version_service.py +104 -1
  71. claude_mpm/skills/__init__.py +21 -0
  72. claude_mpm/skills/agent_skills_injector.py +324 -0
  73. claude_mpm/skills/bundled/LICENSE_ATTRIBUTIONS.md +79 -0
  74. claude_mpm/skills/bundled/api-documentation.md +393 -0
  75. claude_mpm/skills/bundled/async-testing.md +571 -0
  76. claude_mpm/skills/bundled/code-review.md +143 -0
  77. claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +79 -0
  78. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +178 -0
  79. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/agent-prompts.md +577 -0
  80. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/coordination-patterns.md +467 -0
  81. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/examples.md +537 -0
  82. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/troubleshooting.md +730 -0
  83. claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +112 -0
  84. claude_mpm/skills/bundled/collaboration/requesting-code-review/references/code-reviewer-template.md +146 -0
  85. claude_mpm/skills/bundled/collaboration/requesting-code-review/references/review-examples.md +412 -0
  86. claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +81 -0
  87. claude_mpm/skills/bundled/collaboration/writing-plans/references/best-practices.md +362 -0
  88. claude_mpm/skills/bundled/collaboration/writing-plans/references/plan-structure-templates.md +312 -0
  89. claude_mpm/skills/bundled/database-migration.md +199 -0
  90. claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +152 -0
  91. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/advanced-techniques.md +668 -0
  92. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/examples.md +587 -0
  93. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/integration.md +438 -0
  94. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/tracing-techniques.md +391 -0
  95. claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
  96. claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
  97. claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
  98. claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
  99. claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
  100. claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
  101. claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
  102. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
  103. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
  104. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
  105. claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +131 -0
  106. claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +325 -0
  107. claude_mpm/skills/bundled/debugging/verification-before-completion/references/integration-and-workflows.md +490 -0
  108. claude_mpm/skills/bundled/debugging/verification-before-completion/references/red-flags-and-failures.md +425 -0
  109. claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +499 -0
  110. claude_mpm/skills/bundled/docker-containerization.md +194 -0
  111. claude_mpm/skills/bundled/express-local-dev.md +1429 -0
  112. claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
  113. claude_mpm/skills/bundled/git-workflow.md +414 -0
  114. claude_mpm/skills/bundled/imagemagick.md +204 -0
  115. claude_mpm/skills/bundled/json-data-handling.md +223 -0
  116. claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +86 -0
  117. claude_mpm/skills/bundled/main/internal-comms/SKILL.md +43 -0
  118. claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
  119. claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
  120. claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
  121. claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
  122. claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +160 -0
  123. claude_mpm/skills/bundled/main/mcp-builder/reference/design_principles.md +412 -0
  124. claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
  125. claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
  126. claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
  127. claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
  128. claude_mpm/skills/bundled/main/mcp-builder/reference/workflow.md +1237 -0
  129. claude_mpm/skills/bundled/main/mcp-builder/scripts/connections.py +157 -0
  130. claude_mpm/skills/bundled/main/mcp-builder/scripts/evaluation.py +425 -0
  131. claude_mpm/skills/bundled/main/skill-creator/SKILL.md +189 -0
  132. claude_mpm/skills/bundled/main/skill-creator/references/best-practices.md +500 -0
  133. claude_mpm/skills/bundled/main/skill-creator/references/creation-workflow.md +464 -0
  134. claude_mpm/skills/bundled/main/skill-creator/references/examples.md +619 -0
  135. claude_mpm/skills/bundled/main/skill-creator/references/progressive-disclosure.md +437 -0
  136. claude_mpm/skills/bundled/main/skill-creator/references/skill-structure.md +231 -0
  137. claude_mpm/skills/bundled/main/skill-creator/scripts/init_skill.py +303 -0
  138. claude_mpm/skills/bundled/main/skill-creator/scripts/package_skill.py +113 -0
  139. claude_mpm/skills/bundled/main/skill-creator/scripts/quick_validate.py +72 -0
  140. claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
  141. claude_mpm/skills/bundled/pdf.md +141 -0
  142. claude_mpm/skills/bundled/performance-profiling.md +567 -0
  143. claude_mpm/skills/bundled/php/espocrm-development/SKILL.md +170 -0
  144. claude_mpm/skills/bundled/php/espocrm-development/references/architecture.md +602 -0
  145. claude_mpm/skills/bundled/php/espocrm-development/references/common-tasks.md +821 -0
  146. claude_mpm/skills/bundled/php/espocrm-development/references/development-workflow.md +742 -0
  147. claude_mpm/skills/bundled/php/espocrm-development/references/frontend-customization.md +726 -0
  148. claude_mpm/skills/bundled/php/espocrm-development/references/hooks-and-services.md +764 -0
  149. claude_mpm/skills/bundled/php/espocrm-development/references/testing-debugging.md +831 -0
  150. claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
  151. claude_mpm/skills/bundled/rust/desktop-applications/SKILL.md +226 -0
  152. claude_mpm/skills/bundled/rust/desktop-applications/references/architecture-patterns.md +901 -0
  153. claude_mpm/skills/bundled/rust/desktop-applications/references/native-gui-frameworks.md +901 -0
  154. claude_mpm/skills/bundled/rust/desktop-applications/references/platform-integration.md +775 -0
  155. claude_mpm/skills/bundled/rust/desktop-applications/references/state-management.md +937 -0
  156. claude_mpm/skills/bundled/rust/desktop-applications/references/tauri-framework.md +770 -0
  157. claude_mpm/skills/bundled/rust/desktop-applications/references/testing-deployment.md +961 -0
  158. claude_mpm/skills/bundled/security-scanning.md +327 -0
  159. claude_mpm/skills/bundled/systematic-debugging.md +473 -0
  160. claude_mpm/skills/bundled/test-driven-development.md +378 -0
  161. claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +119 -0
  162. claude_mpm/skills/bundled/testing/condition-based-waiting/references/patterns-and-implementation.md +253 -0
  163. claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
  164. claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
  165. claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
  166. claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
  167. claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
  168. claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
  169. claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +140 -0
  170. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md +572 -0
  171. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/core-anti-patterns.md +411 -0
  172. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/detection-guide.md +569 -0
  173. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/tdd-connection.md +695 -0
  174. claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +184 -0
  175. claude_mpm/skills/bundled/testing/webapp-testing/decision-tree.md +459 -0
  176. claude_mpm/skills/bundled/testing/webapp-testing/examples/console_logging.py +35 -0
  177. claude_mpm/skills/bundled/testing/webapp-testing/examples/element_discovery.py +44 -0
  178. claude_mpm/skills/bundled/testing/webapp-testing/examples/static_html_automation.py +34 -0
  179. claude_mpm/skills/bundled/testing/webapp-testing/playwright-patterns.md +479 -0
  180. claude_mpm/skills/bundled/testing/webapp-testing/reconnaissance-pattern.md +687 -0
  181. claude_mpm/skills/bundled/testing/webapp-testing/scripts/with_server.py +129 -0
  182. claude_mpm/skills/bundled/testing/webapp-testing/server-management.md +758 -0
  183. claude_mpm/skills/bundled/testing/webapp-testing/troubleshooting.md +868 -0
  184. claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
  185. claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
  186. claude_mpm/skills/bundled/xlsx.md +157 -0
  187. claude_mpm/skills/registry.py +97 -9
  188. claude_mpm/skills/skills_registry.py +348 -0
  189. claude_mpm/skills/skills_service.py +739 -0
  190. claude_mpm/tools/code_tree_analyzer/__init__.py +45 -0
  191. claude_mpm/tools/code_tree_analyzer/analysis.py +299 -0
  192. claude_mpm/tools/code_tree_analyzer/cache.py +131 -0
  193. claude_mpm/tools/code_tree_analyzer/core.py +380 -0
  194. claude_mpm/tools/code_tree_analyzer/discovery.py +403 -0
  195. claude_mpm/tools/code_tree_analyzer/events.py +168 -0
  196. claude_mpm/tools/code_tree_analyzer/gitignore.py +308 -0
  197. claude_mpm/tools/code_tree_analyzer/models.py +39 -0
  198. claude_mpm/tools/code_tree_analyzer/multilang_analyzer.py +224 -0
  199. claude_mpm/tools/code_tree_analyzer/python_analyzer.py +284 -0
  200. claude_mpm/utils/agent_dependency_loader.py +2 -2
  201. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.3.dist-info}/METADATA +211 -33
  202. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.3.dist-info}/RECORD +206 -64
  203. claude_mpm/agents/INSTRUCTIONS_OLD_DEPRECATED.md +0 -602
  204. claude_mpm/cli/commands/mpm_init.py +0 -2008
  205. claude_mpm/tools/code_tree_analyzer.py +0 -1825
  206. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.3.dist-info}/WHEEL +0 -0
  207. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.3.dist-info}/entry_points.txt +0 -0
  208. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.3.dist-info}/licenses/LICENSE +0 -0
  209. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,253 @@
1
+ # Detailed Patterns and Implementation Guide
2
+
3
+ This reference provides detailed implementation patterns, common mistakes, and edge cases for condition-based waiting.
4
+
5
+ ## Common Mistakes
6
+
7
+ ### ❌ Polling too fast
8
+ ```typescript
9
+ // BAD: Wastes CPU
10
+ await new Promise(r => setTimeout(r, 1));
11
+ ```
12
+
13
+ **✅ Fix:** Poll every 10ms
14
+ ```typescript
15
+ await new Promise(r => setTimeout(r, 10)); // Balanced interval
16
+ ```
17
+
18
+ ### ❌ No timeout
19
+ ```typescript
20
+ // BAD: Loop forever if condition never met
21
+ while (true) {
22
+ const result = condition();
23
+ if (result) return result;
24
+ await new Promise(r => setTimeout(r, 10));
25
+ }
26
+ ```
27
+
28
+ **✅ Fix:** Always include timeout with clear error
29
+ ```typescript
30
+ const startTime = Date.now();
31
+ while (true) {
32
+ const result = condition();
33
+ if (result) return result;
34
+
35
+ if (Date.now() - startTime > timeoutMs) {
36
+ throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);
37
+ }
38
+
39
+ await new Promise(r => setTimeout(r, 10));
40
+ }
41
+ ```
42
+
43
+ ### ❌ Stale data
44
+ ```typescript
45
+ // BAD: Cache state before loop
46
+ const state = machine.getState();
47
+ await waitFor(() => state === 'ready'); // state never updates!
48
+ ```
49
+
50
+ **✅ Fix:** Call getter inside loop for fresh data
51
+ ```typescript
52
+ await waitFor(() => machine.getState() === 'ready'); // Fresh on each poll
53
+ ```
54
+
55
+ ## When Arbitrary Timeout IS Correct
56
+
57
+ There are legitimate cases where a fixed timeout is the right approach:
58
+
59
+ ```typescript
60
+ // Tool ticks every 100ms - need 2 ticks to verify partial output
61
+ await waitForEvent(manager, 'TOOL_STARTED'); // First: wait for condition
62
+ await new Promise(r => setTimeout(r, 200)); // Then: wait for timed behavior
63
+ // 200ms = 2 ticks at 100ms intervals - documented and justified
64
+ ```
65
+
66
+ **Requirements for justified arbitrary timeouts:**
67
+ 1. First wait for triggering condition (condition-based wait comes first)
68
+ 2. Based on known timing (not guessing - actual system tick rate)
69
+ 3. Comment explaining WHY timeout is necessary
70
+
71
+ ## Advanced Patterns
72
+
73
+ ### Waiting with transformation
74
+ ```typescript
75
+ // Wait for event and return transformed data
76
+ const userId = await waitFor(
77
+ () => events.find(e => e.type === 'USER_CREATED')?.data.id,
78
+ 'user creation event'
79
+ );
80
+ ```
81
+
82
+ ### Waiting with complex conditions
83
+ ```typescript
84
+ // Multiple conditions must be met
85
+ await waitFor(
86
+ () => {
87
+ const user = getUser();
88
+ return user?.verified && user?.credits > 0 ? user : undefined;
89
+ },
90
+ 'verified user with credits'
91
+ );
92
+ ```
93
+
94
+ ### Waiting with side effects
95
+ ```typescript
96
+ // Log attempts while waiting
97
+ let attempts = 0;
98
+ await waitFor(
99
+ () => {
100
+ attempts++;
101
+ if (attempts % 10 === 0) {
102
+ console.log(`Still waiting after ${attempts} attempts...`);
103
+ }
104
+ return isReady() || undefined;
105
+ },
106
+ 'system ready'
107
+ );
108
+ ```
109
+
110
+ ### Waiting with custom timeouts per condition
111
+ ```typescript
112
+ // Different timeouts for different scenarios
113
+ async function waitForDeploy(environment: string) {
114
+ const timeout = environment === 'prod' ? 30000 : 5000;
115
+ return waitFor(
116
+ () => checkDeployStatus(environment),
117
+ `${environment} deployment`,
118
+ timeout
119
+ );
120
+ }
121
+ ```
122
+
123
+ ## Domain-Specific Helpers
124
+
125
+ When you have common waiting scenarios, create domain-specific helpers:
126
+
127
+ ```typescript
128
+ // Event-based waiting
129
+ async function waitForEvent(
130
+ manager: EventManager,
131
+ eventType: string,
132
+ timeoutMs = 5000
133
+ ) {
134
+ return waitFor(
135
+ () => manager.getEvents().find(e => e.type === eventType),
136
+ `event ${eventType}`,
137
+ timeoutMs
138
+ );
139
+ }
140
+
141
+ // Count-based waiting
142
+ async function waitForEventCount(
143
+ manager: EventManager,
144
+ minCount: number,
145
+ timeoutMs = 5000
146
+ ) {
147
+ return waitFor(
148
+ () => {
149
+ const events = manager.getEvents();
150
+ return events.length >= minCount ? events : undefined;
151
+ },
152
+ `at least ${minCount} events`,
153
+ timeoutMs
154
+ );
155
+ }
156
+
157
+ // Pattern matching waiting
158
+ async function waitForEventMatch(
159
+ manager: EventManager,
160
+ matcher: (event: Event) => boolean,
161
+ timeoutMs = 5000
162
+ ) {
163
+ return waitFor(
164
+ () => manager.getEvents().find(matcher),
165
+ 'event matching predicate',
166
+ timeoutMs
167
+ );
168
+ }
169
+ ```
170
+
171
+ See @example.ts for complete working implementations from real debugging session.
172
+
173
+ ## Debugging Tips
174
+
175
+ ### Add descriptive error messages
176
+ ```typescript
177
+ // GOOD: Clear what failed
178
+ await waitFor(
179
+ () => orders.find(o => o.status === 'SHIPPED'),
180
+ 'order to be shipped',
181
+ 5000
182
+ );
183
+ // Error: "Timeout waiting for order to be shipped after 5000ms"
184
+
185
+ // BETTER: Include context
186
+ await waitFor(
187
+ () => orders.find(o => o.id === orderId && o.status === 'SHIPPED'),
188
+ `order ${orderId} to be shipped`,
189
+ 5000
190
+ );
191
+ // Error: "Timeout waiting for order abc-123 to be shipped after 5000ms"
192
+ ```
193
+
194
+ ### Log current state on timeout
195
+ ```typescript
196
+ async function waitForWithDebug<T>(
197
+ condition: () => T | undefined | null | false,
198
+ description: string,
199
+ getCurrentState: () => any,
200
+ timeoutMs = 5000
201
+ ): Promise<T> {
202
+ const startTime = Date.now();
203
+
204
+ while (true) {
205
+ const result = condition();
206
+ if (result) return result;
207
+
208
+ if (Date.now() - startTime > timeoutMs) {
209
+ const state = getCurrentState();
210
+ throw new Error(
211
+ `Timeout waiting for ${description} after ${timeoutMs}ms. ` +
212
+ `Current state: ${JSON.stringify(state)}`
213
+ );
214
+ }
215
+
216
+ await new Promise(r => setTimeout(r, 10));
217
+ }
218
+ }
219
+ ```
220
+
221
+ ## Performance Considerations
222
+
223
+ ### Poll interval trade-offs
224
+ - **1ms**: Too fast, wastes CPU (10,000 checks/second)
225
+ - **10ms**: Good default, responsive (100 checks/second)
226
+ - **50ms**: Acceptable for slow operations (20 checks/second)
227
+ - **100ms+**: Only for very slow operations or known timing
228
+
229
+ ### Choose appropriate timeout values
230
+ ```typescript
231
+ // Fast operations - short timeout
232
+ await waitFor(() => cache.get(key), 'cache hit', 1000);
233
+
234
+ // Network operations - medium timeout
235
+ await waitFor(() => fetchStatus(), 'API response', 5000);
236
+
237
+ // External systems - long timeout
238
+ await waitFor(() => checkDeployment(), 'deployment complete', 30000);
239
+ ```
240
+
241
+ ### Avoid expensive condition checks
242
+ ```typescript
243
+ // BAD: Expensive regex on every poll
244
+ await waitFor(() => /complex.*regex.*pattern/.test(getLargeString()), ...);
245
+
246
+ // GOOD: Cache expensive computations
247
+ let parsed;
248
+ await waitFor(() => {
249
+ const str = getString();
250
+ parsed = parsed || expensiveParse(str);
251
+ return parsed.isReady;
252
+ }, ...);
253
+ ```
@@ -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.