forge-orkes 0.3.5 → 0.3.7

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.
@@ -8,6 +8,11 @@ const templateDir = path.join(__dirname, '..', 'template');
8
8
  const targetDir = process.cwd();
9
9
  const pkgVersion = require('../package.json').version;
10
10
 
11
+ // --- Section markers for CLAUDE.md ---
12
+
13
+ const FORGE_START = '<!-- forge:start -->';
14
+ const FORGE_END = '<!-- forge:end -->';
15
+
11
16
  // --- File classification for upgrades ---
12
17
 
13
18
  // Framework-owned: Forge controls these entirely
@@ -16,9 +21,6 @@ const FRAMEWORK_OWNED_DIRS = ['.claude/agents', '.claude/skills'];
16
21
  // Template-only: reference templates Forge controls
17
22
  const TEMPLATE_ONLY_DIRS = ['.forge/templates'];
18
23
 
19
- // Merge-owned: never auto-overwrite, stage for review
20
- const MERGE_OWNED_FILES = ['CLAUDE.md'];
21
-
22
24
  // Settings file gets smart-merge (overwrite forge.* keys, preserve user hooks)
23
25
  const SETTINGS_FILE = '.claude/settings.json';
24
26
 
@@ -128,27 +130,62 @@ function upgradeDir(relDir) {
128
130
  }
129
131
 
130
132
  /**
131
- * Handle merge-owned files: stage new version for manual review if different.
133
+ * Smart-merge CLAUDE.md using section markers.
134
+ * - If markers exist: replace the forge section, preserve everything else
135
+ * - If no markers but forge content exists: replace it and add markers
136
+ * - If no forge content: append with markers
137
+ * Returns 'replaced' | 'appended' | 'unchanged' | 'created'
132
138
  */
133
- function handleMergeFile(relFile) {
134
- const srcPath = path.join(templateDir, relFile);
135
- const destPath = path.join(targetDir, relFile);
139
+ function mergeClaudeMd() {
140
+ const srcPath = path.join(templateDir, 'CLAUDE.md');
141
+ const destPath = path.join(targetDir, 'CLAUDE.md');
136
142
 
137
143
  if (!fs.existsSync(srcPath)) return null;
138
- if (!fs.existsSync(destPath)) return null;
139
144
 
140
- const srcContent = fs.readFileSync(srcPath, 'utf-8');
141
- const destContent = fs.readFileSync(destPath, 'utf-8');
145
+ const forgeContent = fs.readFileSync(srcPath, 'utf-8');
146
+
147
+ // No existing CLAUDE.md — just copy
148
+ if (!fs.existsSync(destPath)) {
149
+ fs.writeFileSync(destPath, forgeContent);
150
+ return 'created';
151
+ }
152
+
153
+ const existing = fs.readFileSync(destPath, 'utf-8');
142
154
 
143
- if (srcContent === destContent) return 'unchanged';
155
+ // Check if content is already identical
156
+ if (existing === forgeContent) return 'unchanged';
144
157
 
145
- // Stage the new version for manual review
146
- const upgradeDir = path.join(targetDir, '.forge', 'upgrade');
147
- fs.mkdirSync(upgradeDir, { recursive: true });
148
- const basename = path.basename(relFile);
149
- const newPath = path.join(upgradeDir, `${basename}.new`);
150
- fs.writeFileSync(newPath, srcContent);
151
- return 'staged';
158
+ const startIdx = existing.indexOf(FORGE_START);
159
+ const endIdx = existing.indexOf(FORGE_END);
160
+
161
+ if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
162
+ // Markers found — replace the section between them (inclusive)
163
+ const before = existing.substring(0, startIdx);
164
+ const after = existing.substring(endIdx + FORGE_END.length);
165
+ const merged = before + forgeContent + after;
166
+
167
+ // Clean up any double newlines at the seams
168
+ const cleaned = merged.replace(/\n{3,}/g, '\n\n');
169
+ fs.writeFileSync(destPath, cleaned);
170
+ return 'replaced';
171
+ }
172
+
173
+ // No markers — check if there's an old forge section (starts with "# Forge")
174
+ const forgeHeaderIdx = existing.indexOf('# Forge\n');
175
+ if (forgeHeaderIdx !== -1) {
176
+ // Old install without markers — replace from "# Forge" to end of file
177
+ // (Forge content is always appended at the end in old installs)
178
+ const before = existing.substring(0, forgeHeaderIdx);
179
+ const merged = before + forgeContent;
180
+ const cleaned = merged.replace(/\n{3,}/g, '\n\n');
181
+ fs.writeFileSync(destPath, cleaned);
182
+ return 'replaced';
183
+ }
184
+
185
+ // No forge content at all — append with markers
186
+ const merged = existing.trimEnd() + '\n\n' + forgeContent + '\n';
187
+ fs.writeFileSync(destPath, merged);
188
+ return 'appended';
152
189
  }
153
190
 
154
191
  /**
@@ -178,49 +215,40 @@ function upgradeSettings() {
178
215
  return 'updated';
179
216
  }
180
217
 
218
+ /**
219
+ * Detect if Forge is already installed in this project.
220
+ */
221
+ function isForgeInstalled() {
222
+ const settingsPath = path.join(targetDir, SETTINGS_FILE);
223
+ if (!fs.existsSync(settingsPath)) return false;
224
+
225
+ try {
226
+ const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
227
+ return !!settings.forge;
228
+ } catch {
229
+ return false;
230
+ }
231
+ }
232
+
181
233
  // --- Commands ---
182
234
 
183
235
  async function install() {
184
236
  console.log('\n Forge - Meta-prompting framework for Claude Code\n');
185
237
 
186
- // Handle CLAUDE.md
187
- const srcClaudeMd = path.join(templateDir, 'CLAUDE.md');
188
- const destClaudeMd = path.join(targetDir, 'CLAUDE.md');
189
- let claudeMdAction = 'copy';
190
-
191
- if (fs.existsSync(destClaudeMd)) {
192
- console.log(' CLAUDE.md already exists in this directory.\n');
193
- const answer = await prompt(
194
- ' What would you like to do? (a)ppend / (r)eplace / (s)kip: '
195
- );
196
-
197
- if (answer === 'a' || answer === 'append') {
198
- claudeMdAction = 'append';
199
- } else if (answer === 'r' || answer === 'replace') {
200
- claudeMdAction = 'replace';
201
- } else {
202
- claudeMdAction = 'skip';
203
- }
204
- }
205
-
206
- const srcContent = fs.readFileSync(srcClaudeMd, 'utf-8');
207
-
208
- switch (claudeMdAction) {
209
- case 'copy':
210
- case 'replace':
211
- fs.writeFileSync(destClaudeMd, srcContent);
212
- console.log(
213
- ` ${claudeMdAction === 'replace' ? 'Replaced' : 'Created'} CLAUDE.md`
214
- );
238
+ // Handle CLAUDE.md — use smart merge
239
+ const claudeStatus = mergeClaudeMd();
240
+ switch (claudeStatus) {
241
+ case 'created':
242
+ console.log(' Created CLAUDE.md');
243
+ break;
244
+ case 'replaced':
245
+ console.log(' Updated Forge section in CLAUDE.md (user content preserved)');
215
246
  break;
216
- case 'append': {
217
- const existing = fs.readFileSync(destClaudeMd, 'utf-8');
218
- fs.writeFileSync(destClaudeMd, existing + '\n\n' + srcContent);
247
+ case 'appended':
219
248
  console.log(' Appended Forge config to existing CLAUDE.md');
220
249
  break;
221
- }
222
- case 'skip':
223
- console.log(' Skipped CLAUDE.md');
250
+ case 'unchanged':
251
+ console.log(' CLAUDE.md already up to date');
224
252
  break;
225
253
  }
226
254
 
@@ -274,7 +302,6 @@ async function upgrade() {
274
302
  added: [],
275
303
  unchanged: [],
276
304
  removed: [],
277
- needsReview: [],
278
305
  };
279
306
 
280
307
  // 1. Process framework-owned directories
@@ -295,14 +322,14 @@ async function upgrade() {
295
322
  results.removed.push(...dirResult.removed);
296
323
  }
297
324
 
298
- // 3. Process merge-owned files
299
- for (const file of MERGE_OWNED_FILES) {
300
- const status = handleMergeFile(file);
301
- if (status === 'staged') {
302
- results.needsReview.push(file);
303
- } else if (status === 'unchanged') {
304
- results.unchanged.push(file);
305
- }
325
+ // 3. Smart-merge CLAUDE.md using section markers
326
+ const claudeStatus = mergeClaudeMd();
327
+ if (claudeStatus === 'replaced' || claudeStatus === 'appended') {
328
+ results.updated.push('CLAUDE.md');
329
+ } else if (claudeStatus === 'unchanged') {
330
+ results.unchanged.push('CLAUDE.md');
331
+ } else if (claudeStatus === 'created') {
332
+ results.added.push('CLAUDE.md');
306
333
  }
307
334
 
308
335
  // 4. Smart-merge settings.json
@@ -314,8 +341,7 @@ async function upgrade() {
314
341
  }
315
342
 
316
343
  // Report results
317
- const totalChanges =
318
- results.updated.length + results.added.length + results.needsReview.length;
344
+ const totalChanges = results.updated.length + results.added.length;
319
345
 
320
346
  if (totalChanges === 0 && results.removed.length === 0) {
321
347
  console.log(' Already up to date.\n');
@@ -338,14 +364,6 @@ async function upgrade() {
338
364
  console.log();
339
365
  }
340
366
 
341
- if (results.needsReview.length > 0) {
342
- console.log(` Needs manual review (${results.needsReview.length}):`);
343
- for (const f of results.needsReview) {
344
- console.log(` ${f} → .forge/upgrade/${path.basename(f)}.new`);
345
- }
346
- console.log();
347
- }
348
-
349
367
  if (results.removed.length > 0) {
350
368
  console.log(` Removed from template (${results.removed.length}):`);
351
369
  for (const f of results.removed) {
@@ -366,6 +384,13 @@ if (subcommand === 'upgrade') {
366
384
  console.error('Error:', err.message);
367
385
  process.exit(1);
368
386
  });
387
+ } else if (isForgeInstalled()) {
388
+ // Auto-detect: Forge already installed, run upgrade instead
389
+ console.log(' Forge detected — running upgrade automatically.\n');
390
+ upgrade().catch((err) => {
391
+ console.error('Error:', err.message);
392
+ process.exit(1);
393
+ });
369
394
  } else {
370
395
  install().catch((err) => {
371
396
  console.error('Error:', err.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-orkes",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Set up the Forge meta-prompting framework for Claude Code in your project",
5
5
  "bin": {
6
6
  "create-forge": "./bin/create-forge.js"
@@ -30,12 +30,11 @@ Check for state files in this order:
30
30
  5. **If no active milestones:** Proceed to init or ask user to create one.
31
31
  6. Load the selected milestone's state file (`.forge/state/milestone-{id}.yml`)
32
32
  7. **Route based on `current.status`, NOT on `overall_percent`.** The `current.status` field is the authoritative workflow position. A milestone is only complete when `current.status` equals `complete`. Even if `overall_percent` is 100%, the milestone still needs to go through any remaining workflow steps (verifying, auditing, refactoring) before it is truly done.
33
- 8. Report position from the milestone-specific state:
33
+ 8. Report position briefly, then **immediately route to the next skill** (see Step 3: Mandatory Auto-Routing):
34
34
  - **Workflow status** (`current.status`) — this is the primary indicator of where you are
35
- - Current phase, plan, task
35
+ - Phase progress using precise terminology: "Executed" (code done, not verified), "Verified", "Pending", "In progress" — **never say "Complete" for a phase that hasn't been verified**
36
36
  - Task progress percentage (`overall_percent`) — this measures task completion, not workflow completion
37
- - Active blockers
38
- - Recent decisions
37
+ - **Do NOT present a menu of options.** State the position, state the next action, invoke the skill.
39
38
 
40
39
  If Beads is installed and enabled (`settings.json → forge.beads_integration: true`), also run `bd prime` for cross-session context. See `beads-integration` skill for details. This is optional — Forge works fully without it.
41
40
 
@@ -61,393 +60,7 @@ If state exists → go to **Step 2B: Detect Tier**.
61
60
 
62
61
  ## Step 2A: Project Init
63
62
 
64
- This interactive workflow runs once when Forge doesn't find an existing project. First, detect whether this is a **brownfield** (existing codebase) or **greenfield** (new project) then run the appropriate init path.
65
-
66
- ### Detect Project Type
67
-
68
- Check for signals of an existing codebase:
69
-
70
- ```
71
- Check: package.json OR requirements.txt OR go.mod OR Cargo.toml (dependency manifest)
72
- Check: .git/ (version control history)
73
- Check: src/ OR app/ OR lib/ (source directories)
74
- Check: existing config files (tsconfig.json, .eslintrc, vite.config, etc.)
75
- ```
76
-
77
- - **2+ signals found** → **Brownfield path** (existing codebase)
78
- - **0-1 signals** → **Greenfield path** (new project)
79
-
80
- Ask user to confirm: *"This looks like an [existing project / new project]. Is that right?"*
81
-
82
- ---
83
-
84
- ### Brownfield Path: Discover Existing Project
85
-
86
- For existing codebases, **scan first, confirm with user second.** Don't ask the user to describe what you can discover.
87
-
88
- #### Discovery Step 0: Framework Detection
89
-
90
- Before scanning the tech stack, check for two things: (1) existing meta-prompting frameworks with project knowledge to absorb, and (2) companion tools that should be preserved alongside Forge.
91
-
92
- **Meta-Framework Signatures** (contain project knowledge — candidates for absorption):
93
-
94
- ```
95
- # GSD (Get Shit Done)
96
- Check: agents/gsd-*.md OR commands/gsd/ directory
97
- Check: Root-level PROJECT.md + REQUIREMENTS.md + ROADMAP.md + STATE.md
98
- Check: get-shit-done/ directory
99
- Check: CONTEXT.md with "NON-NEGOTIABLE" or "DEFERRED" sections
100
-
101
- # Spec-Kit
102
- Check: spec-driven.md
103
- Check: templates/ with spec-template.md
104
- Check: extensions/catalog.json
105
- Check: constitution-template.md
106
-
107
- # BMAD
108
- Check: agents/ with 20+ agent files
109
- Check: workflows/ directory
110
- Check: bmad-* prefixed files
111
-
112
- # Generic / Unknown
113
- Check: .claude/agents/ or .claude/skills/ (someone else's custom framework)
114
- Check: CLAUDE.md with framework-like routing tables
115
- Check: Any structured agent/workflow system
116
- ```
117
-
118
- **Companion Tool Signatures** (not frameworks — independent tools that work alongside Forge):
119
-
120
- ```
121
- # Beads (persistent cross-session memory)
122
- Check: .beads/ directory
123
- Check: beads.jsonl or beads.db
124
- Check: bd CLI available (Bash: which bd)
125
- → If found: Enable forge.beads_integration in settings.json. Do NOT absorb or archive.
126
- → Beads is independent — it runs alongside Forge, not inside it.
127
- ```
128
-
129
- **If a meta-framework is detected**, present the finding and offer three options:
130
-
131
- *"I found an existing [{framework name}] setup in this project. It contains project documentation and decisions that are valuable. How would you like to handle it?"*
132
-
133
- **Option A: Absorb & Convert** (recommended)
134
- Read all existing framework documentation, extract the project knowledge, and convert it into Forge's format. This means:
135
- - Project descriptions → `.forge/project.yml`
136
- - Requirements → `.forge/requirements.yml`
137
- - Roadmaps/plans → `.forge/roadmap.yml`
138
- - Context/decisions → `.forge/context.md`
139
- - Current state/progress → `.forge/state/index.yml` + `.forge/state/milestone-{id}.yml`
140
- - Constitutional rules (if any) → `.forge/constitution.md`
141
- - Design system rules (if any) → `.forge/design-system.md`
142
-
143
- → Go to **Framework Absorption** below.
144
-
145
- **Option B: Archive & Start Fresh**
146
- Move existing framework files into `.forge/archive/{framework-name}/` for reference, then run the standard brownfield discovery (which will still scan the codebase itself). The archive is preserved and can be consulted later.
147
-
148
- **Option C: Keep Both (Transition Period)**
149
- Initialize Forge alongside the existing framework. Forge reads from `.forge/` while old framework files remain in place. Useful when you want to try Forge without committing. Remove the old framework later when confident.
150
-
151
- ---
152
-
153
- #### Framework Absorption (Option A)
154
-
155
- When absorbing an existing framework, read its documentation and convert systematically.
156
-
157
- **GSD Absorption Map:**
158
-
159
- | GSD Source | Read | Extract | Write to Forge |
160
- |-----------|------|---------|---------------|
161
- | `PROJECT.md` | Project name, description, tech stack, goals | Structured project info | `.forge/project.yml` |
162
- | `REQUIREMENTS.md` | Feature requirements, acceptance criteria | Convert prose to YAML with IDs | `.forge/requirements.yml` |
163
- | `ROADMAP.md` | Phases, milestones, dependencies | Convert to YAML with dependency refs | `.forge/roadmap.yml` |
164
- | `STATE.md` | Current phase, progress, blockers | Machine-readable state | `.forge/state/index.yml` + `.forge/state/milestone-{id}.yml` |
165
- | `CONTEXT.md` | NON-NEGOTIABLE decisions, DEFERRED ideas | Locked decisions, deferred items | `.forge/context.md` |
166
- | `references/ui-brand.md` | Design system rules, brand guidelines | Component mappings, style rules | `.forge/design-system.md` |
167
- | `references/verification-patterns.md` | Verification approach | Inform `verifying` skill config | Constitution articles |
168
- | `references/tdd.md` | Testing approach | Inform constitution Article II | Constitution articles |
169
- | Agent customizations | Custom agent behaviors, tool restrictions | Map to Forge agent definitions | `.claude/agents/*.md` (if custom) |
170
-
171
- **Spec-Kit Absorption Map:**
172
-
173
- | Spec-Kit Source | Read | Extract | Write to Forge |
174
- |----------------|------|---------|---------------|
175
- | `spec-driven.md` | Core methodology | Governance patterns | `.forge/constitution.md` |
176
- | `templates/spec-template.md` | Spec structure | Requirements format | `.forge/requirements.yml` |
177
- | `templates/constitution-template.md` | Constitutional articles | Immutable gates | `.forge/constitution.md` |
178
- | `extensions/` | Extension configs | Specialized skills | `.claude/skills/` (if relevant) |
179
- | Project specs (if filled in) | Project-specific decisions | Locked decisions | `.forge/context.md` |
180
-
181
- **Generic Framework Absorption:**
182
-
183
- For unknown frameworks, use the `researching` skill to:
184
- 1. Read all markdown and config files in the framework directory
185
- 2. Identify: project descriptions, requirements, decisions, state, design rules
186
- 3. Map each to the closest Forge equivalent
187
- 4. Present the mapping to the user for confirmation before writing
188
-
189
- **Absorption Process:**
190
-
191
- 1. Read all source files from the existing framework
192
- 2. For each Forge target file, synthesize content from the relevant sources
193
- 3. Convert prose to YAML where Forge expects YAML (project, requirements, roadmap, state)
194
- 4. Preserve markdown where Forge expects markdown (constitution, context, design-system)
195
- 5. **Never discard information** — if something doesn't map to a Forge file, note it in `.forge/context.md` under a "Carried Forward" section
196
- 6. Move original framework files to `.forge/archive/{framework-name}/`
197
- 7. Present a diff-style summary: *"Here's what I converted: [list]. And here's what I archived for reference: [list]. Anything I should handle differently?"*
198
-
199
- After absorption, **always** continue with the standard brownfield steps below (tech stack scan, design system detection, etc.). This is critical — see the verification step next.
200
-
201
- #### Documentation vs. Codebase Verification
202
-
203
- **Never trust framework documentation at face value.** Documentation drifts. The codebase is the source of truth.
204
-
205
- After reading existing framework docs, **cross-reference every claim against the actual code**:
206
-
207
- ```
208
- For each claim in the documentation:
209
- 1. Find the corresponding code (Glob, Grep, Read)
210
- 2. Verify the claim matches reality
211
- 3. Flag any discrepancies
212
- ```
213
-
214
- **Common drift patterns to check:**
215
-
216
- | Documentation Says | Verify Against |
217
- |-------------------|----------------|
218
- | "Tech stack: React + PostgreSQL" | `package.json` dependencies, actual imports in `src/` |
219
- | "Uses PrimeReact for all UI" | `Grep: src/ for "from 'primereact"` — are there also raw HTML tables, custom modals? |
220
- | "Tests written for all features" | `Glob: src/**/*.test.*` — actual coverage vs. claimed coverage |
221
- | "Auth uses Clerk/Auth0/etc." | `Grep: src/ for auth imports` — is there also custom auth code? |
222
- | "State management via Redux" | `package.json` + actual imports — did they switch to Zustand mid-project? |
223
- | "API uses REST" | `Grep: src/ for GraphQL, tRPC, WebSocket` — mixed protocols? |
224
- | Requirements list features A, B, C | Do routes/components for A, B, C actually exist? Are any partially implemented? |
225
- | Roadmap says "Phase 2 complete" | Are Phase 2 features actually wired and working, or are there stubs? |
226
-
227
- **When discrepancies are found:**
228
-
229
- Present them to the user clearly:
230
-
231
- *"I found some differences between the GSD documentation and the actual codebase:*
232
-
233
- - *PROJECT.md says 'PostgreSQL' but I only see SQLite in dependencies*
234
- - *REQUIREMENTS.md lists a 'notifications' feature but I can't find any notification code*
235
- - *STATE.md says Phase 2 is complete, but the dashboard component looks like a stub (returns placeholder text)*
236
- - *The docs mention PrimeReact exclusively, but I found 3 files using raw HTML tables instead of DataTable*
237
-
238
- *Should I update the Forge config to match what's actually in the code, or are some of these features that were removed/deferred?"*
239
-
240
- **Priority order for truth:**
241
- 1. **What the code actually does** — highest authority
242
- 2. **What the user confirms** — resolves ambiguity
243
- 3. **What the documentation says** — useful context, but may be stale
244
-
245
- Write the verified state to Forge files. For any unresolved discrepancies, add them to `.forge/context.md` under a "Needs Resolution" section so they get addressed during planning.
246
-
247
- ---
248
-
249
- #### Discovery Step 1: Tech Stack Scan
250
-
251
- ```bash
252
- # Package manifest
253
- Read: package.json → name, dependencies, devDependencies, scripts
254
- # Or: requirements.txt, go.mod, Cargo.toml, etc.
255
-
256
- # Config files
257
- Glob: tsconfig.json, .eslintrc*, vite.config.*, next.config.*, webpack.config.*
258
- Glob: .env.example, docker-compose.yml
259
-
260
- # Source structure
261
- Bash: find src/ -type f | head -50 # understand file organization
262
- Bash: wc -l src/**/*.{ts,tsx,js,jsx} 2>/dev/null | tail -1 # codebase size
263
- ```
264
-
265
- From this, auto-detect:
266
- - Language and framework
267
- - Build tools and test framework
268
- - Database (from dependencies or config)
269
- - Project name and description (from package.json or README)
270
-
271
- #### Discovery Step 2: Design System Detection
272
-
273
- ```bash
274
- # Check dependencies for known UI libraries
275
- Grep: package.json for: primereact, @mui/, @chakra-ui/, @radix-ui/, antd, @headlessui/
276
- Grep: package.json for: tailwindcss, primeflex, @emotion/, styled-components
277
-
278
- # Check actual usage in source
279
- Grep: src/ for import patterns: "from 'primereact", "from '@mui/", "from '@/components/ui"
280
- Grep: src/ for icon usage: "pi pi-", "Material", "lucide-react"
281
-
282
- # Check for theme files
283
- Glob: **/*theme*, **/*variables.scss, **/tailwind.config*, **/globals.css
284
- ```
285
-
286
- From this, auto-detect:
287
- - Component library (and version from package.json)
288
- - Icon set in use
289
- - Layout system (PrimeFlex, Tailwind, MUI Grid, etc.)
290
- - Theme approach (SCSS variables, CSS-in-JS, Tailwind config, design tokens)
291
-
292
- #### Discovery Step 3: Pattern Analysis
293
-
294
- ```bash
295
- # Existing conventions
296
- Glob: src/**/*.test.* OR src/**/*.spec.* # test patterns
297
- Grep: src/ for error handling patterns
298
- Grep: src/ for auth/session patterns
299
- Bash: git log --oneline -20 # commit style
300
-
301
- # Architecture patterns
302
- Bash: ls -la src/ # top-level structure (pages, components, services, etc.)
303
- Glob: src/**/index.{ts,tsx,js} # barrel exports
304
- Grep: src/ for "import.*from.*@/" # path aliases
305
- ```
306
-
307
- #### Discovery Step 4: Present Findings
308
-
309
- Present a structured summary to the user:
310
-
311
- *"I've scanned your codebase. Here's what I found:*
312
-
313
- *Project: {name} — {description from README or package.json}*
314
- *Stack: {language} + {framework} + {database}*
315
- *UI: {component library} with {icon set}, layout via {layout system}*
316
- *Testing: {test framework}, {X} existing test files*
317
- *Size: ~{N} source files, ~{N}K lines*
318
- *Patterns: {commit style}, {folder structure approach}, {key conventions}*
319
-
320
- *Does this look right? Anything I missed or got wrong?"*
321
-
322
- #### Discovery Step 5: Design System Mapping
323
-
324
- If a component library was detected:
325
- 1. Check `.forge/templates/design-systems/` for an existing example config
326
- 2. If found (e.g., PrimeReact) → copy it as starting point for `.forge/design-system.md`
327
- 3. If not found → use `researching` skill to build a component mapping from docs
328
- 4. **Cross-reference with actual usage**: scan the codebase for which components are already in use and prioritize those in the mapping
329
- 5. Present mapping to user for validation
330
-
331
- If no component library detected but UI files exist:
332
- - Ask: *"I see UI code but no component library. Are you using a design system, or is this custom HTML/CSS?"*
333
-
334
- #### Discovery Step 6: Constitutional Inference
335
-
336
- Based on discovered patterns, **suggest** which articles to enable:
337
-
338
- | Discovery | Suggested Articles |
339
- |-----------|-------------------|
340
- | Test files found | Article II: Test-First (already practicing) |
341
- | Component library detected | Article V: Design System Fidelity |
342
- | Auth/session patterns found | Article VI: Security by Default |
343
- | Established conventions detected | Article IV: Consistency (preserve them) |
344
- | package-lock.json or yarn.lock | Article I: Library-First (already using libraries) |
345
- | Logging/monitoring deps | Article IX: Observability |
346
-
347
- Present grouped recommendations and let user confirm, add, or remove articles.
348
-
349
- ---
350
-
351
- ### Greenfield Path: Build from Description
352
-
353
- For new projects, ask the user to describe what they're building.
354
-
355
- #### Greenfield Step 1: Project Basics
356
-
357
- Ask the user to describe the project. From their description, fill in `.forge/project.yml`:
358
-
359
- - Project name and description
360
- - Primary goal
361
- - Tech stack (language, framework, database, testing)
362
- - Time and scope constraints
363
- - Success criteria
364
- - Known risks
365
-
366
- Present a summary: *"Does this capture your project correctly? Anything to add or change?"*
367
-
368
- #### Greenfield Step 2: Design System Setup
369
-
370
- Ask: *"Does this project use a UI component library or design system?"*
371
-
372
- **If yes**, ask which one and configure `design_system` in `project.yml`:
373
-
374
- ```yaml
375
- design_system:
376
- library: "" # e.g., PrimeReact, Material-UI, shadcn/ui, Ant Design, Chakra UI
377
- version: "" # e.g., 10.x, 5.x
378
- icon_set: "" # e.g., PrimeIcons, Material Icons, Lucide, none
379
- layout_system: "" # e.g., PrimeFlex, MUI Grid, Tailwind, CSS Grid
380
- theme_approach: "" # e.g., SCSS variables, CSS-in-JS, Tailwind config, design tokens
381
- docs_url: "" # e.g., https://primereact.org/datatable/
382
- ```
383
-
384
- Then:
385
- 1. Check `.forge/templates/design-systems/` for a starter config
386
- 2. If found → copy and customize for the project
387
- 3. If not → use `researching` skill to build a component mapping from docs
388
- 4. Write the mapping to `.forge/design-system.md`
389
-
390
- **If no** (plain HTML/CSS, utility-only, or non-UI project):
391
- - Set `design_system.library: none` in project.yml
392
- - Skip design-system.md creation
393
- - Disable Article V in the constitution
394
-
395
- #### Greenfield Step 3: Constitutional Setup
396
-
397
- Present the 9 constitutional articles grouped by domain:
398
-
399
- **Code quality** (recommended for most projects):
400
- - Article I: Library-First — prefer proven libraries over custom code
401
- - Article II: Test-First — tests before or alongside implementation
402
- - Article III: Simplicity — simplest solution wins
403
- - Article IV: Consistency — follow existing project patterns
404
-
405
- **Design & UI** (enable if project has UI):
406
- - Article V: Design System Fidelity — use the design system, don't fight it
407
-
408
- **Security & data** (enable if auth, user data, or APIs involved):
409
- - Article VI: Security by Default — auth, validation, secrets are requirements
410
-
411
- **Architecture** (enable based on project complexity):
412
- - Article VII: Integration-First — real dependencies before mocks
413
- - Article VIII: Documentation-Driven — decisions documented where code lives
414
- - Article IX: Observability — logging, error reporting, health checks
415
-
416
- Ask: *"Which of these articles apply? I'd recommend [suggest based on stack and project type]. You can also add project-specific articles."*
417
-
418
- ---
419
-
420
- ### Finalize Init (Both Paths)
421
-
422
- 1. Write `.forge/project.yml` with all gathered/discovered info
423
- 2. Write `.forge/constitution.md` with selected articles
424
- 3. Write `.forge/design-system.md` (if design system configured)
425
- 4. Initialize milestone-aware state:
426
- - Create `.forge/state/` directory
427
- - Write `.forge/state/index.yml`:
428
- ```yaml
429
- milestones:
430
- - id: 1
431
- name: "{project name}"
432
- status: active
433
- last_updated: "{date}"
434
- ```
435
- - Write `.forge/state/milestone-1.yml`:
436
- ```yaml
437
- milestone:
438
- id: 1
439
- name: "{project name}"
440
- current:
441
- tier: null
442
- phase: null
443
- phase_name: ""
444
- plan: null
445
- task: null
446
- status: not_started
447
- ```
448
- 5. Copy remaining templates as needed
449
-
450
- Confirm: *"Project initialized. Here's what's set up: [summary]. Ready to start working?"*
63
+ If no `.forge/project.yml` exists, invoke the `initializing` skill via `Skill(initializing)`. It handles brownfield/greenfield detection, framework absorption, tech stack scanning, design system setup, and constitutional configuration. After init completes, return here for tier detection.
451
64
 
452
65
  ## Step 2B: Detect Tier
453
66
 
@@ -502,9 +115,23 @@ Based on detected tier and current state, tell the user which skill comes next a
502
115
 
503
116
  **CRITICAL: NEVER use `EnterPlanMode` or Claude Code's native plan mode.** All Forge phases are handled by Forge skills invoked via the `Skill` tool. When the workflow says "planning", that means invoke `Skill(planning)` — not enter native plan mode. Native plan mode writes to a different file format and bypasses Forge's constitutional gates, state management, and structured plan output.
504
117
 
505
- If resuming mid-workflow:
506
- - Read the selected milestone's state file (`.forge/state/milestone-{id}.yml`) for current position
507
- - **Use `current.status` to determine the next skill** this is the authoritative workflow position:
118
+ ### Mandatory Auto-Routing on Resume
119
+
120
+ **When resuming mid-workflow, DO NOT present a menu of options or ask "What would you like to do?".** Routing is deterministic. Give a brief status briefing, then route automatically. The only time to ask the user for a choice is when `current.status == complete` (milestone done) or when state is ambiguous/corrupted.
121
+
122
+ Resume steps:
123
+ 1. Read the selected milestone's state file (`.forge/state/milestone-{id}.yml`) for current position
124
+ 2. **Check for status advancement** (see below)
125
+ 3. **Use `current.status` to determine the next skill** — this is the authoritative workflow position
126
+ 4. **Brief the user, then route.** Show a compact status summary so the user can orient, then immediately invoke the next skill. Format:
127
+
128
+ *"Resuming Milestone {id}: {name}*
129
+ *Workflow: {current.status} — next step: {next skill name}*
130
+ *Phases: {compact phase list with statuses using correct wording — Executed/Verified/Pending/In progress}*
131
+ *Progress: {overall_percent}% of tasks executed*
132
+ *Routing to {skill}..."*
133
+
134
+ This is a **briefing, not a prompt** — the user sees where they are and what's happening next. They can interrupt if they want to do something different, but the default is forward motion.
508
135
 
509
136
  | `current.status` | Next Action (invoke via `Skill` tool) |
510
137
  |-------------------|-------------|
@@ -522,6 +149,27 @@ If resuming mid-workflow:
522
149
  - Skip completed phases (phases before `current.status`)
523
150
  - Resume from current phase
524
151
 
152
+ ### Status Advancement Check
153
+
154
+ Sometimes a session ends before the executing skill advances `current.status`. On resume, detect and fix this:
155
+
156
+ - **If `current.status == executing`**: Check if all phases in the roadmap have been executed (all plans completed, commits made). If YES → advance `current.status` to `verifying` in the state file, then route to verifying. If NO → route to executing for the next unexecuted phase.
157
+ - **If `current.status == verifying`**: Check if verification report exists. If YES and it passed → advance to `auditing`. If NO → route to verifying.
158
+ - **General rule**: If the work for the current status is done but the status wasn't advanced (session ended mid-handoff), advance it now and route to the next skill.
159
+
160
+ ### Phase Status Wording
161
+
162
+ When reporting phase progress on resume, use precise terminology to avoid confusion:
163
+
164
+ | Phase State | Display As | Meaning |
165
+ |------------|-----------|---------|
166
+ | All tasks executed, commits made | **"Executed"** | Code is written and committed, but NOT yet verified |
167
+ | Verified by verifying skill | **"Verified"** | Passed goal-backward verification |
168
+ | Not yet started | **"Pending"** | No work done yet |
169
+ | Currently in progress | **"In progress"** | Partially executed |
170
+
171
+ **Never say a phase is "Complete" unless it has passed through the full workflow** (executed + verified + audited). Use "Executed" for phases where code is done but verification hasn't run. This prevents users from thinking a phase is fully done when it still needs verification.
172
+
525
173
  ### On-Demand Discussion
526
174
 
527
175
  The `discussing` skill can be invoked at any time, regardless of current workflow position. If the user says "discuss Phase 2", "let's talk through the plan", "I want to rethink this", or similar — route to `discussing` immediately. After the discussion concludes, return to whatever skill was active (or re-plan if the discussion changed direction).
@@ -0,0 +1,396 @@
1
+ ---
2
+ name: initializing
3
+ description: "Run once per project to detect brownfield/greenfield, scan tech stack, absorb existing frameworks, configure design system, and set up constitutional gates. Invoked by the forge skill when no .forge/project.yml exists."
4
+ ---
5
+
6
+ # Initializing: Project Setup
7
+
8
+ This interactive workflow runs once when Forge doesn't find an existing project (no `.forge/project.yml`). First, detect whether this is a **brownfield** (existing codebase) or **greenfield** (new project) — then run the appropriate init path.
9
+
10
+ ## Detect Project Type
11
+
12
+ Check for signals of an existing codebase:
13
+
14
+ ```
15
+ Check: package.json OR requirements.txt OR go.mod OR Cargo.toml (dependency manifest)
16
+ Check: .git/ (version control history)
17
+ Check: src/ OR app/ OR lib/ (source directories)
18
+ Check: existing config files (tsconfig.json, .eslintrc, vite.config, etc.)
19
+ ```
20
+
21
+ - **2+ signals found** → **Brownfield path** (existing codebase)
22
+ - **0-1 signals** → **Greenfield path** (new project)
23
+
24
+ Ask user to confirm: *"This looks like an [existing project / new project]. Is that right?"*
25
+
26
+ ---
27
+
28
+ ## Brownfield Path: Discover Existing Project
29
+
30
+ For existing codebases, **scan first, confirm with user second.** Don't ask the user to describe what you can discover.
31
+
32
+ ### Discovery Step 0: Framework Detection
33
+
34
+ Before scanning the tech stack, check for two things: (1) existing meta-prompting frameworks with project knowledge to absorb, and (2) companion tools that should be preserved alongside Forge.
35
+
36
+ **Meta-Framework Signatures** (contain project knowledge — candidates for absorption):
37
+
38
+ ```
39
+ # GSD (Get Shit Done)
40
+ Check: agents/gsd-*.md OR commands/gsd/ directory
41
+ Check: Root-level PROJECT.md + REQUIREMENTS.md + ROADMAP.md + STATE.md
42
+ Check: get-shit-done/ directory
43
+ Check: CONTEXT.md with "NON-NEGOTIABLE" or "DEFERRED" sections
44
+
45
+ # Spec-Kit
46
+ Check: spec-driven.md
47
+ Check: templates/ with spec-template.md
48
+ Check: extensions/catalog.json
49
+ Check: constitution-template.md
50
+
51
+ # BMAD
52
+ Check: agents/ with 20+ agent files
53
+ Check: workflows/ directory
54
+ Check: bmad-* prefixed files
55
+
56
+ # Generic / Unknown
57
+ Check: .claude/agents/ or .claude/skills/ (someone else's custom framework)
58
+ Check: CLAUDE.md with framework-like routing tables
59
+ Check: Any structured agent/workflow system
60
+ ```
61
+
62
+ **Companion Tool Signatures** (not frameworks — independent tools that work alongside Forge):
63
+
64
+ ```
65
+ # Beads (persistent cross-session memory)
66
+ Check: .beads/ directory
67
+ Check: beads.jsonl or beads.db
68
+ Check: bd CLI available (Bash: which bd)
69
+ → If found: Enable forge.beads_integration in settings.json. Do NOT absorb or archive.
70
+ → Beads is independent — it runs alongside Forge, not inside it.
71
+ ```
72
+
73
+ **If a meta-framework is detected**, present the finding and offer three options:
74
+
75
+ *"I found an existing [{framework name}] setup in this project. It contains project documentation and decisions that are valuable. How would you like to handle it?"*
76
+
77
+ **Option A: Absorb & Convert** (recommended)
78
+ Read all existing framework documentation, extract the project knowledge, and convert it into Forge's format. This means:
79
+ - Project descriptions → `.forge/project.yml`
80
+ - Requirements → `.forge/requirements.yml`
81
+ - Roadmaps/plans → `.forge/roadmap.yml`
82
+ - Context/decisions → `.forge/context.md`
83
+ - Current state/progress → `.forge/state/index.yml` + `.forge/state/milestone-{id}.yml`
84
+ - Constitutional rules (if any) → `.forge/constitution.md`
85
+ - Design system rules (if any) → `.forge/design-system.md`
86
+
87
+ → Go to **Framework Absorption** below.
88
+
89
+ **Option B: Archive & Start Fresh**
90
+ Move existing framework files into `.forge/archive/{framework-name}/` for reference, then run the standard brownfield discovery (which will still scan the codebase itself). The archive is preserved and can be consulted later.
91
+
92
+ **Option C: Keep Both (Transition Period)**
93
+ Initialize Forge alongside the existing framework. Forge reads from `.forge/` while old framework files remain in place. Useful when you want to try Forge without committing. Remove the old framework later when confident.
94
+
95
+ ---
96
+
97
+ ### Framework Absorption (Option A)
98
+
99
+ When absorbing an existing framework, read its documentation and convert systematically.
100
+
101
+ **GSD Absorption Map:**
102
+
103
+ | GSD Source | Read | Extract | Write to Forge |
104
+ |-----------|------|---------|---------------|
105
+ | `PROJECT.md` | Project name, description, tech stack, goals | Structured project info | `.forge/project.yml` |
106
+ | `REQUIREMENTS.md` | Feature requirements, acceptance criteria | Convert prose to YAML with IDs | `.forge/requirements.yml` |
107
+ | `ROADMAP.md` | Phases, milestones, dependencies | Convert to YAML with dependency refs | `.forge/roadmap.yml` |
108
+ | `STATE.md` | Current phase, progress, blockers | Machine-readable state | `.forge/state/index.yml` + `.forge/state/milestone-{id}.yml` |
109
+ | `CONTEXT.md` | NON-NEGOTIABLE decisions, DEFERRED ideas | Locked decisions, deferred items | `.forge/context.md` |
110
+ | `references/ui-brand.md` | Design system rules, brand guidelines | Component mappings, style rules | `.forge/design-system.md` |
111
+ | `references/verification-patterns.md` | Verification approach | Inform `verifying` skill config | Constitution articles |
112
+ | `references/tdd.md` | Testing approach | Inform constitution Article II | Constitution articles |
113
+ | Agent customizations | Custom agent behaviors, tool restrictions | Map to Forge agent definitions | `.claude/agents/*.md` (if custom) |
114
+
115
+ **Spec-Kit Absorption Map:**
116
+
117
+ | Spec-Kit Source | Read | Extract | Write to Forge |
118
+ |----------------|------|---------|---------------|
119
+ | `spec-driven.md` | Core methodology | Governance patterns | `.forge/constitution.md` |
120
+ | `templates/spec-template.md` | Spec structure | Requirements format | `.forge/requirements.yml` |
121
+ | `templates/constitution-template.md` | Constitutional articles | Immutable gates | `.forge/constitution.md` |
122
+ | `extensions/` | Extension configs | Specialized skills | `.claude/skills/` (if relevant) |
123
+ | Project specs (if filled in) | Project-specific decisions | Locked decisions | `.forge/context.md` |
124
+
125
+ **Generic Framework Absorption:**
126
+
127
+ For unknown frameworks, use the `researching` skill to:
128
+ 1. Read all markdown and config files in the framework directory
129
+ 2. Identify: project descriptions, requirements, decisions, state, design rules
130
+ 3. Map each to the closest Forge equivalent
131
+ 4. Present the mapping to the user for confirmation before writing
132
+
133
+ **Absorption Process:**
134
+
135
+ 1. Read all source files from the existing framework
136
+ 2. For each Forge target file, synthesize content from the relevant sources
137
+ 3. Convert prose to YAML where Forge expects YAML (project, requirements, roadmap, state)
138
+ 4. Preserve markdown where Forge expects markdown (constitution, context, design-system)
139
+ 5. **Never discard information** — if something doesn't map to a Forge file, note it in `.forge/context.md` under a "Carried Forward" section
140
+ 6. Move original framework files to `.forge/archive/{framework-name}/`
141
+ 7. Present a diff-style summary: *"Here's what I converted: [list]. And here's what I archived for reference: [list]. Anything I should handle differently?"*
142
+
143
+ After absorption, **always** continue with the standard brownfield steps below (tech stack scan, design system detection, etc.). This is critical — see the verification step next.
144
+
145
+ ### Documentation vs. Codebase Verification
146
+
147
+ **Never trust framework documentation at face value.** Documentation drifts. The codebase is the source of truth.
148
+
149
+ After reading existing framework docs, **cross-reference every claim against the actual code**:
150
+
151
+ ```
152
+ For each claim in the documentation:
153
+ 1. Find the corresponding code (Glob, Grep, Read)
154
+ 2. Verify the claim matches reality
155
+ 3. Flag any discrepancies
156
+ ```
157
+
158
+ **Common drift patterns to check:**
159
+
160
+ | Documentation Says | Verify Against |
161
+ |-------------------|----------------|
162
+ | "Tech stack: React + PostgreSQL" | `package.json` dependencies, actual imports in `src/` |
163
+ | "Uses PrimeReact for all UI" | `Grep: src/ for "from 'primereact"` — are there also raw HTML tables, custom modals? |
164
+ | "Tests written for all features" | `Glob: src/**/*.test.*` — actual coverage vs. claimed coverage |
165
+ | "Auth uses Clerk/Auth0/etc." | `Grep: src/ for auth imports` — is there also custom auth code? |
166
+ | "State management via Redux" | `package.json` + actual imports — did they switch to Zustand mid-project? |
167
+ | "API uses REST" | `Grep: src/ for GraphQL, tRPC, WebSocket` — mixed protocols? |
168
+ | Requirements list features A, B, C | Do routes/components for A, B, C actually exist? Are any partially implemented? |
169
+ | Roadmap says "Phase 2 complete" | Are Phase 2 features actually wired and working, or are there stubs? |
170
+
171
+ **When discrepancies are found:**
172
+
173
+ Present them to the user clearly:
174
+
175
+ *"I found some differences between the GSD documentation and the actual codebase:*
176
+
177
+ - *PROJECT.md says 'PostgreSQL' but I only see SQLite in dependencies*
178
+ - *REQUIREMENTS.md lists a 'notifications' feature but I can't find any notification code*
179
+ - *STATE.md says Phase 2 is complete, but the dashboard component looks like a stub (returns placeholder text)*
180
+ - *The docs mention PrimeReact exclusively, but I found 3 files using raw HTML tables instead of DataTable*
181
+
182
+ *Should I update the Forge config to match what's actually in the code, or are some of these features that were removed/deferred?"*
183
+
184
+ **Priority order for truth:**
185
+ 1. **What the code actually does** — highest authority
186
+ 2. **What the user confirms** — resolves ambiguity
187
+ 3. **What the documentation says** — useful context, but may be stale
188
+
189
+ Write the verified state to Forge files. For any unresolved discrepancies, add them to `.forge/context.md` under a "Needs Resolution" section so they get addressed during planning.
190
+
191
+ ---
192
+
193
+ ### Discovery Step 1: Tech Stack Scan
194
+
195
+ ```bash
196
+ # Package manifest
197
+ Read: package.json → name, dependencies, devDependencies, scripts
198
+ # Or: requirements.txt, go.mod, Cargo.toml, etc.
199
+
200
+ # Config files
201
+ Glob: tsconfig.json, .eslintrc*, vite.config.*, next.config.*, webpack.config.*
202
+ Glob: .env.example, docker-compose.yml
203
+
204
+ # Source structure
205
+ Bash: find src/ -type f | head -50 # understand file organization
206
+ Bash: wc -l src/**/*.{ts,tsx,js,jsx} 2>/dev/null | tail -1 # codebase size
207
+ ```
208
+
209
+ From this, auto-detect:
210
+ - Language and framework
211
+ - Build tools and test framework
212
+ - Database (from dependencies or config)
213
+ - Project name and description (from package.json or README)
214
+
215
+ ### Discovery Step 2: Design System Detection
216
+
217
+ ```bash
218
+ # Check dependencies for known UI libraries
219
+ Grep: package.json for: primereact, @mui/, @chakra-ui/, @radix-ui/, antd, @headlessui/
220
+ Grep: package.json for: tailwindcss, primeflex, @emotion/, styled-components
221
+
222
+ # Check actual usage in source
223
+ Grep: src/ for import patterns: "from 'primereact", "from '@mui/", "from '@/components/ui"
224
+ Grep: src/ for icon usage: "pi pi-", "Material", "lucide-react"
225
+
226
+ # Check for theme files
227
+ Glob: **/*theme*, **/*variables.scss, **/tailwind.config*, **/globals.css
228
+ ```
229
+
230
+ From this, auto-detect:
231
+ - Component library (and version from package.json)
232
+ - Icon set in use
233
+ - Layout system (PrimeFlex, Tailwind, MUI Grid, etc.)
234
+ - Theme approach (SCSS variables, CSS-in-JS, Tailwind config, design tokens)
235
+
236
+ ### Discovery Step 3: Pattern Analysis
237
+
238
+ ```bash
239
+ # Existing conventions
240
+ Glob: src/**/*.test.* OR src/**/*.spec.* # test patterns
241
+ Grep: src/ for error handling patterns
242
+ Grep: src/ for auth/session patterns
243
+ Bash: git log --oneline -20 # commit style
244
+
245
+ # Architecture patterns
246
+ Bash: ls -la src/ # top-level structure (pages, components, services, etc.)
247
+ Glob: src/**/index.{ts,tsx,js} # barrel exports
248
+ Grep: src/ for "import.*from.*@/" # path aliases
249
+ ```
250
+
251
+ ### Discovery Step 4: Present Findings
252
+
253
+ Present a structured summary to the user:
254
+
255
+ *"I've scanned your codebase. Here's what I found:*
256
+
257
+ *Project: {name} — {description from README or package.json}*
258
+ *Stack: {language} + {framework} + {database}*
259
+ *UI: {component library} with {icon set}, layout via {layout system}*
260
+ *Testing: {test framework}, {X} existing test files*
261
+ *Size: ~{N} source files, ~{N}K lines*
262
+ *Patterns: {commit style}, {folder structure approach}, {key conventions}*
263
+
264
+ *Does this look right? Anything I missed or got wrong?"*
265
+
266
+ ### Discovery Step 5: Design System Mapping
267
+
268
+ If a component library was detected:
269
+ 1. Check `.forge/templates/design-systems/` for an existing example config
270
+ 2. If found (e.g., PrimeReact) → copy it as starting point for `.forge/design-system.md`
271
+ 3. If not found → use `researching` skill to build a component mapping from docs
272
+ 4. **Cross-reference with actual usage**: scan the codebase for which components are already in use and prioritize those in the mapping
273
+ 5. Present mapping to user for validation
274
+
275
+ If no component library detected but UI files exist:
276
+ - Ask: *"I see UI code but no component library. Are you using a design system, or is this custom HTML/CSS?"*
277
+
278
+ ### Discovery Step 6: Constitutional Inference
279
+
280
+ Based on discovered patterns, **suggest** which articles to enable:
281
+
282
+ | Discovery | Suggested Articles |
283
+ |-----------|-------------------|
284
+ | Test files found | Article II: Test-First (already practicing) |
285
+ | Component library detected | Article V: Design System Fidelity |
286
+ | Auth/session patterns found | Article VI: Security by Default |
287
+ | Established conventions detected | Article IV: Consistency (preserve them) |
288
+ | package-lock.json or yarn.lock | Article I: Library-First (already using libraries) |
289
+ | Logging/monitoring deps | Article IX: Observability |
290
+
291
+ Present grouped recommendations and let user confirm, add, or remove articles.
292
+
293
+ ---
294
+
295
+ ## Greenfield Path: Build from Description
296
+
297
+ For new projects, ask the user to describe what they're building.
298
+
299
+ ### Greenfield Step 1: Project Basics
300
+
301
+ Ask the user to describe the project. From their description, fill in `.forge/project.yml`:
302
+
303
+ - Project name and description
304
+ - Primary goal
305
+ - Tech stack (language, framework, database, testing)
306
+ - Time and scope constraints
307
+ - Success criteria
308
+ - Known risks
309
+
310
+ Present a summary: *"Does this capture your project correctly? Anything to add or change?"*
311
+
312
+ ### Greenfield Step 2: Design System Setup
313
+
314
+ Ask: *"Does this project use a UI component library or design system?"*
315
+
316
+ **If yes**, ask which one and configure `design_system` in `project.yml`:
317
+
318
+ ```yaml
319
+ design_system:
320
+ library: "" # e.g., PrimeReact, Material-UI, shadcn/ui, Ant Design, Chakra UI
321
+ version: "" # e.g., 10.x, 5.x
322
+ icon_set: "" # e.g., PrimeIcons, Material Icons, Lucide, none
323
+ layout_system: "" # e.g., PrimeFlex, MUI Grid, Tailwind, CSS Grid
324
+ theme_approach: "" # e.g., SCSS variables, CSS-in-JS, Tailwind config, design tokens
325
+ docs_url: "" # e.g., https://primereact.org/datatable/
326
+ ```
327
+
328
+ Then:
329
+ 1. Check `.forge/templates/design-systems/` for a starter config
330
+ 2. If found → copy and customize for the project
331
+ 3. If not → use `researching` skill to build a component mapping from docs
332
+ 4. Write the mapping to `.forge/design-system.md`
333
+
334
+ **If no** (plain HTML/CSS, utility-only, or non-UI project):
335
+ - Set `design_system.library: none` in project.yml
336
+ - Skip design-system.md creation
337
+ - Disable Article V in the constitution
338
+
339
+ ### Greenfield Step 3: Constitutional Setup
340
+
341
+ Present the 9 constitutional articles grouped by domain:
342
+
343
+ **Code quality** (recommended for most projects):
344
+ - Article I: Library-First — prefer proven libraries over custom code
345
+ - Article II: Test-First — tests before or alongside implementation
346
+ - Article III: Simplicity — simplest solution wins
347
+ - Article IV: Consistency — follow existing project patterns
348
+
349
+ **Design & UI** (enable if project has UI):
350
+ - Article V: Design System Fidelity — use the design system, don't fight it
351
+
352
+ **Security & data** (enable if auth, user data, or APIs involved):
353
+ - Article VI: Security by Default — auth, validation, secrets are requirements
354
+
355
+ **Architecture** (enable based on project complexity):
356
+ - Article VII: Integration-First — real dependencies before mocks
357
+ - Article VIII: Documentation-Driven — decisions documented where code lives
358
+ - Article IX: Observability — logging, error reporting, health checks
359
+
360
+ Ask: *"Which of these articles apply? I'd recommend [suggest based on stack and project type]. You can also add project-specific articles."*
361
+
362
+ ---
363
+
364
+ ## Finalize Init (Both Paths)
365
+
366
+ 1. Write `.forge/project.yml` with all gathered/discovered info
367
+ 2. Write `.forge/constitution.md` with selected articles
368
+ 3. Write `.forge/design-system.md` (if design system configured)
369
+ 4. Initialize milestone-aware state:
370
+ - Create `.forge/state/` directory
371
+ - Write `.forge/state/index.yml`:
372
+ ```yaml
373
+ milestones:
374
+ - id: 1
375
+ name: "{project name}"
376
+ status: active
377
+ last_updated: "{date}"
378
+ ```
379
+ - Write `.forge/state/milestone-1.yml`:
380
+ ```yaml
381
+ milestone:
382
+ id: 1
383
+ name: "{project name}"
384
+ current:
385
+ tier: null
386
+ phase: null
387
+ phase_name: ""
388
+ plan: null
389
+ task: null
390
+ status: not_started
391
+ ```
392
+ 5. Copy remaining templates as needed
393
+
394
+ Confirm: *"Project initialized. Here's what's set up: [summary]. Ready to start working?"*
395
+
396
+ After init completes, return control to the `forge` skill for tier detection and routing.
@@ -1,3 +1,4 @@
1
+ <!-- forge:start -->
1
2
  # Forge
2
3
 
3
4
  A lean meta-prompting framework for Claude Code. Synthesizes context engineering (GSD) and constitutional governance (Spec-Kit) on Claude Code's native primitives.
@@ -40,6 +41,7 @@ Forge auto-detects complexity. Override with: "Use Quick/Standard/Full tier."
40
41
  | When you need to... | Use skill | Tier |
41
42
  |---------------------|-----------|------|
42
43
  | Start any task (entry point) | `forge` | All |
44
+ | Set up a new project (brownfield or greenfield) | `initializing` | First run only |
43
45
  | Investigate codebase, tech, or requirements | `researching` | Standard, Full |
44
46
  | Talk through approach, trade-offs, or revisit a plan | `discussing` | Standard, Full (also on-demand) |
45
47
  | Make architectural decisions with rationale | `architecting` | Full |
@@ -161,3 +163,4 @@ Every task gets its own commit. Format: `{type}({scope}): {description}`
161
163
  Types: `feat`, `fix`, `test`, `refactor`, `chore`, `docs`
162
164
  Scope: phase-plan or feature area
163
165
  Never use `git add .` or `git add -A` — stage files individually.
166
+ <!-- forge:end -->