Bootstrap the OPSX architecture map from the existing codebase.
This is a structured, multi-phase workflow. Each phase produces intermediate artifacts in openspec/bootstrap/ before writing formal OPSX files.
Treat openspec/config.yaml as the source of truth for authoring policy, but consume its compiled projection semantics: prose-bearing bootstrap artifacts follow the projected documentation language policy, while canonical headings, IDs, schema keys, paths, and commands stay unchanged.
Input: No argument required. Scope hints (folders, domain names) are passed to init.
Steps
Determine current phase
openspec bootstrap status --json
- If no workspace exists, start with init
- If workspace exists and is in progress, resume from the current phase
- If workspace exists and is completed, restart explicitly with
openspec bootstrap init --mode refresh --restart
Execute the current phase
Get phase-specific instructions:
openspec bootstrap instructions [phase] --json
Phase: init
openspec bootstrap init --mode full
Creates workspace at openspec/bootstrap/ with scope configuration.
Supported upgrade paths:
specs-based -> full
raw -> full
raw -> opsx-first
formal-opsx -> refresh
Use opsx-first only for raw repositories when you want the formal OPSX bundle plus a README-only specs starter now, and full behavior specs later.
Use refresh only for repositories that already have the formal OPSX bundle and need a delta-first refresh that merges reviewed changes back into the existing formal files.
Use --restart only when a completed retained workspace already exists and you want a fresh run; it snapshots the old openspec/bootstrap/ into openspec/bootstrap-history/ first.
Phase: scan
- Run `openspec bootstrap validate` to verify gates
- In `refresh`, treat the current formal OPSX bundle as the baseline and use git diff only to narrow scan scope when a stored anchor commit is still reachable
**Phase: map**
- For each domain in evidence.yaml, create `openspec/bootstrap/domain-map/<domain-id>.yaml`:
```yaml
domain:
id: dom.cli
type: domain
intent: CLI entry point and command routing
status: active
capabilities:
- id: cap.cli.init
type: capability
intent: Initialize OpenSpec in a project
status: active
relations:
- from: cap.cli.init
to: dom.cli
type: contains
code_refs:
- id: cap.cli.init
refs:
- path: src/core/init.ts
line_start: 1
- Map incrementally — one domain at a time
- Run
openspec bootstrap status to track per-domain progress
- Run
openspec bootstrap validate after all domains mapped
Phase: review
- Validate regenerates review.md and candidate OPSX files from current
evidence.yaml and domain-map/*.yaml
- Review each domain checkbox in review.md
- In
refresh, review the delta summary against the current formal OPSX baseline instead of re-approving the whole model
- Check all validation checkboxes
- If evidence or domain maps change, rerun validate and re-approve the regenerated review
- Low-confidence domains appear first for priority review
Phase: promote
openspec bootstrap promote -y
Re-validates all upstream gates before writing.
opsx-first: writes the formal OPSX three-file bundle plus only openspec/specs/README.md
full on raw: writes the formal OPSX bundle plus one validated spec per mapped capability
full on specs-based: preserves existing specs, adds only missing capability specs, and fails fast on target-path conflicts
refresh on formal-opsx: merges the reviewed delta into the existing formal OPSX bundle, preserves existing specs, adds only missing specs for newly added capabilities, and fails fast on conflicts
Retains the bootstrap workspace on success for audit history.
Start the next refresh run with openspec bootstrap init --mode refresh --restart, which snapshots the retained workspace into openspec/bootstrap-history/.
After each phase action
- Run
openspec bootstrap validate to verify gate conditions
- Run
openspec bootstrap status to confirm phase advancement
- Continue to next phase
Evidence Guidelines
- Use repository evidence only — do not fabricate
- Attach confidence levels: high (multiple sources), medium (single source), low (inferred)
- Prefer fewer domains with solid evidence over exhaustive noise
- Each domain should map to a clear architectural boundary
Mapping Guidelines
- Capability IDs follow
cap.<domain>.<action> convention
- Code references must point to existing files
- Relations capture structural ownership (contains) and runtime dependencies (depends_on)
- Mark uncertain mappings for review attention
Guardrails
- Do NOT write directly to formal OPSX files — use the bootstrap workspace
- Do NOT fabricate code references
- Do NOT skip the review phase
- Do NOT treat stale review.md checkboxes as approval after evidence or mappings change
- Keep the graph small enough to audit in one sitting
1---2name: openspec-bootstrap-opsx3description: Bootstrap OPSX architecture map from existing codebase using a structured five-phase workflow (init → scan → map → review → promote).4license: MIT5---6
7Bootstrap the OPSX architecture map from the existing codebase.
8
9This is a **structured, multi-phase** workflow. Each phase produces intermediate artifacts in `openspec/bootstrap/` before writing formal OPSX files.
10
11Treat `openspec/config.yaml` as the source of truth for authoring policy, but consume its compiled projection semantics: prose-bearing bootstrap artifacts follow the projected documentation language policy, while canonical headings, IDs, schema keys, paths, and commands stay unchanged.
12
13**Input**: No argument required. Scope hints (folders, domain names) are passed to init.
14
15**Steps**
16
171. **Determine current phase**
18 ```bash
19 openspec bootstrap status --json
20 ```
21 - If no workspace exists, start with init
22 - If workspace exists and is in progress, resume from the current phase
23 - If workspace exists and is completed, restart explicitly with `openspec bootstrap init --mode refresh --restart`
24
252. **Execute the current phase**
26
27 Get phase-specific instructions:
28 ```bash
29 openspec bootstrap instructions [phase] --json
30 ```
31
32 **Phase: init**
33 ```bash
34 openspec bootstrap init --mode full
35 ```
36 Creates workspace at `openspec/bootstrap/` with scope configuration.
37 Supported upgrade paths:
38 - `specs-based -> full`
39 - `raw -> full`
40 - `raw -> opsx-first`
41 - `formal-opsx -> refresh`
42 Use `opsx-first` only for `raw` repositories when you want the formal OPSX bundle plus a README-only specs starter now, and full behavior specs later.
43 Use `refresh` only for repositories that already have the formal OPSX bundle and need a delta-first refresh that merges reviewed changes back into the existing formal files.
44 Use `--restart` only when a completed retained workspace already exists and you want a fresh run; it snapshots the old `openspec/bootstrap/` into `openspec/bootstrap-history/` first.
45
46 **Phase: scan**
47 - Read `package.json`, `README`, OpenSpec config, `openspec/specs/`
48 - Scan source code for structural boundaries
49 - Write `openspec/bootstrap/evidence.yaml` with candidate domains:
50 ```yaml
51 domains:
52 - id: dom.cli
53 confidence: high
54 sources: [code:src/cli/, spec:openspec/specs/cli/]
55 intent: CLI entry point and command routing
56 ```
57 - Run `openspec bootstrap validate` to verify gates
58 - In `refresh`, treat the current formal OPSX bundle as the baseline and use git diff only to narrow scan scope when a stored anchor commit is still reachable
59
60 **Phase: map**
61 - For each domain in evidence.yaml, create `openspec/bootstrap/domain-map/<domain-id>.yaml`:
62 ```yaml
63 domain:
64 id: dom.cli
65 type: domain
66 intent: CLI entry point and command routing
67 status: active
68 capabilities:
69 - id: cap.cli.init
70 type: capability
71 intent: Initialize OpenSpec in a project
72 status: active
73 relations:
74 - from: cap.cli.init
75 to: dom.cli
76 type: contains
77 code_refs:
78 - id: cap.cli.init
79 refs:
80 - path: src/core/init.ts
81 line_start: 1
82 ```
83 - Map incrementally — one domain at a time
84 - Run `openspec bootstrap status` to track per-domain progress
85 - Run `openspec bootstrap validate` after all domains mapped
86
87 **Phase: review**
88 - Validate regenerates review.md and candidate OPSX files from current `evidence.yaml` and `domain-map/*.yaml`
89 - Review each domain checkbox in review.md
90 - In `refresh`, review the delta summary against the current formal OPSX baseline instead of re-approving the whole model
91 - Check all validation checkboxes
92 - If evidence or domain maps change, rerun validate and re-approve the regenerated review
93 - Low-confidence domains appear first for priority review
94
95 **Phase: promote**
96 ```bash
97 openspec bootstrap promote -y
98 ```
99 Re-validates all upstream gates before writing.
100 - `opsx-first`: writes the formal OPSX three-file bundle plus only `openspec/specs/README.md`
101 - `full` on `raw`: writes the formal OPSX bundle plus one validated spec per mapped capability
102 - `full` on `specs-based`: preserves existing specs, adds only missing capability specs, and fails fast on target-path conflicts
103 - `refresh` on `formal-opsx`: merges the reviewed delta into the existing formal OPSX bundle, preserves existing specs, adds only missing specs for newly added capabilities, and fails fast on conflicts
104 Retains the bootstrap workspace on success for audit history.
105 Start the next refresh run with `openspec bootstrap init --mode refresh --restart`, which snapshots the retained workspace into `openspec/bootstrap-history/`.
106
1073. **After each phase action**
108 - Run `openspec bootstrap validate` to verify gate conditions
109 - Run `openspec bootstrap status` to confirm phase advancement
110 - Continue to next phase
111
112**Evidence Guidelines**
113- Use repository evidence only — do not fabricate
114- Attach confidence levels: high (multiple sources), medium (single source), low (inferred)
115- Prefer fewer domains with solid evidence over exhaustive noise
116- Each domain should map to a clear architectural boundary
117
118**Mapping Guidelines**
119- Capability IDs follow `cap.<domain>.<action>` convention
120- Code references must point to existing files
121- Relations capture structural ownership (contains) and runtime dependencies (depends_on)
122- Mark uncertain mappings for review attention
123
124**Guardrails**
125- Do NOT write directly to formal OPSX files — use the bootstrap workspace
126- Do NOT fabricate code references
127- Do NOT skip the review phase
128- Do NOT treat stale review.md checkboxes as approval after evidence or mappings change
129- Keep the graph small enough to audit in one sitting