claude-mpm 4.15.6__py3-none-any.whl → 4.21.0__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 (194) 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 +3 -0
  28. claude_mpm/commands/mpm-init.md +112 -6
  29. claude_mpm/commands/mpm-version.md +113 -0
  30. claude_mpm/commands/mpm.md +1 -0
  31. claude_mpm/config/agent_config.py +2 -2
  32. claude_mpm/constants.py +12 -0
  33. claude_mpm/core/config.py +42 -0
  34. claude_mpm/core/factories.py +1 -1
  35. claude_mpm/core/interfaces.py +56 -1
  36. claude_mpm/core/optimized_agent_loader.py +3 -3
  37. claude_mpm/hooks/__init__.py +8 -0
  38. claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
  39. claude_mpm/hooks/session_resume_hook.py +121 -0
  40. claude_mpm/models/resume_log.py +340 -0
  41. claude_mpm/services/agents/auto_config_manager.py +1 -1
  42. claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
  43. claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
  44. claude_mpm/services/agents/deployment/agent_validator.py +17 -1
  45. claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
  46. claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
  47. claude_mpm/services/agents/local_template_manager.py +1 -1
  48. claude_mpm/services/agents/recommender.py +47 -0
  49. claude_mpm/services/cli/resume_service.py +617 -0
  50. claude_mpm/services/cli/session_manager.py +87 -0
  51. claude_mpm/services/cli/session_pause_manager.py +504 -0
  52. claude_mpm/services/cli/session_resume_helper.py +372 -0
  53. claude_mpm/services/core/interfaces.py +56 -1
  54. claude_mpm/services/core/models/agent_config.py +3 -0
  55. claude_mpm/services/core/models/process.py +4 -0
  56. claude_mpm/services/core/path_resolver.py +1 -1
  57. claude_mpm/services/diagnostics/models.py +21 -0
  58. claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
  59. claude_mpm/services/local_ops/__init__.py +2 -0
  60. claude_mpm/services/mcp_config_manager.py +7 -131
  61. claude_mpm/services/mcp_gateway/auto_configure.py +31 -25
  62. claude_mpm/services/mcp_gateway/core/process_pool.py +19 -10
  63. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +26 -21
  64. claude_mpm/services/session_manager.py +205 -1
  65. claude_mpm/services/unified/deployment_strategies/local.py +1 -1
  66. claude_mpm/services/version_service.py +104 -1
  67. claude_mpm/skills/__init__.py +21 -0
  68. claude_mpm/skills/agent_skills_injector.py +324 -0
  69. claude_mpm/skills/bundled/LICENSE_ATTRIBUTIONS.md +79 -0
  70. claude_mpm/skills/bundled/api-documentation.md +393 -0
  71. claude_mpm/skills/bundled/async-testing.md +571 -0
  72. claude_mpm/skills/bundled/code-review.md +143 -0
  73. claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +79 -0
  74. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +178 -0
  75. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/agent-prompts.md +577 -0
  76. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/coordination-patterns.md +467 -0
  77. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/examples.md +537 -0
  78. claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/troubleshooting.md +730 -0
  79. claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +112 -0
  80. claude_mpm/skills/bundled/collaboration/requesting-code-review/references/code-reviewer-template.md +146 -0
  81. claude_mpm/skills/bundled/collaboration/requesting-code-review/references/review-examples.md +412 -0
  82. claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +81 -0
  83. claude_mpm/skills/bundled/collaboration/writing-plans/references/best-practices.md +362 -0
  84. claude_mpm/skills/bundled/collaboration/writing-plans/references/plan-structure-templates.md +312 -0
  85. claude_mpm/skills/bundled/database-migration.md +199 -0
  86. claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +152 -0
  87. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/advanced-techniques.md +668 -0
  88. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/examples.md +587 -0
  89. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/integration.md +438 -0
  90. claude_mpm/skills/bundled/debugging/root-cause-tracing/references/tracing-techniques.md +391 -0
  91. claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
  92. claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
  93. claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
  94. claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
  95. claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
  96. claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
  97. claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
  98. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
  99. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
  100. claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
  101. claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +131 -0
  102. claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +325 -0
  103. claude_mpm/skills/bundled/debugging/verification-before-completion/references/integration-and-workflows.md +490 -0
  104. claude_mpm/skills/bundled/debugging/verification-before-completion/references/red-flags-and-failures.md +425 -0
  105. claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +499 -0
  106. claude_mpm/skills/bundled/docker-containerization.md +194 -0
  107. claude_mpm/skills/bundled/express-local-dev.md +1429 -0
  108. claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
  109. claude_mpm/skills/bundled/git-workflow.md +414 -0
  110. claude_mpm/skills/bundled/imagemagick.md +204 -0
  111. claude_mpm/skills/bundled/json-data-handling.md +223 -0
  112. claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +86 -0
  113. claude_mpm/skills/bundled/main/internal-comms/SKILL.md +43 -0
  114. claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
  115. claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
  116. claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
  117. claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
  118. claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +160 -0
  119. claude_mpm/skills/bundled/main/mcp-builder/reference/design_principles.md +412 -0
  120. claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
  121. claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
  122. claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
  123. claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
  124. claude_mpm/skills/bundled/main/mcp-builder/reference/workflow.md +1237 -0
  125. claude_mpm/skills/bundled/main/mcp-builder/scripts/connections.py +157 -0
  126. claude_mpm/skills/bundled/main/mcp-builder/scripts/evaluation.py +425 -0
  127. claude_mpm/skills/bundled/main/skill-creator/SKILL.md +189 -0
  128. claude_mpm/skills/bundled/main/skill-creator/references/best-practices.md +500 -0
  129. claude_mpm/skills/bundled/main/skill-creator/references/creation-workflow.md +464 -0
  130. claude_mpm/skills/bundled/main/skill-creator/references/examples.md +619 -0
  131. claude_mpm/skills/bundled/main/skill-creator/references/progressive-disclosure.md +437 -0
  132. claude_mpm/skills/bundled/main/skill-creator/references/skill-structure.md +231 -0
  133. claude_mpm/skills/bundled/main/skill-creator/scripts/init_skill.py +303 -0
  134. claude_mpm/skills/bundled/main/skill-creator/scripts/package_skill.py +113 -0
  135. claude_mpm/skills/bundled/main/skill-creator/scripts/quick_validate.py +72 -0
  136. claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
  137. claude_mpm/skills/bundled/pdf.md +141 -0
  138. claude_mpm/skills/bundled/performance-profiling.md +567 -0
  139. claude_mpm/skills/bundled/php/espocrm-development/SKILL.md +170 -0
  140. claude_mpm/skills/bundled/php/espocrm-development/references/architecture.md +602 -0
  141. claude_mpm/skills/bundled/php/espocrm-development/references/common-tasks.md +821 -0
  142. claude_mpm/skills/bundled/php/espocrm-development/references/development-workflow.md +742 -0
  143. claude_mpm/skills/bundled/php/espocrm-development/references/frontend-customization.md +726 -0
  144. claude_mpm/skills/bundled/php/espocrm-development/references/hooks-and-services.md +764 -0
  145. claude_mpm/skills/bundled/php/espocrm-development/references/testing-debugging.md +831 -0
  146. claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
  147. claude_mpm/skills/bundled/rust/desktop-applications/SKILL.md +226 -0
  148. claude_mpm/skills/bundled/rust/desktop-applications/references/architecture-patterns.md +901 -0
  149. claude_mpm/skills/bundled/rust/desktop-applications/references/native-gui-frameworks.md +901 -0
  150. claude_mpm/skills/bundled/rust/desktop-applications/references/platform-integration.md +775 -0
  151. claude_mpm/skills/bundled/rust/desktop-applications/references/state-management.md +937 -0
  152. claude_mpm/skills/bundled/rust/desktop-applications/references/tauri-framework.md +770 -0
  153. claude_mpm/skills/bundled/rust/desktop-applications/references/testing-deployment.md +961 -0
  154. claude_mpm/skills/bundled/security-scanning.md +327 -0
  155. claude_mpm/skills/bundled/systematic-debugging.md +473 -0
  156. claude_mpm/skills/bundled/test-driven-development.md +378 -0
  157. claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +119 -0
  158. claude_mpm/skills/bundled/testing/condition-based-waiting/references/patterns-and-implementation.md +253 -0
  159. claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
  160. claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
  161. claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
  162. claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
  163. claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
  164. claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
  165. claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +140 -0
  166. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md +572 -0
  167. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/core-anti-patterns.md +411 -0
  168. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/detection-guide.md +569 -0
  169. claude_mpm/skills/bundled/testing/testing-anti-patterns/references/tdd-connection.md +695 -0
  170. claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +184 -0
  171. claude_mpm/skills/bundled/testing/webapp-testing/decision-tree.md +459 -0
  172. claude_mpm/skills/bundled/testing/webapp-testing/examples/console_logging.py +35 -0
  173. claude_mpm/skills/bundled/testing/webapp-testing/examples/element_discovery.py +44 -0
  174. claude_mpm/skills/bundled/testing/webapp-testing/examples/static_html_automation.py +34 -0
  175. claude_mpm/skills/bundled/testing/webapp-testing/playwright-patterns.md +479 -0
  176. claude_mpm/skills/bundled/testing/webapp-testing/reconnaissance-pattern.md +687 -0
  177. claude_mpm/skills/bundled/testing/webapp-testing/scripts/with_server.py +129 -0
  178. claude_mpm/skills/bundled/testing/webapp-testing/server-management.md +758 -0
  179. claude_mpm/skills/bundled/testing/webapp-testing/troubleshooting.md +868 -0
  180. claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
  181. claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
  182. claude_mpm/skills/bundled/xlsx.md +157 -0
  183. claude_mpm/skills/registry.py +97 -9
  184. claude_mpm/skills/skills_registry.py +348 -0
  185. claude_mpm/skills/skills_service.py +739 -0
  186. claude_mpm/utils/agent_dependency_loader.py +2 -2
  187. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/METADATA +211 -33
  188. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/RECORD +192 -60
  189. claude_mpm/agents/INSTRUCTIONS_OLD_DEPRECATED.md +0 -602
  190. claude_mpm/cli/commands/mpm_init.py +0 -2008
  191. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/WHEEL +0 -0
  192. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/entry_points.txt +0 -0
  193. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/licenses/LICENSE +0 -0
  194. {claude_mpm-4.15.6.dist-info → claude_mpm-4.21.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,312 @@
1
+ # Plan Structure Templates
2
+
3
+ ## Standard Plan Document Header
4
+
5
+ **Every plan MUST start with this header:**
6
+
7
+ ```markdown
8
+ # [Feature Name] Implementation Plan
9
+
10
+ > **For Claude:** Use `${SUPERPOWERS_SKILLS_ROOT}/skills/collaboration/executing-plans/SKILL.md` to implement this plan task-by-task.
11
+
12
+ **Goal:** [One sentence describing what this builds]
13
+
14
+ **Architecture:** [2-3 sentences about approach]
15
+
16
+ **Tech Stack:** [Key technologies/libraries]
17
+
18
+ ---
19
+ ```
20
+
21
+ ## Task Template Structure
22
+
23
+ ```markdown
24
+ ### Task N: [Component Name]
25
+
26
+ **Files:**
27
+ - Create: `exact/path/to/file.py`
28
+ - Modify: `exact/path/to/existing.py:123-145`
29
+ - Test: `tests/exact/path/to/test.py`
30
+
31
+ **Step 1: Write the failing test**
32
+
33
+ ```python
34
+ def test_specific_behavior():
35
+ result = function(input)
36
+ assert result == expected
37
+ ```
38
+
39
+ **Step 2: Run test to verify it fails**
40
+
41
+ Run: `pytest tests/path/test.py::test_name -v`
42
+ Expected: FAIL with "function not defined"
43
+
44
+ **Step 3: Write minimal implementation**
45
+
46
+ ```python
47
+ def function(input):
48
+ return expected
49
+ ```
50
+
51
+ **Step 4: Run test to verify it passes**
52
+
53
+ Run: `pytest tests/path/test.py::test_name -v`
54
+ Expected: PASS
55
+
56
+ **Step 5: Commit**
57
+
58
+ ```bash
59
+ git add tests/path/test.py src/path/file.py
60
+ git commit -m "feat: add specific feature"
61
+ ```
62
+ ```
63
+
64
+ ## Bite-Sized Task Examples
65
+
66
+ ### Example 1: Database Model
67
+
68
+ ```markdown
69
+ ### Task 1: User Model and Schema
70
+
71
+ **Files:**
72
+ - Create: `src/models/user.py`
73
+ - Create: `tests/models/test_user.py`
74
+ - Create: `migrations/001_create_users_table.sql`
75
+
76
+ **Step 1: Write the failing test**
77
+
78
+ ```python
79
+ def test_user_model_creation():
80
+ user = User(username="alice", email="alice@example.com")
81
+ assert user.username == "alice"
82
+ assert user.email == "alice@example.com"
83
+ assert user.created_at is not None
84
+ ```
85
+
86
+ **Step 2: Run test to verify it fails**
87
+
88
+ Run: `pytest tests/models/test_user.py::test_user_model_creation -v`
89
+ Expected: FAIL with "ModuleNotFoundError: No module named 'models.user'"
90
+
91
+ **Step 3: Write minimal implementation**
92
+
93
+ In `src/models/user.py`:
94
+ ```python
95
+ from datetime import datetime
96
+ from dataclasses import dataclass
97
+
98
+ @dataclass
99
+ class User:
100
+ username: str
101
+ email: str
102
+ created_at: datetime = None
103
+
104
+ def __post_init__(self):
105
+ if self.created_at is None:
106
+ self.created_at = datetime.utcnow()
107
+ ```
108
+
109
+ **Step 4: Run test to verify it passes**
110
+
111
+ Run: `pytest tests/models/test_user.py::test_user_model_creation -v`
112
+ Expected: PASS
113
+
114
+ **Step 5: Commit**
115
+
116
+ ```bash
117
+ git add src/models/user.py tests/models/test_user.py
118
+ git commit -m "feat: add User model with basic fields"
119
+ ```
120
+ ```
121
+
122
+ ### Example 2: API Endpoint
123
+
124
+ ```markdown
125
+ ### Task 3: GET /users/:id Endpoint
126
+
127
+ **Files:**
128
+ - Modify: `src/api/routes.py:15` (add route)
129
+ - Create: `src/api/handlers/users.py`
130
+ - Create: `tests/api/test_users_endpoint.py`
131
+
132
+ **Step 1: Write the failing test**
133
+
134
+ ```python
135
+ def test_get_user_by_id(client, db_with_users):
136
+ response = client.get("/users/1")
137
+ assert response.status_code == 200
138
+ assert response.json["username"] == "alice"
139
+ assert response.json["email"] == "alice@example.com"
140
+ ```
141
+
142
+ **Step 2: Run test to verify it fails**
143
+
144
+ Run: `pytest tests/api/test_users_endpoint.py::test_get_user_by_id -v`
145
+ Expected: FAIL with "404 Not Found"
146
+
147
+ **Step 3: Write minimal implementation**
148
+
149
+ In `src/api/handlers/users.py`:
150
+ ```python
151
+ from flask import jsonify
152
+ from src.models.user import User
153
+ from src.db import get_db
154
+
155
+ def get_user(user_id):
156
+ db = get_db()
157
+ user = db.query(User).filter(User.id == user_id).first()
158
+ if not user:
159
+ return jsonify({"error": "User not found"}), 404
160
+ return jsonify({
161
+ "id": user.id,
162
+ "username": user.username,
163
+ "email": user.email
164
+ })
165
+ ```
166
+
167
+ In `src/api/routes.py` at line 15:
168
+ ```python
169
+ from src.api.handlers.users import get_user
170
+
171
+ # Add this route
172
+ app.route("/users/<int:user_id>", methods=["GET"])(get_user)
173
+ ```
174
+
175
+ **Step 4: Run test to verify it passes**
176
+
177
+ Run: `pytest tests/api/test_users_endpoint.py::test_get_user_by_id -v`
178
+ Expected: PASS
179
+
180
+ **Step 5: Commit**
181
+
182
+ ```bash
183
+ git add src/api/handlers/users.py src/api/routes.py tests/api/test_users_endpoint.py
184
+ git commit -m "feat: add GET /users/:id endpoint"
185
+ ```
186
+ ```
187
+
188
+ ## Granularity Guidelines
189
+
190
+ **Each step should take 2-5 minutes:**
191
+
192
+ ✅ **Good granularity:**
193
+ - "Write the failing test" - single test function
194
+ - "Run it to make sure it fails" - one command
195
+ - "Implement the minimal code to make the test pass" - focused function
196
+ - "Run the tests and make sure they pass" - verify
197
+ - "Commit" - checkpoint
198
+
199
+ ❌ **Too large (split these up):**
200
+ - "Implement the user authentication system" - needs 10+ tasks
201
+ - "Add validation and error handling" - multiple tests/steps
202
+ - "Create all the models" - one task per model
203
+
204
+ ❌ **Too small (combine these):**
205
+ - "Import the datetime module" - part of implementation step
206
+ - "Type the function signature" - part of implementation step
207
+ - "Add one line of code" - too granular
208
+
209
+ ## Multi-File Task Structure
210
+
211
+ When a task involves multiple related files:
212
+
213
+ ```markdown
214
+ ### Task 4: Email Validation with Helper
215
+
216
+ **Files:**
217
+ - Create: `src/utils/validators.py`
218
+ - Create: `tests/utils/test_validators.py`
219
+ - Modify: `src/models/user.py:12` (use validator)
220
+ - Modify: `tests/models/test_user.py` (add validation tests)
221
+
222
+ **Step 1: Write failing test for validator**
223
+
224
+ In `tests/utils/test_validators.py`:
225
+ ```python
226
+ def test_validate_email_valid():
227
+ assert validate_email("alice@example.com") == True
228
+
229
+ def test_validate_email_invalid():
230
+ assert validate_email("not-an-email") == False
231
+ ```
232
+
233
+ **Step 2: Run validator test to verify it fails**
234
+
235
+ Run: `pytest tests/utils/test_validators.py -v`
236
+ Expected: FAIL with "NameError: name 'validate_email' is not defined"
237
+
238
+ **Step 3: Implement email validator**
239
+
240
+ In `src/utils/validators.py`:
241
+ ```python
242
+ import re
243
+
244
+ def validate_email(email: str) -> bool:
245
+ pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
246
+ return bool(re.match(pattern, email))
247
+ ```
248
+
249
+ **Step 4: Run validator test to verify it passes**
250
+
251
+ Run: `pytest tests/utils/test_validators.py -v`
252
+ Expected: PASS (both tests)
253
+
254
+ **Step 5: Write failing test for User model validation**
255
+
256
+ In `tests/models/test_user.py`:
257
+ ```python
258
+ def test_user_model_rejects_invalid_email():
259
+ with pytest.raises(ValueError, match="Invalid email"):
260
+ User(username="alice", email="not-an-email")
261
+ ```
262
+
263
+ **Step 6: Run User model test to verify it fails**
264
+
265
+ Run: `pytest tests/models/test_user.py::test_user_model_rejects_invalid_email -v`
266
+ Expected: FAIL (no validation yet)
267
+
268
+ **Step 7: Add validation to User model**
269
+
270
+ In `src/models/user.py` at line 12:
271
+ ```python
272
+ from src.utils.validators import validate_email
273
+
274
+ @dataclass
275
+ class User:
276
+ username: str
277
+ email: str
278
+ created_at: datetime = None
279
+
280
+ def __post_init__(self):
281
+ if not validate_email(self.email):
282
+ raise ValueError(f"Invalid email: {self.email}")
283
+ if self.created_at is None:
284
+ self.created_at = datetime.utcnow()
285
+ ```
286
+
287
+ **Step 8: Run User model test to verify it passes**
288
+
289
+ Run: `pytest tests/models/test_user.py::test_user_model_rejects_invalid_email -v`
290
+ Expected: PASS
291
+
292
+ **Step 9: Run all tests to ensure nothing broke**
293
+
294
+ Run: `pytest tests/ -v`
295
+ Expected: All tests PASS
296
+
297
+ **Step 10: Commit**
298
+
299
+ ```bash
300
+ git add src/utils/validators.py tests/utils/test_validators.py src/models/user.py tests/models/test_user.py
301
+ git commit -m "feat: add email validation to User model"
302
+ ```
303
+ ```
304
+
305
+ ## Plan File Naming Convention
306
+
307
+ Save plans to: `docs/plans/YYYY-MM-DD-<feature-name>.md`
308
+
309
+ **Examples:**
310
+ - `docs/plans/2025-01-15-user-authentication.md`
311
+ - `docs/plans/2025-01-16-api-rate-limiting.md`
312
+ - `docs/plans/2025-01-17-database-migration-users.md`
@@ -0,0 +1,199 @@
1
+ ---
2
+ skill_id: database-migration
3
+ skill_version: 0.1.0
4
+ description: Safe patterns for evolving database schemas in production.
5
+ updated_at: 2025-10-30T17:00:00Z
6
+ tags: [database, migration, schema, production]
7
+ ---
8
+
9
+ # Database Migration
10
+
11
+ Safe patterns for evolving database schemas in production.
12
+
13
+ ## Migration Principles
14
+
15
+ 1. **Backward compatible** - New code works with old schema
16
+ 2. **Reversible** - Can rollback if needed
17
+ 3. **Tested** - Verify on staging before production
18
+ 4. **Incremental** - Small changes, not big-bang
19
+ 5. **Zero downtime** - No service interruption
20
+
21
+ ## Safe Migration Pattern
22
+
23
+ ### Phase 1: Add New (Compatible)
24
+ ```sql
25
+ -- Add new column (nullable initially)
26
+ ALTER TABLE users ADD COLUMN full_name VARCHAR(255) NULL;
27
+
28
+ -- Deploy new code that writes to both old and new
29
+ UPDATE users SET full_name = CONCAT(first_name, ' ', last_name);
30
+ ```
31
+
32
+ ### Phase 2: Migrate Data
33
+ ```sql
34
+ -- Backfill existing data
35
+ UPDATE users
36
+ SET full_name = CONCAT(first_name, ' ', last_name)
37
+ WHERE full_name IS NULL;
38
+ ```
39
+
40
+ ### Phase 3: Make Required
41
+ ```sql
42
+ -- Make column required
43
+ ALTER TABLE users ALTER COLUMN full_name SET NOT NULL;
44
+ ```
45
+
46
+ ### Phase 4: Remove Old (After New Code Deployed)
47
+ ```sql
48
+ -- Remove old columns
49
+ ALTER TABLE users DROP COLUMN first_name;
50
+ ALTER TABLE users DROP COLUMN last_name;
51
+ ```
52
+
53
+ ## Common Migrations
54
+
55
+ ### Adding Index
56
+ ```sql
57
+ -- Create index concurrently (PostgreSQL)
58
+ CREATE INDEX CONCURRENTLY idx_users_email ON users(email);
59
+ ```
60
+
61
+ ### Renaming Column
62
+ ```sql
63
+ -- Phase 1: Add new column
64
+ ALTER TABLE users ADD COLUMN email_address VARCHAR(255);
65
+
66
+ -- Phase 2: Copy data
67
+ UPDATE users SET email_address = email;
68
+
69
+ -- Phase 3: Drop old column (after deploy)
70
+ ALTER TABLE users DROP COLUMN email;
71
+ ```
72
+
73
+ ### Changing Column Type
74
+ ```sql
75
+ -- Phase 1: Add new column with new type
76
+ ALTER TABLE products ADD COLUMN price_cents INTEGER;
77
+
78
+ -- Phase 2: Migrate data
79
+ UPDATE products SET price_cents = CAST(price * 100 AS INTEGER);
80
+
81
+ -- Phase 3: Drop old column
82
+ ALTER TABLE products DROP COLUMN price;
83
+ ALTER TABLE products RENAME COLUMN price_cents TO price;
84
+ ```
85
+
86
+ ### Adding Foreign Key
87
+ ```sql
88
+ -- Add column first
89
+ ALTER TABLE orders ADD COLUMN user_id INTEGER NULL;
90
+
91
+ -- Populate data
92
+ UPDATE orders SET user_id = (
93
+ SELECT id FROM users WHERE users.email = orders.user_email
94
+ );
95
+
96
+ -- Add foreign key
97
+ ALTER TABLE orders
98
+ ADD CONSTRAINT fk_orders_users
99
+ FOREIGN KEY (user_id) REFERENCES users(id);
100
+ ```
101
+
102
+ ## Migration Tools
103
+
104
+ ### Python (Alembic)
105
+ ```python
106
+ # Generate migration
107
+ alembic revision --autogenerate -m "add user full_name"
108
+
109
+ # Apply migration
110
+ alembic upgrade head
111
+
112
+ # Rollback
113
+ alembic downgrade -1
114
+ ```
115
+
116
+ ### JavaScript (Knex)
117
+ ```javascript
118
+ // Create migration
119
+ knex migrate:make add_full_name
120
+
121
+ // Apply migrations
122
+ knex migrate:latest
123
+
124
+ // Rollback
125
+ knex migrate:rollback
126
+ ```
127
+
128
+ ### Rails
129
+ ```ruby
130
+ # Generate migration
131
+ rails generate migration AddFullNameToUsers full_name:string
132
+
133
+ # Run migrations
134
+ rails db:migrate
135
+
136
+ # Rollback
137
+ rails db:rollback
138
+ ```
139
+
140
+ ## Testing Migrations
141
+
142
+ ```python
143
+ def test_migration_forward_backward():
144
+ # Apply migration
145
+ apply_migration("add_full_name")
146
+
147
+ # Verify schema
148
+ assert column_exists("users", "full_name")
149
+
150
+ # Rollback
151
+ rollback_migration()
152
+
153
+ # Verify rollback
154
+ assert not column_exists("users", "full_name")
155
+ ```
156
+
157
+ ## Dangerous Operations
158
+
159
+ ### ❌ Avoid in Production
160
+ ```sql
161
+ -- Locks table for long time
162
+ ALTER TABLE users ADD COLUMN email VARCHAR(255) NOT NULL;
163
+
164
+ -- Can't rollback
165
+ DROP TABLE old_users;
166
+
167
+ -- Breaks existing code immediately
168
+ ALTER TABLE users DROP COLUMN email;
169
+ ```
170
+
171
+ ### ✅ Safe Alternatives
172
+ ```sql
173
+ -- Add as nullable first
174
+ ALTER TABLE users ADD COLUMN email VARCHAR(255) NULL;
175
+
176
+ -- Rename instead of drop
177
+ ALTER TABLE old_users RENAME TO archived_users;
178
+
179
+ -- Keep old column until new code deployed
180
+ -- (multi-phase approach)
181
+ ```
182
+
183
+ ## Rollback Strategy
184
+
185
+ ```sql
186
+ -- Every migration needs DOWN
187
+ -- UP
188
+ ALTER TABLE users ADD COLUMN full_name VARCHAR(255);
189
+
190
+ -- DOWN
191
+ ALTER TABLE users DROP COLUMN full_name;
192
+ ```
193
+
194
+ ## Remember
195
+ - Test migrations on copy of production data
196
+ - Have rollback plan ready
197
+ - Monitor during deployment
198
+ - Communicate with team about schema changes
199
+ - Keep migrations small and focused
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: Root Cause Tracing
3
+ description: Systematically trace bugs backward through call stack to find original trigger
4
+ when_to_use: when errors occur deep in execution and you need to trace back to find the original trigger
5
+ version: 2.0.0
6
+ languages: all
7
+ progressive_disclosure:
8
+ entry_point:
9
+ summary: "Trace bugs backward through call chains to find original triggers instead of fixing symptoms"
10
+ when_to_use: "When errors manifest deep in execution, unclear data origins, or long call chains. Use AFTER systematic-debugging Phase 1."
11
+ quick_start: "1. Observe symptom 2. Find immediate cause 3. Ask what called this 4. Keep tracing up 5. Fix at source + add defense"
12
+ references:
13
+ - tracing-techniques.md
14
+ - examples.md
15
+ - advanced-techniques.md
16
+ - integration.md
17
+ context_limit: 800
18
+ tags:
19
+ - debugging
20
+ - root-cause
21
+ - tracing
22
+ - call-stack
23
+ ---
24
+
25
+ # Root Cause Tracing
26
+
27
+ ## Overview
28
+
29
+ Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
30
+
31
+ **Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
32
+
33
+ This skill is a specialized technique within the systematic-debugging workflow, typically applied during Phase 1 (Root Cause Investigation) when dealing with deep call stacks.
34
+
35
+ ## When to Use This Skill
36
+
37
+ **Use root-cause-tracing when:**
38
+ - Error happens deep in execution (not at entry point)
39
+ - Stack trace shows long call chain
40
+ - Unclear where invalid data originated
41
+ - Need to find which test/code triggers the problem
42
+ - Symptom appears far from actual cause
43
+
44
+ **Relationship with systematic-debugging:**
45
+ - systematic-debugging: The overall framework (Phases 1-4)
46
+ - root-cause-tracing: A specific technique for Phase 1 investigation
47
+ - Use root-cause-tracing WITHIN systematic-debugging Phase 1
48
+
49
+ ## The Iron Law
50
+
51
+ ```
52
+ NEVER FIX JUST WHERE THE ERROR APPEARS
53
+ ALWAYS TRACE BACK TO FIND THE ORIGINAL TRIGGER
54
+ ```
55
+
56
+ Fixing symptoms creates bandaid solutions that mask root problems.
57
+
58
+ ## Core Principles
59
+
60
+ 1. **Trace Backward**: Follow call chain from symptom to source
61
+ 2. **Find Original Trigger**: Identify where bad data/state originated
62
+ 3. **Fix at Source**: Address root cause, not symptom
63
+ 4. **Defense-in-Depth**: Add validation at each layer after fixing source
64
+
65
+ ## Quick Start
66
+
67
+ ### The 5-Step Trace Process
68
+
69
+ 1. **Observe the Symptom**: What error message? What failed operation?
70
+ 2. **Find Immediate Cause**: What code directly causes this error?
71
+ 3. **Ask What Called This**: Trace one level up the call stack
72
+ 4. **Keep Tracing Up**: Continue until you find the original trigger
73
+ 5. **Fix at Source + Defense**: Fix root cause and add layer validation
74
+
75
+ ### Decision Tree
76
+
77
+ ```
78
+ Error appears deep in stack?
79
+ → Yes: Start tracing backward
80
+ → Can identify caller? → Trace one level up → Repeat
81
+ → Cannot identify caller? → Add instrumentation (see advanced-techniques.md)
82
+ → No: May not need tracing (error at entry point)
83
+ ```
84
+
85
+ ## The Tracing Process
86
+
87
+ **Example: Git init in wrong directory**
88
+ ```
89
+ Error symptom → execFileAsync('git', ['init'], { cwd: '' })
90
+ ← WorktreeManager.createSessionWorktree(projectDir='')
91
+ ← Session.create() → Project.create() → Test code
92
+ ← ROOT CAUSE: setupCoreTest() returns { tempDir: '' } before beforeEach
93
+ ```
94
+
95
+ **At each level ask:** Where did this value come from? Is this the origin?
96
+
97
+ **For detailed tracing methodology, see [Tracing Techniques](references/tracing-techniques.md)**
98
+ **For complete real-world examples, see [Examples](references/examples.md)**
99
+
100
+ ## After Finding Root Cause
101
+
102
+ **Fix at source** (throw if accessed before initialization) + **Add defense-in-depth** (validate at Project.create, WorkspaceManager, environment guards, instrumentation).
103
+
104
+ This prevents similar bugs and catches issues earlier.
105
+
106
+ ## Navigation
107
+
108
+ For detailed information:
109
+ - **[Tracing Techniques](references/tracing-techniques.md)**: Complete tracing methodology, patterns, and decision trees
110
+ - **[Examples](references/examples.md)**: Real-world debugging scenarios with full trace chains
111
+ - **[Advanced Techniques](references/advanced-techniques.md)**: Stack traces, instrumentation, test pollution detection
112
+ - **[Integration](references/integration.md)**: How to use with systematic-debugging and other skills
113
+
114
+ ## Key Reminders
115
+
116
+ - NEVER fix just where the error appears
117
+ - ALWAYS trace back to find the original trigger
118
+ - Use `console.error()` for debugging in tests (logger may be suppressed)
119
+ - Log BEFORE the dangerous operation, not after it fails
120
+ - Include context: directory, cwd, environment, timestamps
121
+ - Add defense-in-depth after fixing source
122
+ - Document your trace as you go (write down the call chain)
123
+
124
+ ## Red Flags - STOP
125
+
126
+ If you catch yourself thinking:
127
+ - "I'll just add validation here" (without finding source)
128
+ - "This will prevent the error" (symptom fix)
129
+ - "Too hard to trace back" (add instrumentation instead)
130
+ - "Quick fix for now" (creates technical debt)
131
+
132
+ **ALL of these mean: Continue tracing to find root cause.**
133
+
134
+ ## Integration with Other Skills
135
+
136
+ - **systematic-debugging**: Use root-cause-tracing during Phase 1
137
+ - **defense-in-depth**: Add after finding root cause
138
+ - **verification-before-completion**: Verify fix worked at source
139
+ - **test-driven-development**: Write test for root cause, not symptom
140
+
141
+ See [Integration](references/integration.md) for complete workflow examples.
142
+
143
+ ## Real-World Impact
144
+
145
+ From debugging session (2025-10-03):
146
+ - Found root cause through 5-level trace
147
+ - Fixed at source (getter validation)
148
+ - Added 4 layers of defense
149
+ - 1847 tests passed, zero pollution
150
+ - Time saved: 3+ hours vs symptom-fix approach
151
+
152
+ **Bottom line:** Tracing takes 15-30 minutes. Symptom fixes take hours of whack-a-mole.