@dzhechkov/keysarium 1.4.0 → 1.5.0
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.
- package/README.md +50 -3
- package/bin/cli.js +0 -0
- package/package.json +5 -3
- package/templates/.claude/commands/analyst-manual.md +38 -0
- package/templates/.claude/commands/casarium.md +55 -4
- package/templates/.claude/commands/feature-adr.md +8 -0
- package/templates/.claude/rules/trust-tiers.md +5 -0
- package/templates/.claude/shards/feature-adr.shard.md +64 -10
- package/templates/.claude/shards/phase-ai-factory.shard.md +109 -0
- package/templates/.claude/skills/ai-factory-mapper/README.md +90 -0
- package/templates/.claude/skills/ai-factory-mapper/SKILL.md +309 -0
- package/templates/.claude/skills/ai-factory-mapper/assets/report-template.md +123 -0
- package/templates/.claude/skills/ai-factory-mapper/references/catalog.md +230 -0
- package/templates/.claude/skills/ai-factory-mapper/references/coverage-formula.md +219 -0
- package/templates/.claude/skills/ai-factory-mapper/references/decomposition-checklist.md +183 -0
- package/templates/.claude/skills/ai-factory-mapper/references/pattern-library.md +312 -0
- package/templates/.claude/skills/ai-factory-mapper/scripts/build_docx_report.js +423 -0
- package/templates/.claude/skills/analyst-manual-full/SKILL.md +286 -0
- package/templates/.claude/skills/edu-site-generator/SKILL.md +254 -0
- package/templates/.claude/skills/edu-site-generator/examples/sample-course-structure.md +116 -0
- package/templates/.claude/skills/edu-site-generator/modules/00-content-analysis.md +84 -0
- package/templates/.claude/skills/edu-site-generator/modules/01-course-structure.md +75 -0
- package/templates/.claude/skills/edu-site-generator/modules/02-data-generation.md +186 -0
- package/templates/.claude/skills/edu-site-generator/modules/03-scaffold.md +249 -0
- package/templates/.claude/skills/edu-site-generator/modules/04-components.md +130 -0
- package/templates/.claude/skills/edu-site-generator/modules/05-gamification.md +163 -0
- package/templates/.claude/skills/edu-site-generator/modules/06-deploy.md +88 -0
- package/templates/.claude/skills/edu-site-generator/modules/07-verification.md +97 -0
- package/templates/.claude/skills/edu-site-generator/references/component-templates.md +436 -0
- package/templates/.claude/skills/edu-site-generator/references/data-schemas.md +164 -0
- package/templates/.claude/skills/edu-site-generator/references/exercise-catalog.md +110 -0
- package/templates/.claude/skills/edu-site-generator/references/tech-stack.md +69 -0
- package/templates/.claude/skills/feature-adr/SKILL.md +245 -59
- package/templates/.claude/skills/feature-adr/modules/03-adr.md +43 -0
- package/templates/.claude/skills/feature-adr/modules/03.5-ideation-swarm.md +180 -0
- package/templates/.claude/skills/feature-adr/modules/06-implementation-plan.md +56 -7
- package/templates/.claude/skills/feature-adr/modules/08-qe.md +87 -23
- package/templates/.claude/skills/feature-adr/modules/09-fleet-qe.md +305 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/README.md +143 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/brutal-honesty-review.md +240 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/chaos-engineering-resilience.md +163 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/code-goal-planner.md +446 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/enterprise-integration-testing.md +111 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/mutation-testing.md +236 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/performance-testing.md +315 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/qcsd-ideation-swarm.md +126 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/qcsd-production-swarm.md +108 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/qe-coverage-analysis.md +193 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/qe-requirements-validation.md +254 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/regression-testing.md +233 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/risk-based-testing.md +212 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/security-testing.md +311 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/shift-left-testing.md +231 -0
- package/templates/.claude/skills/feature-adr/references/agentic-qe/tdd-london-chicago.md +249 -0
- package/templates/.claude/skills/transcript-site-generator/SKILL.md +287 -0
- package/templates/.claude/skills/transcript-site-generator/examples/sample-text-only-site.md +123 -0
- package/templates/.claude/skills/transcript-site-generator/examples/sample-transcript-site.md +134 -0
- package/templates/.claude/skills/transcript-site-generator/modules/00-input-analysis.md +132 -0
- package/templates/.claude/skills/transcript-site-generator/modules/01-content-parsing.md +117 -0
- package/templates/.claude/skills/transcript-site-generator/modules/02-site-generation.md +293 -0
- package/templates/.claude/skills/transcript-site-generator/modules/03-interactivity.md +406 -0
- package/templates/.claude/skills/transcript-site-generator/modules/04-deploy.md +130 -0
- package/templates/.claude/skills/transcript-site-generator/modules/05-verification.md +155 -0
- package/templates/.claude/skills/transcript-site-generator/references/component-catalog.md +86 -0
- package/templates/.claude/skills/transcript-site-generator/references/data-schemas.md +123 -0
- package/templates/.claude/skills/transcript-site-generator/references/tech-stack.md +132 -0
- package/templates/CLAUDE.md +9 -2
- package/templates/docs/edu-site-generator/01-deployment-guide.md +911 -0
- package/templates/docs/edu-site-generator/02-admin-guide.md +901 -0
- package/templates/docs/edu-site-generator/03-user-guide.md +1008 -0
- package/templates/docs/edu-site-generator/04-infrastructure-requirements.md +489 -0
- package/templates/docs/edu-site-generator/05-architecture.md +902 -0
- package/templates/docs/edu-site-generator/06-user-flows.md +759 -0
- package/templates/docs/transcript-site-generator/01-deployment-guide.md +1042 -0
- package/templates/docs/transcript-site-generator/02-admin-guide.md +918 -0
- package/templates/docs/transcript-site-generator/03-user-guide.md +925 -0
- package/templates/docs/transcript-site-generator/04-infrastructure-requirements.md +482 -0
- package/templates/docs/transcript-site-generator/05-architecture.md +1068 -0
- package/templates/docs/transcript-site-generator/06-user-flows.md +855 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-testing
|
|
3
|
+
description: "Test for security vulnerabilities using OWASP principles. Use when conducting security audits, testing auth, or implementing security practices."
|
|
4
|
+
category: specialized-testing
|
|
5
|
+
priority: critical
|
|
6
|
+
tokenEstimate: 1200
|
|
7
|
+
agents: [qe-security-scanner, qe-api-contract-validator, qe-quality-analyzer]
|
|
8
|
+
implementation_status: optimized
|
|
9
|
+
optimization_version: 1.0
|
|
10
|
+
last_optimized: 2025-12-02
|
|
11
|
+
dependencies: []
|
|
12
|
+
quick_reference_card: true
|
|
13
|
+
tags: [security, owasp, sast, dast, vulnerabilities, auth, injection]
|
|
14
|
+
trust_tier: 3
|
|
15
|
+
validation:
|
|
16
|
+
schema_path: schemas/output.json
|
|
17
|
+
validator_path: scripts/validate-config.json
|
|
18
|
+
eval_path: evals/security-testing.yaml
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Security Testing
|
|
22
|
+
|
|
23
|
+
<default_to_action>
|
|
24
|
+
When testing security or conducting audits:
|
|
25
|
+
1. TEST OWASP Top 10 vulnerabilities systematically
|
|
26
|
+
2. VALIDATE authentication and authorization on every endpoint
|
|
27
|
+
3. SCAN dependencies for known vulnerabilities (npm audit)
|
|
28
|
+
4. CHECK for injection attacks (SQL, XSS, command)
|
|
29
|
+
5. VERIFY secrets aren't exposed in code/logs
|
|
30
|
+
|
|
31
|
+
**Quick Security Checks:**
|
|
32
|
+
- Access control → Test horizontal/vertical privilege escalation
|
|
33
|
+
- Crypto → Verify password hashing, HTTPS, no sensitive data exposed
|
|
34
|
+
- Injection → Test SQL injection, XSS, command injection
|
|
35
|
+
- Auth → Test weak passwords, session fixation, MFA enforcement
|
|
36
|
+
- Config → Check error messages don't leak info
|
|
37
|
+
|
|
38
|
+
**Critical Success Factors:**
|
|
39
|
+
- Think like an attacker, build like a defender
|
|
40
|
+
- Security is built in, not added at the end
|
|
41
|
+
- Test continuously in CI/CD, not just before release
|
|
42
|
+
</default_to_action>
|
|
43
|
+
|
|
44
|
+
## Quick Reference Card
|
|
45
|
+
|
|
46
|
+
### When to Use
|
|
47
|
+
- Security audits and penetration testing
|
|
48
|
+
- Testing authentication/authorization
|
|
49
|
+
- Validating input sanitization
|
|
50
|
+
- Reviewing security configuration
|
|
51
|
+
|
|
52
|
+
### OWASP Top 10 (2021)
|
|
53
|
+
| # | Vulnerability | Key Test |
|
|
54
|
+
|---|---------------|----------|
|
|
55
|
+
| 1 | Broken Access Control | User A accessing User B's data |
|
|
56
|
+
| 2 | Cryptographic Failures | Plaintext passwords, HTTP |
|
|
57
|
+
| 3 | Injection | SQL/XSS/command injection |
|
|
58
|
+
| 4 | Insecure Design | Rate limiting, session timeout |
|
|
59
|
+
| 5 | Security Misconfiguration | Verbose errors, exposed /admin |
|
|
60
|
+
| 6 | Vulnerable Components | npm audit, outdated packages |
|
|
61
|
+
| 7 | Auth Failures | Weak passwords, no MFA |
|
|
62
|
+
| 8 | Integrity Failures | Unsigned updates, malware |
|
|
63
|
+
| 9 | Logging Failures | No audit trail for breaches |
|
|
64
|
+
| 10 | SSRF | Server fetching internal URLs |
|
|
65
|
+
|
|
66
|
+
### Tools
|
|
67
|
+
| Type | Tool | Purpose |
|
|
68
|
+
|------|------|---------|
|
|
69
|
+
| SAST | SonarQube, Semgrep | Static code analysis |
|
|
70
|
+
| DAST | OWASP ZAP, Burp | Dynamic scanning |
|
|
71
|
+
| Deps | npm audit, Snyk | Dependency vulnerabilities |
|
|
72
|
+
| Secrets | git-secrets, TruffleHog | Secret scanning |
|
|
73
|
+
|
|
74
|
+
### Agent Coordination
|
|
75
|
+
- `qe-security-scanner`: Multi-layer SAST/DAST scanning
|
|
76
|
+
- `qe-api-contract-validator`: API security testing
|
|
77
|
+
- `qe-quality-analyzer`: Security code review
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Key Vulnerability Tests
|
|
82
|
+
|
|
83
|
+
### 1. Broken Access Control
|
|
84
|
+
```javascript
|
|
85
|
+
// Horizontal escalation - User A accessing User B's data
|
|
86
|
+
test('user cannot access another user\'s order', async () => {
|
|
87
|
+
const userAToken = await login('userA');
|
|
88
|
+
const userBOrder = await createOrder('userB');
|
|
89
|
+
|
|
90
|
+
const response = await api.get(`/orders/${userBOrder.id}`, {
|
|
91
|
+
headers: { Authorization: `Bearer ${userAToken}` }
|
|
92
|
+
});
|
|
93
|
+
expect(response.status).toBe(403);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Vertical escalation - Regular user accessing admin
|
|
97
|
+
test('regular user cannot access admin', async () => {
|
|
98
|
+
const userToken = await login('regularUser');
|
|
99
|
+
expect((await api.get('/admin/users', {
|
|
100
|
+
headers: { Authorization: `Bearer ${userToken}` }
|
|
101
|
+
})).status).toBe(403);
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. Injection Attacks
|
|
106
|
+
```javascript
|
|
107
|
+
// SQL Injection
|
|
108
|
+
test('prevents SQL injection', async () => {
|
|
109
|
+
const malicious = "' OR '1'='1";
|
|
110
|
+
const response = await api.get(`/products?search=${malicious}`);
|
|
111
|
+
expect(response.body.length).toBeLessThan(100); // Not all products
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// XSS
|
|
115
|
+
test('sanitizes HTML output', async () => {
|
|
116
|
+
const xss = '<script>alert("XSS")</script>';
|
|
117
|
+
await api.post('/comments', { text: xss });
|
|
118
|
+
|
|
119
|
+
const html = (await api.get('/comments')).body;
|
|
120
|
+
expect(html).toContain('<script>');
|
|
121
|
+
expect(html).not.toContain('<script>');
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 3. Cryptographic Failures
|
|
126
|
+
```javascript
|
|
127
|
+
test('passwords are hashed', async () => {
|
|
128
|
+
await db.users.create({ email: 'test@example.com', password: 'MyPassword123' });
|
|
129
|
+
const user = await db.users.findByEmail('test@example.com');
|
|
130
|
+
|
|
131
|
+
expect(user.password).not.toBe('MyPassword123');
|
|
132
|
+
expect(user.password).toMatch(/^\$2[aby]\$\d{2}\$/); // bcrypt
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('no sensitive data in API response', async () => {
|
|
136
|
+
const response = await api.get('/users/me');
|
|
137
|
+
expect(response.body).not.toHaveProperty('password');
|
|
138
|
+
expect(response.body).not.toHaveProperty('ssn');
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 4. Security Misconfiguration
|
|
143
|
+
```javascript
|
|
144
|
+
test('errors don\'t leak sensitive info', async () => {
|
|
145
|
+
const response = await api.post('/login', { email: 'nonexistent@test.com', password: 'wrong' });
|
|
146
|
+
expect(response.body.error).toBe('Invalid credentials'); // Generic message
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('sensitive endpoints not exposed', async () => {
|
|
150
|
+
const endpoints = ['/debug', '/.env', '/.git', '/admin'];
|
|
151
|
+
for (let ep of endpoints) {
|
|
152
|
+
expect((await fetch(`https://example.com${ep}`)).status).not.toBe(200);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 5. Rate Limiting
|
|
158
|
+
```javascript
|
|
159
|
+
test('rate limiting prevents brute force', async () => {
|
|
160
|
+
const responses = [];
|
|
161
|
+
for (let i = 0; i < 20; i++) {
|
|
162
|
+
responses.push(await api.post('/login', { email: 'test@example.com', password: 'wrong' }));
|
|
163
|
+
}
|
|
164
|
+
expect(responses.filter(r => r.status === 429).length).toBeGreaterThan(0);
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Security Checklist
|
|
171
|
+
|
|
172
|
+
### Authentication
|
|
173
|
+
- [ ] Strong password requirements (12+ chars)
|
|
174
|
+
- [ ] Password hashing (bcrypt, scrypt, Argon2)
|
|
175
|
+
- [ ] MFA for sensitive operations
|
|
176
|
+
- [ ] Account lockout after failed attempts
|
|
177
|
+
- [ ] Session ID changes after login
|
|
178
|
+
- [ ] Session timeout
|
|
179
|
+
|
|
180
|
+
### Authorization
|
|
181
|
+
- [ ] Check authorization on every request
|
|
182
|
+
- [ ] Least privilege principle
|
|
183
|
+
- [ ] No horizontal escalation
|
|
184
|
+
- [ ] No vertical escalation
|
|
185
|
+
|
|
186
|
+
### Data Protection
|
|
187
|
+
- [ ] HTTPS everywhere
|
|
188
|
+
- [ ] Encrypted at rest
|
|
189
|
+
- [ ] Secrets not in code/logs
|
|
190
|
+
- [ ] PII compliance (GDPR)
|
|
191
|
+
|
|
192
|
+
### Input Validation
|
|
193
|
+
- [ ] Server-side validation
|
|
194
|
+
- [ ] Parameterized queries (no SQL injection)
|
|
195
|
+
- [ ] Output encoding (no XSS)
|
|
196
|
+
- [ ] Rate limiting
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## CI/CD Integration
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
# GitHub Actions
|
|
204
|
+
security-checks:
|
|
205
|
+
steps:
|
|
206
|
+
- name: Dependency audit
|
|
207
|
+
run: npm audit --audit-level=high
|
|
208
|
+
|
|
209
|
+
- name: SAST scan
|
|
210
|
+
run: npm run sast
|
|
211
|
+
|
|
212
|
+
- name: Secret scan
|
|
213
|
+
uses: trufflesecurity/trufflehog@main
|
|
214
|
+
|
|
215
|
+
- name: DAST scan
|
|
216
|
+
if: github.ref == 'refs/heads/main'
|
|
217
|
+
run: docker run owasp/zap2docker-stable zap-baseline.py -t https://staging.example.com
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Pre-commit hooks:**
|
|
221
|
+
```bash
|
|
222
|
+
#!/bin/sh
|
|
223
|
+
git-secrets --scan
|
|
224
|
+
npm run lint:security
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Agent-Assisted Security Testing
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
// Comprehensive multi-layer scan
|
|
233
|
+
await Task("Security Scan", {
|
|
234
|
+
target: 'src/',
|
|
235
|
+
layers: { sast: true, dast: true, dependencies: true, secrets: true },
|
|
236
|
+
severity: ['critical', 'high', 'medium']
|
|
237
|
+
}, "qe-security-scanner");
|
|
238
|
+
|
|
239
|
+
// OWASP Top 10 testing
|
|
240
|
+
await Task("OWASP Scan", {
|
|
241
|
+
categories: ['broken-access-control', 'injection', 'cryptographic-failures'],
|
|
242
|
+
depth: 'comprehensive'
|
|
243
|
+
}, "qe-security-scanner");
|
|
244
|
+
|
|
245
|
+
// Validate fix
|
|
246
|
+
await Task("Validate Fix", {
|
|
247
|
+
vulnerability: 'CVE-2024-12345',
|
|
248
|
+
expectedResolution: 'upgrade package to v2.0.0',
|
|
249
|
+
retestAfterFix: true
|
|
250
|
+
}, "qe-security-scanner");
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Agent Coordination Hints
|
|
256
|
+
|
|
257
|
+
### Memory Namespace
|
|
258
|
+
```
|
|
259
|
+
aqe/security/
|
|
260
|
+
├── scans/* - Scan results
|
|
261
|
+
├── vulnerabilities/* - Found vulnerabilities
|
|
262
|
+
├── fixes/* - Remediation tracking
|
|
263
|
+
└── compliance/* - Compliance status
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Fleet Coordination
|
|
267
|
+
```typescript
|
|
268
|
+
const securityFleet = await FleetManager.coordinate({
|
|
269
|
+
strategy: 'security-testing',
|
|
270
|
+
agents: [
|
|
271
|
+
'qe-security-scanner',
|
|
272
|
+
'qe-api-contract-validator',
|
|
273
|
+
'qe-quality-analyzer',
|
|
274
|
+
'qe-deployment-readiness'
|
|
275
|
+
],
|
|
276
|
+
topology: 'parallel'
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Common Mistakes
|
|
283
|
+
|
|
284
|
+
### ❌ Security by Obscurity
|
|
285
|
+
Hiding admin at `/super-secret-admin` → **Use proper auth**
|
|
286
|
+
|
|
287
|
+
### ❌ Client-Side Validation Only
|
|
288
|
+
JavaScript validation can be bypassed → **Always validate server-side**
|
|
289
|
+
|
|
290
|
+
### ❌ Trusting User Input
|
|
291
|
+
Assuming input is safe → **Sanitize, validate, escape all input**
|
|
292
|
+
|
|
293
|
+
### ❌ Hardcoded Secrets
|
|
294
|
+
API keys in code → **Environment variables, secret management**
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Related Skills
|
|
299
|
+
- [agentic-quality-engineering](../agentic-quality-engineering/) - Security with agents
|
|
300
|
+
- [api-testing-patterns](../api-testing-patterns/) - API security testing
|
|
301
|
+
- [compliance-testing](../compliance-testing/) - GDPR, HIPAA, SOC2
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Remember
|
|
306
|
+
|
|
307
|
+
**Think like an attacker:** What would you try to break? Test that.
|
|
308
|
+
**Build like a defender:** Assume input is malicious until proven otherwise.
|
|
309
|
+
**Test continuously:** Security testing is ongoing, not one-time.
|
|
310
|
+
|
|
311
|
+
**With Agents:** Agents automate vulnerability scanning, track remediation, and validate fixes. Use agents to maintain security posture at scale.
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shift-left-testing
|
|
3
|
+
description: "Move testing activities earlier in the development lifecycle to catch defects when they're cheapest to fix. Use when implementing TDD, CI/CD, or early quality practices."
|
|
4
|
+
category: testing-methodologies
|
|
5
|
+
priority: high
|
|
6
|
+
tokenEstimate: 900
|
|
7
|
+
agents: [qe-test-generator, qe-requirements-validator, qe-regression-risk-analyzer]
|
|
8
|
+
implementation_status: optimized
|
|
9
|
+
optimization_version: 1.0
|
|
10
|
+
last_optimized: 2025-12-02
|
|
11
|
+
dependencies: []
|
|
12
|
+
quick_reference_card: true
|
|
13
|
+
tags: [shift-left, early-testing, tdd, bdd, ci-cd, prevention]
|
|
14
|
+
trust_tier: 3
|
|
15
|
+
validation:
|
|
16
|
+
schema_path: schemas/output.json
|
|
17
|
+
validator_path: scripts/validate-config.json
|
|
18
|
+
eval_path: evals/shift-left-testing.yaml
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Shift-Left Testing
|
|
23
|
+
|
|
24
|
+
<default_to_action>
|
|
25
|
+
When implementing early testing practices:
|
|
26
|
+
1. VALIDATE requirements before coding (testability, BDD scenarios)
|
|
27
|
+
2. WRITE tests before implementation (TDD red-green-refactor)
|
|
28
|
+
3. AUTOMATE in CI pipeline (every commit triggers tests)
|
|
29
|
+
4. FOLLOW test pyramid: Many unit (70%), some integration (20%), few E2E (10%)
|
|
30
|
+
5. FIX defects immediately - never let them accumulate
|
|
31
|
+
|
|
32
|
+
**Quick Shift-Left Levels:**
|
|
33
|
+
- Level 1: Unit tests with each PR (developer responsibility)
|
|
34
|
+
- Level 2: TDD practice (tests before code)
|
|
35
|
+
- Level 3: BDD/Example mapping in refinement (requirements testing)
|
|
36
|
+
- Level 4: Risk analysis in design (architecture testing)
|
|
37
|
+
|
|
38
|
+
**Critical Success Factors:**
|
|
39
|
+
- Defects found in requirements cost 1x; in production cost 100x
|
|
40
|
+
- Every commit must run automated tests
|
|
41
|
+
- Quality is built in, not tested in
|
|
42
|
+
</default_to_action>
|
|
43
|
+
|
|
44
|
+
## Quick Reference Card
|
|
45
|
+
|
|
46
|
+
### When to Use
|
|
47
|
+
- Reducing cost of defects
|
|
48
|
+
- Implementing CI/CD pipelines
|
|
49
|
+
- Starting TDD practice
|
|
50
|
+
- Improving requirements quality
|
|
51
|
+
|
|
52
|
+
### Cost of Defects by Phase
|
|
53
|
+
| Phase | Relative Cost | Example |
|
|
54
|
+
|-------|--------------|---------|
|
|
55
|
+
| Requirements | 1x | Fix doc: 30 min |
|
|
56
|
+
| Design | 5x | Redesign: few hours |
|
|
57
|
+
| Development | 10x | Code fix: 1 day |
|
|
58
|
+
| Testing | 20x | Fix + retest: 2 days |
|
|
59
|
+
| Production | 100x | Hotfix + rollback + investigation |
|
|
60
|
+
|
|
61
|
+
### Test Pyramid
|
|
62
|
+
```
|
|
63
|
+
/\ E2E (10%) - Critical user journeys
|
|
64
|
+
/ \
|
|
65
|
+
/ \ Integration (20%) - Component interactions
|
|
66
|
+
/ \
|
|
67
|
+
/________\ Unit (70%) - Fast, isolated, comprehensive
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Shift-Left Levels
|
|
71
|
+
| Level | Practice | When |
|
|
72
|
+
|-------|----------|------|
|
|
73
|
+
| 1 | Unit tests in PR | Before merge |
|
|
74
|
+
| 2 | TDD | Before implementation |
|
|
75
|
+
| 3 | BDD/Example Mapping | During refinement |
|
|
76
|
+
| 4 | Risk Analysis | During design |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Level 1: Tests in Every PR
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
# CI pipeline - tests run on every commit
|
|
84
|
+
name: CI
|
|
85
|
+
on: [push, pull_request]
|
|
86
|
+
jobs:
|
|
87
|
+
test:
|
|
88
|
+
runs-on: ubuntu-latest
|
|
89
|
+
steps:
|
|
90
|
+
- uses: actions/checkout@v4
|
|
91
|
+
- run: npm ci
|
|
92
|
+
- run: npm run test:unit
|
|
93
|
+
- run: npm run test:integration
|
|
94
|
+
- run: npm run lint
|
|
95
|
+
|
|
96
|
+
quality-gate:
|
|
97
|
+
needs: test
|
|
98
|
+
steps:
|
|
99
|
+
- name: Coverage Check
|
|
100
|
+
run: npx coverage-check --min 80
|
|
101
|
+
- name: No New Warnings
|
|
102
|
+
run: npm run lint -- --max-warnings 0
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Level 2: TDD Practice
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
// Red: Write failing test first
|
|
111
|
+
test('calculates discount for orders over $100', () => {
|
|
112
|
+
const order = new Order([{ price: 150 }]);
|
|
113
|
+
expect(order.discount).toBe(15); // 10% off
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Green: Minimal implementation
|
|
117
|
+
class Order {
|
|
118
|
+
get discount() {
|
|
119
|
+
return this.total > 100 ? this.total * 0.1 : 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Refactor: Improve while keeping green
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Level 3: BDD in Refinement
|
|
129
|
+
|
|
130
|
+
```gherkin
|
|
131
|
+
# Example mapping before coding
|
|
132
|
+
Feature: Loyalty Discount
|
|
133
|
+
Scenario: Gold member gets 15% discount
|
|
134
|
+
Given a customer with "gold" membership
|
|
135
|
+
When they checkout with $200 in cart
|
|
136
|
+
Then discount applied is $30
|
|
137
|
+
And order total is $170
|
|
138
|
+
|
|
139
|
+
Scenario: New customer gets no discount
|
|
140
|
+
Given a customer with no membership
|
|
141
|
+
When they checkout with $200 in cart
|
|
142
|
+
Then no discount is applied
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Level 4: Risk Analysis in Design
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// During architecture review
|
|
151
|
+
await Task("Risk Analysis", {
|
|
152
|
+
phase: 'design',
|
|
153
|
+
component: 'payment-service',
|
|
154
|
+
questions: [
|
|
155
|
+
'What happens when payment gateway times out?',
|
|
156
|
+
'How do we handle duplicate submissions?',
|
|
157
|
+
'What if inventory changed during checkout?'
|
|
158
|
+
]
|
|
159
|
+
}, "qe-requirements-validator");
|
|
160
|
+
|
|
161
|
+
// Output: Testability requirements, failure mode tests
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Agent-Assisted Shift-Left
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// Validate requirements testability
|
|
170
|
+
await Task("Requirements Validation", {
|
|
171
|
+
requirements: userStories,
|
|
172
|
+
check: ['INVEST-criteria', 'testability', 'ambiguity'],
|
|
173
|
+
generateBDD: true
|
|
174
|
+
}, "qe-requirements-validator");
|
|
175
|
+
|
|
176
|
+
// Generate tests from requirements
|
|
177
|
+
await Task("Generate Tests", {
|
|
178
|
+
source: 'requirements',
|
|
179
|
+
types: ['unit', 'integration', 'e2e'],
|
|
180
|
+
coverage: 'comprehensive'
|
|
181
|
+
}, "qe-test-generator");
|
|
182
|
+
|
|
183
|
+
// Smart test selection for changes
|
|
184
|
+
await Task("Select Regression Tests", {
|
|
185
|
+
changedFiles: prFiles,
|
|
186
|
+
algorithm: 'risk-based',
|
|
187
|
+
targetReduction: 0.7 // 70% time savings
|
|
188
|
+
}, "qe-regression-risk-analyzer");
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Agent Coordination Hints
|
|
194
|
+
|
|
195
|
+
### Memory Namespace
|
|
196
|
+
```
|
|
197
|
+
aqe/shift-left/
|
|
198
|
+
├── requirements/* - Validated requirements
|
|
199
|
+
├── generated-tests/* - Auto-generated tests
|
|
200
|
+
├── coverage-targets/* - Coverage goals by component
|
|
201
|
+
└── pipeline-results/* - CI/CD test history
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Fleet Coordination
|
|
205
|
+
```typescript
|
|
206
|
+
const shiftLeftFleet = await FleetManager.coordinate({
|
|
207
|
+
strategy: 'shift-left',
|
|
208
|
+
agents: [
|
|
209
|
+
'qe-requirements-validator', // Level 3-4
|
|
210
|
+
'qe-test-generator', // Level 2
|
|
211
|
+
'qe-regression-risk-analyzer' // Smart selection
|
|
212
|
+
],
|
|
213
|
+
topology: 'sequential'
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Related Skills
|
|
220
|
+
- [tdd-london-chicago](../tdd-london-chicago/) - TDD practices
|
|
221
|
+
- [holistic-testing-pact](../holistic-testing-pact/) - Proactive testing
|
|
222
|
+
- [cicd-pipeline-qe-orchestrator](../cicd-pipeline-qe-orchestrator/) - Pipeline integration
|
|
223
|
+
- [shift-right-testing](../shift-right-testing/) - Production feedback
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Remember
|
|
228
|
+
|
|
229
|
+
**Earlier = Cheaper.** Requirements defects cost 1x; production defects cost 100x. Test pyramid: 70% unit, 20% integration, 10% E2E. Every commit runs tests. TDD builds quality in.
|
|
230
|
+
|
|
231
|
+
**With Agents:** Agents validate requirements testability, generate tests from specs, and select optimal regression suites. Use agents to implement shift-left practices consistently.
|