@primitive.ai/prim 0.1.0-alpha.12 → 0.1.0-alpha.121

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 (57) hide show
  1. package/README.md +550 -38
  2. package/SKILL.md +320 -75
  3. package/assets/primitive-gameplan/SKILL.md +134 -0
  4. package/assets/primitive-gameplan/claude-hooks.json +28 -0
  5. package/assets/primitive-gameplan/scripts/activate.mjs +37 -0
  6. package/dist/chunk-2DNC2MUN.js +503 -0
  7. package/dist/chunk-2PFJJO2M.js +262 -0
  8. package/dist/chunk-4GLVJLEQ.js +55 -0
  9. package/dist/chunk-4GYJHN26.js +1440 -0
  10. package/dist/chunk-6DEROXLM.js +22695 -0
  11. package/dist/chunk-7LXRFXZG.js +1992 -0
  12. package/dist/chunk-AKGRY7OU.js +1572 -0
  13. package/dist/chunk-BHT6X3T5.js +1450 -0
  14. package/dist/chunk-DQ4I3FLF.js +164 -0
  15. package/dist/chunk-DVHD6LBQ.js +258 -0
  16. package/dist/chunk-EZXEWFDG.js +210 -0
  17. package/dist/chunk-HG7FJK7R.js +253 -0
  18. package/dist/chunk-JSBRDJBE.js +30 -0
  19. package/dist/chunk-JXRJLHE4.js +168 -0
  20. package/dist/chunk-JZC2LHS6.js +209 -0
  21. package/dist/chunk-KZB4ABIB.js +13 -0
  22. package/dist/chunk-LQLP26RL.js +459 -0
  23. package/dist/chunk-M4NZJCPQ.js +135 -0
  24. package/dist/chunk-MRDY7VQP.js +96 -0
  25. package/dist/chunk-NMZSCSMY.js +157 -0
  26. package/dist/chunk-NQZLXYTW.js +36 -0
  27. package/dist/chunk-OXW6PSPT.js +439 -0
  28. package/dist/chunk-OYHYCK4K.js +13 -0
  29. package/dist/chunk-S3ZIMGXV.js +844 -0
  30. package/dist/chunk-WN7OURQ3.js +175 -0
  31. package/dist/daemon/server.js +26506 -0
  32. package/dist/hook-runtime/daemon/server.js +26507 -0
  33. package/dist/hook-runtime/hooks/post-commit.js +23898 -0
  34. package/dist/hook-runtime/hooks/post-rewrite.js +23797 -0
  35. package/dist/hook-runtime/hooks/post-tool-use.js +36213 -0
  36. package/dist/hook-runtime/hooks/pre-commit.js +1741 -0
  37. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +35071 -0
  38. package/dist/hook-runtime/hooks/pre-tool-use.js +96 -0
  39. package/dist/hook-runtime/hooks/prim-hook.js +36273 -0
  40. package/dist/hook-runtime/hooks/session-end.js +1250 -0
  41. package/dist/hook-runtime/hooks/session-start.js +34021 -0
  42. package/dist/hook-runtime/index.js +71700 -0
  43. package/dist/hook-runtime/statusline-main.js +954 -0
  44. package/dist/hooks/post-commit.js +197 -0
  45. package/dist/hooks/post-rewrite.js +206 -0
  46. package/dist/hooks/post-tool-use.js +295 -0
  47. package/dist/hooks/pre-commit.js +16 -108
  48. package/dist/hooks/pre-tool-use-worker.js +238 -0
  49. package/dist/hooks/pre-tool-use.js +87 -0
  50. package/dist/hooks/prim-hook.js +245 -0
  51. package/dist/hooks/session-end.js +67 -0
  52. package/dist/hooks/session-start.js +312 -0
  53. package/dist/index.js +11249 -572
  54. package/dist/statusline-main.js +953 -0
  55. package/package.json +51 -17
  56. package/skills/prim-welcome/SKILL.md +197 -0
  57. package/dist/chunk-3APLWTLB.js +0 -165
package/SKILL.md CHANGED
@@ -1,21 +1,17 @@
1
1
  ---
2
2
  name: prim
3
- description: Use the prim CLI for managing Primitive specs, contexts, projects, and pre-commit hooks. TRIGGER when the user mentions Primitive, prim, "specs" (in the Primitive sense), or "contexts" (in the Primitive sense); when the repo's package.json depends on @primitive.ai/prim; when the user asks to sync, map, update, or auto-map a spec; when configuring Primitive pre-commit hooks. SKIP when "spec" means test specs (vitest, jest, rspec), when "context" means React context or LLM context window, or for unrelated CLIs.
3
+ description: Use the prim CLI for Primitive’s decision graph. MUST INVOKE before finishing any coding, planning, specification, or review task where the user or agent chose between plausible approaches or established or changed a lasting goal, priority, constraint, invariant, default, commitment, tradeoff, exception, or shared instruction—even when Primitive was not mentioned. Also invoke for Primitive setup, reading decisions, conflict gates, reconcile, rationale confirmations, linking, and team presence. SKIP — do not invoke even to check — when the task shows no fork that should guide future work, for example temporary tactics (a change that is explicitly temporary or to-be-reverted); routine implementation that merely follows an existing decision or a convention already visible in the code or repo instructions; or the word “decision” merely naming code, data, or UI. Such signals need no graph lookup to rule out.
4
4
  ---
5
5
 
6
6
  # Working with the prim CLI
7
7
 
8
- `prim` is the official CLI for [Primitive](https://app.getprimitive.ai). Use it -- don't reach for shell or curl.
8
+ `prim` is the official CLI for [Primitive](https://app.getprimitive.ai)'s **decision graph**. Use it -- don't reach for shell or curl.
9
9
 
10
10
  ## Mental model
11
11
 
12
- A **spec** captures intent for execution -- it defines what should be done, usually so other agents (or humans) can act on it. A **context** is everything else: supporting material that informs but doesn't define the work -- design docs, references, prior art, shared documentation, examples. When deciding which to create, ask: does this say *what to do*, or does it *inform* whoever's doing it? A project has at most one spec but can link many contexts.
12
+ In an active repo, prim passively captures the **decisions** your team makes -- which library, which pattern, which config value -- into a queryable graph, and links them: a decision can depend on earlier decisions (auto-linked from shared files, or related by hand — see *Relate decisions*) and reference the files it touched. **Conflict Gates** can check a later change against that graph and surface any load-bearing decision it conflicts with. When **Enforcement** is enabled for an organization, prim can warn, pause, or block the edit until you resolve the conflict. Capture in active repos runs independently.
13
13
 
14
- In Primitive, a markdown spec is associated with a **project**. The spec is the source of truth: `npx --yes @primitive.ai/prim spec sync` parses the spec, diffs it against the project, and **applies the diff** -- adding, updating, or **archiving** items in the project to match. Items removed from a spec are soft-archived (recoverable via the dashboard), not deleted -- but they leave the active view, so flag the user before large spec rewrites on projects with work in flight.
15
-
16
- A **spec is a kind of context** -- same IDs, same storage. The `npx --yes @primitive.ai/prim spec ...` commands are a focused view onto specs; `npx --yes @primitive.ai/prim context get <id>` works on a spec ID and vice versa. For structured metadata on a spec (review status, root project, sync version, scope, file patterns), use `npx --yes @primitive.ai/prim context get <specId>` -- it returns JSON.
17
-
18
- `npx --yes @primitive.ai/prim spec list` returns only spec-type contexts. `npx --yes @primitive.ai/prim context list` returns all contexts regardless of type.
14
+ Low-level capture runs automatically in active repos through the session hooks installed by `npx --yes @primitive.ai/prim claude install` (Claude Code), `npx --yes @primitive.ai/prim cursor install` (Cursor), `npx --yes @primitive.ai/prim codex install` (Codex), or `npx --yes @primitive.ai/prim hermes install` (Hermes). An inactive repo is not passively captured. Deliberately record higher-order forks in the road through `prim decisions create` as described below. Your job is also to **read** the graph before load-bearing edits and **answer** the occasional rationale confirmation. (Responding to Conflict Gates applies only once Enforcement is enabled — see below.)
19
15
 
20
16
  ## Auth
21
17
 
@@ -24,109 +20,358 @@ Run `npx --yes @primitive.ai/prim auth status` first. It exits **0 if authentica
24
20
  Three ways to authenticate, in priority order:
25
21
 
26
22
  1. **`PRIM_TOKEN` environment variable** -- preferred for agents and CI. Set it before invoking prim and you're done; no interactive flow, no token files.
27
- 2. **`npx --yes @primitive.ai/prim auth set-token <token>`** -- saves a bearer token to `~/.config/prim/token`. Use when the user has a long-lived token in hand.
28
- 3. **`npx --yes @primitive.ai/prim auth login`** -- opens a browser via WorkOS OAuth. **An agent cannot complete this.** If `auth status` exits non-zero and `PRIM_TOKEN` is unset, **stop and ask the user** to run `npx --yes @primitive.ai/prim auth login` themselves.
23
+ 2. **`npx --yes @primitive.ai/prim auth set-token <token>`** -- saves a bearer token in Primitive's config directory (`PRIM_CONFIG_DIR`, then `$XDG_CONFIG_HOME/prim`, default `~/.config/prim`). Use when the user has a long-lived token in hand.
24
+ 3. **`npx --yes @primitive.ai/prim auth login`** -- opens a browser via WorkOS OAuth. **Drive this yourself; do not hand it to the user.** It blocks up to 2 minutes waiting for approval -- that wait is expected, not a failure. The user's only action is clicking "Authorize". Run it in the background, surface the authorize URL it prints on STDERR so the user can click it if the browser didn't open, then poll `auth status` until it exits 0. If it times out before they click, run it again -- never fall back to asking them to run it.
29
25
 
30
- The CLI auto-refreshes expired tokens. On unrecoverable expiry it throws `Authentication expired. Run prim auth login to re-authenticate.` -- relay it.
26
+ The CLI auto-refreshes a still-valid session from the stored refresh token (proactively ~60s before expiry, and again on a 401), so a short access-token "expires in 2m" is normal -- not a reason to re-authenticate or warn the user. Only an absent refresh token, or an explicit `Authentication expired. Run prim auth login to re-authenticate.`, warrants a re-login -- which you then drive yourself, per the above. Relay that message if it appears.
31
27
 
32
28
  ## Ground rules
33
29
 
34
- 1. Don't guess IDs. Discover them with `npx --yes @primitive.ai/prim spec list`, `npx --yes @primitive.ai/prim spec list --project-id <pid>`, or `npx --yes @primitive.ai/prim context list`.
35
- 2. Every command accepts `--help`. When unsure of flags, run `npx --yes @primitive.ai/prim <cmd> --help` rather than guessing.
36
- 3. The CLI prints API errors as one-liners to stderr and exits non-zero. Treat any non-zero exit as actionable. If a command fails with an unrecognized error, re-run with `--help` to check your flags. If auth-related, re-check `auth status`.
30
+ 1. Every command accepts `--help`. When unsure of flags, run `npx --yes @primitive.ai/prim <cmd> --help` rather than guessing.
31
+ 2. The CLI prints API errors as one-liners to stderr and exits non-zero. Treat any non-zero exit as actionable. If auth-related, re-check `auth status`.
32
+ 3. `<idOrShortId>` arguments use the `dec_<8 hex>` ID shown in feeds and gate reasons. Bare short IDs and legacy full IDs remain accepted as inputs.
33
+ 4. In `npx --yes @primitive.ai/prim ...`, `npx --yes` is npm's flag and only skips npm's package-install confirmation. It is not user consent for a Primitive action. Prim's global flag appears after the package name: `npx --yes @primitive.ai/prim --yes ...`.
37
34
 
38
- ## Common workflows
35
+ ## Conflict Gates & Enforcement
39
36
 
40
- ### Read a spec's current text (do this before any partial edit)
41
- ```
42
- npx --yes @primitive.ai/prim spec get <id> --text-only > spec.md
43
- ```
44
- `npx --yes @primitive.ai/prim spec update <id> --file <path>` replaces the entire body. Fetch first if you're only changing part of it.
37
+ **Conflict Gates** check each edit against the decision graph before it lands and surface any load-bearing decision it conflicts with. When **Enforcement** is enabled for an organization, a conflicting edit can be warned, blocked, or paused for confirmation until you resolve the conflict. Automatic decision capture in active repos (above) runs independently.
38
+
39
+ When Enforcement is enabled, before an edit (Claude Code: Edit/Write/MultiEdit; Cursor: Write/Delete/Shell; Codex: apply_patch; Hermes: write_file/patch) a PreToolUse hook scores the target file against the graph:
40
+
41
+ - **deny** -- the edit is blocked. Name each governing Decision and the proposed conflicting edit. Overriding a Decision requires explicit human approval for that specific override. Reconcile bypasses are disabled until a host can provide verifiable human approval; keep the edit blocked and choose a compatible approach.
42
+ - **warn / additional context** -- the edit proceeds, but a relevant prior decision is surfaced. Read it. Cursor, Codex, and Hermes map a would-be `ask` to **deny**. Do not change gate settings, use sandbox escalation, or request prefix permissions to evade the block. Automatic approval review, `--yes`, and an agent assertion are not human approval.
43
+ - **No confirmed conflict within two seconds** -- work proceeds silently. Incomplete checks and service failures do not deny the tool or add a notice. Already admitted evaluations continue for internal review; later findings do not stop or undo that edit.
44
+
45
+ The two-second automatic budget includes local preparation, authentication, and network requests. A confirmed conflict can retain normal block/warn policy while other Decisions are still being evaluated; partial coverage remains explicit in the receipt. The full tool input is hashed before redaction and truncation. The CLI never falls back to V3. Explicit `prim decisions preflight status <checkId>` and `resume <checkId>` remain available for internal inspection and recovery with the longer manual budget.
46
+
47
+ Run `prim <agent> install` to repair the two-second hook timeout and fail-open settings, then `prim doctor`. Claude uses its default failure behavior; Cursor uses `failClosed: false`; Hermes uses `fail_closed: false`. Codex also permits tools on hook failure. Restart or refresh the host as directed. Older CLI installations retain blocking behavior until upgraded and repaired.
48
+
49
+ ## Read the graph before large or load-bearing edits
50
+
51
+ - `npx --yes @primitive.ai/prim decisions check --files "src/a.ts,src/b.ts"` -- which active decisions reference the files you're about to touch (comma-separated paths, one `--files` value). Run it before a big change.
52
+ - `npx --yes @primitive.ai/prim decisions recent` -- the team's recent decisions, each row badged by author and agent (`Your Claude Code` / `Your Cursor` / `Your Codex` / `Your Hermes`); `--limit <n>` and `--since <dur>` narrow it. `--author "<name>"` filters to one teammate (feed name, `"First Last"`, last name, username, email, or email local-part) -- the way to answer "what has X decided?"; an unknown or ambiguous name comes back as `unavailable` with the reason, and `authorHasDecisions` in the JSON distinguishes "no feed-visible decisions" (false) from "has decisions, none in this window" (true). The page defaults to the 10 most recent, so it can hide older ones: on an author query the JSON's `windowTotal` is how many that teammate has in the window. When `windowTotal` exceeds the rows returned, don't present the page as complete -- tell the user you're showing the most recent N of `windowTotal` and offer to pull the rest, which is a re-run with `--limit <windowTotal>` (capped at 100; `windowTotalCapped` means the count is a floor rendered `N+`, and a window past 100 can't be fetched whole).
53
+ - `npx --yes @primitive.ai/prim decisions show <idOrShortId>` and `npx --yes @primitive.ai/prim decisions cascade <idOrShortId>` -- full detail, and the downstream blast radius a change would disturb.
54
+
55
+ Before presenting decision reads, use the current conversation, task, and available memory to understand what matters to the requester and how they want it delivered. Do not dump the API's chronological rows unchanged. Group related decisions around goals or workstreams, lead with decisions that affect the requester's current work, and surface conflicts, supersessions, or consequential tradeoffs before background activity. Explain why an item is relevant when the connection is supported; do not invent relevance or rationale. Preserve the response's `unavailable`, truncation, and count semantics when reshaping it.
56
+
57
+ Then tailor the delivery to this requester, not a generic reader. Take your cues from the signals actually present — durable preferences in memory, the format and depth they've used or asked for earlier in the conversation, and the shape of their current goal — and match the form (a one-line answer, a table, grouped headers, or prose), the depth (a bare intent versus full rationale, alternatives, and tradeoffs), the altitude (strategic direction versus specific ids and files), the fields they actually track, and the register of the exchange. Where a preference isn't evidenced, default to a concise, skimmable summary — read taste from signal the way you read rationale, never conjuring a persona from thin air. Tailoring changes how the facts land, never which facts: keep every conflict, supersession, and consequential tradeoff in view even when the requester wants it terse, and never let style override the `unavailable`, truncation, and count semantics above.
58
+
59
+ ## Referring to Decisions
60
+
61
+ A Decision's public ID is `dec_<8 lowercase hex characters>`. Use it in commands,
62
+ written references, and links: `https://app.getprimitive.ai/decisions/dec_<short>`.
63
+ Use `webUrl` when present; otherwise build that URL from the public `id` or
64
+ `decisionId`. Intent-labelled Markdown links are supported. No lookup of an
65
+ internal record ID is needed to construct a link. Full IDs remain accepted only
66
+ as legacy inputs; never ask for or print them. Public JSON identity fields contain
67
+ prefixed short IDs; `shortId` remains a bare eight-character compatibility alias.
68
+
69
+ ## Record a resolution
70
+
71
+ Bare `prim reconcile <idOrShortId>` rejects with `human_approval_required` and exit 2. It cannot grant permission to edit, including with `--flag`, `--yes`, or `--non-interactive`.
72
+
73
+ After resolving a conflict, record the actual outcome with `prim reconcile <id> --check <checkId> --outcome followed|superseded`. Use `followed` when you retained the Decision. Use `superseded` only after an explicitly authorized replacement has already been persisted. Recording an outcome does not bypass the gate or change a Decision.
74
+
75
+ ## Answer rationale confirmations
76
+
77
+ Occasionally the graph asks you (or the user) to confirm *why* a decision was made — a low-friction yes/no, never a paragraph. Answer it with:
45
78
 
46
- ### Update a spec from a local file and apply to the project
47
79
  ```
48
- npx --yes @primitive.ai/prim spec list --project-id <pid> # find the spec for a project
49
- npx --yes @primitive.ai/prim spec update <id> --file spec.md # replaces spec body
50
- npx --yes @primitive.ai/prim spec sync <id> # required -- update doesn't apply changes to the project
80
+ npx --yes @primitive.ai/prim decisions confirm <idOrShortId>
51
81
  ```
52
- `npx --yes @primitive.ai/prim spec sync` is **async**: it returns immediately with `Triggered sync for spec`, then applies in the background. The project isn't updated when the command returns -- surface that to the user.
53
82
 
54
- Auto-map runs automatically on the server after every `spec update`. Call `npx --yes @primitive.ai/prim spec auto-map <id>` explicitly only to re-run mapping without changing the spec text.
83
+ Confirmations are author-targeted and rare by design; answering keeps the graph's rationale trustworthy. Don't manufacture rationale — if you don't know why a decision was made, say so.
84
+
85
+ ## Preserve durable user decisions
86
+
87
+ Capture is automatic for low-level choices made while coding in an active repo. Use the deliberate CLI path for higher-order decisions that emerge in conversation: goals, priorities, principles, invariants, constraints, defaults, commitments, durable tradeoffs, and exceptions.
88
+
89
+ A decision worth deliberately recording is a genuine **fork in the road**: the user or agent encountered multiple plausible paths, selected one, and that selection should inform future work. The litmus: does the selection govern future work, or did it merely happen once? A second litmus: was the rejected path one the product could actually have shipped — a defensible alternative a teammate could have argued for — rather than an obviously-wrong option the quality bar already excludes (leaving a surface broken or empty)? “Of course we did this” marks a forced choice, not a fork. A release-scoped choice — what is in or out of one release — reverses at the next release; it is ephemeral, not a decision. Record the chosen behavior, direction, constraint, or tradeoff—not routine implementation needed to finish the task or follow an existing convention. Small design choices made in-flight while implementing—such as edge-case handling, parameter defaults, retry or timeout values, log levels, naming, or the shape of an internal data structure—are implementation details even when you chose between alternatives: never deliberately record them or spend a rationale question on them; passive capture already covers coding activity. A teammate working elsewhere should benefit from knowing it — and that test is a gate, not a nicety. The graph is the team's shared memory: a decision that configures only your own working environment — editor, shell, or terminal tooling, a personal dev box or remote coding machine, which worktree manager, launcher, or TUI you run — is personal, not a team decision, however durable and well-reasoned, even when the setup touches repo-owned helper scripts. Never record a personal-environment decision on your own initiative; record only positions the team's shared work must preserve. An explicit request to record that specific decision still wins — note when honoring it that the record is visible to the whole team.
90
+
91
+ ### Ground the rationale in real sources
92
+
93
+ Before deliberately recording a decision, actively gather the real context behind **why this path was chosen** — aim to populate the decision with as much genuine, source-grounded rationale as you can find, never a plausible-sounding guess. Start with the current conversation — it is itself a primary source: when the why was stated or is visible in this session, capture it in `--rationale` at create time rather than omitting it. Then reach for every tool, connector, and MCP server available to you to pull from the actual sources the decision or task points to: Slack threads, Granola or other meeting notes, Linear issues, Zoom transcripts, email, and repository docs or skills. Don't limit yourself to that list — use whatever integrations you have. Read the source directly instead of inferring from memory, and target the specific thread, meeting, ticket, or document the user referenced rather than a broad, scattershot search.
94
+
95
+ Record only rationale supported by those sources. Do not mistake the implementation method, the task request, or a restatement of the decision for its rationale. Echoing the spec, PRD, or Linear ticket — the “what” — is not rationale either; the capture-worthy part is the approach reasoning: why this shape and why each recorded alternative loses. When you record an option in `--alternatives`, the rationale should say why it was rejected. Write it as plain, impersonal engineering explanation — the reasons, evidence, and tradeoffs behind the choice, in a sentence or three. Rationale is explanatory, never normative: a constraint future work must obey belongs in `--decided` even when the rationale explains why, and reasoning belongs in `--rationale`, never inlined into the intent while `--rationale` sits empty. `--rationale` is not optional: never invent one, but never silently drop it either — when the why cannot be deduced from all available context, ask the user for it with the one focused question below and record their answer.
96
+
97
+ For proactively identified decisions in an active repo, let confidence in the rationale determine the interaction:
98
+
99
+ - **Clear and well-supported** — record the decision and rationale silently at the natural task boundary.
100
+ - **Plausible but uncertain** — at the task boundary, state the proposed rationale and ask for lightweight confirmation: “I understand the reason for choosing X to be Y. Is that right?” Create the record once they answer, carrying the confirmed or corrected rationale.
101
+ - **No supported rationale** — at the task boundary, ask one focused question: “What made you choose X over the other path?” Create the record once they answer, carrying their stated rationale.
102
+
103
+ The question gates the rationale, not the decision's survival: never fabricate a rationale to fill the gap, and never skip the question to record silently without one. If the user declines to answer, or their next message moves on without answering, record then with `--rationale` absent rather than re-asking or dropping the decision — the only outcome worse than a missing rationale is losing the record entirely.
104
+
105
+ These questions share the interruption budget below; never ask separate questions for the decision and its rationale. If both are uncertain, combine them into one concise prompt. An explicit request to “add this decision to Primitive” that supplies or implies its rationale records immediately; when it supplies none and none is deducible, ask the one rationale question and create the record with the answer — the request is approval to record, not a substitute for the why.
106
+
107
+ ### Inactive repos: approve each deliberate create
108
+
109
+ When passive capture is inactive for the current repo, do not silently turn a durable
110
+ decision into a write. “Inactive” means Prim's effective repo-capture check is false;
111
+ an explicit local `prim.active=false` is always inactive. Every
112
+ `prim decisions create` invocation needs fresh user approval:
113
+
114
+ - An explicit request to record or create that Decision is approval for that one
115
+ invocation; do not ask redundantly.
116
+ - For a proactively identified Decision, present the proposed decision and supported
117
+ rationale — folding the single rationale question into the same prompt when none
118
+ was found — then wait for approval before creating it. A previous approval never
119
+ carries forward to another Decision.
120
+ - After approval, pass Prim's global `--yes` for that invocation:
121
+ `npx --yes @primitive.ai/prim --yes decisions create ... --attribution user`.
122
+ The person's approval of the exact proposed choice is user ratification. The
123
+ first `--yes` is npm's package-install flag; the second is Prim's one-time
124
+ confirmation.
125
+ - Do not run `prim enable` merely to bypass this boundary or infer permission to
126
+ activate the repo. Activation requires a separate user request (a requested
127
+ `prim setup` counts because setup explicitly activates its current repo). A
128
+ one-time create leaves passive capture inactive; auth approval, npm's
129
+ `npx --yes`, setup's shell-permission grant, and earlier creates do not
130
+ independently change that state.
131
+
132
+ ### Direct requests: record without asking permission
133
+
134
+ When the user asks to record a decision—for example, “add this decision to Primitive”—author it directly. Do not ask whether to record; the only question that may accompany a direct request is the single rationale question above, when the request supplies no rationale and none is deducible. In an inactive repo, the request is the one-time approval: use Prim's `--yes` for that create as described above.
135
+
136
+ ### Clear decisions: record without interrupting
137
+
138
+ When the user clearly makes a durable fork-in-the-road decision without explicitly asking to record it, record it at the next natural task boundary without asking a redundant confirmation question **when passive capture is active**. An explicit ratification of a direction—“agreed,” “ship it that way,” or any equivalent affirmation—is such a decision even when the ratified option was your own proposal: the ratification is the approval, so record it and do not ask whether to record. That rule is general: in an active repository, never ask permission to record — the only question the budget permits is the single rationale question, which is required, not optional, when no rationale was stated or found. In an inactive repo, present it and obtain the per-create approval above. Preserve the user's meaning and stated rationale; do not strengthen, broaden, or embellish it. Prefer the governing position over the implementation activity that revealed it.
139
+
140
+ Examples that qualify:
141
+
142
+ - “We're prioritizing retention this quarter.”
143
+ - “Customer data must remain in the EU.”
144
+ - “Authentication state remains server-authoritative.”
145
+ - “Do not introduce another frontend framework.”
146
+
147
+ And one that never qualifies, however deliberate and well-reasoned: “Use my preferred worktree manager, not the alternative I evaluated, on my dev machine” — a personal-environment choice that binds no teammate.
148
+
149
+ Treat changes to shared agent instructions and standards—such as `AGENTS.md`, `CLAUDE.md`, repository skills, architecture rules, and design-system guidance—as a high-signal opportunity to preserve a decision. Inspect what rule the change establishes or revises. If it represents a genuine fork in the road, record the durable policy itself, not “updated the docs.” If the edit only documents a decision already present in Primitive, do not create a duplicate.
150
+
151
+ Apply the same attention during non-code deliberation: planning or “grill me” workflows, spec refinement, behavior design, PR planning or review, and conversations imported from Granola or other connected sources. These workflows can settle important forks before any code changes. Accumulate the confirmed decisions and record them at a natural phase or task boundary; do not interrupt or call Primitive after every answer.
152
+
153
+ ### Onboarding: experience your Decision protecting a teammate
154
+
155
+ **Claude Code and Codex at user scope:** `prim setup` returns `welcomeSkill`
156
+ (a file path) instead of `nextAction`. Read that file and follow it; it replaces
157
+ the rest of this section, which applies to project-scope setup, Cursor and Hermes.
158
+ It hands seeding to the next section.
159
+
160
+ After successful `prim setup`, follow its `nextAction` automatically; the `onboarding`
161
+ object contains the preparation instructions.
162
+ Pass your agent explicitly: Claude, Codex, Cursor and Hermes use the same sequence.
163
+ Run each generated command exactly as a standalone invocation. The first action
164
+ establishes capture isolation before the story is revealed. Do not delegate, wrap
165
+ commands, read fixtures, or manufacture an acknowledgment. If pending, use the
166
+ returned isolation reason and diagnostic action. Unknown trust is not proof that
167
+ hooks are disabled; for Codex, check `/hooks` and approve only if prompted.
168
+
169
+ Setup authorization includes following its returned `nextAction`; do not end the
170
+ turn at welcome or ask whether to start the tour. Installation, hook configuration,
171
+ observed hook execution, and verified capture are different states. Preserve
172
+ `health` warnings and `readiness` rather than declaring everything active.
173
+
174
+ If isolation is pending, run `diagnosticAction` once. It is safe before isolation:
175
+ it reports the installed runtime, native Codex trust when available, and the last
176
+ content-free observation for this run. The acknowledgment event is **PreToolUse**,
177
+ with **Bash** for Codex/Claude, **Shell** for Cursor, and **terminal** for Hermes.
178
+ Codex snapshots hooks in running sessions: a trusted file is not proof that the
179
+ session loaded it. Setup requests a native reload without changing trust. If the
180
+ diagnostic returns `repairAction`, run it once, then follow `resumeAction` for the
181
+ same run. If refresh cannot reach the calling host, have the user exit and resume
182
+ that same Codex session to load its hooks. Ask for hook review only when reported;
183
+ never repeat trust instructions for already-trusted hooks. Missing evidence is
184
+ unknown, not proof of healthy or disabled hooks. After one repair, retry only on
185
+ new evidence. Retain the run even after an expired npm cache. Never fabricate an
186
+ acknowledgment, dump hook configuration/transcripts, or restart the retry budget
187
+ with a new tour. Offer skip only as an option, not as the diagnosis.
188
+
189
+ Run follow-up actions with the configuration-directory access already authorized
190
+ for setup, subject to host policy. Report EPERM/EACCES with the actual path and
191
+ remedy; never infer sandbox/network failure from a quiet command. While npm is
192
+ starting, give a brief progress update after about 15 seconds and keep polling
193
+ that invocation; do not launch duplicates. Only after an actual npm cache error,
194
+ retry once with a newly allocated temporary `npm_config_cache` directory. Reuse
195
+ that cache for subsequent commands. Do not clear the user's cache or change
196
+ permissions recursively. Bootstrap happens before Primitive can print progress.
197
+ Setup opens the authorization browser itself: surface its URL and let the user
198
+ click Authorize; do not invoke computer-use tools to automate that click.
199
+
200
+ Render the returned presentation once; keep raw JSON, launch paths, UUIDs and
201
+ routine STDERR out of the conversation. Surface actionable warnings verbatim.
202
+ If blocked, end with the observed cause (or explicitly unknown boundary), the
203
+ single next repair, and the command to resume the retained run.
204
+
205
+ Render each `presentation` once as Markdown, preserving diagrams and file evidence.
206
+ Do not echo JSON/STDERR, expand the records, or add a prose recap. Keep the returned
207
+ **[DEMO]** titles. This uses the production semantic
208
+ evaluator on private demo records and a demo-only blocking policy; native production
209
+ hooks did not supply the verdict. Production outcomes still vary by agent and
210
+ Decision state, including Claude's permission prompt.
211
+
212
+ The participant is the fictional earlier author, now playing a new engineer in this
213
+ same chat. At `awaitUserPrompt`, show the copyable CSV-export task and **wait for the
214
+ user to enter it**. Only then run `attemptAction`. Do not auto-submit it, ask them to
215
+ adopt the prior Decision, or implement the feature yourself.
216
+
217
+ At the actual block, show the returned unchanged file and **Accept / Supercede** choices.
218
+ Accept uses `choices.adhere`; Supercede uses `choices.supersede`. Supercede approves the replacement,
219
+ **Allow user names and email addresses in CSV exports**, and requires a short
220
+ reason in the user's own words. If missing, ask `choices.supersede.prompt` exactly;
221
+ if already supplied, do not ask again. The exploration prompts in the success message
222
+ are suggestions for the participant, not actions to execute automatically.
223
+ Append `'--reason'` and their single-quoted reason
224
+ to `choices.supersede.command`; escape any apostrophe as `'\''`, matching the
225
+ command's existing shell quoting. Never invent a reason or execute a placeholder.
226
+ Do not call production `reconcile` or `decisions create` for these samples.
227
+
228
+ An unavailable or uncertain judgment remains pending; never invent a block or pass.
229
+ Use `statusAction` for diagnosis and the returned action for recovery. A resolution
230
+ retry uses the same approved bytes and completion receipt. Show success **before**
231
+ following welcome. Continue when the real outcome email is durably queued; provider
232
+ acceptance is not inbox delivery. Cleanup errors retain the path and defer seeding.
233
+
234
+ After completion or explicit skip, follow the exact welcome `nextAction` once.
235
+ It preserves the executable and agent and requests `--after-demo`. Its viewer-based
236
+ `org` result governs the transition: `seed` proposes one real Decision for individual
237
+ approval; `active` continues real work; `unknown` reports unavailable history and
238
+ must never be treated as empty. Do not repeat the feed or seed from fictional data.
239
+
240
+ Passive capture stays excluded for this session, including resumes. Start a new
241
+ session to resume capture; other sessions and real-work enforcement stay active.
242
+ Explicitly approved real Decisions remain available here. Never save this story,
243
+ its Decisions, reason or outcome to repository memory or the real Decision graph.
244
+
245
+ Setup runs the optional story once per local OS-user configuration. `setup --skip-demo`
246
+ remembers a skip; `prim demo --agent <claude|codex|cursor|hermes>` explicitly replays.
247
+ Old completion markers do not force a replay. `recoverableRuns` offers cleanup of
248
+ unfinished runs, including legacy local tours; it does not gate a fresh tour.
249
+ A missing backend/email configuration leaves the optional story pending while setup
250
+ remains successful. Surface the returned remedy or offer its skip action.
251
+
252
+ ### Onboarding: seed the graph from memory, one proposal at a time
253
+
254
+ When onboarding or `prim welcome` reports `"org": "seed"`, seed the viewer's graph by proposing decisions mined from memory. There is no open goals question: the proposals are the whole seeding pass. Propose **one decision per message**, wait for the user's verdict, and only then present the next — never present the candidates as a batch.
255
+
256
+ 1. Gather candidates from the repo's Git-tracked shared memory and agent-instruction files (`git ls-files -- 'MEMORY.md' ':(glob)**/MEMORY.md' 'AGENTS.md' ':(glob)**/AGENTS.md' 'CLAUDE.md' ':(glob)**/CLAUDE.md'` from the repository root; read every path returned) and from your own memory and conversation context — positions the user has already *stated*; the setup guide names each agent's memory surface. Never automatically read an untracked, gitignored, or un-shared memory source; use one only when the user explicitly asks to promote it. Only their words count: never infer a position from the repo's code or history, and never invent one they didn't state. Never use anything from the onboarding demo's fictional story, including the user's adhere/supersede choice and reason.
257
+ 2. A candidate must state an explicit, durable position that appears to remain in force — a genuine fork in the road such as a goal, priority, principle, invariant, constraint, default, commitment, tradeoff, or exception. Do not infer decisions from code, repository structure, or unstated implications, and do not bulk-import the documents. The personal-environment exclusion above applies: never propose a position that binds no teammate.
258
+ 3. Run `npx --yes @primitive.ai/prim decisions recent --limit 20` and drop candidates equivalent to existing decisions. If the result is unavailable or too incomplete to rule out a duplicate confidently, drop the uncertain candidate; explain the limitation.
259
+ 4. Propose the strongest candidates one at a time — **at most six in total**, fewer when the material runs out (never invent a proposal to fill the quota), stopping early if the user declines to continue. Each proposal carries the proposed decision, its source (file path or the stated context), and only rationale or alternatives explicitly supported by that source; when the source yields no rationale, fold the single rationale question into the same prompt. In this and any user-facing presentation, label the position **Decision**, never "Intent" — intent is `--intent` flag vocabulary, not user copy — and label the rejected options **Alternatives rejected**, never "alternatives considered". Make clear, at least on the first proposal, that approved decisions join the team's shared decision graph, visible to any teammates — not a private list. Ask the user to approve, revise, or reject it — do not silently attribute a historical repository position to the onboarding user — and create each approved decision (per the wording and flag rules below) before presenting the next.
260
+ 5. After the final proposal's verdict — or immediately, when there are no viable candidates (say so briefly) — close with the standing guidance from welcome's STDOUT `seedGuidance` field: the user can tell their agent to add any decision to the Primitive decision graph at any time; otherwise, once the agent's prim hooks are active, Primitive passively captures decisions in the background while they work; and other repositories are captured only after `prim enable` is run in each. On an older CLI without that field, state those three points yourself.
261
+
262
+ Outside onboarding, before creating a proactively identified decision, read recent decisions to avoid duplicating an existing position:
55
263
 
56
- ### Map files to a spec (so pre-commit auto-syncs all affected specs)
57
264
  ```
58
- npx --yes @primitive.ai/prim spec map <id> -p "src/auth/**" "src/foo/**" # multiple patterns at once
59
- npx --yes @primitive.ai/prim spec unmap <id> -p "src/auth/**" # remove one
60
- npx --yes @primitive.ai/prim spec unmap <id> # clear all manual patterns
265
+ npx --yes @primitive.ai/prim decisions recent --limit 20
61
266
  ```
62
267
 
63
- ### Create or link a context
268
+ If an equivalent decision is already present, do not create or suggest it again. After this duplicate check—or after the user confirms an onboarding proposal—author the decision directly. If the repo is inactive, that confirmation authorizes Prim's `--yes` only for the approved create:
269
+
64
270
  ```
65
- npx --yes @primitive.ai/prim context create -s project -n "<name>" --file <path> --project-id <pid> # add --spec to make it a spec
66
- npx --yes @primitive.ai/prim context create -s global -n "<name>" --text "..." # filed in the global context pane, not linked to a specific project
67
- npx --yes @primitive.ai/prim context link <ctxId> --project <projectId> # works on any scope
68
- npx --yes @primitive.ai/prim context unlink <ctxId> --project <projectId> # remove a link
271
+ npx --yes @primitive.ai/prim decisions create --intent "Adopt prosemirror-collab over Yjs" --attribution user --area data --rationale "Server-authoritative ordering" --alternatives "Yjs" --alternatives "Automerge" --decided "Collaborative editing state syncs through prosemirror-collab" --decided "The server is the single authority for step ordering"
69
272
  ```
70
273
 
71
- ### Update or delete a context
274
+ Inactive-repo form after approval:
275
+
72
276
  ```
73
- npx --yes @primitive.ai/prim context update <id> -n "<new name>" # rename
74
- npx --yes @primitive.ai/prim context update <id> --file <path> # replace body
75
- npx --yes @primitive.ai/prim context delete <id> # permanent -- confirm with the user first
277
+ npx --yes @primitive.ai/prim --yes decisions create --intent "Adopt prosemirror-collab over Yjs" --attribution user --area data --rationale "Server-authoritative ordering" --alternatives "Yjs" --alternatives "Automerge" --decided "Collaborative editing state syncs through prosemirror-collab" --decided "The server is the single authority for step ordering"
76
278
  ```
77
279
 
78
- ### Create a project (optionally with a linked spec)
280
+ Both `--intent` and `--attribution` are required. Set `--attribution user` only when the person directly stated, selected, or confirmed the exact recorded choice. Set `--attribution agent` when you introduced that exact choice while pursuing a broader request. A broad task prompt, implementation permission, or assignment of responsibility does not turn your implementation choice into a user Decision. If the origin is ambiguous, ask the person to confirm the exact choice before creating it; after confirmation, use `user`. Never guess attribution.
281
+
282
+ Word `--intent` as a short sentence-case normative headline — ideally 4–12 words, no terminal period — stating the standing constraint future work must follow, not a report of the action taken: "Consume AADT and safety data from street_export, not gps_probes_osm", never "Migrate AADT and safety data managers off gps_probes_osm". A one-time-action verb (Migrate, Backfill, Publish) headlines a task execution: restate the ongoing constraint the action implies, and when none exists, do not record a decision at all. Make the intent self-contained for a reader who wasn't in the session — name the release, artifact, or system explicitly, and state what a referenced change does rather than citing a PR or ticket number, which is itself session context; "limit this release" and "keep the GitHub surface (PR 1102)" are failures. Carry one governing decision per intent — a reader of the intent alone must see which option is now in force. Expand every binding specific the choice adopts — scope boundaries, defaults, invariants, schema or API shapes, exceptions, required mechanisms — into `--decided`, and move non-binding reasoning into `--rationale`; a paragraph-length intent that inlines its constraints and reasons is a failure.
283
+
284
+ Other flags: `--kind` (change|exploration|task_execution|unclear, default change), `--rationale` (required by the recording policy above — the CLI accepts its absence, but only for the declined/unanswered fallback), `--area` (a single short lowercase noun — `auth`, `billing`, `infra`), `--decided`, `--alternatives`, `--confidence` (high|medium|low, default high), `--reversibility` (high|low, default high), and `--files` (comma-separated repo-relative paths the decision governs — these are the files Conflict Gates check on later edits when Enforcement is enabled, in the same path form as `decisions check`). Scope a repository-bound Decision more broadly with `--scope-repo`, repeated `--scope-dir <prefix>`, repeated `--scope-glob <glob>`, and/or repeated `--scope-branch <pattern>`; set an effective window with `--effective-from` and `--effective-until`; or limit its audience with repeated `--for-user <id>`, `--for-role <owner|admin|member>`, `--for-agent <claude_code|codex|hermes>`, and `--for-credential <workos_jwt|workos_api_key|service_token>`. Omit selectors for broad directions: a repository-bound Decision without selectors applies to the whole repository. Change a recorded Decision with `decisions rescope <idOrShortId>` and the same selectors; `--clear-window` removes its effective window. Calling `rescope` with no scope options clears its explicit location scope, while a time- or audience-only rescope preserves that location scope. STDOUT is the created identity `{ decisionId, shortId, createdAt }`; STDERR prints `[prim] created dec_<short>.` — pass that `dec_<short>` straight into `decisions show` / `cascade` / `confirm`.
285
+
286
+ `--decided` carries the enforceable detail as standalone bullets — one per independently adopted constraint, the core choice first, with exact names and values. Each bullet states what must remain true and makes sense by itself: never narrate the session ("Chose to document the behavior" is a failure) and never pack independent rules into one semicolon-delimited entry. `--alternatives` takes one concise entry per option actually considered and rejected; omitting it when none were named is normal. The decision's own negation is never an alternative — restating the prohibited or displaced behavior adds nothing; list only options a source or the conversation actually names as considered. Both flags are repeatable: pass one entry per flag occurrence, verbatim — repeat `--decided` for each bullet and `--alternatives` for each option. Values are never split on commas, so write entries as natural prose; a repeated flag, not a delimiter, is what separates entries.
287
+
288
+ ### Inferred decisions: finish first, then optionally ask once
289
+
290
+ When several statements or implementation choices strongly imply a higher-order fork in the road but the user did not state the decision explicitly, do not record it automatically. Complete the requested work first. At the natural stopping point, optionally ask one concise confirmation question that states the synthesized decision:
291
+
292
+ > A broader direction seemed to emerge: prioritize activation and retention before acquisition work. Should I record that as a team decision?
293
+
294
+ Record it only after an affirmative response. Consolidate related evidence into one governing decision rather than listing or recording each underlying implementation choice.
295
+
296
+ ### Interruption budget
297
+
298
+ - Never interrupt active implementation solely to improve Primitive's records.
299
+ - Ask at most one Primitive-related confirmation question per task, only after completing the requested work.
300
+ - Ask nothing when the inference is weak, local, temporary, already recorded, or unlikely to guide another teammate.
301
+ - Do not ask the optional inferred-decision question when the user requested a narrow execution task or appears to want a quick result without discussion; the required rationale question for a clearly made decision still applies at the task boundary.
302
+ - Drop a rejected suggestion. Do not raise it again unless the user materially changes the decision.
303
+ - If ambiguity must already be resolved to perform the task, fold the durable-policy distinction into that necessary question instead of adding a separate Primitive question.
304
+ - Do not narrate or record routine edits, syntax, naming, testing, debugging tactics, or branch/commit mechanics; passive hooks already cover coding activity.
305
+
306
+ ## Relate decisions (link / unlink)
307
+
308
+ prim links decisions automatically when their files overlap, but that heuristic misses real connections and occasionally invents wrong ones. When the user asks you to **relate two existing decisions** — "B depends on A", "these are connected", wiring up two orphans — or to **cut a wrong link**, do it by hand:
309
+
79
310
  ```
80
- npx --yes @primitive.ai/prim project create -n "<name>" -d "<desc>"
81
- npx --yes @primitive.ai/prim project create -n "<name>" --spec <contextId> # value is a context ID
311
+ npx --yes @primitive.ai/prim decisions link <child> --on <parent> # record that <child> depends on <parent>
312
+ npx --yes @primitive.ai/prim decisions unlink <child> --on <parent> # remove that dependency
82
313
  ```
83
314
 
84
- ### Install the pre-commit hook
315
+ Direction is **`<child>` depends on `<parent>`** — the parent is the prerequisite. Read the echoed verdict to confirm you got the arrow right: `[prim] <child> now depends on <parent>.` After linking, `decisions show <child>` lists `<parent>` upstream and `decisions cascade <parent>` shows `<child>` in its downstream blast radius; after unlinking they drop. Both ids accept `dec_<short>` or a full id and may be any two decisions in your org, regardless of status.
316
+
317
+ Safe to run repeatedly:
318
+
319
+ - **Idempotent** — re-linking an existing edge (or unlinking a missing one) is a no-op that still exits 0 (`already_linked` / `not_linked`).
320
+ - **Acyclic** — a self-loop, or any link that would close a dependency cycle, is refused with exit 2 (with the offending chain when it's short enough to render); the graph stays a DAG.
321
+ - **Exit codes** (treat non-zero as actionable): `0` success or no-op; `2` a refused link (self-loop, cycle, or an unavailable identity — retry after identity repair); `4` an id that doesn't resolve. After a non-zero exit, branch on the exit code and the `[prim]` STDERR verdict, **not** on STDOUT keys: only the exit-0 outcomes carry the full `{ outcome, childId, childShortId, parentId, parentShortId }`; a refused link prints a smaller `{ outcome, … }`, and an unresolved id (exit 4) prints nothing to STDOUT.
322
+
323
+ Like authoring, relate only what the user asks for — don't invent relationships they didn't state.
324
+
325
+ ## Presence
326
+
327
+ With the daemon running (`npx --yes @primitive.ai/prim daemon start`), `npx --yes @primitive.ai/prim daemon status` includes the live online count in its STDOUT JSON (when presence is fresh); Claude Code surfaces it in the statusline as `team: N online`. Your captured decisions are attributed to your agent automatically -- no flag required.
328
+
329
+ ## The git hooks
330
+
331
+ `npx --yes @primitive.ai/prim hooks install` installs three git hooks:
332
+
85
333
  ```
86
- npx --yes @primitive.ai/prim hooks install # auto-detects Husky and prompts
334
+ npx --yes @primitive.ai/prim hooks install # auto-detects Husky and prompts
335
+ npx --yes @primitive.ai/prim hooks install --yes # confirm Husky (non-interactive)
336
+ npx --yes @primitive.ai/prim hooks install --target=git-hooks # force .git/hooks (skip Husky detection)
87
337
  npx --yes @primitive.ai/prim hooks uninstall
88
338
  ```
89
- **Note:** `hooks uninstall` only removes `.git/hooks/pre-commit`. If the hook was installed into `.husky/pre-commit`, you must remove the prim block from that file manually.
90
339
 
91
- ## How the pre-commit hook behaves
340
+ - **pre-commit** -- checks staged files against the live decision graph and prints any active decisions that reference them to stderr. It is **warn-only**: failures (auth, network, backend) or matches never block the commit; a successful `git commit` doesn't prove the check ran clean. When the check can't complete it says so ("not verified" / "truncated") rather than implying all-clear.
341
+ - **post-commit** -- records each commit as a capture boundary so the server can classify the surrounding work into decisions. It never blocks and runs in the background.
342
+ - **post-rewrite** -- records amend/rebase rewrites the same way, in the background.
92
343
 
93
- `npx --yes @primitive.ai/prim hooks install` adds a hook that, on every commit:
344
+ All three act only where the repo is active (`prim enable`). Each hook file gets one version-stable block right after its shebang; `prim enable` and `hooks install` write it once and never rewrite a current block, while session hooks only repair Git-private files under `.git` (and never add the pre-commit check). prim never edits a hooks dir outside the repository, such as a shared global `core.hooksPath`: `hooks install --scope user` changes git's global hooks only with `--global-hooks-path` or a yes typed at a terminal. That changes every repository, so never pass the flag for the user without asking, and know that `--yes` does not count. `prim doctor`'s `hook-fired` check fails if a local commit since the hooks were wired never reached prim (in manual mode too, once the repo is enabled): surface it, since capture is silently missing. If the user wires the hooks themselves, they must set `git config prim.gitHooks manual` (prim does not infer hand wiring from what a hook mentions); prim then never edits their hook files; `npx --yes @primitive.ai/prim hooks snippet <hook>` prints the block to place.
94
345
 
95
- 1. Fetches the org's spec-to-file-pattern mappings.
96
- 2. Glob-matches staged files against each spec's patterns (`*` and `**` supported).
97
- 3. For each affected spec, sends `git diff --cached` to `/api/cli/contexts/:id/sync-diff`. The backend runs an **LLM over (current spec + diff)** to produce edits, updates the spec text, then applies the new spec to the project.
98
- 4. Prints `[synced] <id> -- <name>` or `[skip] <id> -- <reason>` per affected spec to stdout, and `[error]` lines to stderr.
346
+ Under `CI=1` (or with `--non-interactive`), `hooks install` fails fast in a Husky repo that Husky has not yet configured, unless `--yes` or `--target` is set; the error names both escapes. `hooks uninstall` removes prim's blocks from `.git/hooks` and `.husky/` alike and leaves the rest of each hook untouched. To suppress the hooks for one commit, use `git commit --no-verify`.
99
347
 
100
- What that means:
101
-
102
- - **The hook is not `npx --yes @primitive.ai/prim spec sync`.** `npx --yes @primitive.ai/prim spec sync` re-applies the *existing* spec to the project. The hook calls `sync-diff` -- an LLM updates the spec from the code change, then applies the new spec to the project. The casual "just commit and the hook will sync" is ambiguous; when explaining to the user, specify which operation you mean.
103
- - **The hook never blocks the commit.** Failures (auth, network, backend) print `[error]` to stderr but exit 0, so a successful `git commit` doesn't prove the spec changed. Check the hook's `[synced]` / `[error]` / `[skip]` output, or verify with `npx --yes @primitive.ai/prim spec get <id>`.
104
- - **Diffs over 256 KiB are truncated.** The hook logs `(truncated: X KiB -> Y KiB analyzed)`. The LLM only sees the first 256 KiB of the diff.
105
- - **To suppress the hook for one commit** (e.g., when intentionally desyncing code from spec, or when committing unrelated changes), use `git commit --no-verify`.
348
+ These git hooks are separate from the **session hooks** (`claude install` / `cursor install` / `codex install` / `hermes install`) that drive in-session capture (and Conflict Gates, when enabled).
106
349
 
107
350
  ## Output formats
108
351
 
109
- | Command | Output | Where the ID is |
110
- |---|---|---|
111
- | `npx --yes @primitive.ai/prim context create` | `Created context: <id>` | Match `^Created context: (\S+)` |
112
- | `npx --yes @primitive.ai/prim project create` | `Created project: <id>` | Match `^Created project: (\S+)` |
113
- | `npx --yes @primitive.ai/prim spec update` | `Updated spec: <id>` | Match `^Updated spec: (\S+)` |
114
- | `npx --yes @primitive.ai/prim spec sync` | `Triggered sync for spec: <id>` | Match `^Triggered sync for spec: (\S+)` |
115
- | `npx --yes @primitive.ai/prim context list`, `npx --yes @primitive.ai/prim spec list` | Table with trailing count line | First token of each row (skip the final `N spec(s)` / `N context(s)` summary line) |
116
- | `npx --yes @primitive.ai/prim spec list --project-id <pid>` | Single-spec block (key:value) | `ID:` line |
117
- | `npx --yes @primitive.ai/prim context get <id>` | Pretty-printed JSON | `._id` field |
118
- | `npx --yes @primitive.ai/prim spec get <id>` | Human-readable key:value block | `ID:` line |
119
- | `npx --yes @primitive.ai/prim spec get <id> --text-only` | Raw spec markdown, nothing else | n/a |
352
+ The CLI keeps STDOUT machine-readable and STDERR human-readable. The `decisions` and `reconcile` commands **always** emit a single JSON document on STDOUT — no flag needed; pipe straight to `jq`. The `decisions` commands have **no** `--json` flag and reject one; `reconcile` accepts a reserved no-op `--json`. `auth status` and `skill status` default to human-readable STDOUT and take `--json` to switch to JSON.
353
+
354
+ - **STDOUT is machine-readable** — JSON (one document per invocation). `decisions` reads project lean shapes, not raw rows.
355
+ - **STDERR is human-readable** — a verdict-first line, plus presence notes (and, when Conflict Gates are enabled, the gate/verdict-footer notes).
356
+ - **Exit code is authoritative** where it carries meaning — `auth status` exits 0 when authenticated; `decisions show`/`cascade`/`confirm` exit non-zero (e.g. 4 not-found) on a missing or unauthorized id.
357
+
358
+ Examples:
359
+
360
+ - `npx --yes @primitive.ai/prim auth status --json | jq -r .authenticated` — boolean; the exit code remains the authoritative signal
361
+ - `npx --yes @primitive.ai/prim decisions recent | jq -r '.decisions[].shortId'` — list recent decision short ids (STDOUT is already JSON)
362
+ - `npx --yes @primitive.ai/prim decisions recent --author "Maya" | jq -r 'if .unavailable then "UNAVAILABLE: \(.unavailable)" else .decisions[].intent end'` — one teammate's latest decisions (check `.unavailable` first; empty output alone is not "no decisions")
363
+ - `npx --yes @primitive.ai/prim decisions show <id> | jq .` — full decision detail
120
364
 
121
365
  ## Pitfalls
122
366
 
123
- - **`npx --yes @primitive.ai/prim spec sync` archives anything dropped from the spec.** Removed content is archived (recoverable), not deleted.
124
- - **`npx --yes @primitive.ai/prim spec update` doesn't apply changes to the project.** Always follow with `npx --yes @primitive.ai/prim spec sync <id>`.
125
- - **`npx --yes @primitive.ai/prim spec update --file` replaces the whole body.** Fetch with `npx --yes @primitive.ai/prim spec get <id> --text-only` before any partial edit.
126
- - **`npx --yes @primitive.ai/prim spec sync` rejects non-spec contexts** with "Context is not a spec document. Use `prim context` instead." Use `npx --yes @primitive.ai/prim spec list` to find spec IDs.
127
- - **`npx --yes @primitive.ai/prim context delete` is permanent.** Confirm with the user before deleting.
128
- - **Scope is set at creation.** To change it, delete and recreate the context.
367
+ - **An "unavailable" / "not verified" decision check is not an all-clear.** Treat constraints as UNKNOWN and proceed deliberately; never read the silence as approval — the same holds for Conflict Gates once enabled.
368
+ - **When Enforcement is enabled, `deny` blocks the edit for a conflict or an incomplete check.** Read the reason. Resolve the conflict or resume the check; intention alone never authorizes an override.
369
+ - **Reconcile bypasses are disabled.** Human approval cannot be inferred from tool execution or automatic review.
370
+ - **Capture of coding activity is automatic only in active repos; never inject moves by hand.** If an active repo's decisions aren't showing up, check that the session hooks are installed (`claude status` / `cursor status` / `codex status` / `hermes status`) and the daemon is running. Deliberately authoring a higher-order fork—either at the user's request or under the conservative proactive policy above—is a separate, supported path through `decisions create`; in an inactive repo, honor the per-invocation approval boundary above.
371
+ - **Don't fabricate rationale on a confirmation.** If you don't know why a decision was made, say so rather than guessing.
129
372
 
130
373
  ## After each task
131
374
 
132
- Report the names and IDs you touched (spec, context, project) so the user can verify in the dashboard. If you ran `npx --yes @primitive.ai/prim spec sync`, remind the user it's async -- the project settles in the background.
375
+ If the user clearly made a durable fork-in-the-road decision, check recent decisions and record it now if it is not already present when capture is active — asking the single rationale question first when the why is not deducible from available context. When capture is inactive, record it only if the user explicitly requested that create; otherwise present it for the per-invocation approval above. If a strong higher-order decision was only inferred, decide whether it clears the interruption budget; if so, ask the single concise confirmation question after reporting the completed work. Otherwise say nothing about Primitive.
376
+
377
+ If Conflict Gates are enabled and one denied or warned you, report which decision(s) it named and how the conflict was resolved or why the edit remains blocked. If you read the graph before a load-bearing change, note what you found so the user can verify in the dashboard.