opencode-onboard 0.4.4 → 0.4.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.
Files changed (37) hide show
  1. package/README.md +58 -19
  2. package/content/.agents/agents/basic-engineer.md +5 -5
  3. package/content/.agents/agents/devops-manager.md +14 -10
  4. package/content/.agents/skills/ob-global/SKILL.md +9 -7
  5. package/content/.opencode/commands/ob-create-architecture.md +76 -0
  6. package/content/.opencode/commands/ob-create-design.md +53 -0
  7. package/content/.opencode/commands/{create-engineer.md → ob-create-engineer.md} +9 -8
  8. package/content/.opencode/commands/ob-init.md +8 -0
  9. package/content/.opencode/commands/{main.md → ob-main.md} +2 -2
  10. package/content/.opencode/commands/{plan.md → ob-plan.md} +2 -2
  11. package/content/.opencode/commands/opsx-apply.md +212 -193
  12. package/content/.opencode/skills/openspec-apply-change/SKILL.md +234 -176
  13. package/content/AGENTS.md +161 -49
  14. package/content/ARCHITECTURE.md +16 -327
  15. package/content/DESIGN.md +16 -26
  16. package/package.json +1 -1
  17. package/src/commands/join.js +6 -1
  18. package/src/commands/single.js +1 -1
  19. package/src/presets/models.json +2 -2
  20. package/src/presets/platforms.json +4 -0
  21. package/src/steps/copy/agents.js +200 -3
  22. package/src/steps/copy/agents.test.js +45 -0
  23. package/src/steps/copy/copy.test.js +15 -2
  24. package/src/steps/copy/index.js +2 -1
  25. package/src/steps/metadata/index.js +6 -5
  26. package/src/steps/metadata/metadata.test.js +16 -8
  27. package/src/steps/models/write.js +17 -4
  28. package/src/steps/models/write.test.js +57 -56
  29. package/src/steps/openspec/ensemble.js +81 -54
  30. package/src/steps/openspec/ensemble.test.js +40 -8
  31. package/src/steps/optimization/codegraph.js +51 -0
  32. package/src/steps/optimization/codegraph.test.js +104 -0
  33. package/src/steps/optimization/global.js +21 -1
  34. package/src/steps/optimization/global.test.js +3 -0
  35. package/src/steps/platform/index.js +8 -1
  36. package/src/steps/platform/platform.test.js +19 -0
  37. package/content/.opencode/commands/init.md +0 -8
package/content/AGENTS.md CHANGED
@@ -6,13 +6,36 @@
6
6
 
7
7
  ## Trigger
8
8
 
9
- When the user says anything resembling initialization, "init", "initialize", "setup", "start", "bootstrap", "get started", "prepare", execute all steps below in order. Do not ask for confirmation before starting.
9
+ When the user says anything resembling initialization, "init", "initialize", "setup", "start", "bootstrap", "get started", "prepare", execute the steps below. Follow the greenfield/brownfield branching exactly.
10
10
 
11
11
  ---
12
12
 
13
13
  ## Initialization Sequence
14
14
 
15
- ### Step 1, Archive project history into OpenSpec
15
+ ### Step 1, Detect project type
16
+
17
+ Ask the user exactly this question before doing anything else:
18
+
19
+ > "Is this a **greenfield** project (starting from scratch, little or no existing code) or a **brownfield** project (existing codebase)?"
20
+ >
21
+ > - Reply **greenfield** to skip architecture/design/history analysis
22
+ > - Reply **brownfield** to generate docs from your existing code
23
+
24
+ Wait for the answer. Then follow the matching path below.
25
+
26
+ ---
27
+
28
+ ### Greenfield path
29
+
30
+ Skip steps 2, 3, and 4. Jump directly to Step 5.
31
+
32
+ Greenfield note: `ARCHITECTURE.md` and `DESIGN.md` are left as placeholders. Run `/ob-create-architecture` and `/ob-create-design` once the codebase has meaningful content.
33
+
34
+ ---
35
+
36
+ ### Brownfield path
37
+
38
+ #### Step 2, Archive project history into OpenSpec
16
39
 
17
40
  Scan the codebase for any existing documentation, changelogs, ADRs, README files, or notable history that describes decisions already made in this project. Create an OpenSpec archive entry that captures this history so agents have context going forward.
18
41
 
@@ -35,37 +58,23 @@ openspec archive "project-history"
35
58
 
36
59
  ---
37
60
 
38
- ### Step 2, Generate DESIGN.md
61
+ #### Step 3, Generate ARCHITECTURE.md
39
62
 
40
- `DESIGN.md` contains a prompt. You MUST follow this exact sequence, do not skip or reorder steps:
41
-
42
- 1. **Read `DESIGN.md` now** using a file read tool. The file contains a prompt with instructions and an output format.
43
- 2. **Store the full prompt text** in your context.
44
- 3. **Overwrite `DESIGN.md` with an empty string** (zero bytes). Do this before generating any content.
45
- 4. **Analyze the actual codebase**: use `.agents/source-roots.json` as source roots when present, then read CSS files, Tailwind config, component files, token definitions. Do not rely on prior knowledge, read the files.
46
- 5. **Write the result into `DESIGN.md`** following exactly the format and sections described in the stored prompt.
47
-
48
- The output must be a real, populated `DESIGN.md` based on what you found in the codebase, not from memory or assumptions.
63
+ Run `/ob-create-architecture` now. Follow every step defined in that command.
49
64
 
50
65
  ---
51
66
 
52
- ### Step 3, Generate ARCHITECTURE.md
53
-
54
- `ARCHITECTURE.md` contains a prompt. You MUST follow this exact sequence, do not skip or reorder steps:
67
+ #### Step 4, Generate DESIGN.md
55
68
 
56
- 1. **Read `ARCHITECTURE.md` now** using a file read tool. The file contains a prompt with instructions and an output format.
57
- 2. **Store the full prompt text** in your context.
58
- 3. **Overwrite `ARCHITECTURE.md` with an empty string** (zero bytes). Do this before generating any content.
59
- 4. **Analyze the actual codebase**: use `.agents/source-roots.json` as source roots when present, then read folder structure, config files, route definitions, data models, integration points. Do not rely on prior knowledge, read the files.
60
- 5. **Write the result into `ARCHITECTURE.md`** following exactly the format and sections described in the stored prompt.
61
-
62
- The output must be a real, populated `ARCHITECTURE.md` based on what you found in the codebase, covering all sections the prompt describes.
69
+ Run `/ob-create-design` now. Follow every step defined in that command.
63
70
 
64
71
  ---
65
72
 
66
- ### Step 4, Populate OpenSpec config
73
+ ### Step 5, Populate OpenSpec config
74
+
75
+ Write `openspec/config.yaml` with real project information. For greenfield projects, use what little is known (language choice, intended stack, domain). For brownfield, use what was discovered in steps 2–4.
67
76
 
68
- Write `openspec/config.yaml` with the real project information discovered during steps 1-3. Overwrite whatever is currently in the file. The output must contain `schema: spec-driven` and a populated `context:` block. Do not leave placeholder text.
77
+ The output must contain `schema: spec-driven` and a populated `context:` block. Do not leave placeholder text.
69
78
 
70
79
  ```yaml
71
80
  schema: spec-driven
@@ -78,19 +87,19 @@ context: |
78
87
  Domain: <what this project does, in one line>
79
88
  ```
80
89
 
81
- Replace every `<…>` with real values from the codebase. Add a `rules:` section only if the codebase has clear conventions worth enforcing (e.g., max task size, proposal format). Do not invent rules that aren't evidenced by the codebase.
90
+ Replace every `<…>` with real values. Add a `rules:` section only if the codebase has clear conventions worth enforcing. Do not invent rules that aren't evidenced by the codebase.
82
91
 
83
92
  ---
84
93
 
85
- ### Step 5, Rewrite this file
94
+ ### Step 6, Rewrite this file
86
95
 
87
96
  Replace the entire contents of this file (`AGENTS.md`) with everything below the line `<!-- AGENTS-TEMPLATE-START -->` in this same file. Delete the bootstrap section and the template marker, the file should contain only the template content when done.
88
97
 
89
98
  ---
90
99
 
91
- ### Step 6, Confirm
100
+ ### Step 7, Confirm
92
101
 
93
- Tell the user:
102
+ For **brownfield**, tell the user:
94
103
 
95
104
  ```
96
105
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -110,6 +119,28 @@ Nothing will work correctly until you do.
110
119
  After restarting you are ready to work.
111
120
  ```
112
121
 
122
+ For **greenfield**, tell the user:
123
+
124
+ ```
125
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
126
+ Initialization complete (greenfield).
127
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
128
+
129
+ - openspec/config.yaml populated
130
+ - AGENTS.md updated with real guidance
131
+ - ARCHITECTURE.md and DESIGN.md left as placeholders
132
+
133
+ Once your codebase has meaningful content, run:
134
+ /ob-create-architecture → generate architecture docs
135
+ /ob-create-design → generate design system docs
136
+
137
+ !! RESTART OPENCODE NOW !!
138
+
139
+ Quit and reopen OpenCode before doing anything else.
140
+ Nothing will work correctly until you do.
141
+ After restarting you are ready to work.
142
+ ```
143
+
113
144
  ---
114
145
 
115
146
  ## Guardrails During Init
@@ -143,9 +174,10 @@ Source scope is defined by mandatory `ob-global` skill.
143
174
  - Follow the generated `## Source Roots` section from that skill.
144
175
  - Do not duplicate source-scope rules here.
145
176
 
146
- ## I Am the Lead, Full Workflow Ownership
147
-
148
- When the user provides a work item URL or says "implement the plan" or "I've added comments to the PR", **I own the full lifecycle**. I load `ob-global` skill first, then the appropriate userstory skill, and use ensemble tools to coordinate the agent team.
177
+ ## I Am the Lead, Full Workflow Ownership
178
+
179
+ <!-- OB-PLATFORM-WORKFLOW-START -->
180
+ When the user provides a work item URL or says "implement the plan" or "I've added comments to the PR", **I own the full lifecycle**. I load `ob-global` skill first, then the appropriate userstory skill, and use ensemble tools to coordinate the agent team.
149
181
 
150
182
  Trigger patterns, I recognize ALL of these, exact wording does not matter:
151
183
  - User pastes or mentions a GitHub Issue URL → load `ob-userstory-gh` skill → parse issue → run `/opsx-propose` → confirm with user → run `/opsx-apply` → ship
@@ -154,9 +186,20 @@ Trigger patterns, I recognize ALL of these, exact wording does not matter:
154
186
  - `I've added comments to the PR` → read PR comments → fix → update PR
155
187
  - Any GitHub/Azure DevOps PR URL in a feedback/fix request (e.g. "check comments", "fix PR feedback") → run PR Feedback Loop
156
188
 
157
- **A GitHub or Azure DevOps URL anywhere in the user's message is always a trigger, regardless of surrounding words.**
158
-
159
- **Never delegate without a plan. Never write implementation code directly, always spawn specialists, no exceptions. "Small feature", "faster to do it directly", or "environment issues" are not valid reasons to skip ensemble.**
189
+ **A GitHub or Azure DevOps URL anywhere in the user's message is always a trigger, regardless of surrounding words.**
190
+ <!-- OB-PLATFORM-WORKFLOW-END -->
191
+
192
+ **Never delegate without a plan. Default to specialists for implementation. If ensemble is clearly non-functional in the current session (idle teammate, no claim, or repeated spawn failure after one retry), stop forcing it: report the failure, then continue in the main session or ask the user whether to retry later.**
193
+
194
+ ## Engineer Selection
195
+
196
+ Before spawning implementation workers:
197
+ - Inspect `.agents/agents/*.md` and build the list of engineers that actually exist in this project.
198
+ - Exclude `devops-manager` from implementation selection.
199
+ - Prefer the most specialized custom engineer whose description and abilities clearly match the task domain.
200
+ - Use `basic-engineer` only when no custom engineer is a clear fit or as a recovery fallback.
201
+ - Never spawn engineer names that are not present in `.agents/agents/`.
202
+ - When multiple engineers could fit, choose the narrower specialist before the generalist.
160
203
 
161
204
  ## Multi-Agent Execution, opencode-ensemble
162
205
 
@@ -171,11 +214,14 @@ Core tools used in this workflow:
171
214
  **Dashboard**: Monitor running agents at **http://localhost:4747/**
172
215
 
173
216
  **Hard limits:**
217
+ - **Sequential by default.** Default `{{MAX_CONCURRENT_AGENTS}}` to `1`. Raise only when tasks are provably independent and user approves. More concurrency = more tokens burned in parallel.
174
218
  - **Max {{MAX_CONCURRENT_AGENTS}} truly concurrent agents.** All {{MAX_CONCURRENT_AGENTS}} must be spawned and running simultaneously, not sequentially. Spawn in waves if more than {{MAX_CONCURRENT_AGENTS}} are needed. Wait for wave N to finish before spawning wave N+1.
175
219
  - **Non-overlapping file domains.** Each agent owns exclusive directories. Two agents must NEVER touch the same file.
176
220
  - **Immediate shutdown on completion.** The moment an agent's domain has no more pending tasks → `team_shutdown` → `team_merge`. Keep agents alive if more tasks in their domain are pending (rolling batch).
177
- - **Rolling batch assignment.** Agents receive up to 3 tasks initially. When they complete a batch, lead assigns the next batch of up to 3 from the board. Never leave pending tasks orphaned.
178
- - **Stall detection at 5 minutes.** No commits after 5 min → nudge message → 2 min grace → force shutdown + respawn.
221
+ - **Rolling batch assignment.** Agents receive up to 3 tasks initially. When they complete a batch, lead assigns the next batch of up to 3 from the board. Never leave pending tasks orphaned.
222
+ - **Stall detection at 5 minutes.** No commits after 5 min → nudge message → 2 min grace → force shutdown + respawn.
223
+ - **Idle-without-claim is an earlier stall.** If a spawned teammate sits idle with no claimed task after a short wait, resend one short claim-only message with the exact task IDs. If still idle, force shutdown + respawn once with a shorter prompt. If the retry repeats the same failure, treat ensemble as unavailable for that session and stop recycling equivalent workers.
224
+ - **Retry limit.** Max 3 retries per failing task → stop-and-report to user. Never retry indefinitely.
179
225
 
180
226
  **Progress inspection commands (tell user explicitly after spawning):**
181
227
  - `team_status` for live team snapshot
@@ -190,11 +236,12 @@ If a teammate stalls due to model quota/rate-limit exhaustion:
190
236
 
191
237
  ---
192
238
 
193
- ## Pipeline
194
-
195
- ```
196
- devops-manager (lead mode)
197
- → load ob-global + parse work item via skill
239
+ ## Pipeline
240
+
241
+ <!-- OB-PLATFORM-PIPELINE-START -->
242
+ ```
243
+ devops-manager (lead mode)
244
+ → load ob-global + parse work item via skill
198
245
 
199
246
  openspec-propose
200
247
  → proposal.md + specs + tasks
@@ -221,13 +268,17 @@ devops-manager (ship mode)
221
268
  ### Phase 2, Implement
222
269
 
223
270
  ```
224
- 1. Run /opsx-apply.
225
- - Lead adds all tasks to board.
226
- - Lead spawns engineers with initial batch of up to 3 tasks each (rolling batch model).
271
+ 0. Run /quota to check remaining budget before spawning.
272
+ 1. Run /opsx-apply.
273
+ - Step 5b: classify cost tier, announce scope, ask user to confirm if ≥4 tasks.
274
+ - Lead adds all tasks to board.
275
+ - When dependencies exist, lead uses multiple `team_tasks_add` waves so later tasks can reference real task IDs returned by earlier waves.
276
+ - Lead discovers available engineers from `.agents/agents/*.md`, prefers matching custom engineers, then spawns engineers with initial batch of up to 3 tasks each (rolling batch model).
227
277
  - Each engineer claims tasks, implements, completes, messages lead.
228
278
  - Lead assigns next batch (up to 3) to agents that report done. Repeat until board empty.
229
279
  - Lead merges each engineer branch after shutdown, then marks tasks done in tasks.md.
230
280
  2. Verify with tests/build/lint according to task scope.
281
+ 3. Run /quota after all agents are merged.
231
282
  ```
232
283
 
233
284
  ### Phase 3, Ship
@@ -255,9 +306,10 @@ When user says "I've added comments to the PR" or asks to fix PR comments from P
255
306
  6. Wait for engineer results → team_shutdown + team_merge per engineer
256
307
  7. Run verification tasks (tests/build/lint) and fix blockers if any
257
308
  8. team_spawn devops-manager (ship mode) with "push + update PR threads" task ID + team_message "Start now"
258
- 9. Wait → team_results → report what was updated
259
- 10. team_cleanup
260
- ```
309
+ 9. Wait → team_results → report what was updated
310
+ 10. team_cleanup
311
+ ```
312
+ <!-- OB-PLATFORM-PIPELINE-END -->
261
313
 
262
314
  ---
263
315
 
@@ -270,7 +322,7 @@ All agents are universal, no project-specific knowledge. Platform and tech knowl
270
322
  | `devops-manager` | .agents/agents/devops-manager.md | Reads work items, creates PRs, handles review feedback |
271
323
  | `basic-engineer` | .agents/agents/basic-engineer.md | Generic implementation worker using ability-loaded skills |
272
324
 
273
- User can add more custom engineer agents and run them in parallel. Keep behavior ability-driven via skill mappings.
325
+ User can add more custom engineer agents and run them in parallel. Keep behavior ability-driven via skill mappings. Custom engineers are the primary specialization mechanism; `basic-engineer` is the general fallback when no custom engineer is a clear fit.
274
326
 
275
327
  Default `basic-engineer` abilities:
276
328
 
@@ -284,7 +336,7 @@ Default `basic-engineer` abilities:
284
336
 
285
337
  ## Skills
286
338
 
287
- Skills provide platform and tech-specific knowledge. Agents detect and load them automatically, **you never tell an agent which skill to use**.
339
+ Skills provide platform and tech-specific knowledge. Agents usually detect and load them automatically. Prefer auto-detection, but explicitly naming a skill in a spawn prompt is allowed when a workflow requires it or repeated misses show the agent is not loading the right context.
288
340
 
289
341
  `ob-global` is always loaded first, it provides baseline rules for all agents.
290
342
 
@@ -356,6 +408,66 @@ Minimal non-negotiables:
356
408
  - Use `gh`/`az` CLI for platform operations.
357
409
  - In multi-repo source scope, run git operations per repository.
358
410
 
411
+ ### Config file conflict: `opencode.jsonc` vs `.opencode/opencode.json`
412
+
413
+ This project uses `.opencode/opencode.json` as the single OpenCode configuration file. Some tools (e.g., codegraph) may create an `opencode.jsonc` file at the project root. **These two files cannot coexist.**
414
+
415
+ If you detect both `opencode.jsonc` (project root) and `.opencode/opencode.json` exist:
416
+ 1. **Stop immediately** and warn the user: "Conflicting OpenCode config files detected. This project uses `.opencode/opencode.json` only. The root `opencode.jsonc` must be removed or its contents merged into `.opencode/opencode.json`."
417
+ 2. Do NOT proceed with any task until the conflict is resolved.
418
+ 3. If the user asks you to fix it: merge any `mcpServers` or other config from `opencode.jsonc` into `.opencode/opencode.json`, then delete `opencode.jsonc`.
419
+
420
+ ---
421
+
422
+ ## Token Budget & Safety
423
+
424
+ Prevent runaway token spend from unattended sessions. Apply in this priority order.
425
+
426
+ ### 1. Provider-side caps (primary safety layer)
427
+
428
+ Set monthly soft-limit + hard usage cap in your provider dashboard **before** running any agent session:
429
+ - **OpenAI**: [platform.openai.com/account/limits](https://platform.openai.com/account/limits)
430
+ - **Anthropic**: [console.anthropic.com](https://console.anthropic.com)
431
+ - **Google AI Studio**: [aistudio.google.com/app/usage](https://aistudio.google.com/app/usage)
432
+
433
+ Provider caps are the only guarantees that survive agent bugs, infinite loops, or runaway retries.
434
+
435
+ ### 2. Model-cost routing
436
+
437
+ | Task type | Model tier |
438
+ |-----------|-----------|
439
+ | Orchestration loops, task classification, status checks, PR parsing, triage | Fast / cheap (e.g. `haiku`, `gpt-4o-mini`) |
440
+ | Implementation, code review, hard reasoning | Expensive (e.g. `sonnet`, `opus`, `gpt-4o`) |
441
+
442
+ devops-manager orchestrates — use fast model for it. Engineers implement — use expensive model there only.
443
+
444
+ ### 3. Sequential-by-default concurrency
445
+
446
+ Default: **1 agent at a time**. Set `{{MAX_CONCURRENT_AGENTS}}` to `1` unless tasks are provably independent and the user approves higher concurrency. More agents = more tokens burned in parallel; slow down unless scope justifies it.
447
+
448
+ ### 4. Retry limits
449
+
450
+ Max **3 retries** per failing task. On the third failure:
451
+ 1. Shut down the stuck agent.
452
+ 2. Summarize what failed and why.
453
+ 3. Stop — wait for user guidance before retrying.
454
+
455
+ Never silently retry indefinitely. Repeated failures = a design problem, not a retry problem.
456
+
457
+ ### 5. Inactivity and time cutoffs
458
+
459
+ - **No commits after 10 minutes** of cumulative agent runtime → auto-stop, summarize blockers to user.
460
+ - **Max 1 hour** total runtime per `/opsx-apply` session → stop and report at the limit, regardless of remaining tasks.
461
+
462
+ ### 6. Quota checkpoints
463
+
464
+ Use the `opencode-quota` plugin (`/quota` command) to surface real-time token usage:
465
+ - Run `/quota` at **session start** (before spawning any agents) and **after each agent wave**.
466
+ - "When to stop" thresholds:
467
+ - **50% consumed** → review remaining scope; consider reducing
468
+ - **75% consumed** → pause; summarize completed work; ask user whether to continue
469
+ - **90% consumed** → stop immediately; ship what's done; open follow-up change for remainder
470
+
359
471
  ---
360
472
 
361
473
  ## Communication Style
@@ -1,327 +1,16 @@
1
- > Execute this command.
2
-
3
- Analyze the architecture of this codebase with the goal of creating an ARCHITECTURE.md file in the project root and giving the user a file for easy copy & pasting.
4
-
5
- Reference material:
6
- Website : https://architecture.md/
7
- Repo : https://github.com/timajwilliams/architecture
8
-
9
- Requirements:
10
- - Create a complete ARCHITECTURE.md document that enables rapid codebase comprehension for both human developers and AI agents.
11
- - The file must be entirely self-contained. Do not say “see X file” as a substitute for explanation; include the relevant architectural facts directly in the document.
12
- - Be specific and concrete: include actual directories, important files, modules, services, classes, APIs, commands, data stores, configuration points, and integration boundaries where they are discoverable from the codebase.
13
- - Do not invent systems, services, infrastructure, deployment targets, databases, queues, third-party APIs, or security mechanisms that are not supported by evidence in the repository.
14
- - When something cannot be determined from the codebase, explicitly mark it as “Not evident from the repository” rather than guessing.
15
- - Prefer durable architectural facts over transient implementation details. Focus on things that help someone understand where to make changes and how the system fits together.
16
- - Include diagrams using Mermaid where helpful, especially for system context, component relationships, request/data flow, and deployment topology.
17
- - If Mermaid is not appropriate or the architecture is simple, include a clear text-based diagram instead.
18
- - If architecture decisions or tradeoffs are visible from the code, document the rationale and consequences.
19
- - Include technical debt, risks, unclear boundaries, and future architecture considerations when supported by TODOs, comments, docs, issue references, or code structure.
20
- - Use Markdown only. Do not rely on external images, generated assets, or links to local files.
21
- - Write the document as if it will be committed to the repository and maintained over time.
22
-
23
- Recommended ARCHITECTURE.md structure:
24
-
25
- # Architecture Overview
26
-
27
- Briefly describe what the system is, what problem it solves, who/what uses it, and the major architectural style or pattern if evident.
28
-
29
- ## 1. Project Structure
30
-
31
- Provide a high-level annotated tree of the repository. Explain the purpose of each major directory and the architectural layer or concern it represents.
32
-
33
- Include:
34
- - Root-level files that affect architecture, build, runtime, deployment, or developer workflow
35
- - Source directories and their responsibilities
36
- - Test directories and their scope
37
- - Configuration, scripts, generated code, migrations, schemas, or infrastructure directories if present
38
-
39
- ## 2. High-Level System Diagram
40
-
41
- Provide a Mermaid diagram or text diagram showing the major actors, applications, services, data stores, and external systems.
42
-
43
- The diagram should emphasize:
44
- - User or client entry points
45
- - Application/runtime boundaries
46
- - Internal services or modules
47
- - Data stores
48
- - External APIs or platforms
49
- - Direction of communication/data flow
50
-
51
- ## 3. Core Components
52
-
53
- Describe each major component of the system.
54
-
55
- For each component include:
56
- - Name
57
- - Responsibility
58
- - Important files/directories
59
- - Key technologies/frameworks
60
- - Runtime role
61
- - Main inputs and outputs
62
- - Dependencies on other components
63
- - Notes about ownership of business logic, state, or side effects
64
-
65
- Use subsections such as:
66
-
67
- ### 3.1 Frontend / User Interface
68
-
69
- If present, document:
70
- - Framework and rendering model
71
- - Routing/page structure
72
- - State management
73
- - API/data access pattern
74
- - Component organization
75
- - Styling/design-system approach if architecturally relevant
76
- - Build output and deployment assumptions
77
-
78
- ### 3.2 Backend / Server / API
79
-
80
- If present, document:
81
- - Framework/runtime
82
- - Entry points
83
- - Routing/controller structure
84
- - Service/business-logic layer
85
- - Persistence layer
86
- - Middleware
87
- - Authentication/authorization flow
88
- - Background jobs/workers if present
89
-
90
- ### 3.3 Shared Libraries / Common Code
91
-
92
- If present, document:
93
- - Shared types
94
- - Utilities
95
- - Domain models
96
- - Validation schemas
97
- - Cross-cutting abstractions
98
-
99
- ### 3.4 CLI / Scripts / Automation
100
-
101
- If present, document:
102
- - Command entry points
103
- - Build/test/deploy automation
104
- - Code generation
105
- - Data seeding/migration scripts
106
-
107
- ## 4. Data Flow
108
-
109
- Explain how data moves through the system.
110
-
111
- Include:
112
- - Main request lifecycle
113
- - Important user journeys or system workflows
114
- - Read/write paths
115
- - Validation boundaries
116
- - Serialization/deserialization points
117
- - Error handling paths
118
- - Async/event-driven flows if present
119
-
120
- Add a Mermaid sequence diagram for the most important runtime flow when possible.
121
-
122
- ## 5. Data Stores
123
-
124
- List and describe all persistent or semi-persistent storage mechanisms evident in the codebase.
125
-
126
- For each data store include:
127
- - Name
128
- - Type/technology
129
- - Purpose
130
- - Main schemas/tables/collections/entities if discoverable
131
- - Ownership boundaries
132
- - Migration or schema management approach
133
- - Backup, retention, or lifecycle details if evident
134
-
135
- If no persistent storage is evident, say so.
136
-
137
- ## 6. External Integrations / APIs
138
-
139
- Document all external systems the codebase integrates with.
140
-
141
- For each integration include:
142
- - Service name
143
- - Purpose
144
- - Integration method, such as REST, GraphQL, SDK, webhook, OAuth, file import/export, message queue
145
- - Where it is configured or called
146
- - Authentication method if evident
147
- - Failure/retry behavior if evident
148
-
149
- ## 7. Key Technologies
150
-
151
- Summarize the technical stack.
152
-
153
- Include:
154
- - Languages
155
- - Frameworks
156
- - Runtime/platform
157
- - Package managers
158
- - Build tools
159
- - Testing tools
160
- - Linters/formatters
161
- - Infrastructure/deployment tools
162
- - Observability tools
163
- - Important libraries that shape the architecture
164
-
165
- Explain why each technology matters architecturally, not just that it exists.
166
-
167
- ## 8. Deployment & Infrastructure
168
-
169
- Describe how the system appears to be built, packaged, configured, and deployed.
170
-
171
- Include:
172
- - Build artifacts
173
- - Environment variables/configuration model
174
- - Containerization if present
175
- - Hosting/deployment target if evident
176
- - CI/CD workflows
177
- - Infrastructure-as-code
178
- - Runtime process model
179
- - Scaling assumptions if evident
180
-
181
- If deployment is not evident from the repository, state that clearly and summarize what would need to be known.
182
-
183
- ## 9. Security Architecture
184
-
185
- Document security-relevant architecture.
186
-
187
- Include:
188
- - Authentication
189
- - Authorization
190
- - Session/token handling
191
- - Secrets management
192
- - Input validation
193
- - Data encryption in transit/at rest if evident
194
- - CORS/CSP/security headers if present
195
- - Dependency or supply-chain security measures
196
- - Trust boundaries
197
- - Sensitive data handling
198
-
199
- Do not claim security controls exist unless the codebase shows them.
200
-
201
- ## 10. Monitoring & Observability
202
-
203
- Document how the system can be debugged and observed.
204
-
205
- Include:
206
- - Logging approach
207
- - Metrics
208
- - Tracing
209
- - Error reporting
210
- - Health checks
211
- - Audit logs
212
- - Debug tooling
213
- - Operational dashboards or monitoring services if evident
214
-
215
- If observability is minimal or absent, say so and identify the current gaps.
216
-
217
- ## 11. Performance & Scalability
218
-
219
- Document performance-sensitive parts of the architecture.
220
-
221
- Include:
222
- - Caching
223
- - Pagination
224
- - Batching
225
- - Background processing
226
- - Database query patterns
227
- - Asset optimization
228
- - Concurrency model
229
- - Known bottlenecks
230
- - Scaling limits or assumptions
231
-
232
- Only include claims supported by code, configuration, or documentation.
233
-
234
- ## 12. Development Workflow
235
-
236
- Explain how developers work with the project.
237
-
238
- Include:
239
- - Local setup
240
- - Required tools/runtime versions
241
- - Install commands
242
- - Development server commands
243
- - Test commands
244
- - Build commands
245
- - Lint/format/typecheck commands
246
- - Database setup/migrations if present
247
- - Common development loops
248
-
249
- Keep this section architecture-focused; do not duplicate a README unless the workflow affects system structure.
250
-
251
- ## 13. Testing Strategy
252
-
253
- Describe the testing architecture.
254
-
255
- Include:
256
- - Test frameworks
257
- - Unit/integration/e2e test locations
258
- - Fixtures/mocks
259
- - Test data strategy
260
- - CI test execution
261
- - Coverage or quality gates if evident
262
- - Gaps in test coverage if inferable from the repository
263
-
264
- ## 14. Architectural Decisions & Rationale
265
-
266
- Capture important architectural choices visible in the codebase.
267
-
268
- For each decision include:
269
- - Decision
270
- - Evidence in the codebase
271
- - Rationale if inferable
272
- - Consequences/tradeoffs
273
- - Alternatives if mentioned in docs/comments
274
-
275
- Do not invent historical rationale. If rationale is unclear, say “Rationale not documented.”
276
-
277
- ## 15. Constraints, Risks, and Technical Debt
278
-
279
- Document:
280
- - Architectural constraints
281
- - Known limitations
282
- - Tight coupling
283
- - Duplicated abstractions
284
- - Missing boundaries
285
- - Incomplete migrations
286
- - TODO/FIXME items with architectural impact
287
- - Operational risks
288
- - Security or scalability concerns
289
-
290
- Each item should include why it matters and where the evidence appears in the codebase.
291
-
292
- ## 16. Future Considerations / Roadmap
293
-
294
- Summarize future architectural changes that are evident from code comments, docs, TODOs, roadmap files, or incomplete abstractions.
295
-
296
- Separate:
297
- - Explicitly documented future work
298
- - Reasonable architectural recommendations based on current structure
299
-
300
- Clearly label recommendations as recommendations.
301
-
302
- ## 17. Project Identification
303
-
304
- Include:
305
- - Project name
306
- - Repository purpose
307
- - Primary language(s)
308
- - Application type
309
- - Main runtime(s)
310
- - Date of last architecture review
311
- - Maintainer/team if evident
312
-
313
- Use today’s date for “Date of last architecture review.”
314
-
315
- ## 18. Glossary / Acronyms
316
-
317
- Define project-specific terms, acronyms, domain concepts, and internal names that a new developer or AI agent needs to know.
318
-
319
- Validation pass:
320
- - Verify every named component, service, data store, integration, and technology against the repository.
321
- - Remove placeholders.
322
- - Remove generic template text.
323
- - Replace vague statements with concrete codebase-specific facts.
324
- - Ensure every major source directory is represented somewhere in the document.
325
- - Ensure the high-level diagram matches the written component descriptions.
326
- - Ensure the document is useful to someone trying to answer: “Where do I make a change, and what will it affect?”
327
- - If access to a running local server, tests, build output, generated docs, API schema, database schema, Docker environment, or screenshots is available, use them to validate and revise the architecture description.
1
+ > NOT GENERATED YET
2
+ >
3
+ > This file has not been populated yet. It is intentionally empty.
4
+ >
5
+ > **If this is a greenfield project** (no codebase exists yet): skip this for now.
6
+ > Come back and run `/ob-create-architecture` once you have meaningful code, structure, or infrastructure in place.
7
+ >
8
+ > **If this is a brownfield project** (existing codebase): run this command now to generate the architecture documentation:
9
+ >
10
+ > ```
11
+ > /ob-create-architecture
12
+ > ```
13
+ >
14
+ > This command analyzes your folder structure, config files, routes, data models, integrations, and build setup,
15
+ > then writes a complete ARCHITECTURE.md covering components, data flow, tech stack, deployment, and more.
16
+ > It is safe to rerun any time the architecture changes significantly.