@valentia-ai-skills/framework 1.0.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 +103 -0
- package/bin/cli.js +482 -0
- package/package.json +42 -0
- package/scripts/postinstall.js +18 -0
- package/skills/global/api-design/SKILL.md +248 -0
- package/skills/global/api-design/tests/test-prompts.md +25 -0
- package/skills/global/code-standards/SKILL.md +245 -0
- package/skills/global/code-standards/tests/test-prompts.md +26 -0
- package/skills/global/deployment/SKILL.md +240 -0
- package/skills/global/deployment/tests/test-prompts.md +27 -0
- package/skills/global/documentation/SKILL.md +298 -0
- package/skills/global/documentation/tests/test-prompts.md +26 -0
- package/skills/global/git-workflow/SKILL.md +177 -0
- package/skills/global/git-workflow/tests/test-prompts.md +11 -0
- package/skills/global/security-baseline/SKILL.md +239 -0
- package/skills/global/security-baseline/tests/test-prompts.md +23 -0
- package/skills/global/testing-standards/SKILL.md +257 -0
- package/skills/global/testing-standards/tests/test-prompts.md +25 -0
- package/skills/onboarding/SKILL.md +110 -0
- package/skills/stack/devops/SKILL.md +220 -0
- package/skills/stack/devops/tests/test-prompts.md +29 -0
- package/skills/stack/node-backend/SKILL.md +304 -0
- package/skills/stack/node-backend/tests/test-prompts.md +27 -0
- package/skills/stack/python-backend/SKILL.md +304 -0
- package/skills/stack/python-backend/tests/test-prompts.md +27 -0
- package/skills/stack/react/SKILL.md +251 -0
- package/skills/stack/react/tests/test-prompts.md +26 -0
- package/skills/stack/react-native/SKILL.md +255 -0
- package/skills/stack/react-native/tests/test-prompts.md +26 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deployment
|
|
3
|
+
description: >
|
|
4
|
+
Organization-wide deployment standards for CI/CD pipelines, environment
|
|
5
|
+
management, release processes, and rollback procedures. Use this skill
|
|
6
|
+
whenever writing, reviewing, or discussing deployment configurations,
|
|
7
|
+
CI/CD pipelines, Docker files, environment promotion, feature flags,
|
|
8
|
+
release management, or rollback strategies. Triggers on: "deploy",
|
|
9
|
+
"deployment", "CI/CD", "pipeline", "GitHub Actions", "Docker", "Dockerfile",
|
|
10
|
+
"container", "Kubernetes", "k8s", "helm", "terraform", "release",
|
|
11
|
+
"rollback", "staging", "production", "environment", "feature flag",
|
|
12
|
+
"blue-green", "canary", "rolling update". Applies to all teams.
|
|
13
|
+
version: "1.0.0"
|
|
14
|
+
scope: global
|
|
15
|
+
author: Framework Admin
|
|
16
|
+
last_reviewed: 2026-03-19
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Deployment Standards
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
Consistent deployment practices ensure reliable, safe releases across all
|
|
24
|
+
services. These standards cover CI/CD pipelines, environment management,
|
|
25
|
+
containerization, and rollback procedures.
|
|
26
|
+
|
|
27
|
+
## 1. Environment Promotion
|
|
28
|
+
|
|
29
|
+
### Environment Ladder
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Development → Staging → Production
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| Environment | Purpose | Who Deploys | Auto/Manual |
|
|
36
|
+
|-------------|---------|-------------|-------------|
|
|
37
|
+
| Development | Feature testing, integration | Any developer | Auto on PR merge to dev |
|
|
38
|
+
| Staging | Pre-production validation, QA | CI/CD pipeline | Auto on merge to main |
|
|
39
|
+
| Production | Live users | CI/CD + manual approval | Manual gate after staging |
|
|
40
|
+
|
|
41
|
+
### Rules
|
|
42
|
+
- Code must pass through ALL environments in order — no skipping staging
|
|
43
|
+
- Staging must mirror production configuration (same infra, same env vars pattern)
|
|
44
|
+
- Production deployments require at least 1 manual approval
|
|
45
|
+
- Exception: hotfix branches can fast-track with 2 approvals
|
|
46
|
+
|
|
47
|
+
## 2. CI/CD Pipeline Structure
|
|
48
|
+
|
|
49
|
+
### Required Pipeline Stages
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
# Every service must implement these stages:
|
|
53
|
+
|
|
54
|
+
stages:
|
|
55
|
+
# Stage 1: Quality Gates (runs on every PR)
|
|
56
|
+
- lint # Code style, formatting
|
|
57
|
+
- typecheck # TypeScript / mypy
|
|
58
|
+
- test:unit # Unit tests with coverage
|
|
59
|
+
- security:scan # Dependency vulnerability scan
|
|
60
|
+
|
|
61
|
+
# Stage 2: Build (runs on merge to main)
|
|
62
|
+
- build # Compile, bundle, Docker build
|
|
63
|
+
- test:integration # Integration tests against test DB
|
|
64
|
+
|
|
65
|
+
# Stage 3: Deploy (runs after build succeeds)
|
|
66
|
+
- deploy:staging # Auto-deploy to staging
|
|
67
|
+
- test:e2e # E2E tests against staging
|
|
68
|
+
- deploy:production # Manual approval gate → production
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Rules
|
|
72
|
+
- PRs cannot merge if any Stage 1 check fails
|
|
73
|
+
- Build artifacts are created ONCE and promoted through environments
|
|
74
|
+
- Never rebuild between staging and production — same artifact, different config
|
|
75
|
+
- Pipeline must complete in under 15 minutes for Stage 1 (fast feedback)
|
|
76
|
+
- Full pipeline (through staging E2E) under 30 minutes
|
|
77
|
+
|
|
78
|
+
## 3. Containerization (Docker)
|
|
79
|
+
|
|
80
|
+
### Dockerfile Standards
|
|
81
|
+
|
|
82
|
+
```dockerfile
|
|
83
|
+
# ── Stage 1: Dependencies ──
|
|
84
|
+
FROM node:20-alpine AS deps
|
|
85
|
+
WORKDIR /app
|
|
86
|
+
COPY package.json package-lock.json ./
|
|
87
|
+
RUN npm ci --production=false
|
|
88
|
+
|
|
89
|
+
# ── Stage 2: Build ──
|
|
90
|
+
FROM node:20-alpine AS build
|
|
91
|
+
WORKDIR /app
|
|
92
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
93
|
+
COPY . .
|
|
94
|
+
RUN npm run build
|
|
95
|
+
RUN npm prune --production
|
|
96
|
+
|
|
97
|
+
# ── Stage 3: Production ──
|
|
98
|
+
FROM node:20-alpine AS production
|
|
99
|
+
WORKDIR /app
|
|
100
|
+
|
|
101
|
+
# Security: run as non-root
|
|
102
|
+
RUN addgroup -g 1001 appgroup && \
|
|
103
|
+
adduser -u 1001 -G appgroup -D appuser
|
|
104
|
+
USER appuser
|
|
105
|
+
|
|
106
|
+
COPY --from=build /app/dist ./dist
|
|
107
|
+
COPY --from=build /app/node_modules ./node_modules
|
|
108
|
+
COPY --from=build /app/package.json ./
|
|
109
|
+
|
|
110
|
+
EXPOSE 3000
|
|
111
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
|
|
112
|
+
CMD wget -qO- http://localhost:3000/health || exit 1
|
|
113
|
+
|
|
114
|
+
CMD ["node", "dist/main.js"]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Rules
|
|
118
|
+
- Multi-stage builds always — keep production image minimal
|
|
119
|
+
- Run as non-root user — never run as root in production
|
|
120
|
+
- Include HEALTHCHECK in Dockerfile
|
|
121
|
+
- Pin base image versions: `node:20.11-alpine` not `node:latest`
|
|
122
|
+
- Use `.dockerignore` to exclude: node_modules, .git, .env, tests, docs
|
|
123
|
+
- Production image should be under 200MB
|
|
124
|
+
- No dev dependencies in production stage
|
|
125
|
+
|
|
126
|
+
## 4. Environment Configuration
|
|
127
|
+
|
|
128
|
+
### Config by Environment
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
# Pattern: same env var names, different values per environment
|
|
132
|
+
DATABASE_URL=postgres://... # different per environment
|
|
133
|
+
LOG_LEVEL=debug # development
|
|
134
|
+
LOG_LEVEL=info # staging
|
|
135
|
+
LOG_LEVEL=warn # production
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Rules
|
|
139
|
+
- Same env var names across all environments
|
|
140
|
+
- Secrets stored in secrets manager (not in CI/CD variables for production)
|
|
141
|
+
- Environment-specific config via env vars, never via code branches
|
|
142
|
+
- Every env var documented in README (see documentation skill)
|
|
143
|
+
- Config validated at startup (see security-baseline skill)
|
|
144
|
+
|
|
145
|
+
## 5. Release Strategy
|
|
146
|
+
|
|
147
|
+
### Semantic Versioning
|
|
148
|
+
```
|
|
149
|
+
v{MAJOR}.{MINOR}.{PATCH}
|
|
150
|
+
|
|
151
|
+
MAJOR: Breaking changes (API incompatibility)
|
|
152
|
+
MINOR: New features (backward compatible)
|
|
153
|
+
PATCH: Bug fixes (backward compatible)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Release Process
|
|
157
|
+
1. Merge to main → auto-deploy to staging
|
|
158
|
+
2. QA validates on staging (manual or automated)
|
|
159
|
+
3. Create GitHub Release with tag `v1.2.3`
|
|
160
|
+
4. Release triggers production deployment (with manual approval gate)
|
|
161
|
+
5. Monitor dashboards for 15 minutes post-deploy
|
|
162
|
+
6. If issues: rollback immediately
|
|
163
|
+
|
|
164
|
+
### Feature Flags
|
|
165
|
+
For risky changes, use feature flags:
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// Feature flag pattern
|
|
169
|
+
if (featureFlags.isEnabled("new-checkout-flow", { userId: user.id })) {
|
|
170
|
+
return newCheckoutFlow(order);
|
|
171
|
+
} else {
|
|
172
|
+
return legacyCheckoutFlow(order);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Rules
|
|
177
|
+
- Feature flags for any change affecting > 10% of users
|
|
178
|
+
- Flags have an expiry date — clean up within 2 weeks of full rollout
|
|
179
|
+
- Flag states stored in config service (not hardcoded)
|
|
180
|
+
- Always have a kill switch that reverts to old behavior
|
|
181
|
+
|
|
182
|
+
## 6. Rollback Procedures
|
|
183
|
+
|
|
184
|
+
### Automated Rollback Triggers
|
|
185
|
+
- Error rate > 5% for 2 minutes
|
|
186
|
+
- p99 latency > 5s for 5 minutes
|
|
187
|
+
- Health check failures on > 25% of instances
|
|
188
|
+
|
|
189
|
+
### Manual Rollback Process
|
|
190
|
+
```bash
|
|
191
|
+
# Option 1: Revert to previous container image
|
|
192
|
+
kubectl rollout undo deployment/my-service
|
|
193
|
+
|
|
194
|
+
# Option 2: Deploy a specific known-good version
|
|
195
|
+
kubectl set image deployment/my-service app=my-service:v1.2.2
|
|
196
|
+
|
|
197
|
+
# Option 3: Disable via feature flag (fastest)
|
|
198
|
+
# Toggle flag off in config service
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Rules
|
|
202
|
+
- Every deployment must be rollback-ready before proceeding
|
|
203
|
+
- Database migrations must be backward-compatible (new code works with old schema AND new schema)
|
|
204
|
+
- Rollback should complete in under 5 minutes
|
|
205
|
+
- Post-rollback: create incident ticket, investigate, fix forward
|
|
206
|
+
- Never rollback database migrations in production — fix forward only
|
|
207
|
+
|
|
208
|
+
## 7. Database Migration Safety
|
|
209
|
+
|
|
210
|
+
### Safe Migration Patterns
|
|
211
|
+
```
|
|
212
|
+
✅ ADD a new column (nullable or with default)
|
|
213
|
+
✅ ADD a new table
|
|
214
|
+
✅ ADD a new index (CONCURRENTLY)
|
|
215
|
+
✅ RENAME with a transition period (old name → alias → new name)
|
|
216
|
+
|
|
217
|
+
❌ DROP a column (in same deploy as code change)
|
|
218
|
+
❌ RENAME a column (without transition period)
|
|
219
|
+
❌ CHANGE column type (without transition period)
|
|
220
|
+
❌ ADD NOT NULL without default
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Two-Phase Migration Pattern
|
|
224
|
+
For breaking schema changes:
|
|
225
|
+
1. **Phase 1**: Deploy code that works with BOTH old and new schema. Run migration to add new structure.
|
|
226
|
+
2. **Phase 2** (next release): Deploy code that uses only new schema. Remove old structure.
|
|
227
|
+
|
|
228
|
+
## Checklist
|
|
229
|
+
|
|
230
|
+
Before deploying:
|
|
231
|
+
- [ ] All CI stages pass (lint, typecheck, unit tests, security scan)
|
|
232
|
+
- [ ] Docker image is multi-stage, runs as non-root, under 200MB
|
|
233
|
+
- [ ] Integration tests pass against staging
|
|
234
|
+
- [ ] E2E tests pass against staging
|
|
235
|
+
- [ ] Database migration is backward-compatible
|
|
236
|
+
- [ ] Rollback plan documented and tested
|
|
237
|
+
- [ ] Feature flags in place for risky changes
|
|
238
|
+
- [ ] Monitoring dashboards ready for post-deploy observation
|
|
239
|
+
- [ ] Manual approval obtained for production
|
|
240
|
+
- [ ] Changelog updated
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## Test 1: Dockerfile Creation
|
|
2
|
+
**Prompt**: "Write a Dockerfile for a Node.js Express API service with TypeScript compilation"
|
|
3
|
+
**Expected**:
|
|
4
|
+
- Multi-stage build (deps → build → production)
|
|
5
|
+
- Non-root user
|
|
6
|
+
- HEALTHCHECK instruction
|
|
7
|
+
- Pinned base image version
|
|
8
|
+
- Production-only dependencies in final stage
|
|
9
|
+
- .dockerignore mentioned
|
|
10
|
+
|
|
11
|
+
## Test 2: CI/CD Pipeline
|
|
12
|
+
**Prompt**: "Set up a GitHub Actions workflow for a Python FastAPI service with linting, testing, Docker build, and deployment to staging"
|
|
13
|
+
**Expected**:
|
|
14
|
+
- Stages: lint → typecheck → test → build → deploy
|
|
15
|
+
- Runs on PR and merge to main
|
|
16
|
+
- Docker build with caching
|
|
17
|
+
- Integration tests before deploy
|
|
18
|
+
- Environment-specific secrets handling
|
|
19
|
+
|
|
20
|
+
## Test 3: Database Migration Strategy
|
|
21
|
+
**Prompt**: "I need to rename the 'username' column to 'display_name' in our users table. How do I do this safely?"
|
|
22
|
+
**Expected**:
|
|
23
|
+
- Two-phase migration approach
|
|
24
|
+
- Phase 1: add display_name, backfill, deploy code that reads both
|
|
25
|
+
- Phase 2: drop username column in next release
|
|
26
|
+
- Never rename in a single deploy
|
|
27
|
+
- Backward compatibility emphasized
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation
|
|
3
|
+
description: >
|
|
4
|
+
Organization-wide documentation standards for all projects. Use this skill
|
|
5
|
+
whenever writing, reviewing, or generating documentation — READMEs, API docs,
|
|
6
|
+
architecture decision records, onboarding guides, runbooks, changelogs,
|
|
7
|
+
code comments, or any written technical content. Triggers on: "README",
|
|
8
|
+
"documentation", "docs", "API docs", "Swagger", "OpenAPI", "ADR",
|
|
9
|
+
"architecture decision", "runbook", "onboarding guide", "changelog",
|
|
10
|
+
"technical writing", "document this", "write docs for", "explain this code".
|
|
11
|
+
Applies to all teams and all stacks.
|
|
12
|
+
version: "1.0.0"
|
|
13
|
+
scope: global
|
|
14
|
+
author: Framework Admin
|
|
15
|
+
last_reviewed: 2026-03-19
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Documentation Standards
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
Good documentation reduces onboarding time, prevents knowledge silos, and
|
|
23
|
+
makes services maintainable long-term. Every project must maintain a minimum
|
|
24
|
+
set of documentation. These standards define what, how, and when to document.
|
|
25
|
+
|
|
26
|
+
## 1. README.md (Required for Every Repo)
|
|
27
|
+
|
|
28
|
+
Every repository must have a README with these sections in this order:
|
|
29
|
+
|
|
30
|
+
### Template
|
|
31
|
+
```markdown
|
|
32
|
+
# Project Name
|
|
33
|
+
|
|
34
|
+
One-sentence description of what this project does.
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
\`\`\`bash
|
|
39
|
+
# Clone, install, run — copy-paste ready
|
|
40
|
+
git clone ...
|
|
41
|
+
npm install
|
|
42
|
+
npm run dev
|
|
43
|
+
\`\`\`
|
|
44
|
+
|
|
45
|
+
## Overview
|
|
46
|
+
|
|
47
|
+
2-3 paragraphs explaining:
|
|
48
|
+
- What this service/app does
|
|
49
|
+
- Who uses it (internal team, customers, other services)
|
|
50
|
+
- Key technologies and architecture decisions
|
|
51
|
+
|
|
52
|
+
## Prerequisites
|
|
53
|
+
|
|
54
|
+
- Node.js >= 20
|
|
55
|
+
- PostgreSQL 15+
|
|
56
|
+
- Redis 7+
|
|
57
|
+
|
|
58
|
+
## Setup
|
|
59
|
+
|
|
60
|
+
Step-by-step local development setup. Assume a new developer
|
|
61
|
+
with a blank machine.
|
|
62
|
+
|
|
63
|
+
## Environment Variables
|
|
64
|
+
|
|
65
|
+
| Variable | Description | Required | Default |
|
|
66
|
+
|----------|-------------|----------|---------|
|
|
67
|
+
| DATABASE_URL | PostgreSQL connection string | Yes | — |
|
|
68
|
+
| REDIS_URL | Redis connection string | Yes | — |
|
|
69
|
+
| PORT | Server port | No | 3000 |
|
|
70
|
+
|
|
71
|
+
## API Documentation
|
|
72
|
+
|
|
73
|
+
Link to OpenAPI/Swagger docs or inline endpoint summary.
|
|
74
|
+
|
|
75
|
+
## Testing
|
|
76
|
+
|
|
77
|
+
\`\`\`bash
|
|
78
|
+
npm test # unit tests
|
|
79
|
+
npm run test:e2e # end-to-end tests
|
|
80
|
+
npm run test:cov # coverage report
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
## Deployment
|
|
84
|
+
|
|
85
|
+
How to deploy this service. Link to CI/CD pipeline.
|
|
86
|
+
|
|
87
|
+
## Architecture
|
|
88
|
+
|
|
89
|
+
Brief architecture overview or link to ADR documents.
|
|
90
|
+
|
|
91
|
+
## Contributing
|
|
92
|
+
|
|
93
|
+
Link to CONTRIBUTING.md or team-specific contributing guide.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Rules
|
|
97
|
+
- Quick Start must be copy-paste ready — a new developer runs 3 commands and the app starts
|
|
98
|
+
- Environment variables table must list ALL required vars with descriptions
|
|
99
|
+
- Setup assumes a fresh machine — don't skip steps
|
|
100
|
+
- Update README when adding new env vars, endpoints, or setup steps
|
|
101
|
+
|
|
102
|
+
## 2. API Documentation
|
|
103
|
+
|
|
104
|
+
### OpenAPI / Swagger (Required for All APIs)
|
|
105
|
+
|
|
106
|
+
Every API must have machine-readable documentation:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
# openapi.yaml structure
|
|
110
|
+
openapi: 3.0.3
|
|
111
|
+
info:
|
|
112
|
+
title: User Service API
|
|
113
|
+
version: 1.0.0
|
|
114
|
+
description: Manages user accounts and authentication
|
|
115
|
+
paths:
|
|
116
|
+
/api/v1/users:
|
|
117
|
+
get:
|
|
118
|
+
summary: List users
|
|
119
|
+
description: Returns paginated list of users
|
|
120
|
+
parameters:
|
|
121
|
+
- name: page
|
|
122
|
+
in: query
|
|
123
|
+
schema:
|
|
124
|
+
type: integer
|
|
125
|
+
default: 1
|
|
126
|
+
responses:
|
|
127
|
+
'200':
|
|
128
|
+
description: Successful response
|
|
129
|
+
content:
|
|
130
|
+
application/json:
|
|
131
|
+
schema:
|
|
132
|
+
$ref: '#/components/schemas/UserListResponse'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Rules
|
|
136
|
+
- Auto-generate from code where possible (FastAPI does this, Express needs swagger-jsdoc)
|
|
137
|
+
- Every endpoint documented with: summary, description, parameters, request body, responses
|
|
138
|
+
- Include example request/response payloads
|
|
139
|
+
- Document error responses (400, 401, 403, 404, 500)
|
|
140
|
+
- Keep OpenAPI spec in sync with actual implementation — CI should validate this
|
|
141
|
+
|
|
142
|
+
## 3. Architecture Decision Records (ADRs)
|
|
143
|
+
|
|
144
|
+
When a significant technical decision is made, document it:
|
|
145
|
+
|
|
146
|
+
### ADR Template
|
|
147
|
+
```markdown
|
|
148
|
+
# ADR-{number}: {Title}
|
|
149
|
+
|
|
150
|
+
**Date**: YYYY-MM-DD
|
|
151
|
+
**Status**: Proposed | Accepted | Deprecated | Superseded by ADR-{n}
|
|
152
|
+
**Decision makers**: Names
|
|
153
|
+
|
|
154
|
+
## Context
|
|
155
|
+
|
|
156
|
+
What is the issue? What forces are at play?
|
|
157
|
+
|
|
158
|
+
## Decision
|
|
159
|
+
|
|
160
|
+
What is the change we're making?
|
|
161
|
+
|
|
162
|
+
## Consequences
|
|
163
|
+
|
|
164
|
+
### Positive
|
|
165
|
+
- What becomes easier or better?
|
|
166
|
+
|
|
167
|
+
### Negative
|
|
168
|
+
- What becomes harder or worse?
|
|
169
|
+
|
|
170
|
+
### Risks
|
|
171
|
+
- What could go wrong?
|
|
172
|
+
|
|
173
|
+
## Alternatives Considered
|
|
174
|
+
|
|
175
|
+
| Option | Pros | Cons | Why Rejected |
|
|
176
|
+
|--------|------|------|--------------|
|
|
177
|
+
| Option A | ... | ... | ... |
|
|
178
|
+
| Option B | ... | ... | ... |
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### When to Write an ADR
|
|
182
|
+
- Choosing a framework, database, or major library
|
|
183
|
+
- Changing architecture patterns (monolith → microservices)
|
|
184
|
+
- Changing API versioning strategy
|
|
185
|
+
- Adding a new infrastructure component
|
|
186
|
+
- Any decision that will be hard to reverse
|
|
187
|
+
|
|
188
|
+
### Rules
|
|
189
|
+
- Store in `docs/adrs/` directory in the relevant repo
|
|
190
|
+
- Number sequentially: `001-choose-database.md`, `002-api-versioning.md`
|
|
191
|
+
- Never delete ADRs — mark as Deprecated or Superseded
|
|
192
|
+
- Review ADRs when the context changes significantly
|
|
193
|
+
|
|
194
|
+
## 4. Inline Code Documentation
|
|
195
|
+
|
|
196
|
+
### JSDoc / Docstrings for Public APIs
|
|
197
|
+
|
|
198
|
+
Every exported function, class, or module must have a doc comment:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
/**
|
|
202
|
+
* Calculates the total price for an order including tax and discounts.
|
|
203
|
+
*
|
|
204
|
+
* @param items - Array of order line items
|
|
205
|
+
* @param taxRate - Tax rate as a decimal (e.g., 0.15 for 15%)
|
|
206
|
+
* @param discountCode - Optional discount code to apply
|
|
207
|
+
* @returns The calculated total in cents
|
|
208
|
+
* @throws {ValidationError} If items array is empty
|
|
209
|
+
* @throws {DiscountNotFoundError} If discount code is invalid
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* const total = calculateOrderTotal(items, 0.15, "SAVE20");
|
|
213
|
+
*/
|
|
214
|
+
export function calculateOrderTotal(
|
|
215
|
+
items: OrderItem[],
|
|
216
|
+
taxRate: number,
|
|
217
|
+
discountCode?: string,
|
|
218
|
+
): number {
|
|
219
|
+
// ...
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Rules
|
|
224
|
+
- Document all exported/public functions
|
|
225
|
+
- Include `@param`, `@returns`, `@throws`, and `@example`
|
|
226
|
+
- Internal/private functions: comment only if logic is non-obvious
|
|
227
|
+
- Comments explain WHY, not WHAT (code explains what)
|
|
228
|
+
- Delete stale comments — wrong comments are worse than no comments
|
|
229
|
+
|
|
230
|
+
## 5. Changelog
|
|
231
|
+
|
|
232
|
+
Every project maintains a CHANGELOG.md following Keep a Changelog format:
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
# Changelog
|
|
236
|
+
|
|
237
|
+
## [1.2.0] - 2026-03-19
|
|
238
|
+
### Added
|
|
239
|
+
- User profile photo upload endpoint
|
|
240
|
+
- Rate limiting on auth endpoints
|
|
241
|
+
|
|
242
|
+
### Changed
|
|
243
|
+
- Increased password minimum length from 8 to 12
|
|
244
|
+
|
|
245
|
+
### Fixed
|
|
246
|
+
- Login timeout on slow connections
|
|
247
|
+
|
|
248
|
+
## [1.1.0] - 2026-03-01
|
|
249
|
+
### Added
|
|
250
|
+
- ...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Rules
|
|
254
|
+
- Update changelog in the same PR as the code change
|
|
255
|
+
- Group by: Added, Changed, Deprecated, Removed, Fixed, Security
|
|
256
|
+
- Link version headers to git tags/releases
|
|
257
|
+
- Write for humans — "Added user photo upload" not "Implemented PUT /users/:id/photo"
|
|
258
|
+
|
|
259
|
+
## 6. Runbooks (Required for Production Services)
|
|
260
|
+
|
|
261
|
+
Every service running in production needs a runbook:
|
|
262
|
+
|
|
263
|
+
```markdown
|
|
264
|
+
# Service Name — Runbook
|
|
265
|
+
|
|
266
|
+
## Service Overview
|
|
267
|
+
- What it does, who depends on it
|
|
268
|
+
- Health check URL, dashboards, logs
|
|
269
|
+
|
|
270
|
+
## Common Issues
|
|
271
|
+
|
|
272
|
+
### Issue: High Response Latency
|
|
273
|
+
**Symptoms**: p99 latency > 2s, alerts firing
|
|
274
|
+
**Diagnosis**: Check database connection pool, Redis cache hit rate
|
|
275
|
+
**Resolution**: Scale up DB pool, clear stale cache, check for slow queries
|
|
276
|
+
|
|
277
|
+
### Issue: Out of Memory
|
|
278
|
+
**Symptoms**: OOM kills in container logs
|
|
279
|
+
**Diagnosis**: Check for memory leaks, large payload processing
|
|
280
|
+
**Resolution**: Restart pods, increase memory limit, investigate leak
|
|
281
|
+
|
|
282
|
+
## Escalation
|
|
283
|
+
- L1: On-call engineer (check runbook, restart if needed)
|
|
284
|
+
- L2: Service owner (investigate root cause)
|
|
285
|
+
- L3: Platform team (infrastructure issues)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Checklist
|
|
289
|
+
|
|
290
|
+
Before finalizing documentation:
|
|
291
|
+
- [ ] README has all required sections (Quick Start, Setup, Env Vars, etc.)
|
|
292
|
+
- [ ] Quick Start is copy-paste ready and actually works
|
|
293
|
+
- [ ] All API endpoints documented in OpenAPI format
|
|
294
|
+
- [ ] ADRs written for significant technical decisions
|
|
295
|
+
- [ ] Exported functions have JSDoc/docstrings
|
|
296
|
+
- [ ] CHANGELOG updated with this PR's changes
|
|
297
|
+
- [ ] Runbook exists for production services
|
|
298
|
+
- [ ] No stale or outdated documentation
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
## Test 1: README Generation
|
|
2
|
+
**Prompt**: "Generate a README for a Node.js payment processing microservice that uses Express, PostgreSQL, Redis, and Stripe"
|
|
3
|
+
**Expected**:
|
|
4
|
+
- All required sections present (Quick Start through Contributing)
|
|
5
|
+
- Copy-paste ready Quick Start commands
|
|
6
|
+
- Environment variables table with DATABASE_URL, REDIS_URL, STRIPE_KEY, etc.
|
|
7
|
+
- API documentation section
|
|
8
|
+
- Testing commands
|
|
9
|
+
|
|
10
|
+
## Test 2: ADR Writing
|
|
11
|
+
**Prompt**: "We're deciding between PostgreSQL and MongoDB for our new e-commerce service. Write an ADR recommending PostgreSQL"
|
|
12
|
+
**Expected**:
|
|
13
|
+
- Follows ADR template: Context, Decision, Consequences, Alternatives
|
|
14
|
+
- Pros/cons table comparing both options
|
|
15
|
+
- Clear reasoning for the decision
|
|
16
|
+
- Acknowledges tradeoffs
|
|
17
|
+
- Proper status and metadata
|
|
18
|
+
|
|
19
|
+
## Test 3: Function Documentation
|
|
20
|
+
**Prompt**: "Add documentation to this function: `async function processRefund(orderId: string, amount: number, reason: string, isPartial: boolean)`"
|
|
21
|
+
**Expected**:
|
|
22
|
+
- JSDoc with @param for all 4 parameters
|
|
23
|
+
- @returns describing the return value
|
|
24
|
+
- @throws for possible errors
|
|
25
|
+
- @example showing usage
|
|
26
|
+
- Description of what the function does
|