codingbuddy-rules 4.3.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,244 @@
1
+ ---
2
+ name: context-management
3
+ description: Use when working on long tasks that span multiple sessions, when context compaction is a concern, or when decisions from PLAN mode need to persist through ACT and EVAL modes.
4
+ ---
5
+
6
+ # Context Management
7
+
8
+ ## Overview
9
+
10
+ AI assistant context windows are finite. Long tasks get compacted, earlier decisions are forgotten, and continuity breaks. Context management is the practice of preserving critical information so work survives compaction.
11
+
12
+ **Core principle:** If it matters after the current conversation, write it down. Memory is the enemy of continuity.
13
+
14
+ **Iron Law:**
15
+ ```
16
+ EXTERNAL STATE > INTERNAL MEMORY
17
+ Write decisions to files. Files survive compaction; conversation memory does not.
18
+ ```
19
+
20
+ ## When to Use
21
+
22
+ - Starting a task that will span multiple sessions
23
+ - Beginning PLAN mode (decisions must survive to ACT)
24
+ - Completing ACT mode (progress must survive to EVAL)
25
+ - When conversation is approaching context limits
26
+ - Before any context compaction event
27
+ - When resuming work after a break
28
+
29
+ ## The Context Document (codingbuddy)
30
+
31
+ The primary context persistence mechanism is `docs/codingbuddy/context.md`.
32
+
33
+ ```
34
+ docs/codingbuddy/context.md
35
+ ─────────────────────────────
36
+ This file is:
37
+ - Created/reset by PLAN mode
38
+ - Appended by ACT mode
39
+ - Appended by EVAL mode
40
+ - Always at a fixed, predictable path
41
+ - Safe to read at any point
42
+ ```
43
+
44
+ ### What Goes in Context
45
+
46
+ **PLAN mode writes:**
47
+ - Task description
48
+ - Key design decisions and their rationale
49
+ - Architecture choices
50
+ - Dependencies and constraints
51
+ - Recommended ACT agent
52
+
53
+ **ACT mode writes:**
54
+ - Progress milestones completed
55
+ - Files created/modified
56
+ - Implementation decisions made
57
+ - Issues encountered and resolved
58
+ - Next steps
59
+
60
+ **EVAL mode writes:**
61
+ - Quality findings (with severity)
62
+ - Security issues found
63
+ - Performance observations
64
+ - Recommendations for next iteration
65
+
66
+ ### Context Document Format
67
+
68
+ ```markdown
69
+ # Context: [Task Title]
70
+
71
+ ## PLAN — [timestamp]
72
+ **Task:** [Original task description]
73
+ **Primary Agent:** solution-architect
74
+ **Recommended ACT Agent:** agent-architect
75
+
76
+ ### Decisions
77
+ - Decision 1: [What was decided and why]
78
+ - Decision 2: [What was decided and why]
79
+
80
+ ### Notes
81
+ - Implementation note 1
82
+ - Constraint or dependency to remember
83
+
84
+ ---
85
+
86
+ ## ACT — [timestamp]
87
+ **Primary Agent:** agent-architect
88
+
89
+ ### Progress
90
+ - [x] Created RulesService with search capability
91
+ - [x] Added Tests: 12 passing
92
+ - [ ] SSE transport implementation pending
93
+
94
+ ### Notes
95
+ - Used glob for file discovery (faster than readdir recursion)
96
+ - NestJS module structure: McpModule → RulesModule
97
+
98
+ ---
99
+
100
+ ## EVAL — [timestamp]
101
+
102
+ ### Findings
103
+ - [HIGH] Missing rate limiting on /sse endpoint
104
+ - [MEDIUM] Test coverage at 72%, below 80% target
105
+
106
+ ### Recommendations
107
+ - Add rate limiting middleware
108
+ - Add tests for error cases in RulesService
109
+ ```
110
+
111
+ ## Context Strategy by Task Duration
112
+
113
+ ### Short Tasks (< 1 hour, single session)
114
+
115
+ No special context management needed. Conversation memory is sufficient.
116
+
117
+ ### Medium Tasks (1-4 hours, 1-2 sessions)
118
+
119
+ ```
120
+ 1. Write task summary to context.md at start
121
+ 2. Update progress at each major milestone
122
+ 3. Write completion summary before ending session
123
+ ```
124
+
125
+ ### Long Tasks (multi-day, multiple sessions)
126
+
127
+ ```
128
+ 1. Create context.md with full plan (PLAN mode)
129
+ 2. Create task breakdown in docs/codingbuddy/plan/
130
+ 3. Update context.md after each working session
131
+ 4. Begin each session by reading context.md
132
+ 5. Use git commits as progress markers
133
+ ```
134
+
135
+ ## Session Start Protocol
136
+
137
+ When resuming a task:
138
+
139
+ ```markdown
140
+ ## Session Resume Checklist
141
+
142
+ 1. Read context document:
143
+ - docs/codingbuddy/context.md
144
+
145
+ 2. Check git status:
146
+ - What was last committed?
147
+ - Any uncommitted changes?
148
+
149
+ 3. Check task list:
150
+ - What was pending at last session?
151
+
152
+ 4. Verify environment:
153
+ - Tests still passing?
154
+ - Build still working?
155
+
156
+ 5. Update context with session start note
157
+ ```
158
+
159
+ ## Session End Protocol
160
+
161
+ Before ending a session:
162
+
163
+ ```markdown
164
+ ## Session End Checklist
165
+
166
+ 1. Commit all completed work with descriptive message
167
+
168
+ 2. Update context document:
169
+ - Mark completed items
170
+ - Note pending items
171
+ - Capture any decisions made
172
+
173
+ 3. Note exact stopping point:
174
+ - What file/function was being edited?
175
+ - What was the next intended step?
176
+
177
+ 4. If blocked: note the blocker clearly
178
+
179
+ 5. Push to remote if collaborating
180
+ ```
181
+
182
+ ## Information Priority
183
+
184
+ When deciding what to preserve, use this priority:
185
+
186
+ ```
187
+ MUST preserve:
188
+ - Architecture decisions (hard to reconstruct)
189
+ - Why (not what) was done — rationale survives code changes
190
+ - Open questions and blockers
191
+ - External dependencies and constraints
192
+
193
+ SHOULD preserve:
194
+ - Files created and their purpose
195
+ - Test coverage status
196
+ - Performance baseline numbers
197
+
198
+ CAN skip:
199
+ - Step-by-step implementation details (read the code)
200
+ - Obvious decisions (no need to record "used async/await")
201
+ - Information available in git history
202
+ ```
203
+
204
+ ## Context Anti-Patterns
205
+
206
+ | Anti-Pattern | Problem | Fix |
207
+ |-------------|---------|-----|
208
+ | Relying on conversation memory | Compaction erases it | Write to file |
209
+ | Writing everything verbatim | Context file becomes noise | Summarize decisions, not steps |
210
+ | Never reading context file | Repeating work already done | Read at session start |
211
+ | Single monolithic context file | Hard to navigate | Split by phase (PLAN/ACT/EVAL) |
212
+ | Context file not in git | Lost if repo changes machines | Always commit context docs |
213
+
214
+ ## notepad.md (OMC Alternative)
215
+
216
+ For sessions not using codingbuddy's parse_mode, use OMC's notepad:
217
+
218
+ ```
219
+ notepad_write_priority: Critical info always loaded at session start
220
+ notepad_write_working: Session-specific notes (auto-pruned after 7 days)
221
+ notepad_write_manual: Permanent notes that must survive
222
+ ```
223
+
224
+ **When to use notepad vs context.md:**
225
+ - `context.md` → For codingbuddy PLAN/ACT/EVAL workflow
226
+ - notepad → For ad-hoc sessions without formal workflow
227
+
228
+ ## Quick Reference
229
+
230
+ ```
231
+ Context File Locations:
232
+ ──────────────────────
233
+ docs/codingbuddy/context.md → Primary context (PLAN/ACT/EVAL)
234
+ docs/codingbuddy/plan/ → Detailed plan documents
235
+ ~/.claude/notepad.md → Global session notes (OMC)
236
+
237
+ Update Context via MCP:
238
+ ──────────────────────
239
+ update_context(mode, decisions[], notes[], progress[], status)
240
+
241
+ Read Context via MCP:
242
+ ──────────────────────
243
+ read_context(verbosity: minimal|standard|full)
244
+ ```
@@ -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
+ ```