archik 0.6.19 → 0.7.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.
@@ -0,0 +1,21 @@
1
+ ---
2
+ description: Apply the pending archik suggestion sidecar over the main file
3
+ ---
4
+
5
+ # /archik:accept — apply the pending suggestion
6
+
7
+ The user wants to accept the pending architecture suggestion.
8
+
9
+ Run the CLI — do NOT edit any archik file by hand:
10
+
11
+ ```
12
+ npx archik suggest accept
13
+ ```
14
+
15
+ If it exits 0, also run `npx archik validate` to confirm the new main
16
+ file is clean, and tell the user it's applied.
17
+
18
+ If it exits non-zero (no sidecar present, or the sidecar fails to
19
+ parse), surface the error to the user verbatim and stop. Do not
20
+ attempt to fix the sidecar by editing it; ask the user how they
21
+ want to proceed.
@@ -0,0 +1,28 @@
1
+ ---
2
+ description: Describe a node in the archik diagram and its incoming/outgoing edges
3
+ argument-hint: <node-id>
4
+ ---
5
+
6
+ # /archik:describe — explain a node from the archik diagram
7
+
8
+ The user wants details about the node with id **$ARGUMENTS**.
9
+
10
+ Use the query CLI — do NOT `cat` or read any archik YAML directly:
11
+
12
+ ```
13
+ npx archik q describe $ARGUMENTS
14
+ ```
15
+
16
+ If you need adjacent context, also run:
17
+
18
+ ```
19
+ npx archik q deps $ARGUMENTS
20
+ npx archik q dependents $ARGUMENTS
21
+ ```
22
+
23
+ Summarize what came back in plain prose: the node's kind and stack,
24
+ what it depends on, what depends on it, and any responsibilities or
25
+ notes. Don't dump the raw CLI output unless the user asks for it.
26
+
27
+ If the CLI exits 1 (unknown id), tell the user and offer to run
28
+ `npx archik q list` to find the right id.
@@ -0,0 +1,24 @@
1
+ ---
2
+ description: Start the archik live canvas in the browser (detached)
3
+ ---
4
+
5
+ # /archik:dev — open the archik canvas
6
+
7
+ The user wants the live archik canvas running so they can see the
8
+ diagram and review suggestions visually.
9
+
10
+ Run the CLI — do NOT spawn dev servers any other way:
11
+
12
+ ```
13
+ npx archik status
14
+ ```
15
+
16
+ If nothing is running for this project, start it detached:
17
+
18
+ ```
19
+ npx archik start
20
+ ```
21
+
22
+ Surface the URL it prints (or the existing URL from `status`) so the
23
+ user can click straight to it. Do not try to open the browser
24
+ yourself.
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: Discard the pending archik suggestion sidecar
3
+ ---
4
+
5
+ # /archik:reject — discard the pending suggestion
6
+
7
+ The user wants to throw away the pending architecture suggestion.
8
+
9
+ Run the CLI — do NOT delete files manually:
10
+
11
+ ```
12
+ npx archik suggest reject
13
+ ```
14
+
15
+ Surface the result to the user. If there was no pending sidecar, the
16
+ command will say so — pass that through unchanged.
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: Propose architecture changes to the archik diagram from a feature description
3
+ argument-hint: <feature description>
4
+ ---
5
+
6
+ # /archik:suggest — propose architecture changes
7
+
8
+ The user wants you to capture the structural impact of a feature in
9
+ the archik diagram. The user-facing description is:
10
+
11
+ **$ARGUMENTS**
12
+
13
+ This slash command IS the user's confirmation that they want a
14
+ sidecar suggestion. Skip the "want me to update the YAML?" question
15
+ and produce one now.
16
+
17
+ ## CLI-only — do not touch archik files directly
18
+
19
+ You MUST interact with archik exclusively through the `npx archik`
20
+ CLI. Do NOT use Read, Write, or Edit on any file under `.archik/`,
21
+ on `architecture.archik.yaml`, or on any sidecar. The CLI is the
22
+ sanctioned interface; everything else is a manual edit and breaks
23
+ the contract with the user.
24
+
25
+ ## Steps
26
+
27
+ 1. **Make sure the canvas is running** so the user can review:
28
+ ```
29
+ npx archik status
30
+ ```
31
+ If nothing is running for this project, start it detached:
32
+ ```
33
+ npx archik start
34
+ ```
35
+ Note the URL it prints — you'll surface it at the end.
36
+
37
+ 2. **Ground yourself in the current diagram** using the query CLI
38
+ (do not `cat` the YAML):
39
+ ```
40
+ npx archik q stats
41
+ npx archik q list
42
+ ```
43
+ If `$ARGUMENTS` mentions a specific node by name, also run
44
+ `npx archik q describe <id>` for it.
45
+
46
+ 3. **Author the draft** in a workspace temp file (NOT under
47
+ `.archik/`). Use the path `/tmp/archik-draft-<short-id>.yaml`.
48
+ The draft is the *full proposed end-state* of the document — every
49
+ node and edge, not just the delta. Follow the schema, kinds, and
50
+ relationships documented in the archik skill.
51
+
52
+ 4. **Stage the draft as the sidecar via the CLI**:
53
+ ```
54
+ npx archik suggest set /tmp/archik-draft-<id>.yaml --note "$ARGUMENTS"
55
+ ```
56
+ This validates the schema, checks cross-file references, stamps
57
+ `metadata.suggestion`, and atomically renames it into place. If
58
+ the command exits non-zero, fix the reported errors in the temp
59
+ file and re-run — never edit the sidecar directly.
60
+
61
+ 5. **Tell the user how to review**. Surface the canvas URL from
62
+ step 1 plus the terminal options:
63
+ - "📝 Suggestion ready — open the canvas at <URL> and use the
64
+ **Review** banner to see added/removed/changed nodes."
65
+ - "Or from the terminal: `npx archik suggest show` /
66
+ `npx archik suggest accept` / `npx archik suggest reject`."
67
+
68
+ ## Notes
69
+
70
+ - If a sidecar already exists, `suggest set` overwrites it. Mention
71
+ to the user that you replaced their previous pending suggestion.
72
+ - If `npx archik` is unreachable (offline, sandboxed), STOP and tell
73
+ the user. Do not fall back to writing YAML by hand.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: archik
3
- description: Use whenever .archik/main.archik.yaml or architecture.archik.yaml exists in the project, or the user asks about the system's architecture, services, dependencies, or data flow. The YAML is the shared map of the project between the user and Claude — read it before answering structural questions, and propose updates when work introduces or changes nodes/edges. Also covers the archik CLI for validation and rendering.
3
+ description: Use whenever .archik/main.archik.yaml or architecture.archik.yaml exists in the project, or the user asks about the system's architecture, services, dependencies, or data flow. The YAML is the shared map between the user and Claude. Interact with it ONLY through the `npx archik` CLI — `q` for queries, `suggest set` for proposals, `validate` after every change. Never read, write, or edit archik files manually.
4
4
  ---
5
5
 
6
6
  # Archik — the project's shared map
@@ -20,25 +20,66 @@ The file lives in one of two places, in this order of preference:
20
20
  2. `architecture.archik.yaml` — the legacy root location, still
21
21
  fully supported.
22
22
 
23
- Run `archik validate` (or check both paths) to find which one the
23
+ Run `npx archik validate` (or check both paths) to find which one the
24
24
  project uses. Don't assume — small differences here matter.
25
25
 
26
26
  Treat the file as a shared vocabulary. It exists so the user and
27
27
  you can talk about the system without re-explaining it every time.
28
28
 
29
+ ## Hard rule: the CLI is the only interface to archik files
30
+
31
+ You MUST NOT use `Read`, `Write`, `Edit`, or any other file-touching
32
+ tool against `.archik/main.archik.yaml`, `architecture.archik.yaml`,
33
+ any `*.archik.yaml` sub-file, or any sidecar. The `npx archik` CLI is
34
+ the contract — it owns reads, writes, validation, and lifecycle.
35
+
36
+ | Need | Use |
37
+ | ----------------------------- | ----------------------------------------- |
38
+ | Inspect structure | `npx archik q ...` |
39
+ | Validate | `npx archik validate <path>` |
40
+ | Propose a change | `npx archik suggest set <draft>` |
41
+ | Apply / discard a suggestion | `npx archik suggest accept | reject` |
42
+ | Render or diff | `npx archik render` / `npx archik diff` |
43
+
44
+ `.archik/main.archik.yaml` is the user's source of truth — only
45
+ `npx archik suggest accept` is allowed to mutate it. The sidecar
46
+ `.archik/main.archik.suggested.yaml` is owned by the CLI too — only
47
+ `npx archik suggest set` (writes it) and `accept` / `reject`
48
+ (consumes it) may touch it.
49
+
50
+ If `npx archik` is unreachable (offline, sandboxed, missing), STOP
51
+ and tell the user. Do NOT fall back to reading or editing YAML by
52
+ hand — that breaks the contract and silently desyncs the canvas.
53
+
54
+ The user-facing slash commands (`/archik:suggest`,
55
+ `/archik:describe`, `/archik:accept`, `/archik:reject`,
56
+ `/archik:dev`) are thin shims over this same CLI. When a user types
57
+ `/archik:suggest <description>`, treat it as direct authorisation to
58
+ run the sidecar workflow now — skip the "want me to update the YAML?"
59
+ question.
60
+
29
61
  ## Protocol
30
62
 
31
63
  1. **Before** answering structural questions — *"what does X do?",
32
- "what depends on Y?", "where does data flow when …?"* — read
33
- the archik file. Don't guess from filenames or memory.
34
- 2. **When** work introduces, removes, or rewires components, write
35
- the proposed end-state to a sibling `*.suggested.yaml` next to
36
- the main file (same schema, plus a `metadata.suggestion` block —
37
- see "Suggesting changes" below). Don't edit the main file
38
- directly; the user reviews and accepts in the canvas or via
39
- `archik suggest accept`.
40
- 3. **After** every edit to a YAML, run `archik validate`. Fix any
41
- reported errors before declaring the change done.
64
+ "what depends on Y?", "where does data flow when …?"* — query
65
+ the diagram with `npx archik q ...` (see CLI section). The CLI
66
+ walks the root file plus every `.archik/*.archik.yaml` sub-file
67
+ and returns focused, deterministic answers. Don't guess from
68
+ filenames or memory, and don't read the YAML directly — see the
69
+ hard rule above.
70
+ 2. **When** work introduces, removes, or rewires components, author
71
+ the proposed end-state in a workspace temp file (e.g.
72
+ `/tmp/archik-draft-<id>.yaml`) and stage it as the sidecar with
73
+ `npx archik suggest set <tmp> --note "<one-liner>"`. Do NOT
74
+ write `.archik/main.archik.suggested.yaml` directly — the CLI is
75
+ the only thing allowed to put files in `.archik/`. The user
76
+ reviews and accepts in the canvas or via
77
+ `npx archik suggest accept`.
78
+ 3. **After** every `suggest set`, the CLI has already validated for
79
+ you — schema, cross-file existence, the lot. If it exits non-zero,
80
+ fix the temp draft and re-run; never patch the sidecar directly.
81
+ For files outside `.archik/` (none, in a normal flow), use
82
+ `npx archik validate <path>`.
42
83
 
43
84
  The sections below are the detailed reference behind these three
44
85
  rules — *when* to consult, *when* to propose, schema, taxonomy,
@@ -51,16 +92,21 @@ The archik file tells you *what* exists. The source tree tells you
51
92
  the file is valuable — without it you just know there's "an Orders
52
93
  service" but not where to go to read or edit it. So:
53
94
 
54
- 1. **Read the archik file in full.** Use `archik validate` first to
55
- find the canonical path (it prefers `.archik/main.archik.yaml`,
56
- falls back to `architecture.archik.yaml`). Then `cat` it —
57
- don't grep, you want the whole shape in your head.
95
+ 1. **Pull the diagram shape from the CLI.** Don't `cat` the YAML —
96
+ use the query CLI:
97
+ ```
98
+ npx archik q stats # files, node and edge counts, kind histogram
99
+ npx archik q list # every node, with kind and parent
100
+ npx archik q edges # every edge, with relationship and endpoints
101
+ ```
102
+ That gives you the same picture as reading the file, without
103
+ touching it.
58
104
  2. **List the source tree.** A single `ls` of the top-level project
59
105
  directory plus the most likely source roots is usually enough:
60
- `ls -F . src/ services/ packages/ apps/ 2>/dev/null`. If the
61
- project has sub-architectures under `.archik/`, list those too
62
- (`ls .archik/`) — they're how the user breaks the diagram up by
63
- component.
106
+ `ls -F . src/ services/ packages/ apps/ 2>/dev/null`. (`ls
107
+ .archik/` is fine for *finding out which sub-architectures
108
+ exist*; don't open the YAMLs themselves — query them via
109
+ `npx archik q list --file <name>`.)
64
110
  3. **Build the mapping in your head.** Most projects follow one of
65
111
  two patterns: each top-level archik node id matches a folder
66
112
  under `src/` (or `services/` / `packages/`), or the `stack` /
@@ -68,79 +114,72 @@ service" but not where to go to read or edit it. So:
68
114
  — those are the places where moving a folder will outgrow the
69
115
  diagram, and where new code is most likely to need a YAML
70
116
  update too.
71
- 4. **Run `archik check`** if it's available — it walks `src/`,
72
- `services/`, `packages/`, and `apps/` and flags nodes that
73
- don't have a matching folder (and folders that look like
74
- services but aren't in the diagram). Cheap drift detector;
75
- worth running before any non-trivial edit.
117
+ 4. **Cross-check the source tree** when answering structural
118
+ questions: most projects keep one folder per top-level node under
119
+ `src/` (or `services/` / `packages/`). Mismatches are where
120
+ moving code will outgrow the diagram and where new code most
121
+ often needs a YAML update too.
76
122
 
77
123
  When the user asks "where would I add X?" or "what's the right
78
124
  place for Y?", you should already have the answer because step 3
79
125
  gave it to you. When they ask "what would `archik render` show?",
80
- the answer is in step 1.
126
+ run `npx archik render --out /tmp/preview.svg` and describe it.
81
127
 
82
128
  ## Suggesting changes (the sidecar workflow)
83
129
 
84
- The archik file is the user's source of truth. You don't get to
85
- mutate it directly. Instead, write your proposed end-state to a
86
- sidecar file in the same directory, with the same stem plus
87
- `.suggested`:
130
+ The archik file is the user's source of truth. You don't mutate it
131
+ directly, and you don't write the sidecar directly either — both are
132
+ under `.archik/` and only the CLI is allowed to touch that
133
+ directory (see the hard rule).
88
134
 
89
- ```
90
- # new convention
91
- .archik/main.archik.yaml ← truth — user owns it
92
- .archik/main.archik.suggested.yaml ← your draft proposal
135
+ The flow is always the same:
93
136
 
94
- # legacy layout — same naming rule, just at the root
95
- architecture.archik.yaml
96
- architecture.archik.suggested.yaml
97
- ```
137
+ 1. Author the *full proposed end-state* document in a workspace temp
138
+ file outside `.archik/`. Pick a path like
139
+ `/tmp/archik-draft-<short-id>.yaml`.
140
+ 2. Run `npx archik suggest set <tmp> --note "<one-liner>"`. The CLI
141
+ parses, schema-validates, checks cross-file references, stamps
142
+ `metadata.suggestion`, and atomically renames the draft into
143
+ place as `.archik/main.archik.suggested.yaml` (or the legacy
144
+ `architecture.archik.suggested.yaml`).
145
+ 3. If `set` exits non-zero, fix the temp file based on the reported
146
+ errors and re-run. Never patch the sidecar with `Edit`/`Write`.
98
147
 
99
- The sidecar is a complete, valid Archik document — same schema as the
100
- main file, plus a `metadata.suggestion` block that marks it as a
101
- proposal:
148
+ A minimal draft looks exactly like a normal archik document — the
149
+ CLI fills in the suggestion marker for you, so you don't have to:
102
150
 
103
151
  ```yaml
104
152
  version: "1.0"
105
153
  name: My Architecture
106
- metadata:
107
- suggestion:
108
- from: .archik/main.archik.yaml
109
- at: 2026-04-26T17:00:00Z
110
- note: add Stripe payment flow # optional one-liner
111
154
  nodes:
112
155
  # ... entire proposed end-state, not just the delta
113
156
  edges:
114
157
  # ...
115
158
  ```
116
159
 
117
- Once you've written the sidecar:
160
+ Once `suggest set` has succeeded:
118
161
 
119
162
  * The canvas shows a **📝 Suggestion pending** banner with `Review`,
120
163
  `Accept`, `Reject` buttons. Review **toggles an in-canvas overlay
121
164
  on the same page** — added nodes/edges get green frames, removed
122
165
  ones get red dashed frames and dim out, changed ones get amber
123
- frames, and each gets a `+` / `−` / `~` badge. The button label
124
- flips to "Hide diff" while the overlay is on; click again to drop
125
- back to the regular view. Accept renames the sidecar over the main
126
- file; Reject deletes the sidecar. Both also clear review mode so
127
- the canvas snaps back to the new truth.
128
- * From the terminal: `archik suggest show | accept | reject`.
166
+ frames, and each gets a `+` / `−` / `~` badge. Accept renames the
167
+ sidecar over the main file; Reject deletes the sidecar.
168
+ * From the terminal: `npx archik suggest show | accept | reject`.
129
169
 
130
170
  If the user has no canvas open and asks "apply it", run
131
- `archik suggest accept` for them (only after they've explicitly
171
+ `npx archik suggest accept` for them (only after they've explicitly
132
172
  asked).
133
173
 
134
174
  **Key rules:**
135
175
 
136
176
  * Write the *full proposed document*, not a patch. The diff is
137
177
  computed by archik between the main file and the sidecar.
138
- * Run `archik validate architecture.archik.suggested.yaml` after
139
- writing. The schema enforces cross-references (no dangling edges,
140
- no parent cycles, no duplicate ids); silent failures are not OK.
141
- * If a suggestion sidecar already exists, treat it as your previous
142
- proposal — extend or replace it. Don't write a new sidecar with a
143
- different name.
178
+ * Don't call `Write`/`Edit` against `.archik/main.archik.suggested.yaml`
179
+ or any peer file under `.archik/`. The CLI owns that directory.
180
+ * If a suggestion sidecar already exists, `npx archik suggest set`
181
+ overwrites it. Tell the user you're replacing their previous
182
+ pending suggestion.
144
183
 
145
184
  ## When to consult the YAML
146
185
 
@@ -181,7 +220,7 @@ The YAML tracks **shape**, not implementation detail.
181
220
 
182
221
  ## Hard rules for editing
183
222
 
184
- The schema enforces these — `archik validate` will reject the file
223
+ The schema enforces these — `npx archik validate` will reject the file
185
224
  if you break any of them, so don't bother trying.
186
225
 
187
226
  - **Never put coordinates** (`x`, `y`, `width`, `height`, `viewport`) in
@@ -264,6 +303,10 @@ Constraints (the schema enforces them):
264
303
 
265
304
  - The cross-file path follows the same rules as `archikFile` (relative,
266
305
  forward slashes, no `..`, ends in `.archik.yaml`).
306
+ - The path is resolved against the **project root** (parent of
307
+ `.archik/` under the new layout, the doc's own directory under the
308
+ legacy one) — same rule as `archikFile`. `npx archik validate` exits
309
+ 1 if the file isn't on disk.
267
310
  - The *local* endpoint id must still match a node in this file.
268
311
  - An edge with **both** `fromFile` and `toFile` is rejected — author
269
312
  it inside one of the two referenced files instead.
@@ -282,12 +325,18 @@ Constraints (the schema enforces them):
282
325
  - Must use forward slashes; `..` segments are rejected.
283
326
  - Must end in `.archik.yaml` (the suggestion sidecar is derived
284
327
  automatically as `<stem>.suggested.yaml` next to it).
328
+ - **Resolved against the project root**, not the file's own
329
+ directory. With the new layout the project root is the parent of
330
+ `.archik/`, so a sibling sub-file is `.archik/orders.archik.yaml`
331
+ (with the prefix), NOT `orders.archik.yaml`. `npx archik validate`
332
+ exits 1 if the target file isn't on disk — catch it there instead
333
+ of as a 404 in the canvas.
285
334
  - Cycles aren't checked at parse time (each file validates on its
286
335
  own); if you wire a loop the canvas just lets the user navigate
287
336
  in and out.
288
337
 
289
338
  Conventional layout: keep sub-files under `.archik/` next to
290
- `main.archik.yaml`. Example:
339
+ `main.archik.yaml`, and reference them with the `.archik/` prefix:
291
340
 
292
341
  ```
293
342
  .archik/main.archik.yaml # entry point
@@ -295,6 +344,16 @@ Conventional layout: keep sub-files under `.archik/` next to
295
344
  .archik/payments.archik.yaml # Payments service internals
296
345
  ```
297
346
 
347
+ ```yaml
348
+ # in .archik/main.archik.yaml
349
+ nodes:
350
+ - id: orders
351
+ kind: service
352
+ name: Orders
353
+ archikFile: .archik/orders.archik.yaml # ✅ project-root relative
354
+ # archikFile: orders.archik.yaml # ❌ validate fails
355
+ ```
356
+
298
357
  ## Node kinds (27 total, grouped by purpose)
299
358
 
300
359
  | Group | Kinds |
@@ -573,52 +632,106 @@ edges:
573
632
 
574
633
  ## CLI
575
634
 
576
- These commands are available globally if archik was installed via
577
- `npm link`. Without a positional path, each command resolves the
578
- archik file in this order: `.archik/main.archik.yaml` (preferred),
579
- then `architecture.archik.yaml` (legacy). If both exist the
580
- command errors and asks the user to pick one.
635
+ The CLI is the agent-friendly bridge to archik. Prefer it over
636
+ re-reading the YAML when answering structural questions — the answers
637
+ are deterministic, focused, and don't pollute your context with the
638
+ whole diagram.
639
+
640
+ ### Running the CLI
641
+
642
+ The CLI ships as the `archik` npm package. Two equivalent ways to
643
+ invoke any command:
581
644
 
582
645
  ```
583
- archik validate # schema check (run after every edit)
584
- archik validate path/to/file.yaml
585
- archik render --out diagram.svg # headless layout → SVG
586
- archik render --theme light --out diagram-light.svg
587
- archik diff a.yaml b.yaml # text + colour-coded SVG diff
588
- archik diff a.yaml b.yaml --out diff.svg
589
- archik suggest show # summary of pending sidecar (default)
590
- archik suggest accept # apply the sidecar over the main file
591
- archik suggest reject # discard the sidecar
592
- archik watch # re-render SVG on save
593
- archik check # drift: nodes vs source dirs
594
- archik dev # open the live editor in the browser (foreground)
595
- archik start # same as dev, detached — returns the prompt
596
- archik stop # stop the background server
597
- archik status # list running archik instances
598
- archik init # scaffold a starter file (also installs this skill into ./.claude/skills/archik/ unless --no-skill)
599
- archik skill # install/refresh this skill in cwd
646
+ npx archik <command> # works without installing — caches after first use
647
+ archik <command> # if the user has run `npm i -g archik`
600
648
  ```
601
649
 
602
- If `archik` isn't on PATH (the user hasn't run `npm link` yet), fall
603
- back to the in-repo form: `npm run archik -- <command>` from the
604
- archik checkout.
650
+ **Default to `npx archik` in your suggestions and shell calls.** It
651
+ just works in fresh repos, doesn't require a global install, and
652
+ falls through to the cached binary on subsequent runs. Suggest
653
+ `npm i -g archik` only when the user wants the live canvas
654
+ (`archik dev`) on a fast keystroke.
655
+
656
+ If neither form is reachable (offline, sandboxed shell), fall back to
657
+ reading the YAML directly with the same schema documented above —
658
+ the file is always the source of truth.
659
+
660
+ ### Without a positional path
661
+
662
+ Every read command resolves the archik file in this order:
663
+ `.archik/main.archik.yaml` (preferred), then
664
+ `architecture.archik.yaml` (legacy). If both exist the command errors
665
+ and asks the user to pick one.
666
+
667
+ ### Querying the diagram (use this for structural questions)
668
+
669
+ ```
670
+ npx archik q describe <id> # node + its incoming/outgoing edges
671
+ npx archik q deps <id> # outgoing edges (what this node uses)
672
+ npx archik q dependents <id> # incoming edges (what uses this node)
673
+ npx archik q list # all nodes
674
+ --kind <k> # filter by kind (service, function, …)
675
+ --parent <id> # filter by container
676
+ --file <p> # filter by file (substring match)
677
+ npx archik q edges # all edges
678
+ --from <id> # filter by source
679
+ --to <id> # filter by target
680
+ --rel <name> # filter by relationship
681
+ npx archik q impact <id> # what would break if this node were removed
682
+ npx archik q stats # files, nodes, edges, kind histogram
683
+ ```
684
+
685
+ Add `--json` to any `q` subcommand for a stable machine-readable
686
+ shape (object on stdout). Exit codes: `0` found, `1` empty / unknown
687
+ id, `2` could not load. Walks the root file plus every
688
+ `.archik/*.archik.yaml` sub-file. Cross-file id collisions error
689
+ rather than silently picking — surface the ambiguity.
690
+
691
+ ### Authoring & lifecycle
692
+
693
+ ```
694
+ npx archik validate # schema + cross-file existence (CI-friendly, exit 1 on error)
695
+ npx archik validate --json # structured { ok, file, nodes, edges, errors }
696
+ npx archik render --out diagram.svg
697
+ --theme light # "dark" (default) or "light"
698
+ npx archik diff a.yaml b.yaml # text summary
699
+ npx archik diff a.yaml b.yaml --out diff.svg
700
+ npx archik diff a.yaml b.yaml --json
701
+ npx archik suggest show # summary of pending sidecar (default)
702
+ --json # structured output
703
+ npx archik suggest set <draft> # validate a draft YAML and stage it as the sidecar
704
+ --note '<text>' # set metadata.suggestion.note
705
+ --main <path> # override main file detection
706
+ --json # structured output
707
+ - # draft path "-" reads from stdin
708
+ npx archik suggest accept # apply the sidecar over the main file
709
+ npx archik suggest reject # discard the sidecar
710
+ npx archik watch # re-render SVG on save
711
+ npx archik dev # open the live editor in the browser
712
+ npx archik start | stop | status # detached canvas server lifecycle
713
+ npx archik init # scaffold a starter file + install skill + slash commands
714
+ npx archik skill # install/refresh the Claude skill in cwd
715
+ npx archik commands # install/refresh the /archik:* slash commands in cwd
716
+ ```
605
717
 
606
718
  ## Verification workflow
607
719
 
608
- After **every** edit you make to the archik file:
609
-
610
- 1. Run `archik validate` — fix any reported errors before declaring
611
- the change done. Schema errors include the path of the offending
612
- field so you can fix them precisely.
613
- 2. If the project has an `archik dev` server running, the file watcher
614
- broadcasts the change automatically — no restart needed.
615
- 3. If the project commits a rendered SVG (e.g. `docs/architecture.svg`),
616
- regenerate it with `archik render --out docs/architecture.svg` so
617
- the committed picture matches the YAML.
618
- 4. For nodes whose `kind` implies code (`service`, `function`, `worker`,
619
- `agent`, `frontend`, `gateway`, `tool`, `module`), consider
620
- `archik check` to flag nodes that don't have a matching source
621
- folder under `src/`, `services/`, `packages/`, or `apps/`.
720
+ After **every** `npx archik suggest set` or `npx archik suggest
721
+ accept`:
722
+
723
+ 1. The CLI has already validated the schema and cross-file references
724
+ for you — `set` refuses to write a broken sidecar, `accept` runs
725
+ over a sidecar that was validated when it was staged. If `set`
726
+ reported errors, fix them in the temp draft and re-run; never
727
+ reach for `Write`/`Edit` on the sidecar.
728
+ 2. If the project has an `archik dev` server running, the file
729
+ watcher broadcasts the change to the canvas automatically — no
730
+ restart needed. Surface the URL so the user can click through.
731
+ 3. If the project commits a rendered SVG (e.g.
732
+ `docs/architecture.svg`), regenerate it with `npx archik render
733
+ --out docs/architecture.svg` so the committed picture matches the
734
+ YAML.
622
735
 
623
736
  ## Things to avoid
624
737