organic-growth 3.1.0 → 3.3.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Test](https://github.com/lab71tech/organic-growth/actions/workflows/test.yml/badge.svg)](https://github.com/lab71tech/organic-growth/actions/workflows/test.yml) [![GitHub Release](https://img.shields.io/github/v/release/lab71tech/organic-growth)](https://github.com/lab71tech/organic-growth/releases)
4
4
 
5
- Claude Code setup for incremental software development.
5
+ Claude Code, opencode, and Codex setup for incremental software development.
6
6
 
7
7
  Grow features in natural stages, where each stage delivers a complete, working system.
8
8
 
@@ -21,24 +21,40 @@ bunx organic-growth
21
21
  # Or with npx:
22
22
  npx organic-growth
23
23
 
24
+ # Install for opencode:
25
+ bunx organic-growth --opencode
26
+
27
+ # Install for Codex:
28
+ bunx organic-growth --codex
29
+ # Or:
30
+ bunx organic-growth --target codex
31
+
24
32
  # With a product DNA document:
25
33
  bunx organic-growth docs/my-product-spec.md
26
34
 
27
35
  # Force overwrite existing files:
28
36
  bunx organic-growth --force
37
+
38
+ # Upgrade managed files (preserves CLAUDE.md, .mcp.json, etc.):
39
+ bunx organic-growth --upgrade
40
+
41
+ # Upgrade Codex templates explicitly:
42
+ bunx organic-growth --upgrade --codex
29
43
  ```
30
44
 
31
- This installs `CLAUDE.md` at your project root and a `.claude/` directory with agents and commands. No runtime dependencies.
45
+ Default install creates `CLAUDE.md` and `.claude/` for Claude Code. `--opencode` installs `AGENTS.md` and `.opencode/`. `--codex` installs `AGENTS.md` and `.codex/`. No runtime dependencies.
32
46
 
33
47
  ## What You Get
34
48
 
49
+ ### Claude Code (default)
50
+
35
51
  ```
36
52
  CLAUDE.md # Project context template + growth philosophy
37
53
  .claude/
38
54
  ├── agents/
39
55
  │ └── gardener.md # Plans, implements, and validates growth stages
40
56
  ├── commands/
41
- │ ├── seed.md # /seed — bootstrap new project
57
+ │ ├── seed.md # /seed — plant the seed (new or existing project)
42
58
  │ ├── grow.md # /grow — plan a new feature
43
59
  │ ├── map.md # /map — view or adjust growth map
44
60
  │ ├── next.md # /next — implement next stage
@@ -55,15 +71,50 @@ CLAUDE.md # Project context template + growth philosop
55
71
  └── growth/ # One growth plan per feature
56
72
  ```
57
73
 
74
+ ### opencode
75
+
76
+ ```
77
+ AGENTS.md # Project context template + growth philosophy
78
+ .opencode/
79
+ ├── agents/
80
+ │ └── gardener.md
81
+ ├── commands/
82
+ │ ├── seed.md
83
+ │ ├── grow.md
84
+ │ ├── map.md
85
+ │ ├── next.md
86
+ │ ├── next-automatic.md
87
+ │ ├── replan.md
88
+ │ └── review.md
89
+ └── ...
90
+ ```
91
+
92
+ ### Codex
93
+
94
+ ```
95
+ AGENTS.md # Project context template + growth philosophy
96
+ .codex/
97
+ └── prompts/
98
+ ├── seed.md
99
+ ├── grow.md
100
+ ├── map.md
101
+ ├── next.md
102
+ ├── next-automatic.md
103
+ ├── replan.md
104
+ └── review.md
105
+ ```
106
+
58
107
  Growth plan files (`.organic-growth/growth/*.md`) use plant-themed visual markers -- seedlings for pending stages, trees for completed ones, vines between sections -- so you can tell at a glance where a feature stands.
59
108
 
60
109
  A **post-stage test** hook and a **post-stage review** hook run automatically after every stage commit, in order:
61
110
 
62
- 1. **Test hook** — runs your test suite (discovered from the `**Test:**` field in CLAUDE.md) and injects pass/fail results into the conversation. On failure, tells Claude to fix before continuing.
111
+ 1. **Test hook** — runs your test suite (discovered from the `**Test:**` field in `CLAUDE.md`) and injects pass/fail results into the conversation. On failure, tells Claude to fix before continuing.
63
112
  2. **Review hook** — captures the commit diff and injects it as review context, giving the gardener agent an immediate second look at what changed.
64
113
 
65
114
  Tests run first so failures are caught before the review. This makes the quality gate deterministic — tests always run after stage commits, regardless of whether the agent remembers to.
66
115
 
116
+ Codex support uses prompt files in `.codex/prompts/`. Launch Codex with `CODEX_HOME=.codex codex` to use the repo-local Organic Growth prompts. Claude-style post-stage hooks are not currently installed for Codex. Upgrade auto-detects the installed target when the repo contains only one managed config tree, but the explicit form `npx organic-growth --upgrade --codex` is also supported.
117
+
67
118
  ## Workflow
68
119
 
69
120
  ```bash
@@ -92,7 +143,7 @@ Tests run first so failures are caught before the review. This makes the quality
92
143
  - **Rolling plan:** 3-5 stages ahead, re-evaluate every 3
93
144
  - **Two-layer quality:** [properties](#property-based-planning) before code, deterministic tools after every stage, LLM review on demand
94
145
  - **Context hygiene:** fresh session every 3 stages
95
- - **Product context required:** fill in CLAUDE.md or provide a DNA document
146
+ - **Product context required:** fill in `CLAUDE.md` or `AGENTS.md`, or provide a DNA document
96
147
 
97
148
  ## Property-Based Planning
98
149
 
@@ -106,19 +157,20 @@ Properties are not test cases or user stories. A test says "when I do X, Y happe
106
157
  count decreases by exactly one" [invariant]
107
158
  ```
108
159
 
109
- **Why this matters for LLM-assisted development:** When Claude generates a stage, you review 3-5 properties instead of a 300-line diff. If the properties are right, the code is constrained to be right. The review shifts from "is this code correct?" to "are these rules complete?"
160
+ **Why this matters for LLM-assisted development:** When your coding agent generates a stage, you review 3-5 properties instead of a 300-line diff. If the properties are right, the code is constrained to be right. The review shifts from "is this code correct?" to "are these rules complete?"
110
161
 
111
162
  Properties **accumulate** across stages. Stage 3 must still satisfy the properties from stages 1 and 2. They are permanent commitments, not checkboxes to discard. This is what prevents regressions as the feature grows.
112
163
 
113
- The gardener agent handles the full property format — categories, failure analysis, dependency tracking. See the [example growth plan](docs/example-growth-plan.md) for what this looks like in practice.
164
+ The gardener agent handles the full property format — categories, failure analysis, dependency tracking. See the [example growth plan](.organic-growth/example-growth-plan.md) for what this looks like in practice.
114
165
 
115
166
  ## After Install
116
167
 
117
- 1. Edit `CLAUDE.md` — fill in the Product section (or run `/seed`)
168
+ 1. Edit `CLAUDE.md` or `AGENTS.md` — fill in the Product section (or run `/seed`)
118
169
  2. Fill in Quality Tools section with your project's lint/test commands
119
- 3. Start building with `/grow`
170
+ 3. For Codex, launch with `CODEX_HOME=.codex codex`
171
+ 4. Start building with `/grow`
120
172
 
121
- See the [example growth plan](docs/example-growth-plan.md) to see properties, stages, and accumulation in action.
173
+ See the [example growth plan](.organic-growth/example-growth-plan.md) to see properties, stages, and accumulation in action.
122
174
 
123
175
  ## Releases
124
176
 
package/bin/cli.mjs CHANGED
@@ -18,6 +18,7 @@ const __filename = fileURLToPath(import.meta.url);
18
18
  const __dirname = dirname(__filename);
19
19
  const TEMPLATES_DIR = join(__dirname, '..', 'templates');
20
20
  const TEMPLATES_OPENCODE_DIR = join(__dirname, '..', 'templates-opencode');
21
+ const TEMPLATES_CODEX_DIR = join(__dirname, '..', 'templates-codex');
21
22
  const TARGET_DIR = process.cwd();
22
23
 
23
24
  const RESET = '\x1b[0m';
@@ -120,19 +121,87 @@ function readVersion() {
120
121
  return pkg.version;
121
122
  }
122
123
 
124
+ const TARGETS = {
125
+ claude: {
126
+ label: 'Claude Code',
127
+ templatesDir: TEMPLATES_DIR,
128
+ contextFile: 'CLAUDE.md',
129
+ userFiles: ['CLAUDE.md', '.mcp.json'],
130
+ },
131
+ opencode: {
132
+ label: 'opencode',
133
+ templatesDir: TEMPLATES_OPENCODE_DIR,
134
+ contextFile: 'AGENTS.md',
135
+ userFiles: ['AGENTS.md', 'opencode.json'],
136
+ },
137
+ codex: {
138
+ label: 'Codex',
139
+ templatesDir: TEMPLATES_CODEX_DIR,
140
+ contextFile: 'AGENTS.md',
141
+ userFiles: ['AGENTS.md'],
142
+ }
143
+ };
144
+
145
+ function detectInstalledTarget(targetDir) {
146
+ const installedTargets = [];
147
+
148
+ if (existsSync(join(targetDir, '.claude'))) installedTargets.push('claude');
149
+ if (existsSync(join(targetDir, '.opencode'))) installedTargets.push('opencode');
150
+ if (existsSync(join(targetDir, '.codex'))) installedTargets.push('codex');
151
+
152
+ if (installedTargets.length > 1) {
153
+ console.error(`Error: multiple managed target directories found (${installedTargets.join(', ')}). Re-run with --target, --opencode, or --codex.`);
154
+ process.exit(1);
155
+ }
156
+
157
+ return installedTargets[0] || null;
158
+ }
159
+
160
+ function parseTarget(args, targetDir, upgrade) {
161
+ const explicitTargetIndex = args.findIndex(arg => arg === '--target');
162
+ const explicitTarget = explicitTargetIndex >= 0 ? args[explicitTargetIndex + 1] : null;
163
+ const isOpencode = args.includes('--opencode');
164
+ const isCodex = args.includes('--codex');
165
+
166
+ if (explicitTargetIndex >= 0 && !explicitTarget) {
167
+ console.error(`Error: missing value for --target. Expected one of: ${Object.keys(TARGETS).join(', ')}.`);
168
+ process.exit(1);
169
+ }
170
+
171
+ if (explicitTarget && !TARGETS[explicitTarget]) {
172
+ console.error(`Error: unknown target "${explicitTarget}". Expected one of: ${Object.keys(TARGETS).join(', ')}.`);
173
+ process.exit(1);
174
+ }
175
+
176
+ const selected = [explicitTarget, isOpencode ? 'opencode' : null, isCodex ? 'codex' : null].filter(Boolean);
177
+ if (selected.length > 1) {
178
+ console.error('Error: choose only one install target. Use either --target, --opencode, or --codex.');
179
+ process.exit(1);
180
+ }
181
+
182
+ if (selected.length === 0 && upgrade) {
183
+ return detectInstalledTarget(targetDir) || 'claude';
184
+ }
185
+
186
+ return selected[0] || 'claude';
187
+ }
188
+
123
189
  function printHelp() {
124
190
  log('');
125
- log(`${GREEN}🌱 Organic Growth${RESET} — Claude Code + opencode setup for incremental development`);
191
+ log(`${GREEN}🌱 Organic Growth${RESET} — Claude Code, opencode, and Codex setup for incremental development`);
126
192
  log('');
127
193
  log(`${CYAN}Usage:${RESET}`);
128
194
  log(` npx organic-growth [options] [dna-file.md]`);
129
195
  log('');
130
196
  log(`${CYAN}Options:${RESET}`);
131
197
  log(` -f, --force Overwrite existing files without prompting`);
198
+ log(` --upgrade Update managed files while preserving user customizations`);
132
199
  log(` --migrate Move legacy docs/growth and docs/product-dna.md to .organic-growth/`);
133
200
  log(` -h, --help Show this help message`);
134
201
  log(` -v, --version Show version number`);
202
+ log(` --target Install templates for claude, opencode, or codex`);
135
203
  log(` --opencode Install opencode templates (AGENTS.md + .opencode/)`);
204
+ log(` --codex Install Codex templates (AGENTS.md + .codex/)`);
136
205
  log('');
137
206
  log(`${CYAN}Arguments:${RESET}`);
138
207
  log(` dna-file.md Path to a product DNA document to copy into .organic-growth/`);
@@ -140,7 +209,10 @@ function printHelp() {
140
209
  log(`${CYAN}Examples:${RESET}`);
141
210
  log(` npx organic-growth Install Claude Code templates`);
142
211
  log(` npx organic-growth --opencode Install opencode templates`);
212
+ log(` npx organic-growth --codex Install Codex templates`);
213
+ log(` npx organic-growth --target codex Install Codex templates`);
143
214
  log(` npx organic-growth --force Install templates (overwrite existing)`);
215
+ log(` npx organic-growth --upgrade Update managed files, keep user customizations`);
144
216
  log(` npx organic-growth --migrate Migrate legacy docs/ state into .organic-growth/`);
145
217
  log(` npx organic-growth spec.md Install templates + copy DNA document`);
146
218
  log('');
@@ -160,126 +232,213 @@ async function install() {
160
232
  }
161
233
 
162
234
  const force = args.includes('--force') || args.includes('-f');
235
+ const upgrade = args.includes('--upgrade');
163
236
  const migrate = args.includes('--migrate');
164
- const isOpencode = args.includes('--opencode');
237
+ const target = parseTarget(args, TARGET_DIR, upgrade);
238
+ const targetConfig = TARGETS[target];
165
239
  const dna = args.find(a => !a.startsWith('-') && a.endsWith('.md'));
166
240
 
241
+ // --upgrade and --force are mutually exclusive
242
+ if (upgrade && force) {
243
+ console.error('Error: --upgrade and --force are mutually exclusive. Use --upgrade to update managed files while preserving user customizations, or --force to overwrite everything.');
244
+ process.exit(1);
245
+ }
246
+
247
+ // User-customized files that --upgrade should never overwrite or create
248
+ const USER_FILES = new Set(targetConfig.userFiles);
249
+
250
+ function isUserFile(filePath) {
251
+ // Check if the file's basename (top-level name) is in the user files set
252
+ return USER_FILES.has(filePath);
253
+ }
254
+
167
255
  log('');
168
- if (isOpencode) {
169
- log(`${GREEN}🌱 Organic Growth${RESET} — opencode setup for incremental development`);
256
+ if (upgrade) {
257
+ log(`${GREEN}🌱 Organic Growth${RESET} — upgrading managed files`);
170
258
  } else {
171
- log(`${GREEN}🌱 Organic Growth${RESET} — Claude Code setup for incremental development`);
259
+ log(`${GREEN}🌱 Organic Growth${RESET} — ${targetConfig.label} setup for incremental development`);
172
260
  }
173
261
  log('');
174
262
 
175
- const templatesDir = isOpencode ? TEMPLATES_OPENCODE_DIR : TEMPLATES_DIR;
176
- const files = getAllFiles(templatesDir);
177
- const created = [];
178
- const skipped = [];
263
+ if (upgrade) {
264
+ // Read existing version for display
265
+ const versionFilePath = join(TARGET_DIR, '.organic-growth', '.version');
266
+ const fromVersion = existsSync(versionFilePath)
267
+ ? readFileSync(versionFilePath, 'utf8').trim()
268
+ : 'unknown';
269
+ const toVersion = readVersion();
179
270
 
180
- for (const file of files) {
181
- const src = join(templatesDir, file);
182
- const dest = join(TARGET_DIR, file);
183
- const destDir = dirname(dest);
271
+ const templatesDir = targetConfig.templatesDir;
272
+ const files = getAllFiles(templatesDir);
273
+ const updated = [];
274
+ const skippedUser = [];
184
275
 
185
- if (!existsSync(destDir)) {
186
- mkdirSync(destDir, { recursive: true });
187
- }
276
+ for (const file of files) {
277
+ const src = join(templatesDir, file);
278
+ const dest = join(TARGET_DIR, file);
279
+ const destDir = dirname(dest);
188
280
 
189
- if (existsSync(dest) && !force) {
190
- if (!process.stdin.isTTY) {
191
- skipped.push(file);
281
+ if (isUserFile(file)) {
282
+ // User-customized files: skip if they exist, don't create if missing
283
+ if (existsSync(dest)) {
284
+ skippedUser.push(file);
285
+ }
286
+ // If it doesn't exist, we intentionally do NOT create it (P8)
192
287
  continue;
193
288
  }
194
- const answer = await ask(`${YELLOW}!${RESET} ${file} already exists. Overwrite? [y/N] `);
195
- if (answer !== 'y' && answer !== 'yes') {
196
- skipped.push(file);
197
- continue;
289
+
290
+ // Managed file: overwrite (or create if new)
291
+ if (!existsSync(destDir)) {
292
+ mkdirSync(destDir, { recursive: true });
198
293
  }
294
+ copyFileSync(src, dest);
295
+ updated.push(file);
199
296
  }
200
297
 
201
- copyFileSync(src, dest);
202
- created.push(file);
203
- }
298
+ // Display upgrade results
299
+ info(`Upgrading from ${CYAN}${fromVersion}${RESET} to ${CYAN}${toVersion}${RESET}`);
300
+ log('');
204
301
 
205
- // Create .organic-growth/growth/ directory
206
- const growthDir = join(TARGET_DIR, '.organic-growth', 'growth');
207
- if (!existsSync(growthDir)) {
208
- mkdirSync(growthDir, { recursive: true });
209
- created.push('.organic-growth/growth/');
210
- }
302
+ if (updated.length > 0) {
303
+ log(`${GREEN}Updated:${RESET}`);
304
+ for (const f of updated) {
305
+ log(` ${DIM}${f}${RESET}`);
306
+ }
307
+ }
308
+ if (skippedUser.length > 0) {
309
+ log(`${YELLOW}Skipped (user customized):${RESET}`);
310
+ for (const f of skippedUser) {
311
+ log(` ${DIM}${f}${RESET}`);
312
+ }
313
+ }
211
314
 
212
- // Handle DNA document
213
- if (dna) {
214
- const dnaSource = resolve(TARGET_DIR, dna);
215
- if (existsSync(dnaSource)) {
216
- const dnaDest = join(TARGET_DIR, '.organic-growth', 'product-dna.md');
217
- mkdirSync(dirname(dnaDest), { recursive: true });
218
- copyFileSync(dnaSource, dnaDest);
219
- success(`Product DNA copied from ${dna}`);
220
- } else {
221
- warn(`DNA file not found: ${dna}`);
315
+ // Write version file after all managed files are updated
316
+ const ogDir = join(TARGET_DIR, '.organic-growth');
317
+ if (!existsSync(ogDir)) {
318
+ mkdirSync(ogDir, { recursive: true });
222
319
  }
223
- }
320
+ writeFileSync(join(ogDir, '.version'), toVersion);
224
321
 
225
- if (migrate) {
226
- const migrated = migrateLegacyState(TARGET_DIR);
227
- if (migrated.length > 0) {
228
- log('');
229
- log(`${GREEN}Migrated:${RESET}`);
230
- for (const step of migrated) {
231
- log(` ${DIM}${step}${RESET}`);
322
+ log('');
323
+ log(`${GREEN}Done!${RESET} ${updated.length} updated, ${skippedUser.length} skipped.`);
324
+ log('');
325
+ } else {
326
+ // Normal install flow
327
+ const templatesDir = targetConfig.templatesDir;
328
+ const files = getAllFiles(templatesDir);
329
+ const created = [];
330
+ const skipped = [];
331
+
332
+ for (const file of files) {
333
+ const src = join(templatesDir, file);
334
+ const dest = join(TARGET_DIR, file);
335
+ const destDir = dirname(dest);
336
+
337
+ if (!existsSync(destDir)) {
338
+ mkdirSync(destDir, { recursive: true });
232
339
  }
233
- } else {
234
- info('No legacy docs/ state found to migrate');
235
- }
236
- }
237
340
 
238
- log('');
239
- if (created.length > 0) {
240
- log(`${GREEN}Installed:${RESET}`);
241
- for (const f of created) {
242
- log(` ${DIM}${f}${RESET}`);
341
+ if (existsSync(dest) && !force) {
342
+ if (!process.stdin.isTTY) {
343
+ skipped.push(file);
344
+ continue;
345
+ }
346
+ const answer = await ask(`${YELLOW}!${RESET} ${file} already exists. Overwrite? [y/N] `);
347
+ if (answer !== 'y' && answer !== 'yes') {
348
+ skipped.push(file);
349
+ continue;
350
+ }
351
+ }
352
+
353
+ copyFileSync(src, dest);
354
+ created.push(file);
243
355
  }
244
- }
245
- if (skipped.length > 0) {
246
- log(`${YELLOW}Skipped (already exist):${RESET}`);
247
- for (const f of skipped) {
248
- log(` ${DIM}${f}${RESET}`);
356
+
357
+ // Create .organic-growth/growth/ directory
358
+ const growthDir = join(TARGET_DIR, '.organic-growth', 'growth');
359
+ if (!existsSync(growthDir)) {
360
+ mkdirSync(growthDir, { recursive: true });
361
+ created.push('.organic-growth/growth/');
249
362
  }
250
- }
251
363
 
252
- log('');
253
- log(`${GREEN}Done!${RESET} Next steps:`);
254
- log('');
255
- if (isOpencode) {
364
+ // Handle DNA document
256
365
  if (dna) {
257
- info(`Run ${CYAN}/seed .organic-growth/product-dna.md${RESET} to bootstrap from your DNA document`);
258
- } else {
259
- info(`Run ${CYAN}/seed${RESET} to bootstrap a new project (interview mode)`);
260
- info(`Or: ${CYAN}/seed path/to/product-doc.md${RESET} if you have a product document`);
366
+ const dnaSource = resolve(TARGET_DIR, dna);
367
+ if (existsSync(dnaSource)) {
368
+ const dnaDest = join(TARGET_DIR, '.organic-growth', 'product-dna.md');
369
+ mkdirSync(dirname(dnaDest), { recursive: true });
370
+ copyFileSync(dnaSource, dnaDest);
371
+ success(`Product DNA copied from ${dna}`);
372
+ } else {
373
+ warn(`DNA file not found: ${dna}`);
374
+ }
261
375
  }
262
- info(`Edit ${CYAN}AGENTS.md${RESET} to fill in your tech stack and quality tools`);
263
- } else {
376
+
377
+ if (migrate) {
378
+ const migrated = migrateLegacyState(TARGET_DIR);
379
+ if (migrated.length > 0) {
380
+ log('');
381
+ log(`${GREEN}Migrated:${RESET}`);
382
+ for (const step of migrated) {
383
+ log(` ${DIM}${step}${RESET}`);
384
+ }
385
+ } else {
386
+ info('No legacy docs/ state found to migrate');
387
+ }
388
+ }
389
+
390
+ log('');
391
+ if (created.length > 0) {
392
+ log(`${GREEN}Installed:${RESET}`);
393
+ for (const f of created) {
394
+ log(` ${DIM}${f}${RESET}`);
395
+ }
396
+ }
397
+ if (skipped.length > 0) {
398
+ log(`${YELLOW}Skipped (already exist):${RESET}`);
399
+ for (const f of skipped) {
400
+ log(` ${DIM}${f}${RESET}`);
401
+ }
402
+ }
403
+
404
+ // Write version file after all templates and DNA are handled
405
+ const versionFilePath = join(TARGET_DIR, '.organic-growth', '.version');
406
+ const ogDir = dirname(versionFilePath);
407
+ if (!existsSync(ogDir)) {
408
+ mkdirSync(ogDir, { recursive: true });
409
+ }
410
+ writeFileSync(versionFilePath, readVersion());
411
+
412
+ log('');
413
+ log(`${GREEN}Done!${RESET} Next steps:`);
414
+ log('');
264
415
  if (dna) {
265
416
  info(`Run ${CYAN}/seed .organic-growth/product-dna.md${RESET} to bootstrap from your DNA document`);
266
417
  } else {
267
418
  info(`Run ${CYAN}/seed${RESET} to bootstrap a new project (interview mode)`);
268
419
  info(`Or: ${CYAN}/seed path/to/product-doc.md${RESET} if you have a product document`);
269
420
  }
270
- info(`Edit ${CYAN}CLAUDE.md${RESET} to fill in your tech stack and quality tools`);
271
- }
272
- log('');
273
- log(`${DIM}Commands available after setup:${RESET}`);
274
- log(` ${CYAN}/seed${RESET} — bootstrap project (interview or DNA document)`);
275
- log(` ${CYAN}/grow${RESET} — plan and start a new feature`);
276
- log(` ${CYAN}/map${RESET} view or adjust the system growth map`);
277
- log(` ${CYAN}/next${RESET} — implement the next growth stage`);
278
- log(` ${CYAN}/next-automatic${RESET} run multiple stages automatically`);
279
- log(` ${CYAN}/replan${RESET} re-evaluate when things change`);
280
- log(` ${CYAN}/review${RESET} deep quality review of recent stages`);
421
+ info(`Edit ${CYAN}${targetConfig.contextFile}${RESET} to fill in your tech stack and quality tools`);
422
+ if (target === 'codex') {
423
+ info(`Launch Codex with ${CYAN}CODEX_HOME=.codex codex${RESET} so the installed prompts are used for this repo`);
424
+ }
425
+ log('');
426
+ log(`${DIM}Commands available after setup:${RESET}`);
427
+ log(` ${CYAN}/seed${RESET} bootstrap project (interview or DNA document)`);
428
+ log(` ${CYAN}/grow${RESET} — plan and start a new feature`);
429
+ log(` ${CYAN}/map${RESET} view or adjust the system growth map`);
430
+ log(` ${CYAN}/next${RESET} implement the next growth stage`);
431
+ log(` ${CYAN}/next-automatic${RESET} run multiple stages automatically`);
432
+ log(` ${CYAN}/replan${RESET} — re-evaluate when things change`);
433
+ log(` ${CYAN}/review${RESET} — deep quality review of recent stages`);
281
434
 
282
- log('');
435
+ log('');
436
+ const upgradeHint = target === 'claude'
437
+ ? 'npx organic-growth --upgrade'
438
+ : `npx organic-growth --upgrade --${target}`;
439
+ log(`${DIM}To upgrade later: ${upgradeHint}${RESET}`);
440
+ log('');
441
+ }
283
442
  }
284
443
 
285
444
  install().catch(err => {
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "organic-growth",
3
- "version": "3.1.0",
4
- "description": "Claude Code and opencode setup for incremental software development — grow features in natural stages",
3
+ "version": "3.3.0",
4
+ "description": "Claude Code, opencode, and Codex setup for incremental software development — grow features in natural stages",
5
5
  "bin": {
6
6
  "organic-growth": "bin/cli.mjs"
7
7
  },
8
8
  "files": [
9
9
  "bin/",
10
10
  "templates/",
11
- "templates-opencode/"
11
+ "templates-opencode/",
12
+ "templates-codex/"
12
13
  ],
13
14
  "keywords": [
14
15
  "claude-code",
15
16
  "opencode",
17
+ "codex",
18
+ "openai",
16
19
  "ai",
17
20
  "agents",
18
21
  "agile",
@@ -1,13 +1,39 @@
1
1
  ---
2
- description: Bootstrap a new project — from DNA document or interview
2
+ description: Plant the seed for a project — from DNA document or interview
3
3
  ---
4
4
 
5
- Plant the seed for a new project.
5
+ Plant the seed for a project.
6
6
 
7
- 0. Scan project root for existing code (`src/`, `package.json`, `build.gradle`, `README.md`, etc.).
8
- If code already exists:
9
- - Read README/build files to auto-fill Tech Stack
10
- - Discover quality commands (build, lint, test)
7
+ 0. **Detect existing project.**
8
+ Scan project root for existing code (`src/`, `lib/`, `app/`, `package.json`, `build.gradle`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `pom.xml`, `README.md`, etc.).
9
+
10
+ - If code or build files already exist → **EXISTING = true**
11
+ - If the project root is empty or contains only config files → **EXISTING = false**
12
+
13
+ When EXISTING = true, scan these files and extract the noted information:
14
+
15
+ **Auto-discovery checklist:**
16
+ - `package.json` → scripts (build, test, lint, start), engines, dependencies and devDependencies for stack detection (e.g., react, express, typescript)
17
+ - `build.gradle` / `build.gradle.kts` → plugins (java, kotlin, spring-boot), tasks (test, check, ktlintCheck), dependencies for framework detection
18
+ - `pyproject.toml` → build-system, project.scripts, dependencies, optional-dependencies, tool sections (pytest, ruff, mypy, black)
19
+ - `Cargo.toml` → edition, dependencies, dev-dependencies, workspace members, features
20
+ - `go.mod` → go version, module path, require directives for framework detection (gin, echo, fiber)
21
+ - `pom.xml` → plugins, parent (spring-boot-starter-parent), dependencies, build configuration
22
+ - `Makefile` → target names (build, test, lint, check, fmt, run) and the commands they execute
23
+ - `README.md` → project description, setup/install instructions, usage examples for product context
24
+ - `.github/workflows/*.yml` → build/test/lint commands used in CI steps, language versions in matrix
25
+ - `.gitlab-ci.yml` → build/test/lint commands used in CI stages, image versions
26
+
27
+ From the discovered files, populate the **Quality Tools** section of CLAUDE.md with the exact commands for:
28
+ - **Build:** (e.g., `npm run build`, `./gradlew build`, `cargo build`)
29
+ - **Lint:** (e.g., `npm run lint`, `./gradlew ktlintCheck`, `cargo clippy`)
30
+ - **Type check:** (e.g., `tsc --noEmit`, or N/A)
31
+ - **Test:** (e.g., `npm test`, `./gradlew test`, `cargo test`)
32
+ - **Smoke:** (e.g., `npm start`, `./gradlew bootRun`, or a health endpoint)
33
+
34
+ Present the discovered tech stack and quality tools to the user for confirmation before writing them.
35
+
36
+ Also:
11
37
  - Adjust interview: skip "what tech stack?" and "what are you building?"
12
38
  - Ask instead: "what change do you want to make?" and "any constraints?"
13
39
  - Check recent git commits and ask whether to follow existing commit convention
@@ -24,7 +50,22 @@ Plant the seed for a new project.
24
50
  - If Business Rules are missing, ask: "Any rules that must ALWAYS hold?"
25
51
  - Confirm with the user: "Here's what I extracted. Anything to adjust?"
26
52
 
27
- **Path BNo DNA:**
53
+ **Path B1Existing project, no DNA (EXISTING = true):**
54
+ - Present what you discovered in Step 0 to the user:
55
+ "Here's what I discovered about your project:" followed by a summary of
56
+ the tech stack, quality tools, and any product context from README.md.
57
+ - Ask the user to confirm or adjust what was discovered.
58
+ - Then ask only gap-filling questions ONE AT A TIME (skip any already
59
+ answered by the discoveries):
60
+ - What core problem does this project solve?
61
+ - What business rules must ALWAYS be true?
62
+ - What are the current priorities? (e.g., new feature, refactor, stabilize)
63
+ - Any hard constraints? (performance, compliance, deployment, backwards compatibility)
64
+ - Generate `.organic-growth/product-dna.md` using the structured template.
65
+ Leave missing sections as `<!-- to be filled -->`.
66
+ - Fill in CLAUDE.md Product section from discoveries + answers.
67
+
68
+ **Path B2 — Greenfield, no DNA (EXISTING = false):**
28
69
  - Before the interview, briefly consider what this project could be:
29
70
  what kind of system, likely domain risks, and which questions matter most.
30
71
  Do not create separate brainstorming artifacts.
@@ -49,7 +90,13 @@ Plant the seed for a new project.
49
90
  3. Check if CLAUDE.md already has a filled Product section.
50
91
  If yes, ask: "Product context already exists. Overwrite or update?"
51
92
 
52
- 4. Generate `.organic-growth/growth/project-bootstrap.md` the first growth plan:
93
+ 4. **Growth plan generation (greenfield only).**
94
+
95
+ If EXISTING = true → **skip this step entirely.** Do NOT generate
96
+ `project-bootstrap.md`. Existing projects do not need bootstrap stages —
97
+ the user will run `/grow` to plan their first feature against the existing codebase.
98
+
99
+ If EXISTING = false → generate `.organic-growth/growth/project-bootstrap.md` — the first growth plan:
53
100
  - Stage 1: Initialize project (build tool, dependencies, empty build passes)
54
101
  - Stage 2: Hello World endpoint/page (proves stack works end-to-end)
55
102
  - Stage 3: First domain concept with hardcoded data
@@ -57,7 +104,12 @@ Plant the seed for a new project.
57
104
  - Stage 5: First real behavior with real data
58
105
  - Include `Capabilities:` tags in the plan header
59
106
 
60
- 5. If the project has 4+ distinct capabilities (from DNA/interview),
107
+ 5. **Growth map generation (greenfield only).**
108
+
109
+ If EXISTING = true → **skip this step entirely.** Do NOT generate
110
+ `growth-map.md`. There is no bootstrap plan to map.
111
+
112
+ If EXISTING = false → if the project has 4+ distinct capabilities (from DNA/interview),
61
113
  generate `.organic-growth/growth-map.md` draft:
62
114
  - Organize sequence into Walking Skeleton and what follows
63
115
  - Add short "Why This Order"
@@ -65,6 +117,12 @@ Plant the seed for a new project.
65
117
  - Present as aspirational, not a commitment
66
118
 
67
119
  6. Present a summary of what was created:
120
+
121
+ If EXISTING = true:
122
+ - Product DNA (`.organic-growth/product-dna.md`)
123
+ - CLAUDE.md Product/Tech Stack/Priorities sections
124
+
125
+ If EXISTING = false:
68
126
  - Product DNA (`.organic-growth/product-dna.md`)
69
127
  - CLAUDE.md Product/Tech Stack/Priorities sections
70
128
  - Growth plan (`.organic-growth/growth/project-bootstrap.md`)
@@ -79,7 +137,14 @@ Plant the seed for a new project.
79
137
  - Do NOT create src/, lib/, app/, or any implementation directories.
80
138
  - Do NOT commit anything beyond the seed files created above.
81
139
 
82
- The ONLY files you create are:
140
+ If EXISTING = true, the ONLY files you create are:
141
+ - `.organic-growth/product-dna.md`
142
+ - `CLAUDE.md` (fill in Product/Tech Stack/Priorities sections)
143
+
144
+ Say exactly:
145
+ "Seed planted. Run `/grow` when you're ready to plan your first feature."
146
+
147
+ If EXISTING = false, the ONLY files you create are:
83
148
  - `.organic-growth/product-dna.md`
84
149
  - `.organic-growth/growth/project-bootstrap.md`
85
150
  - `.organic-growth/growth-map.md` (if applicable)
@@ -0,0 +1,53 @@
1
+ ---
2
+ description: Plan and start growing a new feature from seed
3
+ ---
4
+
5
+ Grow a new feature using the Organic Growth approach.
6
+
7
+ 1. Read `AGENTS.md` first.
8
+ - If the Product section is still placeholders or empty, stop and tell the user to run `/seed` first.
9
+
10
+ 2. Read `.organic-growth/product-dna.md` and `.organic-growth/growth-map.md` if they exist.
11
+ - Treat business rules and completed capabilities as constraints.
12
+ - Search `.organic-growth/growth/` for related plans by capability tag when needed.
13
+
14
+ 3. Explore the current codebase so the plan reflects reality, not assumptions.
15
+
16
+ 4. Briefly reason through the problem space for `$ARGUMENTS`:
17
+ - 2-3 possible approaches
18
+ - riskiest assumption
19
+ - likely failure points
20
+ Keep this internal. Do not create separate artifacts.
21
+
22
+ 5. Ask the user 2-3 clarifying questions at most.
23
+ Focus on acceptance criteria, constraints, and the riskiest part.
24
+
25
+ 6. Create `.organic-growth/growth/<feature-name>.md` with:
26
+ - `Status: 🌱 Growing`
27
+ - 3-7 capability tags
28
+ - a one-paragraph Seed section
29
+ - 3-5 concrete stages
30
+ - a short horizon
31
+ - a Growth Log section
32
+
33
+ 7. For every concrete stage, define properties before implementation hints.
34
+ Consider invariants, state transitions, roundtrips, and boundaries.
35
+ Properties must express domain rules, not implementation details.
36
+
37
+ 8. Self-check the plan before presenting it:
38
+ - completeness
39
+ - independence from implementation
40
+ - property accumulation across stages
41
+ - boundary coverage where meaningful
42
+
43
+ 9. If `.organic-growth/growth-map.md` exists, update it:
44
+ - mark matching capabilities as `🌱`
45
+ - add the plan link
46
+ - insert new capabilities in the best-fit section when missing
47
+
48
+ 10. Present the plan for review.
49
+ Focus the user on reviewing properties, not implementation hints.
50
+
51
+ 11. Stop after the plan is approved.
52
+ Do not implement stage 1.
53
+ Say exactly: `Plan ready. Run /next when you're ready to grow stage 1.`
@@ -0,0 +1,22 @@
1
+ ---
2
+ description: View or update the growth map — your system's big picture
3
+ ---
4
+
5
+ Show or adjust the growth map.
6
+
7
+ 1. If `.organic-growth/growth-map.md` does not exist:
8
+ - Check whether `AGENTS.md` or `.organic-growth/product-dna.md` has enough context to draft one.
9
+ - If yes, generate a draft and present it for review.
10
+ - If no, tell the user to run `/seed` first or describe the system.
11
+
12
+ 2. If the map exists and `$ARGUMENTS` is empty:
13
+ - show the current map
14
+ - summarize statuses as `🌳 complete | 🌱 growing | ⬜ planned | 💡 candidates`
15
+ - suggest the next capability based on sequence and dependencies
16
+
17
+ 3. If `$ARGUMENTS` requests a change:
18
+ - update the map
19
+ - verify the new order still makes sense given completed plans and dependencies
20
+ - explain the reasoning behind the change
21
+
22
+ Input: $ARGUMENTS
@@ -0,0 +1,30 @@
1
+ ---
2
+ description: Run multiple growth stages automatically from the active plan
3
+ ---
4
+
5
+ Run multiple growth stages in sequence. Stop on the first failure.
6
+
7
+ 1. Find the active growth plan in `.organic-growth/growth/`.
8
+ If no plan exists, tell the user to run `/grow` first and stop.
9
+
10
+ 2. Count the remaining concrete stages marked with `🌱`.
11
+
12
+ 3. Parse `$ARGUMENTS`.
13
+ - If it is a positive integer, use it as the maximum number of stages to run.
14
+ - If it is empty, run all remaining concrete stages.
15
+ - Otherwise, tell the user the argument must be a positive integer and stop.
16
+
17
+ 4. For each stage:
18
+ - re-read `AGENTS.md` and the growth plan from disk
19
+ - identify the first remaining `🌱` stage
20
+ - execute the full `/next` workflow for exactly that stage
21
+ - re-read the plan and verify the stage changed from `🌱` to `🌳`
22
+ - if verification fails, stop immediately
23
+
24
+ 5. After the loop, report:
25
+ - stages attempted
26
+ - stages completed
27
+ - first failure, if any
28
+ - whether all requested stages completed
29
+
30
+ 6. If 3 or more stages completed, suggest running `/review` and starting a fresh Codex session.
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: Grow the next stage from the current growth plan
3
+ ---
4
+
5
+ Continue growing: implement the next stage from the active growth plan.
6
+
7
+ 1. Read `AGENTS.md`, the active growth plan in `.organic-growth/growth/`, and any related completed plans.
8
+
9
+ 2. Find the next `🌱` stage.
10
+ - If no plan exists, tell the user to run `/grow` first.
11
+ - If all stages are complete, say so and suggest what might grow next.
12
+
13
+ 3. If this is stage 3, 6, 9, or later, re-evaluate the remaining stages before implementing.
14
+ Update the plan if reality has changed.
15
+
16
+ 4. Implement only this stage.
17
+ - Treat the stage properties as acceptance criteria.
18
+ - Write or update tests first so each property is encoded explicitly.
19
+ - Then write the minimum code needed to pass the new and inherited properties.
20
+
21
+ 5. Run the quality gate and fix failures within the same stage:
22
+ - Build
23
+ - Lint
24
+ - Type check
25
+ - Full test suite
26
+ - Smoke check
27
+
28
+ 6. Self-review before committing:
29
+ - this stage only
30
+ - no work smuggled in from future stages
31
+ - earlier properties still hold
32
+ - implementation still matches the properties
33
+
34
+ 7. Update project state files.
35
+ - Mark the stage as `🌳` in the growth plan.
36
+ - Add a Growth Log entry for this stage.
37
+ - Update `.organic-growth/growth-map.md` if it exists.
38
+ - Add new domain concepts to `.organic-growth/product-dna.md` if introduced.
39
+ - Update `README.md` to reflect the current working system.
40
+ - Update `AGENTS.md` Current state when the milestone meaningfully changed.
41
+
42
+ 8. Commit with:
43
+ ```
44
+ feat(scope): stage N — <what grew>
45
+
46
+ Growth plan: .organic-growth/growth/<feature>.md
47
+ ```
48
+
49
+ 9. Report what grew, what properties were verified, what commands you ran, and what should happen next.
@@ -0,0 +1,23 @@
1
+ ---
2
+ description: Re-evaluate the growth plan when reality changes
3
+ ---
4
+
5
+ Something changed. Re-evaluate the active growth plan from current state.
6
+
7
+ 1. Find the active plan in `.organic-growth/growth/`.
8
+ If no active plan exists, tell the user to run `/grow` first.
9
+
10
+ 2. Read `AGENTS.md`, the active growth plan, related completed plans, and the current codebase.
11
+
12
+ 3. Use `$ARGUMENTS` as the reason for replanning.
13
+ If no reason is given, ask: `What changed?`
14
+
15
+ 4. Preserve completed stages unless there is an explicit reason to invalidate them.
16
+ If a previous property must be broken, record it in `Breaks:` with the reason.
17
+
18
+ 5. Rewrite only the remaining stages and horizon so they reflect current reality.
19
+ Keep properties first, implementation hints second.
20
+
21
+ 6. Update `.organic-growth/growth-map.md` if the capability ordering or dependencies changed.
22
+
23
+ 7. Present the updated plan and explain the delta from the previous one.
@@ -0,0 +1,64 @@
1
+ ---
2
+ description: Deep quality review of recent growth stages (fresh context, no implementation bias)
3
+ ---
4
+
5
+ Review code quality of recent stages. Run this after several stages
6
+ or before merging — it provides a second opinion with zero bias from
7
+ the implementation session.
8
+
9
+ 1. Determine scope:
10
+ - If $ARGUMENTS contains a number (e.g., `/review 3`): review last N stages
11
+ - If $ARGUMENTS contains a feature name: review that feature's stages
12
+ - Default: review all stages since last review (or last 5, whichever is smaller)
13
+
14
+ 2. Read the growth plan to understand intent of each reviewed stage.
15
+
16
+ 3. For each stage in scope, examine the git diff and review for:
17
+
18
+ **Correctness:**
19
+ - Does the code actually do what the stage intended?
20
+ - Are there logic errors, off-by-one, null cases?
21
+ - Do the tests test the right thing? (not just "test exists")
22
+
23
+ **Consistency:**
24
+ - Does new code follow the same patterns as existing code?
25
+ - Naming conventions, error handling style, project structure
26
+ - If `.organic-growth/product-dna.md` exists: do domain terms match?
27
+
28
+ **Simplicity:**
29
+ - Is anything over-engineered for the current stage?
30
+ - Code that belongs in future stages?
31
+ - Unnecessary abstractions or premature optimization?
32
+
33
+ **Security basics:**
34
+ - SQL injection, XSS, hardcoded secrets
35
+ - Auth/authz gaps if relevant
36
+ - Input validation
37
+
38
+ **Test quality:**
39
+ - Do tests break if the feature is removed? (vs always-green tests)
40
+ - Are edge cases covered?
41
+ - Test readability — can someone understand intent from the test?
42
+
43
+ 4. Output a review report:
44
+
45
+ ```
46
+ ## Review: <feature> — stages N-M
47
+
48
+ ### 🟢 Good
49
+ - <what's well done — be specific>
50
+
51
+ ### 🟡 Suggestions
52
+ - <improvements, not blockers>
53
+ - <file:line — what to consider>
54
+
55
+ ### 🔴 Issues
56
+ - <things that should be fixed before continuing>
57
+ - <file:line — what's wrong and why>
58
+
59
+ ### Verdict: ✅ Continue / ⚠️ Fix before next stage / 🔴 Stop and address
60
+ ```
61
+
62
+ 5. If there are 🔴 Issues, offer to fix them now.
63
+
64
+ Scope: $ARGUMENTS
@@ -0,0 +1,70 @@
1
+ ---
2
+ description: Plant the seed for a project — from DNA document or interview
3
+ ---
4
+
5
+ Plant the seed for a project.
6
+
7
+ 0. Detect whether this is an existing project.
8
+ Scan project root for existing code (`src/`, `lib/`, `app/`, `package.json`, `build.gradle`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `pom.xml`, `README.md`, etc.).
9
+
10
+ - If code or build files already exist -> `EXISTING = true`
11
+ - If the project root is empty or contains only config files -> `EXISTING = false`
12
+
13
+ When `EXISTING = true`, inspect the repo and extract:
14
+ - build, lint, typecheck, test, and smoke commands
15
+ - major frameworks and language/runtime versions
16
+ - product context from `README.md`, docs, or recent commits
17
+
18
+ Populate the Quality Tools section of `AGENTS.md` with exact commands.
19
+ Present the discovered stack and tools to the user for confirmation before writing them.
20
+
21
+ 1. Check for a product DNA document from `$ARGUMENTS` or `.organic-growth/product-dna.md`.
22
+
23
+ Path A — DNA exists:
24
+ - Read it.
25
+ - Distill it into the Product section of `AGENTS.md`.
26
+ - Normalize it into `.organic-growth/product-dna.md`.
27
+ - Fill `AGENTS.md` Product, Tech Stack, and Priorities sections from the DNA plus the project scan from Step 0.
28
+ - Populate the Quality Tools section with exact build, lint, typecheck, test, and smoke commands discovered from the repo.
29
+ - If the DNA omits stack or priority details, ask only the minimum follow-up needed to avoid placeholders.
30
+ - If business rules are missing, ask: "Any rules that must ALWAYS hold?"
31
+ - Confirm the extracted summary with the user.
32
+
33
+ Path B1 — existing project, no DNA:
34
+ - Present discovered project context first.
35
+ - Ask only gap-filling questions, one at a time:
36
+ - What core problem does this project solve?
37
+ - What business rules must ALWAYS be true?
38
+ - What are the current priorities?
39
+ - Any hard constraints?
40
+ - Generate `.organic-growth/product-dna.md` using the structured template.
41
+ - Fill `AGENTS.md` Product, Tech Stack, and Priorities sections from discoveries plus answers.
42
+
43
+ Path B2 — greenfield, no DNA:
44
+ - Ask one question at a time:
45
+ - What are you building?
46
+ - Who is it for?
47
+ - What core problem does it solve?
48
+ - What tech stack do you want?
49
+ - Any hard constraints?
50
+ - What matters most right now?
51
+ - What user roles exist?
52
+ - What business rules must ALWAYS be true?
53
+ - What is the main process flow?
54
+ - Generate `.organic-growth/product-dna.md`.
55
+ - Fill `AGENTS.md` Product, Tech Stack, and Priorities sections.
56
+
57
+ 2. In all paths, leave `AGENTS.md` with concrete Product, Tech Stack, Priorities, and Quality Tools entries, not placeholders.
58
+
59
+ 3. If `AGENTS.md` already has real product context, ask whether to overwrite or update it.
60
+
61
+ 4. For greenfield projects only, generate `.organic-growth/growth/project-bootstrap.md` with 3-5 concrete stages and a short horizon.
62
+ Follow the greenfield pattern in `AGENTS.md`.
63
+
64
+ 5. For greenfield projects only, generate `.organic-growth/growth-map.md` if the product has at least 4 distinct capabilities.
65
+
66
+ 6. Present a summary of what was created.
67
+
68
+ 7. Finish with exactly one of:
69
+ - Existing project: `Seed planted. Run /grow when you're ready to plan your first feature.`
70
+ - Greenfield project: `Seed planted. Review the files above, then run /next when you're ready to grow stage 1.`
@@ -0,0 +1,118 @@
1
+ # Project Context
2
+
3
+ ## Product (THE SEED — fill this in)
4
+
5
+ <!-- Without this section, the agent grows weeds. Be brief but specific. -->
6
+ <!-- If you have a full product document, put it in .organic-growth/product-dna.md -->
7
+ <!-- This section is the distilled version — what the agent sees always. -->
8
+ <!-- The DNA document is read only during planning (/grow, /replan). -->
9
+
10
+ **What:** [One sentence. What is this product?]
11
+ **For whom:** [Who uses it? What's their context?]
12
+ **Core problem:** [What pain does it solve?]
13
+ **Key domain concepts:** [3-7 terms that someone new needs to understand]
14
+ **Current state:** [Greenfield / MVP exists / Production system]
15
+ **Full DNA:** [.organic-growth/product-dna.md if exists, otherwise "N/A"]
16
+
17
+ ## Tech Stack (THE SOIL — auto-discovered, but document the non-obvious)
18
+
19
+ <!-- Codex reads your build files. Only add what it CAN'T discover. -->
20
+
21
+ - [Any non-standard commands, e.g.: `./gradlew test --profile staging`]
22
+ - [Unusual conventions, e.g.: "endpoint names in Polish"]
23
+ - [Hard constraints, e.g.: "no Lombok", "Flyway not Liquibase"]
24
+
25
+ ### Quality tools (fill in for your project)
26
+
27
+ <!-- Organic Growth runs these after every stage. List the exact commands. -->
28
+
29
+ - **Build:** [e.g.: `./gradlew build` or `npm run build`]
30
+ - **Lint:** [e.g.: `./gradlew ktlintCheck` or `npm run lint`]
31
+ - **Type check:** [e.g.: `tsc --noEmit` or N/A for dynamic languages]
32
+ - **Test:** [e.g.: `./gradlew test` or `npm test`]
33
+ - **Smoke:** [e.g.: `curl http://localhost:8080/health` or `npm run dev` + check]
34
+
35
+ ## Priorities (LIGHT & WATER — what matters now)
36
+
37
+ <!-- This changes. Update it when priorities shift. -->
38
+
39
+ - [e.g.: "MVP speed over production polish"]
40
+ - [e.g.: "Must work offline first"]
41
+ - [e.g.: "Security is non-negotiable, even for MVP"]
42
+
43
+ ---
44
+
45
+ # Development Philosophy: Organic Growth
46
+
47
+ Every feature is grown in stages from seed to maturity.
48
+ Each stage produces a complete, working system — not a partial one.
49
+ A seedling is a whole plant, not 10% of a tree.
50
+
51
+ ## Growth Rules
52
+
53
+ 1. **One stage = one intent = one commit**
54
+ - Each stage has a single purpose
55
+ - Each stage defines properties (rules that must be true) before implementation
56
+ - Properties become tests — write tests first, then code to pass them
57
+ - Each stage is committed separately with a clear message
58
+ - The app builds, tests pass, and runs after every stage
59
+
60
+ 2. **Rolling plan: 3-5 stages ahead**
61
+ - Never plan more than 5 concrete stages ahead
62
+ - Keep a rough outline of what comes after, but expect it to change
63
+ - Re-evaluate the plan every 3 stages or when something unexpected happens
64
+ - Update `.organic-growth/growth/<feature>.md` after every stage
65
+
66
+ 3. **Vertical, not horizontal**
67
+ - Each stage touches all layers needed (API + service + DB + test)
68
+ - No "build all the backend first, then the frontend"
69
+ - Early stages can return hardcoded values — that's natural
70
+ - Growth: hardcoded -> configurable -> dynamic -> optimized
71
+
72
+ 4. **Context hygiene**
73
+ - Start a fresh Codex session every 3 stages
74
+ - The growth plan in `.organic-growth/growth/` is the continuity mechanism
75
+ - Relaunch Codex with `CODEX_HOME=.codex codex` before continuing if context gets stale
76
+
77
+ 5. **Quality gate after every stage**
78
+ - Build must pass
79
+ - Linter must pass (zero new warnings)
80
+ - Type check must pass (if applicable)
81
+ - ALL tests must pass (not just new ones)
82
+ - App must start (health check / smoke test)
83
+ - Fix all failures within the stage — don't carry debt forward
84
+
85
+ 6. **Deep review on demand**
86
+ - Run `/review` after every 3-5 stages or before merging
87
+ - Reviews run with fresh context (no implementation bias)
88
+ - Check: correctness, consistency, simplicity, security, test quality
89
+ - Fix 🔴 issues before continuing growth
90
+
91
+ ## Growth Stage Patterns
92
+
93
+ For **greenfield** projects, first stages always follow this pattern:
94
+ 1. Empty project with passing build
95
+ 2. Hello World endpoint/page (proves the stack works end-to-end)
96
+ 3. First real domain concept with hardcoded data
97
+ 4. Persistence (database, migration, repository)
98
+ 5. First real behavior with real data
99
+
100
+ For **existing** projects, first stages are:
101
+ 1. The simplest possible version of the new behavior (even hardcoded)
102
+ 2. Connect it to existing data/services
103
+ 3. Add the real logic incrementally
104
+
105
+ ## Commit Convention
106
+
107
+ ```
108
+ feat(scope): stage N — <what grew>
109
+
110
+ Growth plan: .organic-growth/growth/<feature>.md
111
+ ```
112
+
113
+ ## Growth Plan Location
114
+
115
+ All plans live in `.organic-growth/growth/<feature-name>.md`.
116
+ Product DNA lives in `.organic-growth/product-dna.md`.
117
+ Growth map lives in `.organic-growth/growth-map.md` (if exists).
118
+ Prompt files live in `.codex/prompts/` and are used when you launch Codex with `CODEX_HOME=.codex codex`.
@@ -1,13 +1,39 @@
1
1
  ---
2
- description: Bootstrap a new project — from DNA document or interview
2
+ description: Plant the seed for a project — from DNA document or interview
3
3
  ---
4
4
 
5
- Plant the seed for a new project.
5
+ Plant the seed for a project.
6
6
 
7
- 0. Scan project root for existing code (`src/`, `package.json`, `build.gradle`, `README.md`, etc.).
8
- If code already exists:
9
- - Read README/build files to auto-fill Tech Stack
10
- - Discover quality commands (build, lint, test)
7
+ 0. **Detect existing project.**
8
+ Scan project root for existing code (`src/`, `lib/`, `app/`, `package.json`, `build.gradle`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `pom.xml`, `README.md`, etc.).
9
+
10
+ - If code or build files already exist → **EXISTING = true**
11
+ - If the project root is empty or contains only config files → **EXISTING = false**
12
+
13
+ When EXISTING = true, scan these files and extract the noted information:
14
+
15
+ **Auto-discovery checklist:**
16
+ - `package.json` → scripts (build, test, lint, start), engines, dependencies and devDependencies for stack detection (e.g., react, express, typescript)
17
+ - `build.gradle` / `build.gradle.kts` → plugins (java, kotlin, spring-boot), tasks (test, check, ktlintCheck), dependencies for framework detection
18
+ - `pyproject.toml` → build-system, project.scripts, dependencies, optional-dependencies, tool sections (pytest, ruff, mypy, black)
19
+ - `Cargo.toml` → edition, dependencies, dev-dependencies, workspace members, features
20
+ - `go.mod` → go version, module path, require directives for framework detection (gin, echo, fiber)
21
+ - `pom.xml` → plugins, parent (spring-boot-starter-parent), dependencies, build configuration
22
+ - `Makefile` → target names (build, test, lint, check, fmt, run) and the commands they execute
23
+ - `README.md` → project description, setup/install instructions, usage examples for product context
24
+ - `.github/workflows/*.yml` → build/test/lint commands used in CI steps, language versions in matrix
25
+ - `.gitlab-ci.yml` → build/test/lint commands used in CI stages, image versions
26
+
27
+ From the discovered files, populate the **Quality Tools** section of AGENTS.md with the exact commands for:
28
+ - **Build:** (e.g., `npm run build`, `./gradlew build`, `cargo build`)
29
+ - **Lint:** (e.g., `npm run lint`, `./gradlew ktlintCheck`, `cargo clippy`)
30
+ - **Type check:** (e.g., `tsc --noEmit`, or N/A)
31
+ - **Test:** (e.g., `npm test`, `./gradlew test`, `cargo test`)
32
+ - **Smoke:** (e.g., `npm start`, `./gradlew bootRun`, or a health endpoint)
33
+
34
+ Present the discovered tech stack and quality tools to the user for confirmation before writing them.
35
+
36
+ Also:
11
37
  - Adjust interview: skip "what tech stack?" and "what are you building?"
12
38
  - Ask instead: "what change do you want to make?" and "any constraints?"
13
39
  - Check recent git commits and ask whether to follow existing commit convention
@@ -24,7 +50,22 @@ Plant the seed for a new project.
24
50
  - If Business Rules are missing, ask: "Any rules that must ALWAYS hold?"
25
51
  - Confirm with the user: "Here's what I extracted. Anything to adjust?"
26
52
 
27
- **Path BNo DNA:**
53
+ **Path B1Existing project, no DNA (EXISTING = true):**
54
+ - Present what you discovered in Step 0 to the user:
55
+ "Here's what I discovered about your project:" followed by a summary of
56
+ the tech stack, quality tools, and any product context from README.md.
57
+ - Ask the user to confirm or adjust what was discovered.
58
+ - Then ask only gap-filling questions ONE AT A TIME (skip any already
59
+ answered by the discoveries):
60
+ - What core problem does this project solve?
61
+ - What business rules must ALWAYS be true?
62
+ - What are the current priorities? (e.g., new feature, refactor, stabilize)
63
+ - Any hard constraints? (performance, compliance, deployment, backwards compatibility)
64
+ - Generate `.organic-growth/product-dna.md` using the structured template.
65
+ Leave missing sections as `<!-- to be filled -->`.
66
+ - Fill in AGENTS.md Product section from discoveries + answers.
67
+
68
+ **Path B2 — Greenfield, no DNA (EXISTING = false):**
28
69
  - Before the interview, briefly consider what this project could be:
29
70
  what kind of system, likely domain risks, and which questions matter most.
30
71
  Do not create separate brainstorming artifacts.
@@ -49,7 +90,13 @@ Plant the seed for a new project.
49
90
  3. Check if AGENTS.md already has a filled Product section.
50
91
  If yes, ask: "Product context already exists. Overwrite or update?"
51
92
 
52
- 4. Generate `.organic-growth/growth/project-bootstrap.md` the first growth plan:
93
+ 4. **Growth plan generation (greenfield only).**
94
+
95
+ If EXISTING = true → **skip this step entirely.** Do NOT generate
96
+ `project-bootstrap.md`. Existing projects do not need bootstrap stages —
97
+ the user will run `/grow` to plan their first feature against the existing codebase.
98
+
99
+ If EXISTING = false → generate `.organic-growth/growth/project-bootstrap.md` — the first growth plan:
53
100
  - Stage 1: Initialize project (build tool, dependencies, empty build passes)
54
101
  - Stage 2: Hello World endpoint/page (proves stack works end-to-end)
55
102
  - Stage 3: First domain concept with hardcoded data
@@ -57,7 +104,12 @@ Plant the seed for a new project.
57
104
  - Stage 5: First real behavior with real data
58
105
  - Include `Capabilities:` tags in the plan header
59
106
 
60
- 5. If the project has 4+ distinct capabilities (from DNA/interview),
107
+ 5. **Growth map generation (greenfield only).**
108
+
109
+ If EXISTING = true → **skip this step entirely.** Do NOT generate
110
+ `growth-map.md`. There is no bootstrap plan to map.
111
+
112
+ If EXISTING = false → if the project has 4+ distinct capabilities (from DNA/interview),
61
113
  generate `.organic-growth/growth-map.md` draft:
62
114
  - Organize sequence into Walking Skeleton and what follows
63
115
  - Add short "Why This Order"
@@ -65,6 +117,12 @@ Plant the seed for a new project.
65
117
  - Present as aspirational, not a commitment
66
118
 
67
119
  6. Present a summary of what was created:
120
+
121
+ If EXISTING = true:
122
+ - Product DNA (`.organic-growth/product-dna.md`)
123
+ - AGENTS.md Product/Tech Stack/Priorities sections
124
+
125
+ If EXISTING = false:
68
126
  - Product DNA (`.organic-growth/product-dna.md`)
69
127
  - AGENTS.md Product/Tech Stack/Priorities sections
70
128
  - Growth plan (`.organic-growth/growth/project-bootstrap.md`)
@@ -79,7 +137,14 @@ Plant the seed for a new project.
79
137
  - Do NOT create src/, lib/, app/, or any implementation directories.
80
138
  - Do NOT commit anything beyond the seed files created above.
81
139
 
82
- The ONLY files you create are:
140
+ If EXISTING = true, the ONLY files you create are:
141
+ - `.organic-growth/product-dna.md`
142
+ - `AGENTS.md` (fill in Product/Tech Stack/Priorities sections)
143
+
144
+ Say exactly:
145
+ "Seed planted. Run `/grow` when you're ready to plan your first feature."
146
+
147
+ If EXISTING = false, the ONLY files you create are:
83
148
  - `.organic-growth/product-dna.md`
84
149
  - `.organic-growth/growth/project-bootstrap.md`
85
150
  - `.organic-growth/growth-map.md` (if applicable)