archik 0.10.0 → 0.11.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.
@@ -2,20 +2,86 @@
2
2
  description: Apply the pending suggestion
3
3
  ---
4
4
 
5
- # /archik:accept — apply the pending suggestion
5
+ # /archik:accept — apply the pending suggestion and run BUILD → VERIFY
6
6
 
7
- The user wants to accept the pending architecture suggestion.
7
+ This is the **accept branch of the DECIDE gate** in the engineering
8
+ loop, and it opens the **BUILD** and **VERIFY** phases. Don't claim
9
+ done at step 1 — the diagram changed; the code probably hasn't.
8
10
 
9
- Run the CLI — do NOT edit any archik file by hand:
11
+ ## Steps
10
12
 
11
- ```
12
- npx archik suggest accept
13
- ```
13
+ 1. **Apply the sidecar.** CLI only — never edit any archik file by
14
+ hand:
15
+ ```
16
+ npx archik suggest accept
17
+ ```
18
+ If it exits non-zero, surface the error verbatim and stop. Don't
19
+ try to fix the sidecar by editing it; ask the user how to proceed.
14
20
 
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.
21
+ 2. **Validate the merged main file.**
22
+ ```
23
+ npx archik validate
24
+ ```
25
+ If validation fails after accept, that's a bug — surface the
26
+ error and stop.
17
27
 
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.
28
+ If the accepted change has **no code impact** (rename inside a
29
+ non-code-bearing kind, description-only edit, pure metadata),
30
+ skip steps 3–6 and jump straight to step 7.
31
+
32
+ 3. **BUILD — plan (HITL).** Translate the diagram delta into a
33
+ numbered file-level plan and present it for approval **before**
34
+ touching code:
35
+ - Each new code-bearing node (`service`, `function`, `worker`,
36
+ `module`, `page`, `component`, `store`, `hook`) → its
37
+ `sourcePath` and the concrete files / signatures to land there.
38
+ - Each new edge that requires code → the corresponding code
39
+ change (a new `http_call` needs a client; `subscribes` needs a
40
+ consumer handler; `writes` needs a repository method; etc).
41
+ - Any node still `status: proposed` → flag it; code must land
42
+ before flipping to `active`.
43
+ - Default to **tests-first** when behaviour is clearly bounded.
44
+ - If `superpowers:writing-plans` is available, use it; else
45
+ inline.
46
+
47
+ End with: *"Approve the plan and I'll implement it, or push back
48
+ on any step."* Do NOT start coding until approved.
49
+
50
+ 4. **BUILD — implement.** Small reversible commits, one diagram
51
+ delta per commit where practical, no drive-by refactors.
52
+ `superpowers:test-driven-development` when available.
53
+
54
+ **Back-edge to DESIGN:** if implementation reveals the diagram is
55
+ wrong (a missing port, a hidden dependency, a boundary that
56
+ doesn't hold), STOP. Open a fresh `/archik:suggest` to fix the
57
+ diagram first, then resume. Don't paper over it.
58
+
59
+ 5. **BUILD — self-review.** Before claiming done:
60
+ - Each new file matches its node's `sourcePath`?
61
+ - Each new edge corresponds to a real call/handler/query?
62
+ - Bounded-context boundaries respected (no sneaky cross-context
63
+ imports)?
64
+ - Tests cover the new behaviour, not just the happy path?
65
+ - Any new dependency that isn't in the diagram → drift; queue a
66
+ follow-up `/archik:suggest`.
67
+
68
+ `superpowers:requesting-code-review` when available.
69
+
70
+ 6. **VERIFY.** Evidence before assertions:
71
+ ```
72
+ npx archik validate
73
+ ```
74
+ Plus the project's tests / typecheck / lint.
75
+ `superpowers:verification-before-completion` when available.
76
+ If `docs/architecture.svg` is committed, regenerate it:
77
+ ```
78
+ npx archik render --out docs/architecture.svg
79
+ ```
80
+
81
+ 7. **Close the loop.** End with one concrete next-step offer, not
82
+ "done":
83
+ - *"This module wires into four services — worth running
84
+ `/archik:evolve` to see if the boundaries can be cleaner?"*
85
+ - *"Want me to schedule a drift check in two weeks?"*
86
+ - *"This left `payments-worker` as `status: proposed` — flip it
87
+ to `active` once deployed."*
@@ -2,15 +2,45 @@
2
2
  description: Discard the pending suggestion
3
3
  ---
4
4
 
5
- # /archik:reject — discard the pending suggestion
5
+ # /archik:reject — discard the pending suggestion and learn why
6
6
 
7
- The user wants to throw away the pending architecture suggestion.
7
+ This is the **reject branch of the DECIDE gate** in the engineering
8
+ loop. A rejection without a follow-up question loses information and
9
+ forces a silent retry on the same flawed draft. Don't do that — the
10
+ loop's reject feedback edge is the whole point.
8
11
 
9
- Run the CLI — do NOT delete files manually:
12
+ ## Steps
10
13
 
11
- ```
12
- npx archik suggest reject
13
- ```
14
+ 1. **Discard the sidecar.** CLI only — never delete files manually:
15
+ ```
16
+ npx archik suggest reject
17
+ ```
18
+ Surface the result. If there was no pending sidecar, pass that
19
+ message through unchanged and stop.
14
20
 
15
- Surface the result to the user. If there was no pending sidecar, the
16
- command will say so — pass that through unchanged.
21
+ 2. **Ask one specific clarifying question** before regenerating
22
+ anything. Pick the axis that the rejection most likely hits — the
23
+ user's answer becomes a hard constraint on the next draft. Pin it
24
+ to one of:
25
+
26
+ - **Boundary** — *"Did the wrong context own a node? Should
27
+ `payments-worker` live under `orders` or under `billing`?"*
28
+ - **Relationship** — *"Was a sync `http_call` wrong where you
29
+ wanted async `publishes`/`subscribes` over a stream?"*
30
+ - **Scope** — *"Too big? Want a smaller delta that only touches
31
+ the queue, not the worker?"*
32
+ - **Naming** — *"Was the id/name unclear? What would you call
33
+ it?"*
34
+ - **Composition** — *"Should this be one node, or split into a
35
+ port + adapter pair?"*
36
+ - **Lifecycle** — *"Should the new nodes be `status: proposed`
37
+ until the code lands, or active now?"*
38
+
39
+ Pick exactly one — the most likely fit given what was rejected.
40
+ Add a fallback: *"Or tell me a different reason and I'll work from
41
+ that."*
42
+
43
+ 3. **Wait.** Do NOT regenerate the suggestion automatically. The
44
+ user's answer to step 2 is what shapes the next attempt. When
45
+ they reply, loop back to the **DESIGN** phase with the rejection
46
+ reason as a hard constraint and re-stage via `/archik:suggest`.
@@ -22,8 +22,37 @@ on `architecture.archik.yaml`, or on any sidecar. The CLI is the
22
22
  sanctioned interface; everything else is a manual edit and breaks
23
23
  the contract with the user.
24
24
 
25
+ ## This is the DISCOVER → DESIGN → DECIDE handoff of the engineering loop
26
+
27
+ The skill defines a 5-phase loop: **Discover → Design → Decide → Build
28
+ → Verify**. This command covers Discover (grounding) and Design
29
+ (staging the sidecar with rationale), then hands off to the user's
30
+ review and the explicit Decide gate (`/archik:accept` or
31
+ `/archik:reject`). Don't skip clarification just because a slash
32
+ command was typed — clarification is what makes the draft good. Don't
33
+ start Build phase here; that's gated on accept.
34
+
25
35
  ## Steps
26
36
 
37
+ 0. **Frame + clarify (entering DESIGN).** Before any CLI call, restate
38
+ the user's intent in one sentence and list 1–3 sharp clarifying
39
+ questions if any of these are ambiguous in `$ARGUMENTS`:
40
+ - **Boundary** — which existing context owns this, or is it a new
41
+ one? (data ownership = bounded context)
42
+ - **Sync vs async** — request/response (`http_call`) or
43
+ event-driven (`publishes`/`subscribes` over a stream)?
44
+ - **Composition** — one node or split (e.g. port + adapter, gateway
45
+ + service)?
46
+ - **External integrations** — what third-party touches this?
47
+ - **Lifecycle** — built now, or `status: proposed` for a planned
48
+ iteration?
49
+
50
+ Skip questions that `$ARGUMENTS` already answers. If the change is
51
+ trivially small (one node, one edge, no boundary impact), skip the
52
+ clarify pass entirely and go straight to step 1. **Use judgment;
53
+ don't ask questions for the sake of asking.** When in doubt, ask
54
+ the user "you decide?" so they can defer back if they want.
55
+
27
56
  1. **Make sure the canvas is running** so the user can review:
28
57
  ```
29
58
  npx archik status
@@ -90,17 +119,28 @@ the contract with the user.
90
119
  Never write a draft file under `.archik/` and never edit the
91
120
  sidecar directly.
92
121
 
93
- 5. **Tell the user how to review and what's next**. Surface the
94
- canvas URL from step 1 plus the terminal options, then offer a
95
- concrete follow-up:
96
- - "📝 Suggestion ready — open the canvas at <URL> and use the
97
- **Review** banner to see added/removed/changed nodes."
98
- - "Or from the terminal: `npx archik suggest show` /
99
- `npx archik suggest accept` / `npx archik suggest reject`."
100
- - One follow-up sentence picking from: implement the new
101
- node(s) in code, run `/archik:evolve` if the change exposed
102
- architectural smells, regenerate `docs/architecture.svg` if
103
- the project commits one. Don't end the turn at "done".
122
+ 5. **Narrate the design rationale** in 2–4 short bullets before
123
+ handing off to review. The user needs to see *why* this shape, not
124
+ just *what* it is. Cover:
125
+ - Which **bounded context(s)** the change touches and why those
126
+ boundaries.
127
+ - The **separation of concerns** — what each new node owns and why
128
+ it's its own node (not folded into an existing one).
129
+ - **Async vs sync** choice and the reason (cross-context coupling
130
+ should default to async).
131
+ - Any **alternative you rejected** and the trade-off.
132
+
133
+ Keep it tight — bullets, not paragraphs. The diagram does the rest.
134
+
135
+ 6. **Hand off to the DECIDE gate.** Surface the canvas URL plus the
136
+ terminal options, then state the gate clearly:
137
+ - "📝 Suggestion ready — open the canvas at <URL> for the diff."
138
+ - "Terminal: `npx archik suggest show` / `accept` / `reject`."
139
+ - "**Accept** to enter BUILD (plan → implement → self-review), or
140
+ **reject** and tell me what didn't fit (boundary? relationship?
141
+ scope? naming? composition? lifecycle?) so I can revise."
142
+
143
+ Do NOT pre-emptively start implementing. Wait for `/archik:accept`.
104
144
 
105
145
  ## Notes
106
146
 
@@ -89,6 +89,104 @@ Distinction:
89
89
  - **`evolve`** = prescriptive (propose a cleaner shape, then discuss before accepting)
90
90
  - **`suggest`** = targeted (apply one feature-sized change from a description)
91
91
 
92
+ ## The engineering loop (how archik fits into delivering work)
93
+
94
+ Archik is the front of a five-phase loop that turns intent into
95
+ working, reviewed, validated code. **Every structural change runs the
96
+ loop.** Don't skip phases; don't silently retry on rejection; don't
97
+ paper over a wrong design mid-build — go back.
98
+
99
+ ```
100
+ ┌────────────┐ q stats / list / source tree.
101
+ │ DISCOVER │ Read before write. Map intent onto what already
102
+ └─────┬──────┘ exists.
103
+ │
104
+ ┌─────▼──────┐ Frame intent in one line + 1–3 sharp clarifying Qs.
105
+ │ DESIGN │ Stage sidecar (`suggest set`) with rationale:
106
+ │ │ bounded contexts, sync vs async, composition,
107
+ └─────┬──────┘ alternatives rejected. ◄── reject + reason ──┐
108
+ │ │
109
+ ┌─────▼──────┐ Canvas diff: accept | reject (why?) | revise. │
110
+ │ DECIDE │ ───────────────────────────────────────────────────►┤
111
+ └─────┬──────┘ │
112
+ │ accept │
113
+ ┌─────▼──────┐ Plan → Implement → Self-review. │
114
+ │ BUILD │ Small reversible commits, one delta each. │
115
+ │ │ Tests-first when behaviour is clear. │
116
+ │ │ If implementation invalidates the design ─────────►┘
117
+ └─────┬──────┘ loop back to DESIGN — don't paper over.
118
+ │
119
+ ┌─────▼──────┐ npx archik validate; tests; drift; regen SVG.
120
+ │ VERIFY │ Evidence before assertions. Propose next iteration —
121
+ └────────────┘ don't end on "done".
122
+ ```
123
+
124
+ | Phase | Driver | Output / tool |
125
+ | -------- | ------------ | ---------------------------------------------------------- |
126
+ | Discover | Claude | `npx archik q ...` + source-tree `ls` |
127
+ | Design | Claude → User | sidecar via `suggest set`, after 1–3 clarifying Qs (HITL) |
128
+ | Decide | User | `/archik:accept` or `/archik:reject` (HITL gate) |
129
+ | Build | Claude → User | numbered plan (HITL approval), then small commits |
130
+ | Verify | Claude | `npx archik validate` + tests + drift + SVG regen |
131
+
132
+ **Two non-obvious feedback edges** (the things real loops have that flat
133
+ lists miss):
134
+
135
+ 1. **Decide → Design on reject.** A rejection is information; ask one
136
+ specific question (boundary? relationship? scope? naming?
137
+ composition? lifecycle?), treat the answer as a hard constraint,
138
+ re-stage. Never silently retry the same draft.
139
+ 2. **Build → Design on invalidation.** If implementation reveals the
140
+ accepted diagram is wrong (a missing port, a hidden dependency, a
141
+ boundary that doesn't hold), STOP coding. Open a fresh
142
+ `/archik:suggest` to fix the diagram first, then resume. Code that
143
+ silently contradicts the diagram is drift before it's even merged.
144
+
145
+ ### Design heuristics — apply these in the DESIGN phase
146
+
147
+ Before staging a sidecar, run the candidate through this checklist.
148
+ Each item is a yellow flag; flag them out loud in your rationale
149
+ rather than hiding them.
150
+
151
+ - **One reason to change.** Each new node has a single responsibility
152
+ expressible in one sentence. If `description` rambles, decompose.
153
+ - **Bounded contexts.** Name the context this change belongs to. A
154
+ change spanning two contexts is a yellow flag — usually means a
155
+ missing third (orchestrator, port, gateway).
156
+ - **Async at context boundaries.** Default cross-context coupling to
157
+ `publishes` / `subscribes` over a stream/queue. `http_call` across
158
+ contexts is allowed but should be justified (sync-required RPC,
159
+ query for read-side data).
160
+ - **Composition over sprawl.** Group related nodes under a `module`
161
+ parent via `parentId`. Flat top-level lists past ~8 nodes are a
162
+ smell.
163
+ - **Ports & adapters at the edge.** External integrations sit behind
164
+ an `external` node, never inline inside a service. A port (interface)
165
+ + adapter (concrete) pair is preferred when the integration could
166
+ swap.
167
+ - **Public traffic → gateway/auth upstream.** Anything user-facing
168
+ routes through a `gateway`/`auth` node, not directly to a service.
169
+ - **Failure modes.** Async producers imply DLQ/retry on the consumer;
170
+ `http_call` implies timeout + circuit. Don't draw the happy path
171
+ alone.
172
+ - **Lifecycle honesty.** Code-bearing node without code on disk →
173
+ `status: proposed`. About to be removed → `status: deprecated`. The
174
+ diagram should track reality, not aspiration.
175
+
176
+ ### Optional sharpening — `superpowers:*` skills (if installed)
177
+
178
+ The loop is self-contained, but these skills sharpen specific phases
179
+ when the user has them. Check the available-skills list at session
180
+ start; never assume they exist.
181
+
182
+ | Phase | Skill |
183
+ | ------- | ---------------------------------------------- |
184
+ | Design | `superpowers:brainstorming` |
185
+ | Build | `superpowers:writing-plans`, |
186
+ | | `superpowers:test-driven-development`, |
187
+ | | `superpowers:requesting-code-review` |
188
+ | Verify | `superpowers:verification-before-completion` |
189
+
92
190
  ## Protocol — three rules
93
191
 
94
192
  1. **Before** answering structural questions, query via `npx archik q ...`. Never `cat` or `Read` the YAML.
@@ -205,9 +303,17 @@ After a suggestion is accepted, the diagram has changed. Don't just stop — pro
205
303
  3. **Diff vs reality.** Offer to spot-check the source tree against the new diagram: *"Should I scan `src/` to confirm the diagram still matches the code?"*
206
304
  4. **Render.** If the project commits a rendered SVG (`docs/architecture.svg`), regenerate it: `npx archik render --out docs/architecture.svg`. Offer to do this if such a file exists.
207
305
 
208
- After a rejection, ask one clarifying question — *"Want me to try a smaller change that only touches X?"* — instead of going silent.
306
+ After a rejection, **never go silent and never silently retry the same draft**. Ask a question pinned to one of these axes — the answer becomes a constraint when you regenerate:
307
+
308
+ - **Boundary** — *"Did the wrong context own a node? e.g. should `payments-worker` live under `orders` or under `billing`?"*
309
+ - **Relationship** — *"Was a sync `http_call` wrong where you wanted `publishes`/`subscribes`?"*
310
+ - **Scope** — *"Too big? Want me to try a smaller delta that only touches the queue, not the worker?"*
311
+ - **Naming** — *"Was the id/name unclear? What would you call it?"*
312
+ - **Composition** — *"Should this be one node, or split into a port + adapter pair?"*
313
+
314
+ Then loop back to step 2 (Clarify) of the engineering loop with the rejection reason as a hard constraint on the next draft.
209
315
 
210
- The goal: every accepted change ends with the user knowing what's next, not "ok, accepted".
316
+ The goal: every accepted change ends with the user knowing what's next, not "ok, accepted". Every rejection ends with one specific question, not silence.
211
317
 
212
318
  ## Verification workflow
213
319