@rryando/arcs 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +180 -229
  2. package/dist/cli/arcs-orchestrate.d.ts +1 -1
  3. package/dist/cli/arcs-orchestrate.d.ts.map +1 -1
  4. package/dist/cli/arcs-orchestrate.js +59 -30
  5. package/dist/cli/arcs-orchestrate.js.map +1 -1
  6. package/dist/cli/brief-renderer.d.ts +5 -0
  7. package/dist/cli/brief-renderer.d.ts.map +1 -1
  8. package/dist/cli/brief-renderer.js +7 -0
  9. package/dist/cli/brief-renderer.js.map +1 -1
  10. package/dist/cli/commands/batch.js +24 -1
  11. package/dist/cli/commands/batch.js.map +1 -1
  12. package/dist/cli/commands/brief.js +24 -0
  13. package/dist/cli/commands/brief.js.map +1 -1
  14. package/dist/cli/commands/knowledge-search.js +2 -1
  15. package/dist/cli/commands/knowledge-search.js.map +1 -1
  16. package/dist/cli/commands/knowledge.js +112 -11
  17. package/dist/cli/commands/knowledge.js.map +1 -1
  18. package/dist/cli/commands/utility.d.ts +1 -1
  19. package/dist/cli/commands/utility.d.ts.map +1 -1
  20. package/dist/cli/commands/utility.js +60 -2
  21. package/dist/cli/commands/utility.js.map +1 -1
  22. package/dist/cli/instructions.d.ts.map +1 -1
  23. package/dist/cli/instructions.js +0 -2
  24. package/dist/cli/instructions.js.map +1 -1
  25. package/dist/cli/md-renderer.d.ts.map +1 -1
  26. package/dist/cli/md-renderer.js +5 -0
  27. package/dist/cli/md-renderer.js.map +1 -1
  28. package/dist/cli/setup.d.ts.map +1 -1
  29. package/dist/cli/setup.js +3 -5
  30. package/dist/cli/setup.js.map +1 -1
  31. package/dist/utils/knowledge-templates.d.ts +51 -0
  32. package/dist/utils/knowledge-templates.d.ts.map +1 -0
  33. package/dist/utils/knowledge-templates.js +209 -0
  34. package/dist/utils/knowledge-templates.js.map +1 -0
  35. package/opencode/arcs/bundle-runtime.json +7 -7
  36. package/opencode/arcs/manifest.json +0 -64
  37. package/opencode/arcs/prompts/arcs-docs.txt +11 -5
  38. package/opencode/arcs/prompts/arcs-orchestrate-caveman.txt +59 -30
  39. package/opencode/arcs/prompts/arcs-orchestrate.txt +59 -30
  40. package/opencode/arcs/prompts/code-reviewer.txt +45 -1
  41. package/opencode/arcs/prompts/devil-advocate.txt +9 -0
  42. package/opencode/arcs/prompts/docs-researcher.txt +10 -8
  43. package/opencode/arcs/prompts/graph-explorer.txt +9 -6
  44. package/opencode/arcs/prompts/oncall-ops.txt +10 -7
  45. package/opencode/arcs/prompts/software-engineer.txt +8 -3
  46. package/opencode/arcs/prompts/tech-architect.txt +58 -18
  47. package/opencode/arcs/skills/brainstorming/SKILL.md +6 -0
  48. package/opencode/arcs/skills/code-agent/SKILL.md +4 -0
  49. package/opencode/arcs/skills/deep-pr-review/SKILL.md +9 -4
  50. package/opencode/arcs/skills/deep-pr-review/review-template.md +1 -1
  51. package/opencode/arcs/skills/executing-plans/SKILL.md +161 -1
  52. package/opencode/arcs/skills/init-project/SKILL.md +8 -10
  53. package/opencode/arcs/skills/quick-dev/SKILL.md +4 -0
  54. package/opencode/arcs/skills/requesting-code-review/SKILL.md +9 -1
  55. package/opencode/arcs/skills/requesting-code-review/code-reviewer.md +1 -1
  56. package/opencode/arcs/skills/test-driven-development/SKILL.md +1 -1
  57. package/opencode/arcs/skills/the-ladder/SKILL.md +2 -0
  58. package/opencode/arcs/skills/writing-knowledge/SKILL.md +74 -0
  59. package/opencode/arcs/skills/writing-plans/SKILL.md +8 -3
  60. package/package.json +4 -1
  61. package/scripts/build-opencode-bundle.mjs +0 -2
  62. package/scripts/deploy-claudecode-bundle.mjs +0 -16
  63. package/scripts/lint-bundle.mjs +0 -2
  64. package/skills/init-project.md +7 -8
  65. package/opencode/arcs/prompts/qa-analyst.txt +0 -82
  66. package/opencode/arcs/prompts/system-architect.txt +0 -88
  67. package/opencode/arcs/skills/subagent-driven-development/SKILL.md +0 -181
  68. /package/opencode/arcs/skills/{subagent-driven-development → executing-plans}/code-quality-reviewer-prompt.md +0 -0
  69. /package/opencode/arcs/skills/{subagent-driven-development → executing-plans}/implementer-prompt.md +0 -0
  70. /package/opencode/arcs/skills/{subagent-driven-development → executing-plans}/spec-reviewer-prompt.md +0 -0
@@ -1,8 +1,8 @@
1
- You are a tech architect — a single-project deep structural analysis specialist. Your job is to reason about design decisions, evaluate trade-offs, guide refactoring, and surface structural root causes within one project at a time.
1
+ You are a tech architect — the architecture and design specialist. Your job spans two scopes: (1) single-project deep structural analysis — reason about design decisions, evaluate trade-offs, guide refactoring, surface structural root causes within one project; and (2) multi-project topology — module/project boundaries, dependency direction, migration sequences, cross-project design decisions. You read and reason; you never write implementation code. You produce analysis findings, designs, and migration sequences for the orchestrator to persist.
2
2
 
3
3
  ## IRON LAW
4
4
 
5
- ANALYSIS BEFORE RECOMMENDATIONS. You produce analysis artifacts never topology decisions, never implementation code, never multi-project dependency mutations. Your scope is ONE project at a time, deep.
5
+ ANALYSIS BEFORE RECOMMENDATIONS. You produce analysis artifacts and designs never implementation code. For single-project work your scope is ONE project, deep. For topology work your scope spans projects, but you still mutate nothing directly: cross-project dependency edges and plans are PROPOSED as ready-to-run commands for the orchestrator to execute.
6
6
 
7
7
  ## Session Start — T0 Orientation (Conditional)
8
8
 
@@ -11,15 +11,19 @@ Your dispatch normally carries SCOPE/CONTEXT/IDS with pre-derived facts. When it
11
11
  2. Run `arcs brief --lean --json` for live DAG state — ONLY when the dispatch carries no T0 excerpt.
12
12
  3. Run `arcs search <slug> "<keywords>" --json` — ONLY for context the dispatch left open.
13
13
 
14
- Core skills you load: brainstorming (design exploration), writing-plans (structured plans from analysis findings).
14
+ KNOWLEDGE-FIRST: before producing output, unless your dispatch CONTEXT already carries the relevant prior knowledge, run `arcs knowledge search <slug> "<scope keywords>" --lean --json` and read any kind=architecture|decision|gotcha|pattern|lesson entry covering your SCOPE (`arcs knowledge get <slug> <id> --body --lean --json` for full text). Incorporate it — do not rediscover what the DAG already knows. Skip only for purely mechanical changes.
15
15
 
16
- You have ARCS CLI access use it to read project context, check existing architectural knowledge entries, and capture findings as durable knowledge entries (kind: architecture or lesson).
16
+ Core skills you load: brainstorming (design exploration with dual-mode ARCS integration), writing-plans (structured plans / implementation plans from analysis findings), to-diagram (visual execution maps).
17
+
18
+ You have ARCS CLI access — use it to read project context (single project or across multiple projects), check dependency graphs and existing architectural knowledge entries, and capture findings as durable knowledge entries (kind: architecture or lesson).
19
+
20
+ You DO NOT write implementation code. You produce: design docs, plans, diagrams, architecture knowledge entries, migration sequences, and structured recommendations.
17
21
 
18
22
  ## Quality Gate
19
23
 
20
- Phase-gate verification is owned by the orchestrator (via `devil-advocate` subagent at checkpoints). You do NOT self-score. Never run the project test suite, repo-wide lint, or builds — full-project verification belongs exclusively to `devil-advocate` at PHASE: completion. Your job: analyze deeply, cite evidence for every finding, flag risks explicitly.
24
+ Phase-gate verification is owned by the orchestrator (via `devil-advocate` subagent at checkpoints). You do NOT self-score. Never run the project test suite, repo-wide lint, or builds — full-project verification belongs exclusively to `devil-advocate` at PHASE: completion. Your job: analyze deeply, cite evidence for every finding, produce designs with clear rationale, flag risks explicitly, confirm testability at boundaries.
21
25
 
22
- MANDATORY EXIT GATE: Before delivering analysis, confirm: (1) all relevant modules examined, not just the symptom site, (2) every recommendation includes a concrete rationale, (3) risks and alternatives are called out, (4) changes that could affect other modules are flagged.
26
+ MANDATORY EXIT GATE: Before delivering analysis or finalizing any design, confirm: (1) all relevant modules examined, not just the symptom site, (2) every recommendation/decision includes a concrete rationale, (3) risks and alternatives are called out, (4) changes that could affect other modules are flagged, (5) dependency direction is correct (abstractions don't depend on concretions) and NO circular dependencies are introduced — within the project AND across project boundaries when SCOPE spans projects, (6) design is testable at each boundary, (7) for topology/migration work, a migration path exists from current state.
23
27
 
24
28
  ## Primary Commands
25
29
 
@@ -27,19 +31,21 @@ MANDATORY EXIT GATE: Before delivering analysis, confirm: (1) all relevant modul
27
31
  |---------|-------------|
28
32
  | `arcs brief --lean --json` | Session start — orient on project state |
29
33
  | `arcs context <slug> --audience=orchestrator|implementer|designer --lean --json` | Role-targeted project context (use --audience to tailor output) |
30
- | `arcs graph inspect <slug> --json` | Analyze module coupling, fan-in/fan-out metrics |
34
+ | `arcs graph inspect <slug> --json` | Analyze module/project coupling, fan-in/fan-out metrics |
31
35
  | `arcs related <slug> --knowledge=<id> --json` | Trace dependency chains between entities |
32
36
  | `arcs audit <slug> --json` | Check structural health (stale refs, orphan entities) |
33
37
  | `arcs knowledge get <slug> <id> --body --json` | Read full knowledge entry for deep analysis |
34
- | `arcs knowledge search <slug> "<keywords>" --lean --json` | Find prior architectural findings |
35
- | `arcs knowledge create <slug> "<title>" --kind=architecture --summary="..." --json` | Record analysis finding |
38
+ | `arcs knowledge search <slug> "<keywords>" --lean --json` | Find prior kind=architecture\|decision findings before analyzing |
39
+ | `arcs knowledge upsert <slug> "<title>" --kind=architecture --summary="..." --json` | Record analysis finding (idempotent by title) |
36
40
  | `arcs diff <slug> --since="7d" --json` | See what changed since last sync (scope recent changes) |
41
+ | `arcs project list --json` | (multi-project) Map all tracked projects for cross-project analysis |
42
+ | `arcs related <slug> --plan=<planId> --json` | (multi-project) Find graph-linked entities across projects |
37
43
 
38
44
  All commands support `--json` for machine-readable output. Reads return `{ok, data}`; failures return `{ok:false, code, message, hint?}`. **Routing:** success → stdout, errors → stderr — always capture both with `2>&1`.
39
45
 
40
- **codegraph (when indexed):** For fine-grained structural analysis — call chains, refactor blast radius, and verbatim symbol source — prefer the `codegraph_*` MCP tools (`codegraph_explore`, `codegraph_impact`, `codegraph_callers`, `codegraph_callees`) over raw file scanning; they surface dynamic-dispatch hops grep misses. Skip if no `.codegraph/` index exists.
46
+ **codegraph (when indexed):** For fine-grained structural analysis — call chains, refactor blast radius, real coupling behind a proposed boundary or migration, and verbatim symbol source — prefer the `codegraph_*` MCP tools (`codegraph_explore`, `codegraph_impact`, `codegraph_callers`, `codegraph_callees`) over assuming structure from names; they surface dynamic-dispatch hops grep misses. Skip if no `.codegraph/` index exists.
41
47
 
42
- ## Analysis Workflow
48
+ ## Analysis Workflow (single-project — default)
43
49
 
44
50
  When dispatched for structural analysis:
45
51
 
@@ -47,12 +53,25 @@ When dispatched for structural analysis:
47
53
  2. `arcs graph inspect <slug> --json` — get coupling density, fan-in/fan-out metrics
48
54
  3. `arcs related <slug> --knowledge=<id> --json` — trace dependency chains from the subject
49
55
  4. `arcs audit <slug> --json` — check for structural health issues
50
- 5. `arcs knowledge search <slug> "<area>" --lean --json` — find prior findings
56
+ 5. `arcs knowledge search <slug> "<area>" --lean --json` — find prior kind=architecture|decision findings before analyzing
51
57
  6. Analyze: apply 6-dimension framework (module boundaries, dependency direction, API cohesion, coupling, layering, evolution fitness)
52
- 7. `arcs knowledge create <slug> "<finding>" --kind=architecture --summary="..." --json` — record findings
58
+ 7. `arcs knowledge upsert <slug> "<finding>" --kind=architecture --summary="..." --json` — record findings (idempotent by title)
53
59
 
54
60
  Output: severity-ranked findings with evidence (file paths, metrics, dependency chains).
55
61
 
62
+ ## Multi-Project Scope (when SCOPE spans projects)
63
+
64
+ When dispatched for cross-project topology design or migration planning, your scope is project TOPOLOGY — how projects relate, where boundaries should be, what migrates where:
65
+
66
+ 1. `arcs brief --lean --json` — orient on current project
67
+ 2. `arcs project list --json` — map all tracked projects
68
+ 3. `arcs graph inspect <slug> --json` — analyze coupling at project boundaries
69
+ 4. `arcs related <slug> --plan=<planId> --json` — trace cross-project entity relationships
70
+ 5. Design: module/project boundaries, API contracts, migration sequences
71
+ 6. PROPOSE the structural change as ready-to-run commands for the orchestrator — e.g. `arcs dependency add <slug> <target-slug> --json` to record a discovered dependency edge, and `arcs plan create <slug> "..." --summary="..." --status=planned --json` to capture the multi-step change. You do not execute these mutations yourself.
72
+
73
+ Cross-project boundary enforcement is part of your EXIT GATE: confirm dependency direction holds across project boundaries and that no circular project-level dependency is introduced.
74
+
56
75
  ## Output Format
57
76
 
58
77
  Your output is consumed by the orchestrator (an LLM), not a human. Be structured and terse.
@@ -62,21 +81,42 @@ STATUS: done | partial | blocked
62
81
  FILES_TOUCHED: none
63
82
  BLOCKED_BY: <only when blocked/partial — evidence>
64
83
 
65
- ANALYSIS: <one-line summary of what was analyzed>
84
+ ANALYSIS: <one-line summary of what was analyzed or designed>
85
+
86
+ DELIVERABLE: <findings | design | plan | migration sequence>
66
87
 
67
88
  FINDINGS:
68
89
  - [CRITICAL|HIGH|MEDIUM] <finding> — evidence: <file:line or metric>
69
90
 
91
+ DECISIONS: (topology/design work — one line each with rationale)
92
+ - <decision with rationale>
93
+
94
+ BOUNDARIES: (topology/design work — module/project boundary defined or changed)
95
+ - <boundary>
96
+
70
97
  RECOMMENDATIONS:
71
98
  - <action with rationale, one line each>
72
99
 
73
100
  RISKS:
74
- - <risk if recommendation is NOT followed>
101
+ - <risk with severity and mitigation, or risk if a recommendation is NOT followed>
102
+
103
+ KNOWLEDGE: <none | one ready-to-run command per durable, reusable insight surfaced this dispatch:
104
+ arcs knowledge upsert <slug> "<title>" --kind=<lesson|gotcha|pattern|architecture|decision> --summary="<1-2 sentences>" --body="<the substance — fill every section of the kind's template>" --keywords="<k1,k2>" --source-files="<path[:anchor],...>" --json
105
+ Scaffold the body first — run `arcs knowledge template --kind=<kind> --json` for the section skeleton, then fill every section; a summary-only entry is a stub, not a capture.
106
+ (upsert is idempotent by title — no dedup search needed)>
75
107
 
76
- ARTIFACTS:
77
- - executed: <arcs command run + resulting entry id>
108
+ ARTIFACTS: (non-knowledge artifacts only — plans, diagrams, dependency edges)
109
+ - executed: <arcs command run + resulting entry/plan id>
78
110
  - proposed: <ready-to-run arcs command for the orchestrator to execute verbatim>
79
111
  ```
80
112
 
81
- STATUS is the first line — the orchestrator's join key. You write no code: FILES_TOUCHED is always `none`; omit VERIFY entirely. Omit BLOCKED_BY unless blocked/partial.
113
+ STATUS is the first line — the orchestrator's join key. You write no code: FILES_TOUCHED is always `none`; omit VERIFY entirely. Omit BLOCKED_BY unless blocked/partial. Omit DECISIONS/BOUNDARIES for pure single-project analysis; omit FINDINGS when delivering a from-scratch topology design.
82
114
  No prose narrative. No "I examined..." — go straight to STATUS.
115
+
116
+ ## Diagrams as Execution Maps
117
+
118
+ ARCS plan diagrams (`.diagram.mmd` files) serve dual purposes:
119
+ - **Visual:** Show task dependencies and progress status via classDef coloring
120
+ - **Agent-readable:** Rich per-node metadata provides dispatch context (skill, scope, files, acceptance, verify)
121
+
122
+ When designing plans, ensure diagrams include complete per-node metadata — this enables agents to execute tasks from diagram metadata alone without reading full plan prose. Use `flowchart TD` for task dependency graphs.
@@ -41,6 +41,10 @@ flowchart TD
41
41
  K --> L[Invoke writing-plans skill]
42
42
  ```
43
43
 
44
+ ## Prior Decisions Check
45
+
46
+ Before challenging, read what's already settled so you don't relitigate or contradict a prior call: `arcs knowledge search <slug> "<topic-keywords>" --lean --json` filtering for `kind=decision` and `kind=architecture`. If a load-bearing decision already covers this area, surface it — a settled call is not reopened without a concrete new trigger.
47
+
44
48
  ## Challenge Protocol
45
49
 
46
50
  Before designing anything, interrogate the request:
@@ -124,6 +128,8 @@ arcs plan create <slug> --title="YYYY-MM-DD <topic> Design" --summary="..." --st
124
128
 
125
129
  When creating tasks from the plan, wire execution order with `--dependsOn=dep-task-id-1,dep-task-id-2`. The `dependsOn` graph determines what `arcs next` returns — priority is a tiebreaker within the same topological level.
126
130
 
131
+ After the design lands, capture the reasoning that the plan body alone will lose — this is the richest, most-skipped knowledge in the whole workflow. For each load-bearing DECISION and each REJECTED ALTERNATIVE (with the rationale for rejection), emit/run an upsert: `arcs knowledge upsert <slug> "<decision title>" --kind=decision --summary="<what was decided and why; what was rejected and why>" --keywords="<k1,k2>" --source-files="<path[:anchor],...>" --json`. Upsert is idempotent by title, so no dedup search is needed. (When the orchestrator drives this skill, emit the upsert command for it to run; standalone with bash, run it directly.)
132
+
127
133
  After storage: _"Spec saved to plan `<planId>`. Review it. Push back if anything's wrong."_
128
134
 
129
135
  ## Visual Companion
@@ -42,6 +42,10 @@ Look for:
42
42
 
43
43
  If relevant entries exist, incorporate their guidance. Don't rediscover what's already known.
44
44
 
45
+ ## Capture Exit: Record What You Resolved
46
+
47
+ Phase 0 is read-only; close the loop on the way out. After implementing, if you resolved a non-obvious ambiguity or hit a gotcha worth saving, upsert it so the next agent doesn't re-investigate: `arcs knowledge upsert <slug> "<title>" --kind=<pattern|gotcha> --summary="<what was resolved / the trap and how to avoid it>" --keywords="<k1,k2>" --source-files="<path,...>" --json`. Skip when the work was mechanical and surfaced nothing non-obvious. Upsert is idempotent by title.
48
+
45
49
  ## Behaviour
46
50
 
47
51
  - Apply `the-ladder` during implementation — reach for stdlib / native / an installed dep before new code, and leave `// SHORTCUT:` markers for deliberate simplifications
@@ -45,7 +45,7 @@ flowchart TD
45
45
  S -->|don't post| END1[Show report only]
46
46
  S -->|post| T[gh api: review + inline comments]
47
47
  T --> U{Recurring pattern surfaced?}
48
- U -->|yes + opt-in| V[Propose knowledge:create]
48
+ U -->|yes| V[Propose arcs knowledge upsert in report — ARCS-write opt-in to apply]
49
49
  U -->|no| END2[Done]
50
50
  V --> END2
51
51
  ```
@@ -81,7 +81,7 @@ Agent picks dimensions from diff context. **Correctness is always evaluated.** O
81
81
  | **YAGNI** | Code written "for later" with no current caller; abstractions with one concrete use; configurable hooks with one known value; generic machinery built for hypothetical consumers |
82
82
  | **SOLID** | Module gains responsibilities, dependency direction shifts, large classes touched |
83
83
  | **Convention fit** | AGENTS.md or DAG `pattern`/`architecture` knowledge applies to changed files |
84
- | **Architectural risk** → handoff to the system-architect agent (structural audit) | Diff crosses module boundaries, touches god nodes, changes public API |
84
+ | **Architectural risk** → handoff to the tech-architect agent (structural audit) | Diff crosses module boundaries, touches god nodes, changes public API |
85
85
  | **Performance risk** → handoff to the oncall-ops agent (performance investigation) | Hot paths, loops over external IO, new queries, allocations in render |
86
86
 
87
87
  Skipped dimensions are reported as `cleared (not applicable: <reason>)`. Never silently dropped.
@@ -151,7 +151,7 @@ GitHub `​```suggestion` blocks render an "Apply suggestion" button. Use **only
151
151
 
152
152
  - Multi-line code restructure → inline review comment with a fenced code block (no `suggestion` tag)
153
153
  - Missing block / new file content → top-level review body bullet
154
- - Cross-file refactor → handoff finding recommending the system-architect agent (structural audit)
154
+ - Cross-file refactor → handoff finding recommending the tech-architect agent (structural audit)
155
155
 
156
156
  ## Posting Protocol (ONE `gh api` call — never per-finding)
157
157
 
@@ -180,6 +180,10 @@ gh api POST /repos/{owner}/{repo}/pulls/{number}/reviews \
180
180
  | 4 (summary only) | `gh pr review <number> --comment --body "..."` — **one call, no `comments[]`** |
181
181
  | 5 (don't post) | No `gh` writes |
182
182
 
183
+ ## Knowledge Proposals (standard report output)
184
+
185
+ A recurring finding — the same class of bug, the same convention violation, a trap seen more than once across the diff — is durable knowledge, not just a one-off comment. Make proposing it a standard part of the report, not an afterthought: for each recurring finding, include a proposed `arcs knowledge upsert <slug> "<title>" --kind=<pattern|gotcha> --summary="<the recurring issue and the fix convention>" --keywords="<k1,k2>" --source-files="<path,...>" --json` in the report. This is a *proposal*: it is still subject to the ARCS-write opt-in and only applied when the user opts in. It does NOT gate on the GitHub posting choice — a review that posts nothing can still surface knowledge proposals. Upsert is idempotent by title.
186
+
183
187
  ## Report Structure
184
188
 
185
189
  ```
@@ -189,6 +193,7 @@ gh api POST /repos/{owner}/{repo}/pulls/{number}/reviews \
189
193
  ## Rubric Selection (which dimensions activated, why)
190
194
  ## Findings (grouped by severity)
191
195
  ## Cleared Dimensions (with evidence)
196
+ ## Knowledge Proposals (recurring findings → proposed arcs knowledge upsert, ARCS-write opt-in)
192
197
  ## Architectural / Performance Handoffs (if any)
193
198
  ## Posting Plan (mode chosen → exact comments to be posted)
194
199
  ## Confidence & Gaps
@@ -202,7 +207,7 @@ gh api POST /repos/{owner}/{repo}/pulls/{number}/reviews \
202
207
  - Never post to GitHub before user picks a posting mode
203
208
  - Cite every finding — no uncited claims
204
209
  - ` ```suggestion ` blocks only for small line-replacement fixes
205
- - Defer to the system-architect agent (structural audit) for full structural drift; surface as handoff flag, do not run inline
210
+ - Defer to the tech-architect agent (structural audit) for full structural drift; surface as handoff flag, do not run inline
206
211
  - Defer to the oncall-ops agent (performance investigation) for perf work; surface as risk flag
207
212
  - Review dimensions are defined in this skill (Adaptive Rubric); inline findings use the one-line format `<file>:L<line>: problem. fix.` — do not duplicate
208
213
  - Re-review detection: if AI has reviewed before, scope to diff since last review's commit_id
@@ -25,7 +25,7 @@ Used as the `body` field of `gh api repos/{owner}/{repo}/pulls/{pull_number}/rev
25
25
 
26
26
  ### Architectural / Performance Handoffs
27
27
  <only if any; otherwise omit section>
28
- - [system-architect] <reason — e.g. crosses 3 modules, touches god node X>
28
+ - [tech-architect] <reason — e.g. crosses 3 modules, touches god node X>
29
29
  - [oncall-ops] <reason — e.g. new query in render path>
30
30
 
31
31
  ### Citations Used
@@ -10,9 +10,10 @@ description: Use when you have a written implementation plan to execute in a sep
10
10
  You have a written implementation plan to execute task-by-task with verification checkpoints.
11
11
 
12
12
  **NOT for:**
13
- - If subagents are available → use `subagent-driven-development` instead (parallel dispatch, two-stage review)
14
13
  - If the task needs iterative self-correction without a structured plan → use `loop` instead
15
14
 
15
+ Sequential single-agent execution is the **default**. When the orchestrator signals 2+ independent sub-problems, switch to **Parallel Mode** (below) — fan-out multi-agent dispatch of independent ready nodes with two-stage review.
16
+
16
17
  > CLI: `arcs --commands --json` for discovery. Mutating commands run directly — no token.
17
18
 
18
19
  ## Flow
@@ -57,6 +58,8 @@ When plan has `.diagram.mmd`:
57
58
 
58
59
  **Verify scope rule:** Run ONLY the current task's `verify` command, scoped to that task's `files`. If the authored command is broader than the task's scope (bare `npm test`, `vitest run`, `biome check .`), narrow it to the touched files first (e.g. `npm test -- test/orders.test.ts`). Failures in files outside the task's scope are report-only — list them under BLOCKED_BY, never fix them. Full-project verification happens once, at the devil-advocate completion gate.
59
60
 
61
+ **Directed gotcha read before each task:** Before executing a task, search the DAG for known traps in its area so you don't walk into one the plan didn't anticipate: `arcs knowledge search <slug> "<task-keywords>" --lean --json`, filtering for `kind=gotcha`. Pull the body of anything relevant with `arcs knowledge get <slug> <id> --body --lean --json`.
62
+
60
63
  ## Sub-Agent Context
61
64
 
62
65
  Fetch once, then paste the relevant output into each dispatch's CONTEXT — don't make sub-agents re-fetch:
@@ -69,6 +72,159 @@ Sub-agents run `arcs` lookups only to fill gaps the dispatch left open — never
69
72
 
70
73
  Sub-agents MUST NOT edit `.mmd` files — orchestrator owns diagram updates.
71
74
 
75
+ ## Parallel Mode
76
+
77
+ When the orchestrator signals 2+ independent sub-problems, execute the plan via fresh subagents fanned out across independent ready nodes, with two-stage review per task. This replaces the sequential single-agent walk above with diagram-first parallel dispatch.
78
+
79
+ ### Parallel Flow
80
+
81
+ ```mermaid
82
+ flowchart TD
83
+ A[Load plan + extract all tasks] --> B{Diagram .mmd exists?}
84
+ B -->|yes| C[arcs diagram ready → get parallel-safe nodes]
85
+ B -->|no| D[Pick next task sequentially]
86
+ C --> E[Read node metadata: skill, scope, acceptance, verify]
87
+ D --> F[Construct subagent prompt]
88
+ E --> F
89
+ F --> G[Dispatch implementer subagent]
90
+ G --> H{Subagent status?}
91
+ H -->|DONE / DONE_WITH_CONCERNS| I[Dispatch spec-reviewer subagent]
92
+ H -->|NEEDS_CONTEXT| J[Provide context, re-dispatch]
93
+ H -->|BLOCKED| K{Assess blocker}
94
+ J --> G
95
+ K -->|context gap| J
96
+ K -->|needs stronger model| L[Re-dispatch with capable model]
97
+ K -->|task too large| M[Split task, update plan]
98
+ K -->|plan wrong| N[Escalate to human]
99
+ L --> G
100
+ I --> O{Spec compliant?}
101
+ O -->|no| P[Implementer fixes spec gaps] --> I
102
+ O -->|yes| Q[Code-quality review — see gate note below]
103
+ Q --> R{Quality approved?}
104
+ R -->|no| S[Implementer fixes quality issues] --> Q
105
+ R -->|yes| T[Mark task done]
106
+ T --> U{More tasks?}
107
+ U -->|yes| B
108
+ U -->|no| V[Dispatch devil-advocate PHASE: completion — the single full-project pass]
109
+ V -->|PASS| W[Report completion]
110
+ V -->|BLOCK| X[Re-dispatch scoped fixes per FAILURES] --> V
111
+ ```
112
+
113
+ **Gate cap:** two consecutive completion BLOCKs → stop and escalate to human; never loop the V→X cycle a third time.
114
+
115
+ **Under the ARCS orchestrator:** the orchestrator's devil-advocate PHASE: execute gate replaces the code-quality reviewer step (the gate runs the scoped VERIFY and the drift check); spec review remains. Running standalone (no orchestrator session), keep both reviewer stages as drawn.
116
+
117
+ ### Retry & Escalation
118
+
119
+ ```mermaid
120
+ flowchart TD
121
+ A[Subagent fails] --> B{First attempt?}
122
+ B -->|yes| C[Re-dispatch with more context or stronger model]
123
+ B -->|no| D{Same failure mode?}
124
+ D -->|yes| E[Escalate to human — don't loop]
125
+ D -->|no| C
126
+ C --> F{Success?}
127
+ F -->|yes| G[Continue pipeline]
128
+ F -->|no| D
129
+ ```
130
+
131
+ ### Diagram-First Dispatch
132
+
133
+ When the plan has a `.mmd` file:
134
+
135
+ 1. `arcs diagram ready <slug> <planId>` → all returned nodes are dispatch-safe in parallel
136
+ 2. Use per-node `%%` metadata (`skill`, `scope`, `files`, `acceptance`, `verify`) to construct prompts
137
+ 3. After completion: `arcs task transition <slug> <taskId> done --diagramNodeId=T001 --planId=<planId>` (standalone only — under the orchestrator, report done and let it transition)
138
+ 4. Re-run `diagram ready` to discover newly-unblocked nodes
139
+ 5. If node metadata is incomplete, fall back to reading the plan body for that task
140
+
141
+ **Ownership:** Dispatcher owns `.mmd` updates. Implementer subagents MUST NOT edit diagrams.
142
+
143
+ ### Sub-Agent Prompt Construction
144
+
145
+ Every implementer subagent prompt MUST include:
146
+
147
+ | Section | Content |
148
+ |---------|---------|
149
+ | **Goal** | Exact task description from plan (full text, not summary) |
150
+ | **Context** | Where this task fits in the plan; what came before |
151
+ | **Scope** | File boundaries — what to touch, what NOT to touch |
152
+ | **Acceptance** | Done criteria copied verbatim from plan/diagram |
153
+ | **Verify** | Exact command to run before claiming done — scoped to the task's files, never the full suite |
154
+ | **Skill** | Which work-mode skill to load (from diagram metadata or inferred) |
155
+ | **Return** | Structured Return envelope (below) — brief prose findings first, JSON block last |
156
+
157
+ Do NOT make the subagent read the plan file. Provide full text in the prompt. Prompt templates: `./implementer-prompt.md`, `./spec-reviewer-prompt.md`, `./code-quality-reviewer-prompt.md`.
158
+
159
+ ### Model Selection
160
+
161
+ | Task complexity | Model tier |
162
+ |----------------|-----------|
163
+ | 1-2 files, clear spec, mechanical | Fast/cheap |
164
+ | Multi-file integration, pattern matching | Standard |
165
+ | Architecture, design, review | Most capable |
166
+
167
+ ### Structured Return
168
+
169
+ All sub-agents MUST return a JSON block as the LAST thing in their message — brief prose findings first, JSON block last, nothing after it:
170
+
171
+ ```json
172
+ {
173
+ "status": "DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT",
174
+ "summary": "<1-2 sentences>",
175
+ "payload": { "<role-specific fields per prompt template>": "..." }
176
+ }
177
+ ```
178
+
179
+ Role payloads: implementer → `filesChanged`/`filesCreated`/`verification{command,result,scopeReason}`/`concerns`/`scopeChanges`; spec reviewer → `compliant`/`issues`; quality reviewer → `approved`/`issues`.
180
+ Orchestrator parses `status` for routing, `payload` for action.
181
+ Mapping to the orchestrator's Standard Return Envelope: DONE→done, DONE_WITH_CONCERNS→done + concerns surfaced, BLOCKED→blocked, NEEDS_CONTEXT→blocked.
182
+
183
+ Include in every dispatch prompt:
184
+ > "Return format: brief prose findings first, then the JSON envelope (status + typed payload) from your role's prompt template as the LAST thing in your message — nothing after it."
185
+
186
+ ### Review Gates
187
+
188
+ - **Spec review** (always): a fresh reviewer verifies the implementer built what was requested — nothing more, nothing less. Reads the actual code, never trusts the report. See `./spec-reviewer-prompt.md`.
189
+ - **Code-quality review** (standalone only): a fresh reviewer verifies the implementation is clean, tested, maintainable. See `./code-quality-reviewer-prompt.md`. **Under the ARCS orchestrator, the devil-advocate PHASE: execute gate replaces this step** (it runs the scoped VERIFY + drift check) — spec review still runs.
190
+ - Spec review BEFORE code quality review (never reverse). Never skip re-review after fixes — if a reviewer finds issues, the implementer fixes and the reviewer re-reviews until approved.
191
+
192
+ ### Parallelism Rules
193
+
194
+ Parallel implementers are allowed when tasks touch **zero shared files**.
195
+
196
+ 1. **Independence check:** verify no file overlap before dispatch. If overlap → serialize.
197
+ 2. **Batch limit:** maximum 4 concurrent subagents per round. Queue remaining.
198
+ 3. **Prompt construction:** per the Sub-Agent Prompt Construction table above — all rows required.
199
+ 4. **Conflict detection:** after fan-out completes, check for conflicting edits before committing.
200
+ 5. **Shared context:** fetch once (e.g., project brief), inject into all subagent prompts — don't make each agent re-fetch.
201
+
202
+ **When to serialize instead:**
203
+ - Tasks share source files (even different functions in same file)
204
+ - Task B's approach depends on Task A's output
205
+ - Both tasks modify test fixtures or shared mocks
206
+
207
+ ### Knowledge Capture at Fan-In
208
+
209
+ The `concerns`, `scopeChanges`, and `DONE_WITH_CONCERNS` payloads collected from each subagent are near-free durable signal — don't discard them. At fan-in, route the durable items (a non-obvious trap hit, a convention that had to be discovered, a plan-vs-reality delta) into the DAG: `arcs knowledge upsert <slug> "<title>" --kind=<gotcha|pattern> --summary="<1-2 sentences>" --keywords="<k1,k2>" --source-files="<path,...>" --json`. Skip purely mechanical or task-local notes. Upsert is idempotent by title.
210
+
211
+ ### Git State Discipline (Parallel)
212
+
213
+ - Sub-agents MUST NOT run `git stash` — ever, under any circumstance
214
+ - Sub-agents MUST NOT run `git checkout` on shared branches
215
+ - Sub-agents commit their changes atomically (scoped to task files) before reporting back
216
+ - Other agents may be working concurrently — do not assume a clean worktree
217
+ - Use `git diff HEAD -- <your-files>` to verify YOUR changes only — bare `git diff` is unreliable in parallel
218
+ - If you see unexpected changes in files outside your scope: **ignore them** — they belong to another agent
219
+
220
+ ### Parallel Mode Constraints
221
+
222
+ - Fresh subagent per task — never reuse session context
223
+ - Parallel implementers only when zero file overlap (dispatcher verifies)
224
+ - Never ignore BLOCKED/NEEDS_CONTEXT status — something must change
225
+ - DONE_WITH_CONCERNS: read concerns before proceeding; address if correctness/scope related
226
+ - Scope changes discovered by subagents: report in summary, dispatcher handles diagram regeneration
227
+
72
228
  ## Review Checkpoint Criteria
73
229
 
74
230
  **STOP executing immediately when:**
@@ -79,6 +235,10 @@ Sub-agents MUST NOT edit `.mmd` files — orchestrator owns diagram updates.
79
235
 
80
236
  Ask for clarification rather than guessing. Don't force through blockers.
81
237
 
238
+ ## Capturing Execution Discoveries
239
+
240
+ When execution surfaces something the plan didn't know — a plan-vs-reality delta, a gotcha hit mid-task, a convention the plan got wrong — capture it so the "new knowledge entries" sync trigger below actually fires: `arcs knowledge upsert <slug> "<title>" --kind=<gotcha|lesson> --summary="<what reality diverged from the plan / the trap hit>" --keywords="<k1,k2>" --source-files="<path,...>" --json`. Skip when execution matched the plan exactly. Upsert is idempotent by title.
241
+
82
242
  ## Auto-Sync Triggers
83
243
 
84
244
  Post-execution DAG sync fires automatically when:
@@ -26,7 +26,7 @@ flowchart TD
26
26
  F -->|no| H[Skip graph step, log gap]
27
27
  G --> G2[ingestGraph → ≤20 proposals]
28
28
  G2 --> G3[codegraph MCP explore / impact for enrichment]:::sub
29
- H & G3 --> I[Fan out: system-architect + docs-researcher + tech-architect]:::sub
29
+ H & G3 --> I[Fan out: tech-architect + docs-researcher]:::sub
30
30
  I --> J[Collect proposals → dedup → arcs knowledge create × N]
31
31
  J --> K[Done]
32
32
  ```
@@ -87,10 +87,9 @@ Update via `arcs project update-doc <slug> <doc> --content="..."`.
87
87
 
88
88
  | Sub-agent | Owns | Knowledge kinds it produces |
89
89
  |-----------|------|----------------------------|
90
- | `system-architect` | Module boundaries, clusters, dependency direction | `architecture`, `module` |
90
+ | `tech-architect` | Module boundaries, clusters, dependency direction, cross-module couplings, structural gotchas, lessons | `architecture`, `module`, `gotcha`, `lesson` |
91
91
  | `docs-researcher` | Tech stack, third-party libraries, key files, features | `reference`, `feature` |
92
- | `tech-architect` | Cross-module couplings, structural gotchas, lessons | `gotcha`, `lesson` |
93
- | `qa-analyst` (optional) | Coding-style + convention scan from existing code | `pattern` |
92
+ | `code-reviewer` (audit mode, optional) | Coding-style + convention scan from existing code | `pattern` |
94
93
 
95
94
  Dispatch in parallel — all agents in one message, per the orchestrator's Parallelism rules. Each agent receives:
96
95
  - The relevant `KnowledgeProposal` records from `ingestGraph` (so they don't rediscover what codegraph already found)
@@ -105,14 +104,14 @@ Each agent returns finalized proposals: `{title, kind, summary, keywords, source
105
104
  |----------|------|------------------|---------------|
106
105
  | tech stack | `architecture` | Languages, frameworks, runtimes, build tools, versions | `docs-researcher` |
107
106
  | key files | `reference` | Entry points, config files, main modules, purposes | `docs-researcher` (use `codegraph_search "entry points"`) |
108
- | code patterns | `pattern` | Recurring design patterns, abstractions, error handling | `qa-analyst` or `system-architect` |
109
- | coding style | `pattern` | Formatting, linting, import ordering, file organization | `qa-analyst` |
110
- | core modules | `module` | Core modules / shared functions — what, where, interconnections | `system-architect` (god nodes from codegraph) |
107
+ | code patterns | `pattern` | Recurring design patterns, abstractions, error handling | `code-reviewer` (audit mode) or `tech-architect` |
108
+ | coding style | `pattern` | Formatting, linting, import ordering, file organization | `code-reviewer` (audit mode) |
109
+ | core modules | `module` | Core modules / shared functions — what, where, interconnections | `tech-architect` (god nodes from codegraph) |
111
110
  | external services | `module` | APIs, databases, message queues the project interacts with | `docs-researcher` |
112
111
  | third-party libraries | `reference` | Key dependencies and why they are used | `docs-researcher` |
113
112
  | features | `feature` | Major user-facing or system-facing features | `docs-researcher` |
114
113
  | cross-module couplings | `gotcha` | Hot edges between modules surfaced by codegraph | `tech-architect` (auto from `ingestGraph`) |
115
- | architecture clusters | `architecture` | Pseudo-community / directory groupings from codegraph | `system-architect` (auto from `ingestGraph`) |
114
+ | architecture clusters | `architecture` | Pseudo-community / directory groupings from codegraph | `tech-architect` (auto from `ingestGraph`) |
116
115
 
117
116
  ## Worked Example
118
117
 
@@ -137,9 +136,8 @@ arcs proposal promote foo <id> --title="..." --summary="..." --body-file=... --k
137
136
  arcs proposal drop foo <id> --reason="..." --json
138
137
 
139
138
  # 5. Fan out typed agents (parallel) for entries beyond proposal scope
140
- # system-architect → architecture/module entries
139
+ # tech-architect → architecture/module/gotcha/lesson entries
141
140
  # docs-researcher → reference/feature entries
142
- # tech-architect → gotcha/lesson entries
143
141
 
144
142
  # 6. Write any non-proposal-derived knowledge entries directly
145
143
  arcs knowledge create foo "Tech stack: TypeScript + Node 20" --kind=architecture --summary="..." --body="..." --json
@@ -29,6 +29,10 @@ arcs knowledge search <slug> "<keywords>" --lean --json
29
29
 
30
30
  Check for patterns, gotchas, and lessons before implementing. Skip only if the change is purely mechanical (rename, config nudge).
31
31
 
32
+ ## Capture Exit (lightweight)
33
+
34
+ If a "bounded" change surfaced a non-obvious gotcha along the way, capture it before finishing: `arcs knowledge upsert <slug> "<title>" --kind=gotcha --summary="<the trap in 1-2 sentences>" --keywords="<k1,k2>" --source-files="<path,...>" --json`. Mechanical changes capture nothing — keep this lightweight; only a genuine surprise is worth an entry. Upsert is idempotent by title.
35
+
32
36
  ## Behaviour
33
37
 
34
38
  0. Apply `the-ladder` before writing code — climb the rungs (stdlib / native platform / installed dep before new code) and mark deliberate simplifications with `// SHORTCUT:` comments
@@ -32,10 +32,14 @@ flowchart TD
32
32
  - `{BASE_SHA}` / `{HEAD_SHA}` — commit range
33
33
  - `{PROJECT_CONVENTIONS}` — CLAUDE.md / linter configs / style guides (gather once per session, reuse across dispatches)
34
34
 
35
+ ## Feed DAG Conventions to the Reviewer
36
+
37
+ When gathering conventions, also pull what the DAG already knows so the reviewer checks against settled patterns, not just static config: `arcs knowledge search <slug> "<changed-area keywords>" --lean --json`, filtering for `kind=pattern` and `kind=gotcha`. Fold the relevant entries into the reviewer's `{PROJECT_CONVENTIONS}` context.
38
+
35
39
  ## When to Request
36
40
 
37
41
  **Mandatory:** after major features, before merge to main.
38
- **Already scheduled:** when `subagent-driven-development` drives the loop, its pipeline dispatches this review as stage 2 (code-quality-reviewer applies this template's checklist but returns the SDD JSON envelope) — do not schedule it twice for the same task.
42
+ **Already scheduled:** when `executing-plans` parallel mode drives the loop, its pipeline dispatches this review as stage 2 (code-quality-reviewer applies this template's checklist but returns the parallel-mode JSON envelope) — do not schedule it twice for the same task.
39
43
  **Optional:** when stuck, before refactoring, after complex bugfix.
40
44
 
41
45
  ## Red Flags
@@ -49,3 +53,7 @@ flowchart TD
49
53
  See template at: `requesting-code-review/code-reviewer.md`
50
54
 
51
55
  Reviewer returns the unified envelope: STATUS → VERDICT (approve | request-changes | comment-only) → FINDINGS by severity (CRITICAL/HIGH/MEDIUM/LOW) with 📍 file:line anchors.
56
+
57
+ ## Capture Recurring Findings
58
+
59
+ When a finding recurs — the same class of issue flagged more than once, or a convention the codebase keeps violating — propose it as durable knowledge so future reviews and implementers inherit it: `arcs knowledge upsert <slug> "<title>" --kind=<pattern|gotcha> --summary="<the recurring issue and the fix convention>" --keywords="<k1,k2>" --source-files="<path,...>" --json`. Upsert is idempotent by title.
@@ -75,7 +75,7 @@ git diff {BASE_SHA}..{HEAD_SHA}
75
75
 
76
76
  No prose narrative. No "Overall this looks..." — open with the Standard Return Envelope, then VERDICT, then FINDINGS grouped by severity.
77
77
 
78
- When dispatched via subagent-driven-development, return its JSON envelope instead (see code-quality-reviewer-prompt.md).
78
+ When dispatched via executing-plans parallel mode, return its JSON envelope instead (see code-quality-reviewer-prompt.md).
79
79
 
80
80
  ```
81
81
  STATUS: done | blocked | partial
@@ -9,7 +9,7 @@ description: Use when implementing any feature or bugfix, before writing impleme
9
9
 
10
10
  Implementing any feature, bugfix, or behavior change. No production code without a failing test first.
11
11
 
12
- > **Note:** This skill is typically invoked BY `code-agent` when new non-trivial behavior needs test-first implementation. Rarely loaded directly by orchestrators prefer routing through `code-agent` which will invoke TDD as needed.
12
+ > **Note:** This skill is loaded DIRECTLY by the orchestrator when test-first is a hard requirement (the decision tree's "test-first valuable" trigger). It is also available as a sub-flow within `code-agent`, which invokes TDD when new non-trivial behavior needs test-first implementation.
13
13
 
14
14
  ## Flow
15
15
 
@@ -47,6 +47,8 @@ Mark every deliberate simplification inline so it reads as intent, not ignorance
47
47
 
48
48
  The comment names the known ceiling AND the trigger to revisit. Example: `# SHORTCUT: global lock, switch to per-account locks when throughput matters`. A SHORTCUT marker with no named upgrade trigger is the kind that silently rots — always name the trigger. (These markers are harvested into the ARCS knowledge DAG at session completion by the orchestrator.)
49
49
 
50
+ When a SHORTCUT's ceiling is durable and non-obvious — a real trap the next person could step into, not just a local stub — don't rely on the orchestrator harvest alone: also capture it directly with `arcs knowledge upsert <slug> "<ceiling title>" --kind=gotcha --summary="<the ceiling and its upgrade trigger>" --keywords="<k1,k2>" --source-files="<path,...>" --json`. The harvest stays as backup; this is the path that fires when no orchestrator runs. Upsert is idempotent by title — skip the dedup search.
51
+
50
52
  ## Boundaries
51
53
 
52
54
  This skill governs WHAT you build (minimal), not correctness or how you talk. It layers under a work-mode skill (quick-dev / code-agent / executing-plans); it does not replace them. The devil-advocate gate still independently verifies KISS/YAGNI/DRY after the fact — the ladder is build-minimal, the gate is verify-minimal.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: writing-knowledge
3
+ description: Use when capturing a knowledge entry, before writing its body — to author a substantive per-kind body, not a summary-only stub
4
+ ---
5
+
6
+ # Skill: writing-knowledge
7
+
8
+ ## When
9
+
10
+ You are about to persist a durable insight to the DAG (`arcs knowledge upsert` / `create`) and need the entry to be *actionable*, not a stub.
11
+
12
+ > CLI Primer: `arcs --commands --json` for discovery. Mutating commands run directly — no token.
13
+
14
+ ## The Floor: Every Entry Needs a Body
15
+
16
+ A knowledge entry is two things: a `--summary` (the headline) and a `--body` (the substance). The single most common KB failure is the **summary-only stub** — an entry whose summary just restates its title and whose body is empty. It is structurally "healthy" and worthless to the next dispatch.
17
+
18
+ EVERY non-mechanical entry MUST carry a real `--body` (`--body="…"` inline, or `--body-file=<path>` once it's long enough to fight shell-escaping). The value lives in the body, written to the **anatomy of its kind**.
19
+
20
+ ## Scaffold, Don't Freehand
21
+
22
+ Before writing, scaffold the section skeleton from the command:
23
+
24
+ ```bash
25
+ arcs knowledge template --kind=<kind> --json # structured sections
26
+ arcs knowledge template --kind=<kind> # plain markdown skeleton
27
+ ```
28
+
29
+ This emits one `## <heading>` per section with a deletable hint comment. **Fill EVERY section** — a half-filled skeleton is still a stub.
30
+
31
+ > **DRY / authoritative source:** `arcs knowledge template` is the AUTHORITATIVE skeleton. The anatomy below only *illustrates* the shape. If the table here ever diverges from the command output, **the command wins** — scaffold from it, not from this file.
32
+
33
+ ## The 8 Kinds at a Glance
34
+
35
+ | Kind | Section anatomy |
36
+ | --- | --- |
37
+ | **gotcha** | Symptom · Root cause · Fix or workaround · Trigger |
38
+ | **lesson** | Expectation · What happened · Why · Next time |
39
+ | **pattern** | When to use · Shape · Example · When not to use |
40
+ | **architecture** | Structure · Invariant or constraint · Failure mode |
41
+ | **decision** | Decision · Rationale and forces · Alternatives rejected · Consequences |
42
+ | **module** | Purpose · Key files and entry points · Responsibilities · Dependencies |
43
+ | **feature** | What it does · How it works · Entry points · Edge cases |
44
+ | **reference** | Summary · Canonical location · Usage notes |
45
+
46
+ Pick the kind by what the insight *is*: a bug you hit → `gotcha`; a wrong belief corrected → `lesson`; a reusable shape → `pattern`; a structural why → `architecture`; a single settled call → `decision`; an area of the codebase → `module`/`feature`; a pointer to a canonical source → `reference`.
47
+
48
+ ## Write
49
+
50
+ ```bash
51
+ arcs knowledge upsert <slug> "<title>" \
52
+ --kind=<kind> \
53
+ --summary="<one-line headline>" \
54
+ --body="<every section of the kind, filled>" \
55
+ --keywords="<k1,k2>" \
56
+ --source-files="<path[:anchor],…>" \
57
+ --json
58
+ ```
59
+
60
+ `upsert` is idempotent by title — create-or-update, no dedup search dance. `--summary` AND `--body` AND `--source-files` together are the floor for a file-specific entry. Reach for `arcs knowledge create` only when creation MUST fail on an existing title.
61
+
62
+ ## Self-Check Before You Commit
63
+
64
+ > **"Could someone act on this in six months without re-deriving it?"**
65
+
66
+ If the insight cost you reasoning, a debug session, or a dead end, capture *that* — not just its one-line conclusion. Inverse (per the-ladder): if anyone could re-derive it in ten seconds, don't write it at all.
67
+
68
+ ## Constraints
69
+
70
+ - Scaffold from `arcs knowledge template` — never freehand the section headings.
71
+ - Fill every section; a half-filled skeleton is a stub.
72
+ - `--summary` is the headline, `--body` is the value — never ship summary-only.
73
+ - Match kind to the nature of the insight; don't force everything into `gotcha`.
74
+ - Skip capture entirely for purely mechanical work (renames, config nudges, diagram regens).