codingbuddy-rules 4.2.0 → 4.4.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.
@@ -0,0 +1,233 @@
1
+ ---
2
+ name: deployment-checklist
3
+ description: Use before deploying to staging or production. Covers pre-deploy validation, environment verification, rollback planning, health checks, and post-deploy monitoring.
4
+ ---
5
+
6
+ # Deployment Checklist
7
+
8
+ ## Overview
9
+
10
+ Deployments fail in predictable ways. This checklist prevents the most common causes.
11
+
12
+ **Core principle:** Never deploy what you haven't tested. Never deploy without a rollback plan.
13
+
14
+ **Iron Law:**
15
+ ```
16
+ NO DEPLOY WITHOUT ROLLBACK PLAN
17
+ If you can't roll back in < 5 minutes, don't deploy.
18
+ ```
19
+
20
+ ## When to Use
21
+
22
+ - Before every production deployment
23
+ - Before staging deployments of critical features
24
+ - When deploying database migrations with code
25
+ - When changing environment configuration
26
+ - When deploying infrastructure changes
27
+
28
+ ## Phase 1: Pre-Deploy Validation
29
+
30
+ ### Code Readiness
31
+ ```
32
+ - [ ] All tests passing (zero failures)
33
+ - [ ] Test coverage meets threshold (≥ 80% for new code)
34
+ - [ ] No TypeScript errors (tsc --noEmit passes)
35
+ - [ ] Linting passes (eslint/prettier)
36
+ - [ ] No TODO/FIXME in production code paths
37
+ - [ ] Security audit passed (npm audit --audit-level=high)
38
+ - [ ] PR reviewed and approved
39
+ - [ ] Branch up-to-date with main
40
+ ```
41
+
42
+ ### Build Verification
43
+ ```bash
44
+ # Verify build succeeds from clean state
45
+ rm -rf dist/ node_modules/.cache
46
+ npm run build
47
+
48
+ # Verify the build output
49
+ ls dist/
50
+ node dist/main.js --version
51
+ ```
52
+
53
+ ### Environment Configuration
54
+ ```
55
+ - [ ] All required env vars documented in .env.example
56
+ - [ ] Production env vars set in deployment system
57
+ - [ ] No secrets committed to git
58
+ - [ ] Config differences between environments documented
59
+ - [ ] Feature flags configured correctly
60
+ ```
61
+
62
+ ## Phase 2: Database Migration (if applicable)
63
+
64
+ ```
65
+ - [ ] Migration files reviewed and approved
66
+ - [ ] Migration tested on staging with production data snapshot
67
+ - [ ] Rollback migration written and tested
68
+ - [ ] Migration is backward-compatible (expand-contract pattern)
69
+ - [ ] Estimated migration duration known
70
+ - [ ] Maintenance window scheduled if migration > 30s
71
+
72
+ Migration order: deploy migration → verify → deploy code
73
+ ```
74
+
75
+ ```bash
76
+ # Test migration on staging first
77
+ npm run migration:run --env=staging
78
+
79
+ # Verify migration applied correctly
80
+ npm run migration:status
81
+
82
+ # Verify rollback works
83
+ npm run migration:revert --dry-run
84
+ ```
85
+
86
+ ## Phase 3: Deployment Execution
87
+
88
+ ### Staging First
89
+ ```
90
+ 1. Deploy to staging
91
+ 2. Run smoke tests on staging
92
+ 3. Verify critical paths work
93
+ 4. Check error rates in monitoring
94
+ 5. Get sign-off before promoting to production
95
+ ```
96
+
97
+ ### Production Deploy
98
+ ```bash
99
+ # Tag the release
100
+ git tag v$(npm run version --silent)
101
+ git push origin --tags
102
+
103
+ # Deploy (method varies by platform)
104
+ # Heroku: git push heroku main
105
+ # Railway: railway deploy
106
+ # Docker: docker push && kubectl apply
107
+ # PM2: pm2 deploy ecosystem.config.js production
108
+
109
+ # Monitor during deploy
110
+ watch -n 5 'curl -s https://api.example.com/health | jq .status'
111
+ ```
112
+
113
+ ## Phase 4: Health Checks
114
+
115
+ ### Immediate (within 2 minutes of deploy)
116
+ ```bash
117
+ # Health endpoint
118
+ curl https://api.example.com/health
119
+ # Expected: { "status": "ok", "version": "1.2.3" }
120
+
121
+ # MCP server health
122
+ echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | \
123
+ node dist/main.js 2>/dev/null | jq '.result.tools | length'
124
+ # Expected: > 0
125
+
126
+ # Check for error spikes
127
+ # (in your monitoring tool: Datadog, CloudWatch, etc.)
128
+ ```
129
+
130
+ ### Extended (within 10 minutes)
131
+ ```
132
+ - [ ] Error rate < baseline (< 0.1% for APIs)
133
+ - [ ] Response times < baseline (p95 < 500ms)
134
+ - [ ] Memory usage stable (not growing)
135
+ - [ ] No unexpected log errors
136
+ - [ ] Database connections healthy
137
+ - [ ] External integrations responding
138
+ ```
139
+
140
+ ## Phase 5: Rollback Plan
141
+
142
+ **Document before deploying:**
143
+
144
+ ```markdown
145
+ ## Rollback Plan for v1.2.3
146
+
147
+ **Trigger conditions:**
148
+ - Error rate > 1% for 5 minutes
149
+ - P95 latency > 2s for 5 minutes
150
+ - Any data corruption detected
151
+
152
+ **Rollback steps:**
153
+ 1. git revert [commit] → push
154
+ OR
155
+ kubectl rollout undo deployment/mcp-server
156
+ (estimated time: 2 minutes)
157
+
158
+ 2. If database migration was run:
159
+ npm run migration:revert (estimated time: 30 seconds)
160
+
161
+ 3. Verify rollback:
162
+ curl https://api.example.com/health
163
+
164
+ **Decision maker:** [Name/role]
165
+ **Rollback time limit:** 5 minutes from trigger detection
166
+ ```
167
+
168
+ ## Phase 6: Post-Deploy Monitoring
169
+
170
+ ### First 30 minutes
171
+ ```
172
+ - [ ] Monitor error rates every 5 minutes
173
+ - [ ] Check application logs for unexpected errors
174
+ - [ ] Verify key business metrics unchanged
175
+ - [ ] Test critical user paths manually
176
+ - [ ] Watch memory and CPU trends
177
+ ```
178
+
179
+ ### First 24 hours
180
+ ```
181
+ - [ ] Review full day's error logs
182
+ - [ ] Check performance percentiles (p50, p95, p99)
183
+ - [ ] Verify no data anomalies
184
+ - [ ] Team on standby for issues
185
+ ```
186
+
187
+ ## Platform-Specific Checklists
188
+
189
+ ### Docker / Kubernetes
190
+ ```
191
+ - [ ] Image built and pushed to registry
192
+ - [ ] Deployment manifest updated with new image tag
193
+ - [ ] Resource limits set (CPU, memory)
194
+ - [ ] Liveness and readiness probes configured
195
+ - [ ] Rolling update strategy (not Recreate)
196
+ - [ ] kubectl rollout status deployment/name watched
197
+ ```
198
+
199
+ ### NestJS / Node.js
200
+ ```
201
+ - [ ] NODE_ENV=production set
202
+ - [ ] PM2 cluster mode for multi-core usage
203
+ - [ ] Graceful shutdown handler (SIGTERM)
204
+ - [ ] Memory limits configured
205
+ - [ ] Log rotation configured
206
+ ```
207
+
208
+ ## Quick Reference
209
+
210
+ | Environment | Approach |
211
+ |-------------|----------|
212
+ | Development | Deploy freely, no checklist needed |
213
+ | Staging | Run pre-deploy + health check phases |
214
+ | Production | Full checklist, no exceptions |
215
+
216
+ | Severity | Rollback Trigger |
217
+ |----------|-----------------|
218
+ | P0 Critical | Immediate rollback |
219
+ | P1 High | Rollback if > 5 min to fix |
220
+ | P2 Medium | Fix forward or rollback (team decision) |
221
+ | P3 Low | Fix forward in next deploy |
222
+
223
+ ## Red Flags — Do Not Deploy
224
+
225
+ ```
226
+ ❌ Tests failing
227
+ ❌ Build failing
228
+ ❌ npm audit shows HIGH or CRITICAL vulnerabilities
229
+ ❌ No rollback plan documented
230
+ ❌ Migration not tested on staging
231
+ ❌ Team members unavailable for 2h post-deploy
232
+ ❌ Deploying Friday after 3pm
233
+ ```
@@ -0,0 +1,293 @@
1
+ ---
2
+ name: documentation-generation
3
+ description: Use when creating or updating README, API docs, architecture docs, or CHANGELOG. Generates clear, accurate documentation from code structure and context.
4
+ ---
5
+
6
+ # Documentation Generation
7
+
8
+ ## Overview
9
+
10
+ Good documentation is the gift you give your future self and your team. It is NOT optional.
11
+
12
+ **Core principle:** Documentation describes behavior, not code. If the code changes, update the docs.
13
+
14
+ **Iron Law:**
15
+ ```
16
+ DOCS ARE OUTDATED THE MOMENT THEY ARE WRITTEN — AUTOMATE OR ACCEPT THE DEBT
17
+ ```
18
+
19
+ ## When to Use
20
+
21
+ - Creating a new project README
22
+ - Documenting new API endpoints
23
+ - Generating CHANGELOG entries
24
+ - Writing architecture decision records (ADRs)
25
+ - Creating onboarding guides for new team members
26
+ - Documenting AI rules for multi-tool projects
27
+
28
+ ## Document Types & Templates
29
+
30
+ ### 1. README.md
31
+
32
+ A good README answers: What is this? How do I run it? How do I use it?
33
+
34
+ ```markdown
35
+ # Project Name
36
+
37
+ One-sentence description of what this does and who it's for.
38
+
39
+ ## Quick Start
40
+
41
+ \`\`\`bash
42
+ npm install
43
+ npm run dev
44
+ \`\`\`
45
+
46
+ ## Features
47
+
48
+ - Feature 1: Brief description
49
+ - Feature 2: Brief description
50
+
51
+ ## Installation
52
+
53
+ \`\`\`bash
54
+ # Prerequisites
55
+ node >= 18
56
+ npm >= 9
57
+
58
+ # Install
59
+ npm install
60
+
61
+ # Configure
62
+ cp .env.example .env
63
+ # Edit .env with your values
64
+
65
+ # Run
66
+ npm start
67
+ \`\`\`
68
+
69
+ ## Configuration
70
+
71
+ | Variable | Required | Default | Description |
72
+ |----------|----------|---------|-------------|
73
+ | `PORT` | No | `3000` | Server port |
74
+ | `DATABASE_URL` | Yes | — | PostgreSQL connection string |
75
+
76
+ ## API Reference
77
+
78
+ See [API Documentation](./docs/api.md) for full reference.
79
+
80
+ ## Contributing
81
+
82
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
83
+
84
+ ## License
85
+
86
+ MIT
87
+ ```
88
+
89
+ ### 2. API Documentation
90
+
91
+ ````markdown
92
+ # API Reference
93
+
94
+ ## Authentication
95
+
96
+ All endpoints require Bearer token:
97
+ \`\`\`
98
+ Authorization: Bearer <token>
99
+ \`\`\`
100
+
101
+ ## Endpoints
102
+
103
+ ### GET /users
104
+
105
+ List all users.
106
+
107
+ **Parameters:**
108
+ | Name | Type | Required | Description |
109
+ |------|------|----------|-------------|
110
+ | `page` | integer | No | Page number (default: 1) |
111
+ | `limit` | integer | No | Per-page count (default: 20, max: 100) |
112
+
113
+ **Response:**
114
+ \`\`\`json
115
+ {
116
+ "data": [{ "id": "123", "email": "user@example.com" }],
117
+ "meta": { "total": 42, "page": 1 }
118
+ }
119
+ \`\`\`
120
+
121
+ **Errors:**
122
+ | Code | Status | Description |
123
+ |------|--------|-------------|
124
+ | `UNAUTHORIZED` | 401 | Missing or invalid token |
125
+ | `FORBIDDEN` | 403 | Insufficient permissions |
126
+ ````
127
+
128
+ ### 3. Architecture Decision Record (ADR)
129
+
130
+ ```markdown
131
+ # ADR-001: Use NestJS for MCP Server
132
+
133
+ **Date:** 2024-01-15
134
+ **Status:** Accepted
135
+
136
+ ## Context
137
+
138
+ We need a Node.js framework for the MCP server with dependency injection and testability.
139
+
140
+ ## Decision
141
+
142
+ Use NestJS with TypeScript.
143
+
144
+ ## Rationale
145
+
146
+ - Built-in dependency injection for testable code
147
+ - Decorator-based approach matches MCP patterns
148
+ - Strong TypeScript support
149
+ - Module system aligns with MCP's separation of concerns
150
+
151
+ ## Consequences
152
+
153
+ - Higher initial complexity than Express
154
+ - Requires understanding of NestJS modules
155
+ - Excellent testing support out of the box
156
+ ```
157
+
158
+ ### 4. CHANGELOG
159
+
160
+ Follow [Keep a Changelog](https://keepachangelog.com) format:
161
+
162
+ ```markdown
163
+ # Changelog
164
+
165
+ ## [Unreleased]
166
+
167
+ ### Added
168
+ - New feature X
169
+
170
+ ## [1.2.0] - 2024-01-15
171
+
172
+ ### Added
173
+ - Support for SSE transport mode
174
+ - Bearer token authentication for SSE
175
+
176
+ ### Changed
177
+ - Improved error messages for invalid rules
178
+
179
+ ### Fixed
180
+ - Memory leak in rule file watcher
181
+
182
+ ### Security
183
+ - Fixed token exposure in debug logs
184
+
185
+ ## [1.1.0] - 2024-01-01
186
+ ...
187
+ ```
188
+
189
+ ## Generation Process
190
+
191
+ ### Step 1: Gather Context
192
+
193
+ ```bash
194
+ # Understand the project structure
195
+ ls -la
196
+ cat package.json
197
+ git log --oneline -20 # Recent changes for CHANGELOG
198
+
199
+ # Find existing documentation
200
+ find . -name "*.md" -not -path "*/node_modules/*"
201
+ ```
202
+
203
+ ### Step 2: Extract Information from Code
204
+
205
+ For TypeScript projects, extract JSDoc/TSDoc:
206
+ ```typescript
207
+ /**
208
+ * Search rules by query string.
209
+ * @param query - Search term to match against rule content
210
+ * @param options - Optional filters
211
+ * @returns Matching rules sorted by relevance
212
+ */
213
+ async searchRules(query: string, options?: SearchOptions): Promise<Rule[]>
214
+ ```
215
+
216
+ For configuration:
217
+ ```typescript
218
+ // Extract environment variables
219
+ grep -rn "process.env\." src/ | grep -o "process\.env\.[A-Z_]*" | sort -u
220
+ ```
221
+
222
+ ### Step 3: Write Documentation
223
+
224
+ **Principles:**
225
+ - **Show, don't just tell** — Include working examples for every major feature
226
+ - **Start with Why** — First sentence explains purpose, not mechanism
227
+ - **One job per section** — Each section answers one question
228
+ - **Concrete over abstract** — Specific examples beat generic descriptions
229
+
230
+ ### Step 4: Verify Accuracy
231
+
232
+ ```
233
+ - [ ] All code examples are runnable
234
+ - [ ] Environment variables list matches .env.example
235
+ - [ ] API endpoints match actual routes
236
+ - [ ] Prerequisites match actual requirements
237
+ - [ ] Links are not broken
238
+ ```
239
+
240
+ ## Documentation Checklist by Type
241
+
242
+ ### README
243
+ - [ ] One-line description at top
244
+ - [ ] Quick Start (< 5 steps to run)
245
+ - [ ] Configuration table (all env vars)
246
+ - [ ] At least one working code example
247
+ - [ ] Link to full docs / contributing guide
248
+
249
+ ### API Docs
250
+ - [ ] Authentication documented
251
+ - [ ] All endpoints listed
252
+ - [ ] Request/response examples for each
253
+ - [ ] Error codes documented
254
+ - [ ] Rate limits documented
255
+
256
+ ### CHANGELOG
257
+ - [ ] Follows semver (MAJOR.MINOR.PATCH)
258
+ - [ ] Added / Changed / Deprecated / Removed / Fixed / Security sections
259
+ - [ ] Each entry links to issue/PR
260
+ - [ ] Unreleased section at top
261
+
262
+ ### ADR
263
+ - [ ] Context explains why decision was needed
264
+ - [ ] Alternatives considered
265
+ - [ ] Decision and rationale clear
266
+ - [ ] Consequences (positive and negative) listed
267
+
268
+ ## Common Mistakes
269
+
270
+ | Mistake | Fix |
271
+ |---------|-----|
272
+ | Documenting code, not behavior | Describe what it does, not how |
273
+ | Outdated examples | Add docs to definition of done |
274
+ | No quick start | First 5 minutes → working system |
275
+ | Wall of text | Use tables, code blocks, lists |
276
+ | Missing error docs | Document failure modes |
277
+ | Internal jargon | Write for a new team member |
278
+
279
+ ## Tools to Accelerate
280
+
281
+ ```bash
282
+ # TypeScript → API docs
283
+ npx typedoc --out docs/api src/
284
+
285
+ # Markdown linting
286
+ npx markdownlint-cli "**/*.md"
287
+
288
+ # Link checking
289
+ npx markdown-link-check README.md
290
+
291
+ # CHANGELOG generation from git log
292
+ npx conventional-changelog-cli -p angular
293
+ ```