claude-mpm 4.17.0__py3-none-any.whl → 4.18.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.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/BASE_PM.md +48 -17
- claude_mpm/agents/agent_loader.py +4 -4
- claude_mpm/agents/templates/svelte-engineer.json +225 -0
- claude_mpm/config/agent_config.py +2 -2
- claude_mpm/core/factories.py +1 -1
- claude_mpm/core/optimized_agent_loader.py +3 -3
- claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
- claude_mpm/models/resume_log.py +340 -0
- claude_mpm/services/agents/auto_config_manager.py +1 -1
- claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
- claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
- claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
- claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
- claude_mpm/services/agents/local_template_manager.py +1 -1
- claude_mpm/services/core/path_resolver.py +1 -1
- claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
- claude_mpm/services/mcp_config_manager.py +2 -2
- claude_mpm/services/session_manager.py +205 -1
- claude_mpm/services/unified/deployment_strategies/local.py +1 -1
- claude_mpm/skills/bundled/api-documentation.md +393 -0
- claude_mpm/skills/bundled/async-testing.md +571 -0
- claude_mpm/skills/bundled/code-review.md +143 -0
- claude_mpm/skills/bundled/database-migration.md +199 -0
- claude_mpm/skills/bundled/docker-containerization.md +194 -0
- claude_mpm/skills/bundled/express-local-dev.md +1429 -0
- claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
- claude_mpm/skills/bundled/git-workflow.md +414 -0
- claude_mpm/skills/bundled/imagemagick.md +204 -0
- claude_mpm/skills/bundled/json-data-handling.md +223 -0
- claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
- claude_mpm/skills/bundled/pdf.md +141 -0
- claude_mpm/skills/bundled/performance-profiling.md +567 -0
- claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
- claude_mpm/skills/bundled/security-scanning.md +327 -0
- claude_mpm/skills/bundled/systematic-debugging.md +473 -0
- claude_mpm/skills/bundled/test-driven-development.md +378 -0
- claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
- claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
- claude_mpm/skills/bundled/xlsx.md +157 -0
- claude_mpm/utils/agent_dependency_loader.py +2 -2
- {claude_mpm-4.17.0.dist-info → claude_mpm-4.18.0.dist-info}/METADATA +68 -1
- {claude_mpm-4.17.0.dist-info → claude_mpm-4.18.0.dist-info}/RECORD +47 -24
- {claude_mpm-4.17.0.dist-info → claude_mpm-4.18.0.dist-info}/WHEEL +0 -0
- {claude_mpm-4.17.0.dist-info → claude_mpm-4.18.0.dist-info}/entry_points.txt +0 -0
- {claude_mpm-4.17.0.dist-info → claude_mpm-4.18.0.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-4.17.0.dist-info → claude_mpm-4.18.0.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
|