@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.
- package/LICENSE +21 -0
- package/README.md +1248 -0
- package/dist/bin.cjs +11886 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +11869 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.cjs +3887 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1325 -0
- package/dist/index.d.ts +1325 -0
- package/dist/index.js +3835 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/.log/notifications.log +1775 -0
- package/templates/agents/README.md +164 -0
- package/templates/agents/_registry.json +443 -0
- package/templates/agents/design/content-writer.md +353 -0
- package/templates/agents/design/ux-ui-designer.md +382 -0
- package/templates/agents/engineering/astro-engineer.md +293 -0
- package/templates/agents/engineering/db-drizzle-engineer.md +360 -0
- package/templates/agents/engineering/express-engineer.md +316 -0
- package/templates/agents/engineering/fastify-engineer.md +399 -0
- package/templates/agents/engineering/hono-engineer.md +263 -0
- package/templates/agents/engineering/mongoose-engineer.md +473 -0
- package/templates/agents/engineering/nestjs-engineer.md +429 -0
- package/templates/agents/engineering/nextjs-engineer.md +451 -0
- package/templates/agents/engineering/node-typescript-engineer.md +347 -0
- package/templates/agents/engineering/prisma-engineer.md +432 -0
- package/templates/agents/engineering/react-senior-dev.md +394 -0
- package/templates/agents/engineering/tanstack-start-engineer.md +447 -0
- package/templates/agents/engineering/tech-lead.md +269 -0
- package/templates/agents/product/product-functional.md +329 -0
- package/templates/agents/product/product-technical.md +578 -0
- package/templates/agents/quality/debugger.md +514 -0
- package/templates/agents/quality/qa-engineer.md +390 -0
- package/templates/agents/specialized/enrichment-agent.md +277 -0
- package/templates/agents/specialized/i18n-specialist.md +322 -0
- package/templates/agents/specialized/seo-ai-specialist.md +387 -0
- package/templates/agents/specialized/tech-writer.md +300 -0
- package/templates/code-style/.editorconfig +27 -0
- package/templates/code-style/.prettierignore +25 -0
- package/templates/code-style/.prettierrc +12 -0
- package/templates/code-style/biome.json +78 -0
- package/templates/code-style/commitlint.config.js +44 -0
- package/templates/commands/README.md +175 -0
- package/templates/commands/_registry.json +420 -0
- package/templates/commands/add-new-entity.md +211 -0
- package/templates/commands/audit/accessibility-audit.md +360 -0
- package/templates/commands/audit/performance-audit.md +290 -0
- package/templates/commands/audit/security-audit.md +231 -0
- package/templates/commands/code-check.md +127 -0
- package/templates/commands/five-why.md +225 -0
- package/templates/commands/formatting/format-markdown.md +197 -0
- package/templates/commands/git/commit.md +247 -0
- package/templates/commands/meta/create-agent.md +257 -0
- package/templates/commands/meta/create-command.md +312 -0
- package/templates/commands/meta/create-skill.md +321 -0
- package/templates/commands/meta/help.md +318 -0
- package/templates/commands/planning/check-completed-tasks.md +224 -0
- package/templates/commands/planning/cleanup-issues.md +248 -0
- package/templates/commands/planning/planning-cleanup.md +251 -0
- package/templates/commands/planning/sync-planning-github.md +133 -0
- package/templates/commands/planning/sync-todos-github.md +203 -0
- package/templates/commands/quality-check.md +211 -0
- package/templates/commands/run-tests.md +159 -0
- package/templates/commands/start-feature-plan.md +232 -0
- package/templates/commands/start-refactor-plan.md +244 -0
- package/templates/commands/sync-planning.md +176 -0
- package/templates/commands/update-docs.md +242 -0
- package/templates/docs/CHECKPOINT-SYSTEM.md +504 -0
- package/templates/docs/INDEX.md +677 -0
- package/templates/docs/RECOMMENDED-HOOKS.md +415 -0
- package/templates/docs/_registry.json +329 -0
- package/templates/docs/diagrams/README.md +220 -0
- package/templates/docs/diagrams/agent-hierarchy.mmd +55 -0
- package/templates/docs/diagrams/documentation-map.mmd +61 -0
- package/templates/docs/diagrams/tools-relationship.mmd +55 -0
- package/templates/docs/diagrams/workflow-decision-tree.mmd +38 -0
- package/templates/docs/doc-sync.md +533 -0
- package/templates/docs/examples/end-to-end-workflow.md +1505 -0
- package/templates/docs/glossary.md +495 -0
- package/templates/docs/guides/mockup-prompt-engineering.md +644 -0
- package/templates/docs/guides/mockup-setup.md +737 -0
- package/templates/docs/learnings/README.md +250 -0
- package/templates/docs/learnings/common-architectural-patterns.md +123 -0
- package/templates/docs/learnings/common-mistakes-to-avoid.md +149 -0
- package/templates/docs/learnings/markdown-formatting-standards.md +104 -0
- package/templates/docs/learnings/monorepo-command-execution.md +64 -0
- package/templates/docs/learnings/optimization-tips.md +146 -0
- package/templates/docs/learnings/planning-linear-sync-workflow.md +70 -0
- package/templates/docs/learnings/shell-compatibility-fish.md +46 -0
- package/templates/docs/learnings/test-organization-structure.md +68 -0
- package/templates/docs/mcp-installation.md +613 -0
- package/templates/docs/mcp-servers.md +989 -0
- package/templates/docs/notification-installation.md +570 -0
- package/templates/docs/quick-start.md +354 -0
- package/templates/docs/standards/architecture-patterns.md +1064 -0
- package/templates/docs/standards/atomic-commits.md +513 -0
- package/templates/docs/standards/code-standards.md +993 -0
- package/templates/docs/standards/design-standards.md +656 -0
- package/templates/docs/standards/documentation-standards.md +1160 -0
- package/templates/docs/standards/testing-standards.md +969 -0
- package/templates/docs/system-maintenance.md +604 -0
- package/templates/docs/templates/PDR-template.md +561 -0
- package/templates/docs/templates/TODOs-template.md +534 -0
- package/templates/docs/templates/tech-analysis-template.md +800 -0
- package/templates/docs/workflows/README.md +519 -0
- package/templates/docs/workflows/atomic-task-protocol.md +955 -0
- package/templates/docs/workflows/decision-tree.md +482 -0
- package/templates/docs/workflows/edge-cases.md +856 -0
- package/templates/docs/workflows/phase-1-planning.md +957 -0
- package/templates/docs/workflows/phase-2-implementation.md +896 -0
- package/templates/docs/workflows/phase-3-validation.md +792 -0
- package/templates/docs/workflows/phase-4-finalization.md +927 -0
- package/templates/docs/workflows/quick-fix-protocol.md +505 -0
- package/templates/docs/workflows/task-atomization.md +537 -0
- package/templates/docs/workflows/task-completion-protocol.md +448 -0
- package/templates/hooks/on-notification.sh +28 -0
- package/templates/schemas/checkpoint.schema.json +97 -0
- package/templates/schemas/code-registry.schema.json +84 -0
- package/templates/schemas/pdr.schema.json +314 -0
- package/templates/schemas/problems.schema.json +55 -0
- package/templates/schemas/tech-analysis.schema.json +404 -0
- package/templates/schemas/telemetry.schema.json +298 -0
- package/templates/schemas/todos.schema.json +234 -0
- package/templates/schemas/workflows.schema.json +69 -0
- package/templates/scripts/add-changelogs.sh +105 -0
- package/templates/scripts/generate-code-registry.ts +270 -0
- package/templates/scripts/health-check.sh +343 -0
- package/templates/scripts/sync-registry.sh +40 -0
- package/templates/scripts/telemetry-report.ts +36 -0
- package/templates/scripts/validate-docs.sh +224 -0
- package/templates/scripts/validate-registry.sh +225 -0
- package/templates/scripts/validate-schemas.ts +283 -0
- package/templates/scripts/validate-structure.sh +165 -0
- package/templates/scripts/worktree-cleanup.sh +81 -0
- package/templates/scripts/worktree-create.sh +63 -0
- package/templates/sessions/planning/.gitkeep +0 -0
- package/templates/sessions/planning/archived/.gitkeep +0 -0
- package/templates/settings.json +202 -0
- package/templates/settings.local.json +138 -0
- package/templates/skills/README.md +197 -0
- package/templates/skills/_registry.json +473 -0
- package/templates/skills/audit/accessibility-audit.md +309 -0
- package/templates/skills/audit/performance-audit.md +257 -0
- package/templates/skills/audit/security-audit.md +217 -0
- package/templates/skills/auth/nextauth-patterns.md +308 -0
- package/templates/skills/brand-guidelines.md +240 -0
- package/templates/skills/documentation/markdown-formatter.md +302 -0
- package/templates/skills/git/git-commit-helper.md +321 -0
- package/templates/skills/i18n/i18n-patterns.md +251 -0
- package/templates/skills/patterns/error-handling-patterns.md +242 -0
- package/templates/skills/patterns/tdd-methodology.md +342 -0
- package/templates/skills/qa/qa-criteria-validator.md +383 -0
- package/templates/skills/qa/web-app-testing.md +398 -0
- package/templates/skills/react/react-hook-form-patterns.md +359 -0
- package/templates/skills/state/redux-toolkit-patterns.md +272 -0
- package/templates/skills/state/tanstack-query-patterns.md +299 -0
- package/templates/skills/state/zustand-patterns.md +301 -0
- package/templates/skills/tech/mermaid-diagram-specialist.md +195 -0
- package/templates/skills/tech/shadcn-specialist.md +252 -0
- package/templates/skills/tech/vercel-specialist.md +297 -0
- package/templates/skills/testing/api-app-testing.md +254 -0
- package/templates/skills/testing/performance-testing.md +275 -0
- package/templates/skills/testing/security-testing.md +348 -0
- package/templates/skills/utils/add-memory.md +295 -0
- package/templates/skills/utils/json-data-auditor.md +283 -0
- package/templates/skills/utils/pdf-creator-editor.md +342 -0
- package/templates/tools/format-markdown.sh +185 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deployment-platform-specialist
|
|
3
|
+
category: tech
|
|
4
|
+
description: Configure and optimize deployment platform settings for optimal performance and reliability
|
|
5
|
+
usage: When deploying applications, configuring environments, optimizing builds, or troubleshooting deployments
|
|
6
|
+
input: Deployment configuration, environment variables, build settings, platform type
|
|
7
|
+
output: Platform configuration files, deployment strategy, optimization recommendations
|
|
8
|
+
config_required:
|
|
9
|
+
- platform_name: "Deployment platform (e.g., Vercel, Netlify, AWS Amplify)"
|
|
10
|
+
- project_framework: "Framework being deployed (Astro, Next.js, etc.)"
|
|
11
|
+
- build_command: "Command to build the project"
|
|
12
|
+
- output_directory: "Build output directory"
|
|
13
|
+
- node_version: "Node.js version requirement"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Deployment Platform Specialist
|
|
17
|
+
|
|
18
|
+
## ⚙️ Configuration
|
|
19
|
+
|
|
20
|
+
| Setting | Description | Example |
|
|
21
|
+
|---------|-------------|---------|
|
|
22
|
+
| `platform_name` | Deployment platform | `Vercel`, `Netlify`, `AWS Amplify` |
|
|
23
|
+
| `project_framework` | Framework | `Astro`, `Next.js`, `TanStack Start` |
|
|
24
|
+
| `build_command` | Build command | `pnpm build`, `npm run build` |
|
|
25
|
+
| `output_directory` | Output folder | `dist`, `.next`, `build` |
|
|
26
|
+
| `install_command` | Install command | `pnpm install`, `npm install` |
|
|
27
|
+
| `node_version` | Node version | `18.x`, `20.x` |
|
|
28
|
+
| `environment` | Target environment | `production`, `preview`, `development` |
|
|
29
|
+
|
|
30
|
+
## Purpose
|
|
31
|
+
|
|
32
|
+
Expert guidance on deployment platform configuration, environment management, build optimization, and production best practices.
|
|
33
|
+
|
|
34
|
+
## Capabilities
|
|
35
|
+
|
|
36
|
+
- Platform configuration and setup
|
|
37
|
+
- Environment variable management
|
|
38
|
+
- Build performance optimization
|
|
39
|
+
- Preview and production deployments
|
|
40
|
+
- Custom domain configuration
|
|
41
|
+
- Edge function implementation
|
|
42
|
+
- Monitoring and analytics setup
|
|
43
|
+
|
|
44
|
+
## Project Configuration
|
|
45
|
+
|
|
46
|
+
### Platform Config File
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"framework": "astro",
|
|
51
|
+
"buildCommand": "pnpm build",
|
|
52
|
+
"outputDirectory": "dist",
|
|
53
|
+
"installCommand": "pnpm install",
|
|
54
|
+
"devCommand": "pnpm dev",
|
|
55
|
+
"nodeVersion": "20.x",
|
|
56
|
+
"regions": ["iad1"],
|
|
57
|
+
"rewrites": [
|
|
58
|
+
{ "source": "/api/:path*", "destination": "/api/:path*" }
|
|
59
|
+
],
|
|
60
|
+
"headers": [
|
|
61
|
+
{
|
|
62
|
+
"source": "/(.*)",
|
|
63
|
+
"headers": [
|
|
64
|
+
{ "key": "X-Content-Type-Options", "value": "nosniff" },
|
|
65
|
+
{ "key": "X-Frame-Options", "value": "DENY" },
|
|
66
|
+
{ "key": "X-XSS-Protection", "value": "1; mode=block" }
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Environment Variables
|
|
74
|
+
|
|
75
|
+
### Setup
|
|
76
|
+
|
|
77
|
+
Configure via platform dashboard or CLI:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Add variable
|
|
81
|
+
platform-cli env add DATABASE_URL production
|
|
82
|
+
|
|
83
|
+
# Pull variables locally
|
|
84
|
+
platform-cli env pull .env.local
|
|
85
|
+
|
|
86
|
+
# Set variable for all environments
|
|
87
|
+
platform-cli env add API_KEY
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Organization
|
|
91
|
+
|
|
92
|
+
| Environment | Purpose | Examples |
|
|
93
|
+
|-------------|---------|----------|
|
|
94
|
+
| `production` | Live site | Production DB, live API keys |
|
|
95
|
+
| `preview` | PR previews | Staging DB, test API keys |
|
|
96
|
+
| `development` | Local dev | Local DB, dev API keys |
|
|
97
|
+
|
|
98
|
+
### Security
|
|
99
|
+
|
|
100
|
+
- Never commit secrets to git
|
|
101
|
+
- Use platform secret storage
|
|
102
|
+
- Rotate keys regularly
|
|
103
|
+
- Scope variables appropriately
|
|
104
|
+
|
|
105
|
+
## Build Optimization
|
|
106
|
+
|
|
107
|
+
### Caching Strategy
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"caching": {
|
|
112
|
+
"dependencies": true,
|
|
113
|
+
"buildOutputs": true,
|
|
114
|
+
"staticAssets": "max-age=31536000, immutable"
|
|
115
|
+
},
|
|
116
|
+
"build": {
|
|
117
|
+
"env": {
|
|
118
|
+
"NEXT_TELEMETRY_DISABLED": "1",
|
|
119
|
+
"NODE_ENV": "production"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Performance Targets
|
|
126
|
+
|
|
127
|
+
| Metric | Target |
|
|
128
|
+
|--------|--------|
|
|
129
|
+
| Build time | < 3 minutes |
|
|
130
|
+
| Cache hit rate | > 80% |
|
|
131
|
+
| Bundle size | Optimized and analyzed |
|
|
132
|
+
| Build success rate | > 99% |
|
|
133
|
+
|
|
134
|
+
## Deployment Workflow
|
|
135
|
+
|
|
136
|
+
### Git Integration
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
# Auto-deploy configuration
|
|
140
|
+
production_branch: main
|
|
141
|
+
preview_branches:
|
|
142
|
+
- develop
|
|
143
|
+
- feature/*
|
|
144
|
+
- fix/*
|
|
145
|
+
|
|
146
|
+
ignore_paths:
|
|
147
|
+
- "docs/**"
|
|
148
|
+
- "*.md"
|
|
149
|
+
- ".github/**"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Preview Deployments
|
|
153
|
+
|
|
154
|
+
- Automatic on PRs
|
|
155
|
+
- Unique URL per deployment
|
|
156
|
+
- Comment on PR with preview link
|
|
157
|
+
- Run deployment checks
|
|
158
|
+
|
|
159
|
+
## Edge Functions
|
|
160
|
+
|
|
161
|
+
### Middleware Example
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { NextResponse } from 'next/server';
|
|
165
|
+
import type { NextRequest } from 'next/server';
|
|
166
|
+
|
|
167
|
+
export function middleware(request: NextRequest) {
|
|
168
|
+
// Authentication check
|
|
169
|
+
const token = request.cookies.get('auth-token');
|
|
170
|
+
|
|
171
|
+
if (!token && request.nextUrl.pathname.startsWith('/dashboard')) {
|
|
172
|
+
return NextResponse.redirect(new URL('/login', request.url));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return NextResponse.next();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export const config = {
|
|
179
|
+
matcher: '/dashboard/:path*',
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Custom Domains
|
|
184
|
+
|
|
185
|
+
### DNS Configuration
|
|
186
|
+
|
|
187
|
+
| Type | Name | Value | TTL |
|
|
188
|
+
|------|------|-------|-----|
|
|
189
|
+
| A | @ | Platform IP | 3600 |
|
|
190
|
+
| CNAME | www | Platform domain | 3600 |
|
|
191
|
+
|
|
192
|
+
### SSL/TLS
|
|
193
|
+
|
|
194
|
+
- Automatic SSL certificate
|
|
195
|
+
- Force HTTPS redirect
|
|
196
|
+
- HTTP/2 enabled
|
|
197
|
+
- Certificate auto-renewal
|
|
198
|
+
|
|
199
|
+
## Monitoring
|
|
200
|
+
|
|
201
|
+
### Analytics Setup
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
// Enable platform analytics
|
|
205
|
+
export const config = {
|
|
206
|
+
runtime: 'edge',
|
|
207
|
+
analytics: true,
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Metrics to Track
|
|
212
|
+
|
|
213
|
+
- Page load time
|
|
214
|
+
- Core Web Vitals (LCP, FID, CLS)
|
|
215
|
+
- Error rate
|
|
216
|
+
- Build success rate
|
|
217
|
+
- Bandwidth usage
|
|
218
|
+
|
|
219
|
+
## Performance Optimization
|
|
220
|
+
|
|
221
|
+
### Headers Configuration
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"headers": [
|
|
226
|
+
{
|
|
227
|
+
"source": "/static/(.*)",
|
|
228
|
+
"headers": [
|
|
229
|
+
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"source": "/(.*)",
|
|
234
|
+
"headers": [
|
|
235
|
+
{ "key": "X-DNS-Prefetch-Control", "value": "on" },
|
|
236
|
+
{ "key": "Strict-Transport-Security", "value": "max-age=63072000" }
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Redirects
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"redirects": [
|
|
248
|
+
{
|
|
249
|
+
"source": "/old-path",
|
|
250
|
+
"destination": "/new-path",
|
|
251
|
+
"permanent": true
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"source": "/blog/:slug",
|
|
255
|
+
"destination": "/articles/:slug",
|
|
256
|
+
"permanent": false
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Best Practices
|
|
263
|
+
|
|
264
|
+
| Practice | Description |
|
|
265
|
+
|----------|-------------|
|
|
266
|
+
| **Preview First** | Test in preview before production |
|
|
267
|
+
| **Environment Separation** | Different variables per environment |
|
|
268
|
+
| **Build Caching** | Enable for faster builds |
|
|
269
|
+
| **Security Headers** | Set proper security headers |
|
|
270
|
+
| **Analytics** | Monitor real user performance |
|
|
271
|
+
| **Edge Functions** | Use for auth and routing |
|
|
272
|
+
| **Automatic Deployments** | CI/CD with git integration |
|
|
273
|
+
| **Domain Management** | Configure DNS and SSL properly |
|
|
274
|
+
|
|
275
|
+
## Troubleshooting
|
|
276
|
+
|
|
277
|
+
### Common Issues
|
|
278
|
+
|
|
279
|
+
| Issue | Solution |
|
|
280
|
+
|-------|----------|
|
|
281
|
+
| Build timeout | Optimize dependencies, enable caching |
|
|
282
|
+
| Environment variable missing | Check scope (production/preview) |
|
|
283
|
+
| Function timeout | Optimize code or upgrade plan |
|
|
284
|
+
| Cache not working | Verify cache headers configuration |
|
|
285
|
+
|
|
286
|
+
## Checklist
|
|
287
|
+
|
|
288
|
+
- [ ] Build command configured
|
|
289
|
+
- [ ] Output directory correct
|
|
290
|
+
- [ ] Environment variables set
|
|
291
|
+
- [ ] Git integration active
|
|
292
|
+
- [ ] Preview deployments enabled
|
|
293
|
+
- [ ] Security headers configured
|
|
294
|
+
- [ ] Custom domain configured (if needed)
|
|
295
|
+
- [ ] SSL certificate active
|
|
296
|
+
- [ ] Analytics enabled
|
|
297
|
+
- [ ] Build time < 3 minutes
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-app-testing
|
|
3
|
+
category: testing
|
|
4
|
+
description: Comprehensive testing workflow for API endpoints with integration, error handling, and validation
|
|
5
|
+
usage: Use when implementing or updating API routes to ensure complete test coverage
|
|
6
|
+
input: API route file path, service layer, database models, validation schemas
|
|
7
|
+
output: Integration test files, coverage reports, test documentation
|
|
8
|
+
config_required:
|
|
9
|
+
- TEST_FRAMEWORK: "Your test framework (e.g., Vitest, Jest)"
|
|
10
|
+
- TEST_COMMAND: "Command to run tests (e.g., pnpm test)"
|
|
11
|
+
- COVERAGE_COMMAND: "Command to run coverage (e.g., pnpm test:coverage)"
|
|
12
|
+
- COVERAGE_TARGET: "Minimum coverage percentage (e.g., 90%)"
|
|
13
|
+
- API_FRAMEWORK: "API framework used (e.g., Hono, Express)"
|
|
14
|
+
- TEST_DB_SETUP: "How test database is configured (e.g., transactions, in-memory)"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# API Application Testing
|
|
18
|
+
|
|
19
|
+
## ⚙️ Configuration
|
|
20
|
+
|
|
21
|
+
| Setting | Description | Example |
|
|
22
|
+
|---------|-------------|---------|
|
|
23
|
+
| TEST_FRAMEWORK | Test framework used | `Vitest`, `Jest` |
|
|
24
|
+
| TEST_COMMAND | Command to run tests | `pnpm test`, `npm test` |
|
|
25
|
+
| COVERAGE_COMMAND | Command to run coverage | `pnpm test:coverage` |
|
|
26
|
+
| COVERAGE_TARGET | Minimum coverage required | `90%` |
|
|
27
|
+
| API_FRAMEWORK | API framework | `Hono`, `Express`, `Fastify` |
|
|
28
|
+
| TEST_DB_SETUP | Database setup strategy | `Transactions`, `In-memory`, `Mocks` |
|
|
29
|
+
| ORM_TOOL | ORM/Query builder | `Drizzle`, `Prisma`, `TypeORM` |
|
|
30
|
+
|
|
31
|
+
## Purpose
|
|
32
|
+
|
|
33
|
+
Systematic testing approach for API endpoints ensuring functionality, error handling, validation, and documentation accuracy.
|
|
34
|
+
|
|
35
|
+
## Capabilities
|
|
36
|
+
|
|
37
|
+
- Test all HTTP methods (GET, POST, PUT, PATCH, DELETE)
|
|
38
|
+
- Validate request/response schemas
|
|
39
|
+
- Test error scenarios and edge cases
|
|
40
|
+
- Verify authentication and authorization
|
|
41
|
+
- Test database integration
|
|
42
|
+
- Measure test coverage
|
|
43
|
+
- Validate API documentation
|
|
44
|
+
|
|
45
|
+
## Workflow
|
|
46
|
+
|
|
47
|
+
### 1. Test Planning
|
|
48
|
+
|
|
49
|
+
**Actions:**
|
|
50
|
+
- List all endpoints and HTTP methods
|
|
51
|
+
- Review validation schemas
|
|
52
|
+
- Prepare test data fixtures
|
|
53
|
+
- Set up test database
|
|
54
|
+
|
|
55
|
+
**Validation:**
|
|
56
|
+
- [ ] All endpoints documented
|
|
57
|
+
- [ ] Test data covers happy path and edge cases
|
|
58
|
+
- [ ] Database/mocks configured
|
|
59
|
+
|
|
60
|
+
### 2. Happy Path Testing
|
|
61
|
+
|
|
62
|
+
**Test successful scenarios:**
|
|
63
|
+
|
|
64
|
+
**GET endpoints:**
|
|
65
|
+
- Fetch single resource
|
|
66
|
+
- Fetch collection with pagination
|
|
67
|
+
- Filter and sort operations
|
|
68
|
+
|
|
69
|
+
**POST endpoints:**
|
|
70
|
+
- Create resource with valid data
|
|
71
|
+
- Verify database record created
|
|
72
|
+
- Test idempotency if applicable
|
|
73
|
+
|
|
74
|
+
**PUT/PATCH endpoints:**
|
|
75
|
+
- Update resource (full/partial)
|
|
76
|
+
- Confirm database update
|
|
77
|
+
|
|
78
|
+
**DELETE endpoints:**
|
|
79
|
+
- Delete resource
|
|
80
|
+
- Verify cascade operations
|
|
81
|
+
- Confirm 404 on re-fetch
|
|
82
|
+
|
|
83
|
+
**Validation:**
|
|
84
|
+
- [ ] Correct status codes (200, 201, 204)
|
|
85
|
+
- [ ] Response bodies match schemas
|
|
86
|
+
- [ ] Database state reflects changes
|
|
87
|
+
|
|
88
|
+
### 3. Error Handling Testing
|
|
89
|
+
|
|
90
|
+
**Test error scenarios:**
|
|
91
|
+
|
|
92
|
+
**Validation Errors (400):**
|
|
93
|
+
- Missing required fields
|
|
94
|
+
- Invalid field types
|
|
95
|
+
- Out-of-range values
|
|
96
|
+
|
|
97
|
+
**Authentication Errors (401):**
|
|
98
|
+
- Unauthenticated requests
|
|
99
|
+
- Expired tokens
|
|
100
|
+
- Invalid credentials
|
|
101
|
+
|
|
102
|
+
**Authorization Errors (403):**
|
|
103
|
+
- Insufficient permissions
|
|
104
|
+
- Accessing other users' resources
|
|
105
|
+
|
|
106
|
+
**Not Found Errors (404):**
|
|
107
|
+
- Non-existent resource IDs
|
|
108
|
+
- Deleted resources
|
|
109
|
+
|
|
110
|
+
**Conflict Errors (409):**
|
|
111
|
+
- Duplicate creation
|
|
112
|
+
- Business logic violations
|
|
113
|
+
|
|
114
|
+
**Server Errors (500):**
|
|
115
|
+
- Database failures (mocked)
|
|
116
|
+
- Third-party service failures
|
|
117
|
+
|
|
118
|
+
**Validation:**
|
|
119
|
+
- [ ] Correct error status codes
|
|
120
|
+
- [ ] Descriptive error messages
|
|
121
|
+
- [ ] No sensitive data leaked
|
|
122
|
+
- [ ] Consistent error format
|
|
123
|
+
|
|
124
|
+
### 4. Request/Response Validation
|
|
125
|
+
|
|
126
|
+
**Test schema enforcement:**
|
|
127
|
+
- Request body validation
|
|
128
|
+
- Query parameter validation
|
|
129
|
+
- Path parameter validation
|
|
130
|
+
- Response schema compliance
|
|
131
|
+
- Content-type headers
|
|
132
|
+
- Request size limits
|
|
133
|
+
|
|
134
|
+
**Validation:**
|
|
135
|
+
- [ ] Invalid requests rejected
|
|
136
|
+
- [ ] Validation errors descriptive
|
|
137
|
+
- [ ] Response schemas enforced
|
|
138
|
+
|
|
139
|
+
### 5. Integration Testing
|
|
140
|
+
|
|
141
|
+
**Test full request-response cycle:**
|
|
142
|
+
- Database transactions
|
|
143
|
+
- Cascade operations
|
|
144
|
+
- Relationship loading
|
|
145
|
+
- Search and filtering
|
|
146
|
+
- Pagination
|
|
147
|
+
- Sorting
|
|
148
|
+
|
|
149
|
+
**Validation:**
|
|
150
|
+
- [ ] Database state correct
|
|
151
|
+
- [ ] Transactions rolled back on errors
|
|
152
|
+
- [ ] Performance acceptable
|
|
153
|
+
|
|
154
|
+
### 6. Coverage Analysis
|
|
155
|
+
|
|
156
|
+
**Actions:**
|
|
157
|
+
1. Run tests with coverage: `{{COVERAGE_COMMAND}}`
|
|
158
|
+
2. Review coverage report
|
|
159
|
+
3. Identify untested code paths
|
|
160
|
+
4. Add tests for uncovered areas
|
|
161
|
+
|
|
162
|
+
**Validation:**
|
|
163
|
+
- [ ] Coverage >= {{COVERAGE_TARGET}}
|
|
164
|
+
- [ ] All endpoints tested
|
|
165
|
+
- [ ] All error paths tested
|
|
166
|
+
|
|
167
|
+
## Test Structure Example
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { describe, it, expect, beforeAll, afterAll } from '{{TEST_FRAMEWORK}}';
|
|
171
|
+
import { app } from '../src/index';
|
|
172
|
+
import { testDb } from '../helpers/test-db';
|
|
173
|
+
|
|
174
|
+
describe('/api/resources', () => {
|
|
175
|
+
beforeAll(async () => {
|
|
176
|
+
await testDb.seed();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
afterAll(async () => {
|
|
180
|
+
await testDb.cleanup();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('GET /api/resources', () => {
|
|
184
|
+
it('should return paginated resources', async () => {
|
|
185
|
+
const response = await app.request('/api/resources?page=1&limit=10');
|
|
186
|
+
|
|
187
|
+
expect(response.status).toBe(200);
|
|
188
|
+
const data = await response.json();
|
|
189
|
+
|
|
190
|
+
expect(data).toHaveProperty('items');
|
|
191
|
+
expect(data.items).toBeInstanceOf(Array);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe('POST /api/resources', () => {
|
|
196
|
+
it('should create resource with valid data', async () => {
|
|
197
|
+
const resource = {
|
|
198
|
+
name: 'Test Resource',
|
|
199
|
+
value: 100
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const response = await app.request('/api/resources', {
|
|
203
|
+
method: 'POST',
|
|
204
|
+
headers: { 'Content-Type': 'application/json' },
|
|
205
|
+
body: JSON.stringify(resource)
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
expect(response.status).toBe(201);
|
|
209
|
+
const data = await response.json();
|
|
210
|
+
expect(data).toHaveProperty('id');
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('should reject invalid data', async () => {
|
|
214
|
+
const response = await app.request('/api/resources', {
|
|
215
|
+
method: 'POST',
|
|
216
|
+
headers: { 'Content-Type': 'application/json' },
|
|
217
|
+
body: JSON.stringify({ invalid: 'data' })
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
expect(response.status).toBe(400);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Best Practices
|
|
227
|
+
|
|
228
|
+
1. **Test Isolation**: Each test should be independent
|
|
229
|
+
2. **AAA Pattern**: Arrange, Act, Assert
|
|
230
|
+
3. **Descriptive Names**: Test names explain behavior
|
|
231
|
+
4. **Mock External Dependencies**: Don't test third-party services
|
|
232
|
+
5. **Database Transactions**: Rollback after tests
|
|
233
|
+
6. **Fast Tests**: Keep total time under 5 seconds
|
|
234
|
+
7. **Realistic Data**: Use production-like test data
|
|
235
|
+
|
|
236
|
+
## Output
|
|
237
|
+
|
|
238
|
+
**Produces:**
|
|
239
|
+
- Integration test files
|
|
240
|
+
- Test coverage reports (>= {{COVERAGE_TARGET}})
|
|
241
|
+
- Documentation validation results
|
|
242
|
+
- Test data fixtures
|
|
243
|
+
|
|
244
|
+
**Success Criteria:**
|
|
245
|
+
- All tests passing
|
|
246
|
+
- Coverage meets target
|
|
247
|
+
- No console warnings
|
|
248
|
+
- Error handling comprehensive
|
|
249
|
+
|
|
250
|
+
## Related Skills
|
|
251
|
+
|
|
252
|
+
- `tdd-methodology` - Test-Driven Development approach
|
|
253
|
+
- `security-testing` - API security testing
|
|
254
|
+
- `performance-testing` - API performance testing
|