jettypod 3.0.1
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/.claude/PROTECT_SKILLS.md +28 -0
- package/.claude/settings.json +24 -0
- package/.claude/settings.local.json +16 -0
- package/.claude/skills/epic-discover/SKILL.md +262 -0
- package/.claude/skills/feature-discover/SKILL.md +393 -0
- package/.claude/skills/speed-mode/SKILL.md +364 -0
- package/.claude/skills/stable-mode/SKILL.md +591 -0
- package/.github/workflows/test-safety.yml +85 -0
- package/README.md +25 -0
- package/SPEED-STABLE-AUDIT.md +853 -0
- package/SYSTEM-BEHAVIOR.md +1241 -0
- package/TEST_SAFETY_AUDIT.md +314 -0
- package/TEST_SAFETY_IMPLEMENTATION.md +97 -0
- package/cucumber.js +8 -0
- package/docs/COMMAND_REFERENCE.md +903 -0
- package/docs/DECISIONS.md +68 -0
- package/docs/README.md +48 -0
- package/docs/STANDARDS-SYSTEM-DOCUMENTATION.md +374 -0
- package/docs/TEST-REWRITE-PLAN.md +261 -0
- package/docs/ai-test-writing-requirements.md +219 -0
- package/docs/claude-code-skills.md +607 -0
- package/docs/core-jettypod-methodology/comprehensive-jettypod-methodology.md +582 -0
- package/docs/core-jettypod-methodology/deprecated/jettypod-comprehensive-standards.md +1222 -0
- package/docs/core-jettypod-methodology/deprecated/jettypod-operating-guide.md +3399 -0
- package/docs/core-jettypod-methodology/deprecated/jettypod-technical-checklist.md +1325 -0
- package/docs/core-jettypod-methodology/deprecated/jettypod-vibe-coding-framework.md +1544 -0
- package/docs/core-jettypod-methodology/deprecated/prompt-engineering-guide.md +320 -0
- package/docs/core-jettypod-methodology/deprecated/vibe-coding-cheatsheet (1).md +516 -0
- package/docs/core-jettypod-methodology/deprecated/vibe-coding-framework.md +1544 -0
- package/docs/features/jettypod-standards-explained.md +543 -0
- package/docs/features/standards-inventory.md +257 -0
- package/docs/gap-analysis-current-vs-comprehensive-methodology.md +939 -0
- package/docs/jettypod-system-overview.md +409 -0
- package/features/auto-generate-production-chores.feature +14 -0
- package/features/claude-md-protection/steps.js +487 -0
- package/features/decisions/index.js +490 -0
- package/features/decisions/index.test.js +208 -0
- package/features/git-hooks/git-hooks.feature +30 -0
- package/features/git-hooks/index.js +93 -0
- package/features/git-hooks/index.test.js +137 -0
- package/features/git-hooks/post-commit +56 -0
- package/features/git-hooks/post-merge +47 -0
- package/features/git-hooks/pre-commit +28 -0
- package/features/git-hooks/simple-steps.js +53 -0
- package/features/git-hooks/simple-test.feature +10 -0
- package/features/git-hooks/steps.js +196 -0
- package/features/jettypod-update-command.feature +46 -0
- package/features/mode-prompts/index.js +95 -0
- package/features/mode-prompts/simple-steps.js +44 -0
- package/features/mode-prompts/simple-test.feature +9 -0
- package/features/mode-prompts/validation.test.js +120 -0
- package/features/refactor-mode/steps.js +217 -0
- package/features/refactor-mode.feature +49 -0
- package/features/skills-update/index.test.js +216 -0
- package/features/step_definitions/auto-generate-production-chores.steps.js +162 -0
- package/features/step_definitions/terminal-logo.steps.js +145 -0
- package/features/step_definitions/update-command.steps.js +183 -0
- package/features/terminal-logo/index.js +39 -0
- package/features/terminal-logo/terminal-logo.feature +30 -0
- package/features/update-command/index.js +181 -0
- package/features/update-command/index.test.js +225 -0
- package/features/work-commands/bug-workflow-display.feature +22 -0
- package/features/work-commands/index.js +311 -0
- package/features/work-commands/simple-steps.js +69 -0
- package/features/work-commands/stable-tests.feature +57 -0
- package/features/work-commands/steps.js +1120 -0
- package/features/work-commands/validation.test.js +88 -0
- package/features/work-commands/work-commands.feature +13 -0
- package/features/work-tracking/discovery-validation.test.js +228 -0
- package/features/work-tracking/index.js +1511 -0
- package/features/work-tracking/mode-required.feature +112 -0
- package/features/work-tracking/phase-tracking.test.js +482 -0
- package/features/work-tracking/prototype-tracking.test.js +485 -0
- package/features/work-tracking/tree-view.test.js +310 -0
- package/features/work-tracking/work-set-mode.feature +71 -0
- package/features/work-tracking/work-start-mode.feature +88 -0
- package/full-test.txt +0 -0
- package/install.sh +89 -0
- package/jettypod.js +1640 -0
- package/lib/bug-workflow.js +94 -0
- package/lib/bug-workflow.test.js +177 -0
- package/lib/claudemd.js +130 -0
- package/lib/claudemd.test.js +195 -0
- package/lib/comprehensive-standards-full.json +1778 -0
- package/lib/config.js +181 -0
- package/lib/config.test.js +511 -0
- package/lib/constants.js +107 -0
- package/lib/constants.test.js +164 -0
- package/lib/current-work.js +130 -0
- package/lib/current-work.test.js +146 -0
- package/lib/database-project-config.test.js +107 -0
- package/lib/database.js +256 -0
- package/lib/database.test.js +106 -0
- package/lib/decisions-generator.js +102 -0
- package/lib/decisions-generator.test.js +457 -0
- package/lib/decisions-helpers.js +119 -0
- package/lib/decisions-helpers.test.js +310 -0
- package/lib/discovery-checkpoint.js +83 -0
- package/lib/docs-generator.js +280 -0
- package/lib/external-checklist.js +177 -0
- package/lib/git.js +142 -0
- package/lib/git.test.js +145 -0
- package/lib/logo.js +3 -0
- package/lib/migrations/001-epic-to-parent.js +24 -0
- package/lib/migrations/002-default-work-item-modes.js +37 -0
- package/lib/migrations/002-default-work-item-modes.test.js +351 -0
- package/lib/migrations/003-epic-discovery-fields.js +52 -0
- package/lib/migrations/004-discovery-decisions-table.js +32 -0
- package/lib/migrations/005-migrate-decision-data.js +62 -0
- package/lib/migrations/006-feature-phase-field.js +61 -0
- package/lib/migrations/007-prototype-tracking.js +38 -0
- package/lib/migrations/008-scenario-file-field.js +24 -0
- package/lib/migrations/index.js +74 -0
- package/lib/production-helpers.js +69 -0
- package/lib/project-state.test.js +92 -0
- package/lib/test-helpers.js +184 -0
- package/lib/test-helpers.test.js +255 -0
- package/package.json +36 -0
- package/prototypes/test/index.html +1 -0
- package/setup-dist-repo.sh +68 -0
- package/test-safety-check.sh +80 -0
- package/work-item-tracking-plan.md +199 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
# The Vibe Coding Operating System: Complete Implementation Cheatsheet
|
|
2
|
+
|
|
3
|
+
## Core Formula: CLARITY + RISK = MODE
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Low Clarity + Low Risk = Discovery Mode
|
|
7
|
+
High Clarity + Low Risk = Speed Mode
|
|
8
|
+
High Clarity + Low/Med Risk = Stable Mode (NEW)
|
|
9
|
+
High Clarity + High Risk = Production Mode
|
|
10
|
+
Low Clarity + High Risk = STOP (Discovery first)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## The Modes & Their Purpose
|
|
14
|
+
|
|
15
|
+
| Mode | Goal | Time to Ship | Test Count | When to Use |
|
|
16
|
+
|------|------|--------------|------------|-------------|
|
|
17
|
+
| **Discovery** | Find what to build | Never (prototypes only) | 0-3 per prototype | Multiple viable approaches unclear |
|
|
18
|
+
| **Speed** | Validate it works | 2-4 hours | 3-5 BDD scenarios | Know what to build, need it to exist |
|
|
19
|
+
| **Stable** | Make it dependable | 1-2 days | 10-15 BDD + unit tests | Others will depend on it |
|
|
20
|
+
| **Production** | Make it bulletproof | 1-2 weeks | 30+ BDD + full coverage | Public use, sensitive data, money |
|
|
21
|
+
|
|
22
|
+
## Altitude Rules (Hierarchical Constraints)
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Project Mode = Ceiling for everything
|
|
26
|
+
├── Feature Mode ≤ Project Mode
|
|
27
|
+
└── Task Mode ≤ Feature Mode
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Examples:**
|
|
31
|
+
- Project in Speed → Features can be Discovery or Speed (NEVER Production/Stable)
|
|
32
|
+
- Project in Production → Features can be any mode
|
|
33
|
+
- Feature in Speed → Tasks can only be Discovery or Speed
|
|
34
|
+
|
|
35
|
+
## Mode Transition Triggers
|
|
36
|
+
|
|
37
|
+
### Forward Transitions
|
|
38
|
+
- **Discovery → Speed:** "I know exactly what to build now" + can write 3-5 clear scenarios
|
|
39
|
+
- **Speed → Stable:** "Other features will depend on this" OR "10+ daily users"
|
|
40
|
+
- **Stable → Production:** "Going public" OR "Handling sensitive data" OR "100+ users"
|
|
41
|
+
|
|
42
|
+
### Emergency Transition
|
|
43
|
+
- **Any → Recovery:** Something is broken in production → FIX FIRST
|
|
44
|
+
|
|
45
|
+
### Dependency Rule
|
|
46
|
+
**Before Feature B depends on Feature A:** Either elevate A to Stable OR create isolation interface
|
|
47
|
+
|
|
48
|
+
## Test Architecture by Mode
|
|
49
|
+
|
|
50
|
+
### Discovery Mode Tests
|
|
51
|
+
```gherkin
|
|
52
|
+
# 0-3 scenarios per prototype
|
|
53
|
+
Scenario: Does approach X solve the problem?
|
|
54
|
+
Given the user problem
|
|
55
|
+
When using approach X
|
|
56
|
+
Then evaluate if this helps
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Speed Mode Tests (3-5 scenarios)
|
|
60
|
+
```gherkin
|
|
61
|
+
Feature: Core Value Delivery
|
|
62
|
+
|
|
63
|
+
Scenario: Primary happy path
|
|
64
|
+
Given user has [problem]
|
|
65
|
+
When they use core feature
|
|
66
|
+
Then [problem] is solved
|
|
67
|
+
|
|
68
|
+
Scenario: Data persists
|
|
69
|
+
Given work completed
|
|
70
|
+
When app restarts
|
|
71
|
+
Then work still there
|
|
72
|
+
|
|
73
|
+
# Just prove it works
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Stable Mode Tests (10-15 scenarios)
|
|
77
|
+
```gherkin
|
|
78
|
+
Feature: Dependable Behavior
|
|
79
|
+
|
|
80
|
+
# All Speed tests PLUS:
|
|
81
|
+
|
|
82
|
+
Scenario: Handles missing data
|
|
83
|
+
Given incomplete input
|
|
84
|
+
When action attempted
|
|
85
|
+
Then meaningful error
|
|
86
|
+
And system stays stable
|
|
87
|
+
|
|
88
|
+
Scenario: State integrity maintained
|
|
89
|
+
Given concurrent modifications
|
|
90
|
+
When conflicts occur
|
|
91
|
+
Then resolved predictably
|
|
92
|
+
|
|
93
|
+
# Prove it won't surprise dependencies
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Production Mode Tests (30+ scenarios)
|
|
97
|
+
```gherkin
|
|
98
|
+
Feature: Bulletproof System
|
|
99
|
+
|
|
100
|
+
# All Stable tests PLUS:
|
|
101
|
+
|
|
102
|
+
Scenario Outline: Security validation
|
|
103
|
+
Given malicious <input>
|
|
104
|
+
When processed
|
|
105
|
+
Then attack prevented
|
|
106
|
+
|
|
107
|
+
Scenario: Load handling
|
|
108
|
+
Given 100 concurrent users
|
|
109
|
+
When all act simultaneously
|
|
110
|
+
Then response < 200ms
|
|
111
|
+
And no data corruption
|
|
112
|
+
|
|
113
|
+
# Prove nothing bad can happen
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Integration Test Requirements
|
|
117
|
+
|
|
118
|
+
**Every Mode Needs:**
|
|
119
|
+
```gherkin
|
|
120
|
+
Scenario: Features work together
|
|
121
|
+
Given Feature A creates data
|
|
122
|
+
When Feature B uses that data
|
|
123
|
+
Then data flows correctly
|
|
124
|
+
And state is consistent
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Anti-Pattern Prevention:** Claude builds isolated features by default
|
|
128
|
+
- Always include "must integrate with [existing feature]" in prompts
|
|
129
|
+
- Write integration test BEFORE building feature
|
|
130
|
+
- Include current state structure in context
|
|
131
|
+
|
|
132
|
+
## Technical Stack by Mode
|
|
133
|
+
|
|
134
|
+
| Component | Discovery | Speed | Stable | Production |
|
|
135
|
+
|-----------|-----------|--------|---------|------------|
|
|
136
|
+
| **Frontend** | HTML + CDN | Single React file | React components | Next.js/Remix |
|
|
137
|
+
| **State** | Local variables | useState | Context/Zustand | Redux/Zustand + persistence |
|
|
138
|
+
| **Data** | Hard-coded | localStorage | IndexedDB/SQLite | PostgreSQL |
|
|
139
|
+
| **Auth** | None | None | Basic auth | Auth0/Clerk |
|
|
140
|
+
| **Hosting** | Local only | Netlify drop | Netlify/Vercel | AWS/Railway |
|
|
141
|
+
| **Errors** | console.log | Try/catch basics | Error boundaries | Sentry + monitoring |
|
|
142
|
+
| **Backup** | None | None | Export function | Automated backups |
|
|
143
|
+
|
|
144
|
+
## Code Evolution Patterns
|
|
145
|
+
|
|
146
|
+
### Speed Mode Code
|
|
147
|
+
```javascript
|
|
148
|
+
// Just works
|
|
149
|
+
const saveData = (data) => {
|
|
150
|
+
localStorage.setItem('data', JSON.stringify(data))
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Stable Mode Evolution
|
|
155
|
+
```javascript
|
|
156
|
+
// Same feature, hardened
|
|
157
|
+
const saveData = (data) => {
|
|
158
|
+
try {
|
|
159
|
+
if (!data) throw new Error('No data to save')
|
|
160
|
+
const serialized = JSON.stringify(data)
|
|
161
|
+
if (serialized.length > 5000000) {
|
|
162
|
+
throw new Error('Data too large')
|
|
163
|
+
}
|
|
164
|
+
localStorage.setItem('data', serialized)
|
|
165
|
+
return { success: true }
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('Save failed:', error)
|
|
168
|
+
showUserError('Could not save changes')
|
|
169
|
+
return { success: false, error: error.message }
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Production Mode Evolution
|
|
175
|
+
```javascript
|
|
176
|
+
// Bulletproof with monitoring
|
|
177
|
+
const saveData = async (data) => {
|
|
178
|
+
const transaction = await db.transaction()
|
|
179
|
+
try {
|
|
180
|
+
validateData(data) // Throws if invalid
|
|
181
|
+
await transaction.data.upsert(data)
|
|
182
|
+
await transaction.commit()
|
|
183
|
+
await auditLog('data_saved', { userId, dataId: data.id })
|
|
184
|
+
metrics.increment('data.saves.success')
|
|
185
|
+
return { success: true }
|
|
186
|
+
} catch (error) {
|
|
187
|
+
await transaction.rollback()
|
|
188
|
+
logger.error('Save failed', { error, userId, data })
|
|
189
|
+
metrics.increment('data.saves.failure')
|
|
190
|
+
Sentry.captureException(error)
|
|
191
|
+
throw new UserFacingError('Could not save changes. Support notified.')
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## File Organization by Mode
|
|
197
|
+
|
|
198
|
+
### Speed Mode
|
|
199
|
+
```
|
|
200
|
+
/src
|
|
201
|
+
app.js # Everything in one file
|
|
202
|
+
app.test.js # 3-5 tests
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Stable Mode
|
|
206
|
+
```
|
|
207
|
+
/src
|
|
208
|
+
/components # Extracted components
|
|
209
|
+
/utils # Shared utilities
|
|
210
|
+
/tests # Organized tests
|
|
211
|
+
app.js # Main entry
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Production Mode
|
|
215
|
+
```
|
|
216
|
+
/features
|
|
217
|
+
/expenses
|
|
218
|
+
index.js # Public API
|
|
219
|
+
components/ # Feature components
|
|
220
|
+
utils/ # Feature utilities
|
|
221
|
+
tests/ # Feature tests
|
|
222
|
+
types.ts # TypeScript types
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Claude Prompting by Mode
|
|
226
|
+
|
|
227
|
+
### Discovery Mode Prompt
|
|
228
|
+
```
|
|
229
|
+
"Show me 3 different approaches to [problem]:
|
|
230
|
+
1. Simplest possible
|
|
231
|
+
2. More sophisticated
|
|
232
|
+
3. Most complete
|
|
233
|
+
Build working prototypes I can try."
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Speed Mode Prompt
|
|
237
|
+
```
|
|
238
|
+
"Build [feature] that passes these scenarios:
|
|
239
|
+
[3-5 Gherkin scenarios]
|
|
240
|
+
- Single file
|
|
241
|
+
- localStorage for data
|
|
242
|
+
- Ship in 2 hours
|
|
243
|
+
- Skip edge cases"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Stable Mode Prompt
|
|
247
|
+
```
|
|
248
|
+
"Enhance [feature] for reliability:
|
|
249
|
+
Current code: [paste]
|
|
250
|
+
Current tests: [paste]
|
|
251
|
+
Make it dependable for other features to use:
|
|
252
|
+
- Add error handling
|
|
253
|
+
- Validate inputs
|
|
254
|
+
- Stable interface
|
|
255
|
+
- Keep all existing tests passing"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Production Mode Prompt
|
|
259
|
+
```
|
|
260
|
+
"Production-grade implementation:
|
|
261
|
+
[Comprehensive Gherkin scenarios]
|
|
262
|
+
Requirements:
|
|
263
|
+
- Full error handling
|
|
264
|
+
- Security validation
|
|
265
|
+
- Transaction safety
|
|
266
|
+
- Monitoring hooks
|
|
267
|
+
- Performance optimization
|
|
268
|
+
Include tests for all edge cases."
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Daily Workflow Checklist
|
|
272
|
+
|
|
273
|
+
### Starting a Session
|
|
274
|
+
1. **Check Project Mode** (sets ceiling)
|
|
275
|
+
2. **Check Feature Mode** (within project constraints)
|
|
276
|
+
3. **Write test scenarios FIRST** (BDD)
|
|
277
|
+
4. **Include integration requirements**
|
|
278
|
+
5. **Prompt with appropriate mode context**
|
|
279
|
+
|
|
280
|
+
### Before Committing
|
|
281
|
+
- [ ] Tests pass
|
|
282
|
+
- [ ] Integration tests pass
|
|
283
|
+
- [ ] No orphan files
|
|
284
|
+
- [ ] Code matches current mode standards
|
|
285
|
+
|
|
286
|
+
### Mode Transition Checklist
|
|
287
|
+
- [ ] Current tests all passing
|
|
288
|
+
- [ ] Write new mode's tests (they should fail)
|
|
289
|
+
- [ ] Upgrade code to pass new tests
|
|
290
|
+
- [ ] Update integration tests
|
|
291
|
+
- [ ] Clean up obsolete code
|
|
292
|
+
|
|
293
|
+
## Cleanup Schedule
|
|
294
|
+
|
|
295
|
+
| Mode | When to Clean | What to Clean |
|
|
296
|
+
|------|---------------|---------------|
|
|
297
|
+
| Discovery | Never | Nothing - will be deleted |
|
|
298
|
+
| Speed | Never | Nothing - accept the mess |
|
|
299
|
+
| Stable | During transition | Unused files, duplicate utils, organize by feature |
|
|
300
|
+
| Production | Weekly | Dead code, optimize imports, document patterns |
|
|
301
|
+
|
|
302
|
+
## The Dependency Decision Tree
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
Will something depend on this feature?
|
|
306
|
+
├─ No → Keep in Speed Mode
|
|
307
|
+
└─ Yes → Will it be critical to dependencies?
|
|
308
|
+
├─ No → Stable Mode (hardened but simple)
|
|
309
|
+
└─ Yes → Production Mode (full safety)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Recovery Mode Protocol
|
|
313
|
+
|
|
314
|
+
1. **Stop the bleeding** (disable feature/rollback)
|
|
315
|
+
2. **Communicate** (notify affected users)
|
|
316
|
+
3. **Write failing test** (reproduce bug)
|
|
317
|
+
4. **Fix with minimal change** (no refactoring)
|
|
318
|
+
5. **Verify all tests pass**
|
|
319
|
+
6. **Add regression tests**
|
|
320
|
+
7. **Check for similar bugs**
|
|
321
|
+
8. **Write postmortem**
|
|
322
|
+
9. **Return to previous mode**
|
|
323
|
+
|
|
324
|
+
## Anti-Patterns to Avoid
|
|
325
|
+
|
|
326
|
+
### Discovery Mode
|
|
327
|
+
❌ Writing documentation
|
|
328
|
+
❌ Setting up CI/CD
|
|
329
|
+
❌ Choosing architecture
|
|
330
|
+
|
|
331
|
+
### Speed Mode
|
|
332
|
+
❌ Custom auth
|
|
333
|
+
❌ Microservices
|
|
334
|
+
❌ >5 test scenarios
|
|
335
|
+
❌ Refactoring
|
|
336
|
+
|
|
337
|
+
### Stable Mode
|
|
338
|
+
❌ Premature optimization
|
|
339
|
+
❌ Complex monitoring
|
|
340
|
+
❌ Compliance features
|
|
341
|
+
|
|
342
|
+
### Production Mode
|
|
343
|
+
❌ Shipping untested
|
|
344
|
+
❌ No error handling
|
|
345
|
+
❌ Skipping security
|
|
346
|
+
❌ No rollback plan
|
|
347
|
+
|
|
348
|
+
## Success Metrics
|
|
349
|
+
|
|
350
|
+
| Mode | Success Looks Like | Failure Looks Like |
|
|
351
|
+
|------|-------------------|-------------------|
|
|
352
|
+
| Discovery | Clear direction found | Built nothing / Analysis paralysis |
|
|
353
|
+
| Speed | Shipped in <4 hours, users trying it | Took days, over-engineered |
|
|
354
|
+
| Stable | Dependencies work smoothly | Cascading failures through features |
|
|
355
|
+
| Production | 99.9% uptime, no data loss | Security breaches, data corruption |
|
|
356
|
+
|
|
357
|
+
## The Golden Rules
|
|
358
|
+
|
|
359
|
+
1. **Tests are truth** - Documentation lies, tests run
|
|
360
|
+
2. **Mode sets standards** - Don't apply Production patterns in Speed Mode
|
|
361
|
+
3. **Integration is mandatory** - Isolated features are broken features
|
|
362
|
+
4. **Elevation is additive** - Never delete tests, only add
|
|
363
|
+
5. **Dependencies force elevation** - Stable minimum for anything others depend on
|
|
364
|
+
6. **Ship beats perfect** - Speed Mode today beats Production Mode never
|
|
365
|
+
|
|
366
|
+
## Quick Reference: File Cleanup Patterns
|
|
367
|
+
|
|
368
|
+
### The Speed Mode Mess (Accept It)
|
|
369
|
+
```
|
|
370
|
+
/src
|
|
371
|
+
ExpenseList.js ✓ Keep (it works)
|
|
372
|
+
ExpenseListNew.js ✓ Keep (might need later)
|
|
373
|
+
ExpenseList2.js ✓ Keep (who knows?)
|
|
374
|
+
helpers.js ✓ Keep (something uses it)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### The Stable Mode Cleanup (During Transition)
|
|
378
|
+
```bash
|
|
379
|
+
# Step 1: Find orphans
|
|
380
|
+
grep -r "ExpenseListNew" . # Not found? Delete it
|
|
381
|
+
|
|
382
|
+
# Step 2: Consolidate
|
|
383
|
+
cat expense*.js > temp.js # See the duplication
|
|
384
|
+
# Extract shared logic to utils
|
|
385
|
+
|
|
386
|
+
# Step 3: Test
|
|
387
|
+
npm test # Still passes? Cleanup succeeded
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### The Production Mode Organization
|
|
391
|
+
```
|
|
392
|
+
/features/expenses/
|
|
393
|
+
index.js # Public exports only
|
|
394
|
+
ExpenseList.js # Single source of truth
|
|
395
|
+
utils.js # Consolidated helpers
|
|
396
|
+
tests/ # All expense tests
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## Mode-Specific Testing Commands
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
# Discovery Mode
|
|
403
|
+
# No automated tests - just manual testing
|
|
404
|
+
|
|
405
|
+
# Speed Mode
|
|
406
|
+
npm test -- --maxWorkers=1 # 3-5 tests, should be instant
|
|
407
|
+
|
|
408
|
+
# Stable Mode
|
|
409
|
+
npm test -- --coverage # Ensure critical paths covered
|
|
410
|
+
npm run test:integration # Features work together
|
|
411
|
+
|
|
412
|
+
# Production Mode
|
|
413
|
+
npm test -- --coverage --watchAll=false # Full suite
|
|
414
|
+
npm run test:e2e # End-to-end scenarios
|
|
415
|
+
npm run test:load # Performance testing
|
|
416
|
+
npm run test:security # Security scanning
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## The Elevation Pattern in Practice
|
|
420
|
+
|
|
421
|
+
### Week 1: Speed Mode (Working)
|
|
422
|
+
```javascript
|
|
423
|
+
function addExpense(amount) {
|
|
424
|
+
expenses.push(amount)
|
|
425
|
+
updateTotal()
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Week 2: Stable Mode (Dependable)
|
|
430
|
+
```javascript
|
|
431
|
+
function addExpense(amount) {
|
|
432
|
+
if (!isValidAmount(amount)) {
|
|
433
|
+
throw new Error('Invalid amount')
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
try {
|
|
437
|
+
expenses.push(amount)
|
|
438
|
+
updateTotal()
|
|
439
|
+
persistData()
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.error('Failed to add expense', error)
|
|
442
|
+
showUserError('Could not add expense')
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Week 3: Production Mode (Bulletproof)
|
|
448
|
+
```javascript
|
|
449
|
+
async function addExpense(amount, userId, metadata) {
|
|
450
|
+
// Validation
|
|
451
|
+
const validated = await validateExpense(amount, userId)
|
|
452
|
+
|
|
453
|
+
// Transaction
|
|
454
|
+
const transaction = await db.transaction()
|
|
455
|
+
|
|
456
|
+
try {
|
|
457
|
+
// Business logic
|
|
458
|
+
const expense = await transaction.expenses.create({
|
|
459
|
+
amount: validated.amount,
|
|
460
|
+
userId,
|
|
461
|
+
metadata,
|
|
462
|
+
createdAt: new Date()
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
// Update aggregates
|
|
466
|
+
await transaction.userTotals.increment(userId, amount)
|
|
467
|
+
|
|
468
|
+
// Commit
|
|
469
|
+
await transaction.commit()
|
|
470
|
+
|
|
471
|
+
// Side effects
|
|
472
|
+
await auditLog('expense.created', { expenseId: expense.id, userId })
|
|
473
|
+
metrics.increment('expenses.created')
|
|
474
|
+
|
|
475
|
+
return { success: true, expense }
|
|
476
|
+
|
|
477
|
+
} catch (error) {
|
|
478
|
+
await transaction.rollback()
|
|
479
|
+
logger.error('Failed to add expense', { error, userId, amount })
|
|
480
|
+
Sentry.captureException(error)
|
|
481
|
+
|
|
482
|
+
throw new UserFacingError('Could not add expense. Support has been notified.')
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
## Integration Test Template
|
|
488
|
+
|
|
489
|
+
```gherkin
|
|
490
|
+
# EVERY feature needs this test
|
|
491
|
+
Feature: [New Feature] Integration
|
|
492
|
+
|
|
493
|
+
Scenario: Integrates with existing features
|
|
494
|
+
Given the current system state
|
|
495
|
+
When [new feature] is used
|
|
496
|
+
Then it reads existing data correctly
|
|
497
|
+
And it writes data other features can use
|
|
498
|
+
And it respects existing state management
|
|
499
|
+
And it appears in the main UI
|
|
500
|
+
And existing features still work
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
## The Mode Decision Matrix
|
|
504
|
+
|
|
505
|
+
| Question | Discovery | Speed | Stable | Production |
|
|
506
|
+
|----------|-----------|-------|---------|------------|
|
|
507
|
+
| How many users? | 0 (just me testing) | 1-10 | 10-100 | 100+ |
|
|
508
|
+
| Data loss impact? | Don't care | Annoying | Painful | Catastrophic |
|
|
509
|
+
| Development time? | Unlimited | 2-4 hours | 1-2 days | 1-2 weeks |
|
|
510
|
+
| Test coverage? | None | Happy path | Edge cases | Everything |
|
|
511
|
+
| Refactor tolerance? | Change everything | Change freely | Change carefully | Change never |
|
|
512
|
+
| Deploy confidence? | YOLO | Probably fine | Should work | Will work |
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
*Remember: The mode you choose determines the standards you apply. Don't bring Production Mode thinking to Speed Mode problems, and don't bring Speed Mode standards to Production Mode systems.*
|