@qazuor/claude-code-config 0.1.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.
Files changed (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1248 -0
  3. package/dist/bin.cjs +11886 -0
  4. package/dist/bin.cjs.map +1 -0
  5. package/dist/bin.d.cts +1 -0
  6. package/dist/bin.d.ts +1 -0
  7. package/dist/bin.js +11869 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/index.cjs +3887 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +1325 -0
  12. package/dist/index.d.ts +1325 -0
  13. package/dist/index.js +3835 -0
  14. package/dist/index.js.map +1 -0
  15. package/package.json +86 -0
  16. package/templates/.log/notifications.log +1775 -0
  17. package/templates/agents/README.md +164 -0
  18. package/templates/agents/_registry.json +443 -0
  19. package/templates/agents/design/content-writer.md +353 -0
  20. package/templates/agents/design/ux-ui-designer.md +382 -0
  21. package/templates/agents/engineering/astro-engineer.md +293 -0
  22. package/templates/agents/engineering/db-drizzle-engineer.md +360 -0
  23. package/templates/agents/engineering/express-engineer.md +316 -0
  24. package/templates/agents/engineering/fastify-engineer.md +399 -0
  25. package/templates/agents/engineering/hono-engineer.md +263 -0
  26. package/templates/agents/engineering/mongoose-engineer.md +473 -0
  27. package/templates/agents/engineering/nestjs-engineer.md +429 -0
  28. package/templates/agents/engineering/nextjs-engineer.md +451 -0
  29. package/templates/agents/engineering/node-typescript-engineer.md +347 -0
  30. package/templates/agents/engineering/prisma-engineer.md +432 -0
  31. package/templates/agents/engineering/react-senior-dev.md +394 -0
  32. package/templates/agents/engineering/tanstack-start-engineer.md +447 -0
  33. package/templates/agents/engineering/tech-lead.md +269 -0
  34. package/templates/agents/product/product-functional.md +329 -0
  35. package/templates/agents/product/product-technical.md +578 -0
  36. package/templates/agents/quality/debugger.md +514 -0
  37. package/templates/agents/quality/qa-engineer.md +390 -0
  38. package/templates/agents/specialized/enrichment-agent.md +277 -0
  39. package/templates/agents/specialized/i18n-specialist.md +322 -0
  40. package/templates/agents/specialized/seo-ai-specialist.md +387 -0
  41. package/templates/agents/specialized/tech-writer.md +300 -0
  42. package/templates/code-style/.editorconfig +27 -0
  43. package/templates/code-style/.prettierignore +25 -0
  44. package/templates/code-style/.prettierrc +12 -0
  45. package/templates/code-style/biome.json +78 -0
  46. package/templates/code-style/commitlint.config.js +44 -0
  47. package/templates/commands/README.md +175 -0
  48. package/templates/commands/_registry.json +420 -0
  49. package/templates/commands/add-new-entity.md +211 -0
  50. package/templates/commands/audit/accessibility-audit.md +360 -0
  51. package/templates/commands/audit/performance-audit.md +290 -0
  52. package/templates/commands/audit/security-audit.md +231 -0
  53. package/templates/commands/code-check.md +127 -0
  54. package/templates/commands/five-why.md +225 -0
  55. package/templates/commands/formatting/format-markdown.md +197 -0
  56. package/templates/commands/git/commit.md +247 -0
  57. package/templates/commands/meta/create-agent.md +257 -0
  58. package/templates/commands/meta/create-command.md +312 -0
  59. package/templates/commands/meta/create-skill.md +321 -0
  60. package/templates/commands/meta/help.md +318 -0
  61. package/templates/commands/planning/check-completed-tasks.md +224 -0
  62. package/templates/commands/planning/cleanup-issues.md +248 -0
  63. package/templates/commands/planning/planning-cleanup.md +251 -0
  64. package/templates/commands/planning/sync-planning-github.md +133 -0
  65. package/templates/commands/planning/sync-todos-github.md +203 -0
  66. package/templates/commands/quality-check.md +211 -0
  67. package/templates/commands/run-tests.md +159 -0
  68. package/templates/commands/start-feature-plan.md +232 -0
  69. package/templates/commands/start-refactor-plan.md +244 -0
  70. package/templates/commands/sync-planning.md +176 -0
  71. package/templates/commands/update-docs.md +242 -0
  72. package/templates/docs/CHECKPOINT-SYSTEM.md +504 -0
  73. package/templates/docs/INDEX.md +677 -0
  74. package/templates/docs/RECOMMENDED-HOOKS.md +415 -0
  75. package/templates/docs/_registry.json +329 -0
  76. package/templates/docs/diagrams/README.md +220 -0
  77. package/templates/docs/diagrams/agent-hierarchy.mmd +55 -0
  78. package/templates/docs/diagrams/documentation-map.mmd +61 -0
  79. package/templates/docs/diagrams/tools-relationship.mmd +55 -0
  80. package/templates/docs/diagrams/workflow-decision-tree.mmd +38 -0
  81. package/templates/docs/doc-sync.md +533 -0
  82. package/templates/docs/examples/end-to-end-workflow.md +1505 -0
  83. package/templates/docs/glossary.md +495 -0
  84. package/templates/docs/guides/mockup-prompt-engineering.md +644 -0
  85. package/templates/docs/guides/mockup-setup.md +737 -0
  86. package/templates/docs/learnings/README.md +250 -0
  87. package/templates/docs/learnings/common-architectural-patterns.md +123 -0
  88. package/templates/docs/learnings/common-mistakes-to-avoid.md +149 -0
  89. package/templates/docs/learnings/markdown-formatting-standards.md +104 -0
  90. package/templates/docs/learnings/monorepo-command-execution.md +64 -0
  91. package/templates/docs/learnings/optimization-tips.md +146 -0
  92. package/templates/docs/learnings/planning-linear-sync-workflow.md +70 -0
  93. package/templates/docs/learnings/shell-compatibility-fish.md +46 -0
  94. package/templates/docs/learnings/test-organization-structure.md +68 -0
  95. package/templates/docs/mcp-installation.md +613 -0
  96. package/templates/docs/mcp-servers.md +989 -0
  97. package/templates/docs/notification-installation.md +570 -0
  98. package/templates/docs/quick-start.md +354 -0
  99. package/templates/docs/standards/architecture-patterns.md +1064 -0
  100. package/templates/docs/standards/atomic-commits.md +513 -0
  101. package/templates/docs/standards/code-standards.md +993 -0
  102. package/templates/docs/standards/design-standards.md +656 -0
  103. package/templates/docs/standards/documentation-standards.md +1160 -0
  104. package/templates/docs/standards/testing-standards.md +969 -0
  105. package/templates/docs/system-maintenance.md +604 -0
  106. package/templates/docs/templates/PDR-template.md +561 -0
  107. package/templates/docs/templates/TODOs-template.md +534 -0
  108. package/templates/docs/templates/tech-analysis-template.md +800 -0
  109. package/templates/docs/workflows/README.md +519 -0
  110. package/templates/docs/workflows/atomic-task-protocol.md +955 -0
  111. package/templates/docs/workflows/decision-tree.md +482 -0
  112. package/templates/docs/workflows/edge-cases.md +856 -0
  113. package/templates/docs/workflows/phase-1-planning.md +957 -0
  114. package/templates/docs/workflows/phase-2-implementation.md +896 -0
  115. package/templates/docs/workflows/phase-3-validation.md +792 -0
  116. package/templates/docs/workflows/phase-4-finalization.md +927 -0
  117. package/templates/docs/workflows/quick-fix-protocol.md +505 -0
  118. package/templates/docs/workflows/task-atomization.md +537 -0
  119. package/templates/docs/workflows/task-completion-protocol.md +448 -0
  120. package/templates/hooks/on-notification.sh +28 -0
  121. package/templates/schemas/checkpoint.schema.json +97 -0
  122. package/templates/schemas/code-registry.schema.json +84 -0
  123. package/templates/schemas/pdr.schema.json +314 -0
  124. package/templates/schemas/problems.schema.json +55 -0
  125. package/templates/schemas/tech-analysis.schema.json +404 -0
  126. package/templates/schemas/telemetry.schema.json +298 -0
  127. package/templates/schemas/todos.schema.json +234 -0
  128. package/templates/schemas/workflows.schema.json +69 -0
  129. package/templates/scripts/add-changelogs.sh +105 -0
  130. package/templates/scripts/generate-code-registry.ts +270 -0
  131. package/templates/scripts/health-check.sh +343 -0
  132. package/templates/scripts/sync-registry.sh +40 -0
  133. package/templates/scripts/telemetry-report.ts +36 -0
  134. package/templates/scripts/validate-docs.sh +224 -0
  135. package/templates/scripts/validate-registry.sh +225 -0
  136. package/templates/scripts/validate-schemas.ts +283 -0
  137. package/templates/scripts/validate-structure.sh +165 -0
  138. package/templates/scripts/worktree-cleanup.sh +81 -0
  139. package/templates/scripts/worktree-create.sh +63 -0
  140. package/templates/sessions/planning/.gitkeep +0 -0
  141. package/templates/sessions/planning/archived/.gitkeep +0 -0
  142. package/templates/settings.json +202 -0
  143. package/templates/settings.local.json +138 -0
  144. package/templates/skills/README.md +197 -0
  145. package/templates/skills/_registry.json +473 -0
  146. package/templates/skills/audit/accessibility-audit.md +309 -0
  147. package/templates/skills/audit/performance-audit.md +257 -0
  148. package/templates/skills/audit/security-audit.md +217 -0
  149. package/templates/skills/auth/nextauth-patterns.md +308 -0
  150. package/templates/skills/brand-guidelines.md +240 -0
  151. package/templates/skills/documentation/markdown-formatter.md +302 -0
  152. package/templates/skills/git/git-commit-helper.md +321 -0
  153. package/templates/skills/i18n/i18n-patterns.md +251 -0
  154. package/templates/skills/patterns/error-handling-patterns.md +242 -0
  155. package/templates/skills/patterns/tdd-methodology.md +342 -0
  156. package/templates/skills/qa/qa-criteria-validator.md +383 -0
  157. package/templates/skills/qa/web-app-testing.md +398 -0
  158. package/templates/skills/react/react-hook-form-patterns.md +359 -0
  159. package/templates/skills/state/redux-toolkit-patterns.md +272 -0
  160. package/templates/skills/state/tanstack-query-patterns.md +299 -0
  161. package/templates/skills/state/zustand-patterns.md +301 -0
  162. package/templates/skills/tech/mermaid-diagram-specialist.md +195 -0
  163. package/templates/skills/tech/shadcn-specialist.md +252 -0
  164. package/templates/skills/tech/vercel-specialist.md +297 -0
  165. package/templates/skills/testing/api-app-testing.md +254 -0
  166. package/templates/skills/testing/performance-testing.md +275 -0
  167. package/templates/skills/testing/security-testing.md +348 -0
  168. package/templates/skills/utils/add-memory.md +295 -0
  169. package/templates/skills/utils/json-data-auditor.md +283 -0
  170. package/templates/skills/utils/pdf-creator-editor.md +342 -0
  171. package/templates/tools/format-markdown.sh +185 -0
@@ -0,0 +1,275 @@
1
+ ---
2
+ name: performance-testing
3
+ category: testing
4
+ description: Performance testing methodology for database, API, and frontend with benchmarks and optimization
5
+ usage: Use to identify bottlenecks, validate performance targets, and optimize operations
6
+ input: Application components, performance budgets, baseline metrics
7
+ output: Performance reports, bottleneck analysis, optimization recommendations
8
+ config_required:
9
+ - DB_QUERY_TARGET: "Maximum acceptable query time (e.g., 100ms)"
10
+ - API_RESPONSE_TARGET: "Maximum API response time p95 (e.g., 200ms)"
11
+ - FRONTEND_LCP_TARGET: "Largest Contentful Paint target (e.g., 2.5s)"
12
+ - BUNDLE_SIZE_TARGET: "Maximum bundle size (e.g., 500KB gzipped)"
13
+ - THROUGHPUT_TARGET: "Minimum requests per second (e.g., 1000 req/s)"
14
+ ---
15
+
16
+ # Performance Testing
17
+
18
+ ## ⚙️ Configuration
19
+
20
+ | Setting | Description | Example |
21
+ |---------|-------------|---------|
22
+ | DB_QUERY_TARGET | Max query time (p95) | `100ms` |
23
+ | API_RESPONSE_TARGET | Max API response (p95) | `200ms` |
24
+ | FRONTEND_LCP_TARGET | Largest Contentful Paint | `2.5s` |
25
+ | FRONTEND_FID_TARGET | First Input Delay | `100ms` |
26
+ | FRONTEND_CLS_TARGET | Cumulative Layout Shift | `0.1` |
27
+ | BUNDLE_SIZE_TARGET | Max bundle size (gzipped) | `500KB` |
28
+ | THROUGHPUT_TARGET | Min requests/second | `1000 req/s` |
29
+ | ERROR_RATE_TARGET | Max error rate | `0.1%` |
30
+
31
+ ## Purpose
32
+
33
+ Systematic performance testing and optimization across database, API, and frontend layers.
34
+
35
+ ## Capabilities
36
+
37
+ - Identify slow database queries
38
+ - Test API response times under load
39
+ - Measure Core Web Vitals
40
+ - Analyze bundle sizes
41
+ - Detect N+1 query problems
42
+ - Test rendering performance
43
+ - Generate performance reports
44
+
45
+ ## Workflow
46
+
47
+ ### 1. Database Performance Testing
48
+
49
+ **Actions:**
50
+ 1. Enable query logging
51
+ 2. Identify slow queries (> {{DB_QUERY_TARGET}})
52
+ 3. Run EXPLAIN on slow queries
53
+ 4. Check for:
54
+ - N+1 query problems
55
+ - Missing indexes
56
+ - Full table scans
57
+ - Unnecessary SELECT *
58
+ 5. Optimize:
59
+ - Add indexes
60
+ - Use eager loading
61
+ - Implement pagination
62
+ - Select specific columns
63
+
64
+ **Validation:**
65
+ - [ ] All queries < {{DB_QUERY_TARGET}} (p95)
66
+ - [ ] No N+1 patterns
67
+ - [ ] Indexes used effectively
68
+ - [ ] Pagination on large datasets
69
+
70
+ **Example Test:**
71
+
72
+ ```typescript
73
+ import { describe, it, expect } from 'your-test-framework';
74
+ import { db } from '@/db';
75
+
76
+ describe('Database Performance', () => {
77
+ it('should fetch items in < {{DB_QUERY_TARGET}}', async () => {
78
+ const startTime = performance.now();
79
+
80
+ await db.items.findMany({
81
+ limit: 100,
82
+ with: { relations: true }
83
+ });
84
+
85
+ const duration = performance.now() - startTime;
86
+ expect(duration).toBeLessThan(100);
87
+ });
88
+ });
89
+ ```
90
+
91
+ ### 2. API Performance Testing
92
+
93
+ **Actions:**
94
+ 1. Test API response times
95
+ 2. Test under load:
96
+ - Concurrent requests
97
+ - Sustained load
98
+ - Spike testing
99
+ 3. Monitor:
100
+ - Response time (p50, p95, p99)
101
+ - Throughput (req/s)
102
+ - Error rate
103
+ - Resource usage
104
+
105
+ **Validation:**
106
+ - [ ] API response < {{API_RESPONSE_TARGET}} (p95)
107
+ - [ ] Throughput > {{THROUGHPUT_TARGET}}
108
+ - [ ] Error rate < {{ERROR_RATE_TARGET}}
109
+ - [ ] No memory leaks
110
+
111
+ **Load Test Example:**
112
+
113
+ ```yaml
114
+ # Using Artillery
115
+ config:
116
+ target: 'http://localhost:3000'
117
+ phases:
118
+ - duration: 60
119
+ arrivalRate: 20
120
+ - duration: 120
121
+ arrivalRate: 50
122
+ ensure:
123
+ p95: {{API_RESPONSE_TARGET}}
124
+ ```
125
+
126
+ ### 3. Frontend Performance Testing
127
+
128
+ **Core Web Vitals:**
129
+ - LCP (Largest Contentful Paint) < {{FRONTEND_LCP_TARGET}}
130
+ - FID (First Input Delay) < {{FRONTEND_FID_TARGET}}
131
+ - CLS (Cumulative Layout Shift) < {{FRONTEND_CLS_TARGET}}
132
+ - INP (Interaction to Next Paint) < 200ms
133
+
134
+ **Page Load Metrics:**
135
+ - TTFB (Time to First Byte) < 600ms
136
+ - FCP (First Contentful Paint) < 1.8s
137
+ - TTI (Time to Interactive) < 3.5s
138
+
139
+ **Bundle Analysis:**
140
+ - Main bundle < {{BUNDLE_SIZE_TARGET}}
141
+ - Code splitting implemented
142
+ - Lazy loading for routes
143
+
144
+ **Validation:**
145
+ - [ ] Core Web Vitals met
146
+ - [ ] Bundle sizes within budget
147
+ - [ ] Component render < 16ms (60fps)
148
+
149
+ ### 4. Bottleneck Identification
150
+
151
+ **Categories:**
152
+ - **Database**: Slow queries, N+1 problems
153
+ - **API**: Blocking operations, inefficient algorithms
154
+ - **Frontend**: Large bundles, unnecessary re-renders
155
+ - **Network**: Large payloads, missing caching
156
+
157
+ **Prioritization:**
158
+ - High: Affects >50% users, >1s delay
159
+ - Medium: Affects 20-50% users, 500ms-1s delay
160
+ - Low: <20% users, <500ms delay
161
+
162
+ **Validation:**
163
+ - [ ] All bottlenecks identified
164
+ - [ ] Impact assessed
165
+ - [ ] Priority assigned
166
+
167
+ ### 5. Optimization Implementation
168
+
169
+ **Database Optimizations:**
170
+ - Add indexes
171
+ - Optimize queries
172
+ - Implement caching
173
+ - Add pagination
174
+
175
+ **API Optimizations:**
176
+ - Enable compression
177
+ - Implement caching
178
+ - Use async operations
179
+ - Optimize algorithms
180
+
181
+ **Frontend Optimizations:**
182
+ - Code splitting
183
+ - Lazy loading
184
+ - Image optimization
185
+ - Tree shaking
186
+ - Memoization
187
+
188
+ **Validation:**
189
+ - [ ] Optimizations implemented
190
+ - [ ] Tests passing
191
+ - [ ] Performance improved
192
+
193
+ ### 6. Regression Testing
194
+
195
+ **Actions:**
196
+ 1. Run full test suite
197
+ 2. Re-measure performance
198
+ 3. Compare before/after metrics
199
+ 4. Document improvements
200
+
201
+ **Validation:**
202
+ - [ ] All tests passing
203
+ - [ ] Performance improved
204
+ - [ ] No regressions
205
+ - [ ] Gains documented
206
+
207
+ ## Performance Budgets
208
+
209
+ ```json
210
+ {
211
+ "database": {
212
+ "queryTime": { "p95": "{{DB_QUERY_TARGET}}", "unit": "ms" },
213
+ "n1Queries": 0
214
+ },
215
+ "api": {
216
+ "responseTime": { "p95": "{{API_RESPONSE_TARGET}}", "unit": "ms" },
217
+ "throughput": { "min": "{{THROUGHPUT_TARGET}}", "unit": "req/s" }
218
+ },
219
+ "frontend": {
220
+ "lcp": { "max": "{{FRONTEND_LCP_TARGET}}", "unit": "ms" },
221
+ "fid": { "max": "{{FRONTEND_FID_TARGET}}", "unit": "ms" },
222
+ "cls": { "max": "{{FRONTEND_CLS_TARGET}}" },
223
+ "bundleSize": { "max": "{{BUNDLE_SIZE_TARGET}}", "unit": "KB" }
224
+ }
225
+ }
226
+ ```
227
+
228
+ ## Tools
229
+
230
+ **Database:**
231
+ - Query logging
232
+ - EXPLAIN / EXPLAIN ANALYZE
233
+ - Database profiling tools
234
+
235
+ **API:**
236
+ - Artillery (load testing)
237
+ - K6 (performance testing)
238
+ - autocannon (HTTP benchmarking)
239
+
240
+ **Frontend:**
241
+ - Lighthouse
242
+ - Chrome DevTools Performance
243
+ - WebPageTest
244
+ - Bundle Analyzer
245
+
246
+ ## Best Practices
247
+
248
+ 1. **Establish Baselines**: Measure before optimizing
249
+ 2. **Set Budgets**: Define acceptable performance levels
250
+ 3. **Test Regularly**: Include in CI/CD pipeline
251
+ 4. **Optimize Strategically**: Focus on high-impact areas
252
+ 5. **Measure Impact**: Quantify improvements
253
+ 6. **Avoid Premature Optimization**: Profile first
254
+ 7. **Test Realistically**: Use production-like data
255
+ 8. **Monitor Trends**: Track over time
256
+
257
+ ## Output
258
+
259
+ **Produces:**
260
+ - Performance test reports
261
+ - Bottleneck analysis with priorities
262
+ - Optimization recommendations
263
+ - Before/after comparisons
264
+ - Performance budget validation
265
+
266
+ **Success Criteria:**
267
+ - All performance targets met
268
+ - Bottlenecks identified and prioritized
269
+ - Optimizations validated
270
+ - Performance budgets enforced
271
+
272
+ ## Related Skills
273
+
274
+ - `api-app-testing` - API integration testing
275
+ - `security-testing` - Security performance impact
@@ -0,0 +1,348 @@
1
+ ---
2
+ name: security-testing
3
+ category: testing
4
+ description: Security testing covering authentication, authorization, input validation, and OWASP Top 10
5
+ usage: Use to validate security measures and identify vulnerabilities before deployment
6
+ input: Application components, authentication system, validation logic
7
+ output: Security test suite, vulnerability report, remediation recommendations
8
+ config_required:
9
+ - AUTH_MECHANISM: "Authentication system used (e.g., JWT, OAuth, Session)"
10
+ - VALIDATION_LIBRARY: "Validation library (e.g., Zod, Joi, Yup)"
11
+ - ORM_TOOL: "ORM/Query builder for SQL injection prevention"
12
+ - SECURITY_HEADERS: "Required security headers to validate"
13
+ ---
14
+
15
+ # Security Testing
16
+
17
+ ## ⚙️ Configuration
18
+
19
+ | Setting | Description | Example |
20
+ |---------|-------------|---------|
21
+ | AUTH_MECHANISM | Authentication method | `JWT`, `OAuth`, `Session-based` |
22
+ | VALIDATION_LIBRARY | Input validation library | `Zod`, `Joi`, `Yup` |
23
+ | ORM_TOOL | Database access method | `Drizzle`, `Prisma`, `TypeORM` |
24
+ | PASSWORD_POLICY | Password requirements | `8+ chars, uppercase, number` |
25
+ | RATE_LIMIT | Request rate limit | `100 req/15min` |
26
+ | SESSION_TIMEOUT | Session expiration | `30 minutes` |
27
+ | MFA_ENABLED | Multi-factor auth enabled | `true`, `false` |
28
+
29
+ ## Purpose
30
+
31
+ Comprehensive security testing to identify and prevent vulnerabilities across the application stack.
32
+
33
+ ## Capabilities
34
+
35
+ - Test authentication mechanisms
36
+ - Validate authorization controls
37
+ - Prevent injection attacks
38
+ - Test data protection
39
+ - Validate API security
40
+ - Check dependency vulnerabilities
41
+ - Test error handling security
42
+
43
+ ## Workflow
44
+
45
+ ### 1. Authentication Testing
46
+
47
+ **Test scenarios:**
48
+ - Valid/invalid credentials
49
+ - Brute force protection
50
+ - Session management
51
+ - Token expiration
52
+ - Password policies
53
+ - MFA (if applicable)
54
+ - OAuth flows
55
+ - Logout functionality
56
+
57
+ **Validation:**
58
+ - [ ] Strong passwords enforced
59
+ - [ ] Failed login attempts limited
60
+ - [ ] Sessions expire appropriately
61
+ - [ ] Tokens validated properly
62
+ - [ ] Logout invalidates sessions
63
+
64
+ **Example Test:**
65
+
66
+ ```typescript
67
+ import { describe, it, expect } from 'test-framework';
68
+
69
+ describe('Authentication Security', () => {
70
+ it('should reject invalid credentials', async () => {
71
+ const response = await app.request('/api/auth/login', {
72
+ method: 'POST',
73
+ body: JSON.stringify({
74
+ email: 'user@example.com',
75
+ password: 'wrongpassword'
76
+ })
77
+ });
78
+
79
+ expect(response.status).toBe(401);
80
+ });
81
+
82
+ it('should rate limit failed attempts', async () => {
83
+ // Attempt multiple failed logins
84
+ for (let i = 0; i < 10; i++) {
85
+ await app.request('/api/auth/login', {
86
+ method: 'POST',
87
+ body: JSON.stringify({
88
+ email: 'user@example.com',
89
+ password: 'wrong'
90
+ })
91
+ });
92
+ }
93
+
94
+ const response = await app.request('/api/auth/login', {
95
+ method: 'POST',
96
+ body: JSON.stringify({
97
+ email: 'user@example.com',
98
+ password: 'wrong'
99
+ })
100
+ });
101
+
102
+ expect(response.status).toBe(429);
103
+ });
104
+ });
105
+ ```
106
+
107
+ ### 2. Authorization Testing
108
+
109
+ **Test scenarios:**
110
+ - Role-based access control (RBAC)
111
+ - Resource ownership validation
112
+ - Privilege escalation attempts
113
+ - Horizontal access control
114
+ - Vertical access control
115
+ - Admin vs user permissions
116
+
117
+ **Validation:**
118
+ - [ ] Users can only access own resources
119
+ - [ ] Admin-only endpoints protected
120
+ - [ ] No privilege escalation possible
121
+ - [ ] Permissions checked on all operations
122
+
123
+ **Example Test:**
124
+
125
+ ```typescript
126
+ describe('Authorization Security', () => {
127
+ it('should prevent access to other users resources', async () => {
128
+ const userAToken = await getUserToken('user-a');
129
+
130
+ const response = await app.request('/api/resources/user-b-id', {
131
+ headers: { Authorization: `Bearer ${userAToken}` }
132
+ });
133
+
134
+ expect(response.status).toBe(403);
135
+ });
136
+ });
137
+ ```
138
+
139
+ ### 3. Input Validation Testing
140
+
141
+ **Test injection attacks:**
142
+
143
+ **SQL Injection:**
144
+ - Test with SQL injection payloads
145
+ - Verify parameterized queries/ORM used
146
+
147
+ **XSS (Cross-Site Scripting):**
148
+ - Test with XSS payloads
149
+ - Verify output encoding
150
+ - Test reflected and stored XSS
151
+
152
+ **Command Injection:**
153
+ - Test system command inputs
154
+ - Verify safe execution
155
+
156
+ **Path Traversal:**
157
+ - Test file path inputs
158
+ - Verify path sanitization
159
+
160
+ **Validation Bypass:**
161
+ - Test client-side only validation
162
+ - Test type confusion
163
+ - Test boundary values
164
+
165
+ **Validation:**
166
+ - [ ] All inputs validated server-side
167
+ - [ ] SQL injection prevented (ORM usage)
168
+ - [ ] XSS prevented (output escaping)
169
+ - [ ] No command injection possible
170
+ - [ ] Path traversal blocked
171
+
172
+ **Example Test:**
173
+
174
+ ```typescript
175
+ describe('Input Validation Security', () => {
176
+ it('should prevent SQL injection', async () => {
177
+ const maliciousInput = "'; DROP TABLE users; --";
178
+
179
+ const response = await app.request(
180
+ `/api/search?q=${encodeURIComponent(maliciousInput)}`
181
+ );
182
+
183
+ expect(response.status).toBe(200);
184
+
185
+ // Verify database intact
186
+ const usersCount = await db.users.count();
187
+ expect(usersCount).toBeGreaterThan(0);
188
+ });
189
+
190
+ it('should prevent XSS attacks', async () => {
191
+ const xssPayload = '<script>alert("XSS")</script>';
192
+
193
+ const response = await app.request('/api/comments', {
194
+ method: 'POST',
195
+ body: JSON.stringify({ content: xssPayload })
196
+ });
197
+
198
+ const comment = await response.json();
199
+ expect(comment.content).not.toContain('<script>');
200
+ });
201
+ });
202
+ ```
203
+
204
+ ### 4. Data Protection Testing
205
+
206
+ **Test scenarios:**
207
+ - Encryption at rest
208
+ - Encryption in transit (HTTPS)
209
+ - Sensitive data exposure
210
+ - Logging (no secrets)
211
+ - Error messages (no data leakage)
212
+ - Data deletion (proper cleanup)
213
+
214
+ **Validation:**
215
+ - [ ] HTTPS enforced
216
+ - [ ] Sensitive fields encrypted
217
+ - [ ] No secrets in logs
218
+ - [ ] No PII in error messages
219
+ - [ ] Secure data deletion
220
+
221
+ **Example Test:**
222
+
223
+ ```typescript
224
+ describe('Data Protection Security', () => {
225
+ it('should not expose sensitive data', async () => {
226
+ const response = await app.request('/api/users/profile');
227
+ const user = await response.json();
228
+
229
+ expect(user).not.toHaveProperty('password');
230
+ expect(user).not.toHaveProperty('passwordHash');
231
+ });
232
+
233
+ it('should not leak data in errors', async () => {
234
+ const response = await app.request('/api/users/invalid-id');
235
+ const error = await response.json();
236
+
237
+ expect(error.message).not.toContain('database');
238
+ expect(error).not.toHaveProperty('stack');
239
+ });
240
+ });
241
+ ```
242
+
243
+ ### 5. API Security Testing
244
+
245
+ **Test scenarios:**
246
+ - Rate limiting
247
+ - CORS configuration
248
+ - Request size limits
249
+ - Content-type validation
250
+ - Security headers
251
+
252
+ **Validation:**
253
+ - [ ] Rate limiting active
254
+ - [ ] CORS properly configured
255
+ - [ ] Request size limited
256
+ - [ ] Security headers set
257
+
258
+ **Example Test:**
259
+
260
+ ```typescript
261
+ describe('API Security', () => {
262
+ it('should have security headers', async () => {
263
+ const response = await app.request('/api/users');
264
+
265
+ expect(response.headers.get('X-Content-Type-Options')).toBe('nosniff');
266
+ expect(response.headers.get('X-Frame-Options')).toBe('DENY');
267
+ expect(response.headers.get('Content-Security-Policy')).toBeTruthy();
268
+ });
269
+
270
+ it('should enforce CORS policy', async () => {
271
+ const response = await app.request('/api/users', {
272
+ headers: { Origin: 'https://untrusted-site.com' }
273
+ });
274
+
275
+ expect(response.headers.get('Access-Control-Allow-Origin'))
276
+ .not.toBe('*');
277
+ });
278
+ });
279
+ ```
280
+
281
+ ### 6. Dependency Security Testing
282
+
283
+ **Actions:**
284
+ 1. Run dependency audit
285
+ 2. Check for outdated packages
286
+ 3. Review security advisories
287
+ 4. Monitor for new vulnerabilities
288
+
289
+ **Validation:**
290
+ - [ ] No critical vulnerabilities
291
+ - [ ] No high vulnerabilities
292
+ - [ ] Medium vulnerabilities documented
293
+ - [ ] Dependencies up to date
294
+
295
+ **Command:**
296
+
297
+ ```bash
298
+ # Run dependency audit
299
+ {{PACKAGE_MANAGER}} audit --audit-level moderate
300
+ ```
301
+
302
+ ## OWASP Top 10 Coverage
303
+
304
+ | Risk | Covered |
305
+ |------|---------|
306
+ | Broken Access Control | Authorization tests |
307
+ | Cryptographic Failures | HTTPS, encryption tests |
308
+ | Injection | SQL, XSS, command injection tests |
309
+ | Insecure Design | Security by design validation |
310
+ | Security Misconfiguration | Headers, defaults tests |
311
+ | Vulnerable Components | Dependency scanning |
312
+ | Authentication Failures | Auth mechanism tests |
313
+ | Data Integrity Failures | Input validation tests |
314
+ | Logging Failures | Log security validation |
315
+ | SSRF | URL validation |
316
+
317
+ ## Best Practices
318
+
319
+ 1. **Defense in Depth**: Multiple security layers
320
+ 2. **Fail Securely**: Default to deny access
321
+ 3. **Least Privilege**: Minimal required permissions
322
+ 4. **Input Validation**: Validate all inputs server-side
323
+ 5. **Output Encoding**: Prevent XSS
324
+ 6. **Parameterized Queries**: Prevent SQL injection
325
+ 7. **Security Headers**: Set all recommended headers
326
+ 8. **Regular Audits**: Continuous security testing
327
+ 9. **Update Dependencies**: Keep packages current
328
+ 10. **Log Security Events**: Monitor for attacks
329
+
330
+ ## Output
331
+
332
+ **Produces:**
333
+ - Security test suite
334
+ - Vulnerability report
335
+ - Remediation recommendations
336
+ - OWASP Top 10 compliance checklist
337
+
338
+ **Success Criteria:**
339
+ - All security tests passing
340
+ - No critical vulnerabilities
341
+ - Authentication/authorization secure
342
+ - Input validation comprehensive
343
+ - Data protection adequate
344
+
345
+ ## Related Skills
346
+
347
+ - `api-app-testing` - API functionality testing
348
+ - `performance-testing` - Security performance impact