agent_primitives 0.1.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,206 @@
1
+ ---
2
+ name: closing-out-primitives
3
+ description: >-
4
+ The primitives steps of implementing and finishing planned work: verify each
5
+ task with proofs and guard, classify a revision as bug or intent change, then
6
+ the close-out pass — fill evaluations from real specs, reconcile against the
7
+ plan's Intent impact block, triage guard notices, flip status, append
8
+ provenance. Use when implementing or completing a plan in an app with a
9
+ docs/primitives/ tree.
10
+ ---
11
+
12
+ # Closing out primitives
13
+
14
+ **Announce:** "I'm using the closing-out-primitives skill."
15
+
16
+ This skill applies only when the app has a `docs/primitives/` tree; the
17
+ workflow skill that sent you here owns everything else about running the plan
18
+ or implementing its tasks.
19
+
20
+ ## Before starting work
21
+
22
+ **Capability doc:** if the plan header has a **Capability:** line, read that
23
+ one doc (`docs/primitives/capabilities/<name>.md`) and `docs/primitives/compilation.md`
24
+ now — agents always read `compilation.md` when the tree exists — and never the
25
+ whole tree (`primitives-format` § Reading contract). The capability doc
26
+ supplies the Intent clauses and Shape excerpts pasted into the implementing
27
+ agent's prompts, and it is the doc the close-out pass updates. If the line's path
28
+ does not resolve (doc renamed or deleted since planning), check `index.md`
29
+ for a rename; if it is genuinely gone, **stop and flag to the user** — do not
30
+ execute against a missing capability doc. No Capability line:
31
+ if `docs/primitives/` exists, **flag it to the user before proceeding** — the
32
+ plan predates primitives or skipped its gate (the reviewer treats that as a
33
+ plan defect), and executing it silently would drift the tree. Only when the
34
+ app has no tree do you skip everything primitives-related in this run.
35
+
36
+ When dispatching a task to the implementing agent, **paste the Intent clauses
37
+ this task cites, the relevant Shape bullets, and any `compilation.md`
38
+ constraints the task touches** into the prompt's context — the implementing
39
+ agent reads zero primitives files; the excerpt is its whole primitives context
40
+ and the only channel app-wide constraints reach it by.
41
+
42
+ ## Working from an excerpt
43
+
44
+ If the task prompt includes **capability excerpts** (Intent clauses like
45
+ `I1 — …`, Shape bullets, and any `compilation.md` constraints from
46
+ `docs/primitives/`), treat the clauses as acceptance-criteria context and the
47
+ Shape bullets and compilation constraints as binding for this task. Do not
48
+ open or edit `docs/primitives/` yourself — the excerpt is your whole
49
+ primitives context by design.
50
+
51
+ ## Verifying one task
52
+
53
+ **When the app has a `docs/primitives/` tree and the task served an intent clause,** run **`agent_primitives proofs --since HEAD`** and read it against the plan's **Intent impact** entry for each clause you served. The entry names the cases the clause needs; the output counts each clause's tagged examples. A count that comes up short against the entry means a proof you wrote and never tagged, or never wrote — drill in with **`agent_primitives proofs '<capability>#I<n>'`**, whose tagged listing shows which planned case is missing, then find the example in the spec file and tag it (or write it) before reporting. No other check can see this, because `evals` treats one tag as proof of the whole file and `guard` says nothing about an untagged new example. Quote each touched clause's tagged-count line in your report's test and verification results, so the count reaches review rather than your reading of it. If the task's spec list does not cover a cited clause's full wording, say so in your report instead of tagging past it.
54
+
55
+ **When the task touched a spec carrying an `intent:` tag,** finish with **`agent_primitives guard --base HEAD`** (notices only — it never fails). It reports what your work did to promises that already existed. A **proof** notice (`proof/removed`, `proof/weakened`, `evaluation/dropped`) on a still-active clause is yours to fix before reporting: you took coverage off a promise the app still makes, so restore the assertion or the example. An **intent** notice (`intent/rewritten`, `intent/vanished`, `provenance/rewritten`) means an intent clause moved — **you do not own that file**. Report it in the completion notes and change nothing: intent is amended by the user's decision, never by the implementing agent, and never by writing the provenance line that silences the notice (`primitives-format` § Ownership and write points).
56
+
57
+ ## When finished work is revised
58
+
59
+ **Classify against Intent (when a capability doc exists):** read the doc's
60
+ `intent:` frontmatter and decide which of two revisions this is — the distinction
61
+ surfaces *before* delegating, not after:
62
+
63
+ - **The code failed the intent** (bug): "fixed" matches an existing clause.
64
+ No Intent change and **no provenance line**; if the fix moved or added spec
65
+ homes, sync `evaluations:` (and the specs' `intent:` tags) once the fix is
66
+ Approved — a row sync alone is not a provenance event.
67
+ - **The intent changed** ("it should do X instead"): "fixed" contradicts a
68
+ clause. Amend the clauses (supersede / add, per the `primitives-format` skill)
69
+ alongside the fix. Once the fix is Approved: tombstone the superseded
70
+ clause (`superseded_by:` / `superseded_on:`, per `primitives-format`
71
+ § Lifecycle), add or update `evaluations:` for the amended clauses
72
+ from the fix's **reported** specs, retag those examples, and append
73
+ one provenance line:
74
+ `- YYYY-MM-DD — revised: I<n> amended (X instead of Y) per user feedback.`
75
+ Report all of it in the revision's completion report (below).
76
+
77
+ If the fix comes back blocked and the user abandons an intent-change revision,
78
+ **revert the clause amendments made when classifying it** — no shipped change
79
+ references them, so the draft-stage edit rule applies
80
+ (`primitives-format` § Lifecycle); note the reversal in chat, not provenance.
81
+
82
+ The revision's completion report includes:
83
+
84
+ - Primitives sync, if any (clause amendments, `evaluations:`, the one provenance
85
+ line — per the classification above), and the `agent_primitives guard --base <ref>`
86
+ notices for the revision. A bug-fix revision that produced an intent notice is
87
+ a misclassified revision: the fix changed a promise. Say so to the user rather than
88
+ writing the provenance line that quiets it.
89
+
90
+ ## Close-out pass
91
+
92
+ While a plan runs, `docs/primitives/**` edits are orchestration bookkeeping, not
93
+ app code — whoever runs the plan appends provenance lines, syncs
94
+ `evaluations:`, flips `status:`, keeps the capability's `index.md` line in
95
+ sync, and amends Intent clauses when a revision's classification calls for it
96
+ (a user-directed intent change, § When finished work is revised), directly per
97
+ the **`primitives-format`** skill. Structural primitives work (splitting a
98
+ capability, lint passes) goes to **`maintaining-primitives`**; backfills go to
99
+ **`backfilling-primitives`**, run with the human rather than a subagent.
100
+
101
+ Required when the plan has a **Capability:** line, once every task is Approved.
102
+ Part of the definition of done — **not an offer to the user**. Whoever runs the
103
+ plan updates the capability doc directly (see above):
104
+
105
+ 1. **Evaluations** — fill or update `evaluations:` on each intent clause this
106
+ plan touched, from the **specs the implementing agent actually reported** — never
107
+ from what the plan promised. The named spec must also carry the
108
+ **`intent:` tag** (the `tagging-intent` skill); add it if the
109
+ implementing agent did not. Delete-listed specs must actually be gone.
110
+
111
+ **Reconcile against the plan's Intent impact block**, case by case, with
112
+ **`agent_primitives proofs --since <ref>`** — each entry names the cases a
113
+ clause needs and that output counts each clause's tagged examples; a count
114
+ that comes up short is drilled into with
115
+ **`agent_primitives proofs '<capability>#I<n>'`**, whose tagged listing
116
+ shows which planned case is missing. Do this before filling the row —
117
+ `evals` counts files, not cases
118
+ (`running-primitives-checks` § Which examples prove a
119
+ clause). A case the entry named and the listing does not show
120
+ goes back through the implement → review loop, not into `evaluations:`.
121
+ A declared case no spec delivered is a gap. A clause listed `unchanged — regression contract`
122
+ whose evaluation had its **assertions** edited is the one to stop on: a
123
+ refactor may move an evaluation's file, never change what it asserts — an
124
+ edited assertion means behaviour moved and the plan was a mislabelled
125
+ amendment; say so rather than filing the row. `agent_primitives guard`
126
+ (step 2 of this pass) names that case mechanically as `proof/weakened`.
127
+
128
+ **Read the reported examples against the clause before filling the row** —
129
+ breaking the clause has to turn one of them red
130
+ (`tagging-intent` § What counts as proving a clause).
131
+ A clause claiming *only*, *never*, or *any* that came back with a single
132
+ happy-path example goes back through the implement → review loop for the
133
+ missing spec, not into a row that proves less than the clause says.
134
+ 2. **Run the mechanical checks** — they are the check, not a formality:
135
+
136
+ ```bash
137
+ agent_primitives evals # exits 1 on findings
138
+ agent_primitives guard --base <ref> # notices only; never fails a run
139
+ agent_primitives proofs --since <ref> # tagged-example counts per touched clause
140
+ ```
141
+
142
+ `evals` green is a precondition for step 3. Every error is closed by
143
+ writing the spec and tagging the example, never by editing the doc
144
+ (`primitives-format` § Evaluations). The non-blocking warnings,
145
+ `clause/in-flight` and `tag/in-flight`, mark rows this plan still owes.
146
+ Step 1 files them, so one still showing is a row this pass missed.
147
+ `status/plan-missing` means `plan:` names a file that is not on disk: point
148
+ it at where the plan moved.
149
+
150
+ `guard` reads what this run did to promises that already existed
151
+ (`running-primitives-checks` § What a change did to the
152
+ record). Pass the commit the run started from — the branch point
153
+ (`--base main`) for a whole-branch close-out. Then act by kind, because the
154
+ two kinds have opposite handling:
155
+
156
+ - **Proof got smaller** (`proof/removed`, `proof/weakened`,
157
+ `evaluation/dropped`, `evaluation/relayered`) — a live clause is proven by
158
+ less than it was. Send it back through the implement → review loop to
159
+ restore the proof, then re-run. Do not file the `evaluations:` row over
160
+ the top of it.
161
+ - **Intent moved** (`intent/rewritten`, `intent/vanished`, `doc/removed`,
162
+ `status/downgraded`, `provenance/rewritten`) — **surface to the user and
163
+ stop; do not resolve.** Only `intent/rewritten` is discharged, by a new
164
+ provenance entry naming the clause id, and writing that entry to silence
165
+ your own notice is the one move this check exists to catch. The others
166
+ are never discharged; they print until the change is reverted or the
167
+ user rules on it. Only a user decision amends intent
168
+ (`primitives-format` § Ownership and write points).
169
+ - **Expected movement** (`intent/deactivated`, `proof/changed`,
170
+ `evaluation/moved`, `status/closed-out`) — normal when the plan called for it. Confirm each
171
+ against the plan's **Intent impact** block and report them
172
+ (§ What to report); an unplanned one belongs in the group above.
173
+ - **`doc/unreadable`** — the capability doc stopped parsing, so nothing about
174
+ it was compared and this run's `guard` output means nothing for that
175
+ capability. `evals` fails on it too. Fix the frontmatter and re-run both
176
+ before reading either result.
177
+ 3. **Status** — flip `planned` or `amending` to **`status: built`**, removing
178
+ `plan:` in the same edit, only when `agent_primitives evals` reports no
179
+ errors and no in-flight warnings for this capability; otherwise report the
180
+ gap instead of flipping.
181
+ 4. **Provenance** — append **one** line for the whole run:
182
+
183
+ ```markdown
184
+ - YYYY-MM-DD — built [or amended]: docs/plans/<plan>.md. [Accepted debt,
185
+ rejected alternatives, or notable reviewer-approved exceptions, one line.]
186
+ ```
187
+
188
+ **No run mechanics** — those belong in this run's handoff report
189
+ (§ What to report) and git (`primitives-format` § Provenance).
190
+
191
+ Fold in any **`primitives:` provenance candidates** from the reviewer
192
+ reports (decisions, constraints, accepted debt) — one line each, only those
193
+ that pass the same earns-its-place test.
194
+ 5. **Index** — update the capability's `docs/primitives/index.md` line to the
195
+ new status (it still says `planned` or `amending` from plan approval — sync
196
+ it, don't merely confirm it).
197
+
198
+ If a reviewer report proposed a **`compilation.md` amendment**, surface it to
199
+ the user — that file is human-owned; whoever runs the plan never edits it.
200
+
201
+ ## What to report
202
+
203
+ The run's completion package for the user carries:
204
+
205
+ - **Primitives close-out** summary (§ Close-out pass): status, `evaluations:` updated, `agent_primitives evals` result, the provenance line appended — or why status could not flip. Include each touched clause's tagged-example count from `agent_primitives proofs`, so the user sees the count and not only the claim that it was checked.
206
+ - **`agent_primitives guard` notices** (§ Close-out pass), each with what it was: planned, corrected during close-out, or **awaiting the user's decision** — intent notices are never resolved by whoever runs the plan, so any that remain are the first thing the user must rule on.
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: integrating-primitives
3
+ description: >-
4
+ Wire the imported agent_primitives skills into an app's own workflow: its
5
+ planning, implementing, reviewing, spec-writing and brainstorming skills, its
6
+ agent definitions, and its always-loaded rules. Each gets a one-line hook
7
+ that names the right primitives skill and section at the step where it
8
+ applies. Surveys first, asks the human which files to touch, and shows every
9
+ edit for approval before writing it. Use after `agent_primitives import`,
10
+ after a re-import adds a skill, or when the user says integrate, wire up, or
11
+ hook in the primitives skills.
12
+ ---
13
+
14
+ # Integrating primitives (hooks into the app's own workflow)
15
+
16
+ **Announce:** "I'm using the integrating-primitives skill."
17
+
18
+ <objective>
19
+ Each of the app's workflow files gains a hook at the step where a primitives
20
+ skill applies. The hook names the skill and section, and nothing else. The
21
+ primitives rules keep one home, in the imported skills, and the app's files
22
+ keep theirs. No file changes until the human has seen the edit and said yes.
23
+ </objective>
24
+
25
+ ## Hard rules
26
+
27
+ - **Ask, show, then write.** Nothing is written until the human has confirmed
28
+ the file list (§ 2) and approved that file's edit (§ 4). "Looks fine
29
+ overall" is not approval of a specific edit.
30
+ - **A hook names; it never restates.** One or two sentences: the condition,
31
+ the skill by name in bold backticks, and, where § Hook map gives one, the
32
+ `§` heading copied exactly from that skill. No primitives rule text, and no path to a skill file. The import
33
+ directory is the app's choice, and a copied rule drifts from its source.
34
+ - **Every hook is conditional:** "When the app has a `docs/primitives/` tree,
35
+ follow …". Without a tree, the workflow still reads correctly.
36
+ - **Never edit the imported skills.** `agent_primitives import` overwrites
37
+ them, so a change made there is lost on the next import.
38
+ - **Idempotent.** A file that already names the skill at that step needs
39
+ nothing. Say so and move on.
40
+ - **Do not commit.** The human reviews `git diff` and commits.
41
+
42
+ ## 1. Preconditions
43
+
44
+ - Find `primitives-format/SKILL.md` in the app's skills directories (§ 2 lists
45
+ the usual ones). If it isn't there, stop and ask the human to run
46
+ `agent_primitives import <skills directory>` first. A hook naming a skill
47
+ the editor cannot load is a dead link.
48
+ - A missing `docs/primitives/` tree is fine, because the hooks are
49
+ conditional. Say that `bootstrapping-primitives` sets one up, and ask
50
+ whether to continue.
51
+
52
+ ## 2. Survey, then confirm the file list
53
+
54
+ Read only. Look in:
55
+
56
+ | Kind | Usual places |
57
+ |---|---|
58
+ | Skills | `.claude/skills/*/SKILL.md`, `.cursor/skills/*/SKILL.md`, `.agents/skills/*/SKILL.md`, and any directory the human names |
59
+ | Agent definitions | `.claude/agents/*.md`, `.cursor/agents/*.md` |
60
+ | Rules and always-loaded instructions | `CLAUDE.md`, `AGENTS.md`, `.github/copilot-instructions.md`, `.cursor/rules/` |
61
+
62
+ A skills tree exposed to two editors through symlinks is one set of files, so
63
+ dedupe by real path. Leave out the imported primitives skills themselves.
64
+
65
+ Classify each file by the workflow step it drives, judged from what it
66
+ instructs rather than from its name, using § Hook map. One file can drive
67
+ several steps. Leave out files that match no step.
68
+
69
+ Present one list: each file, the steps it drives, the hooks proposed, and
70
+ any existing primitives text found (§ 3). Then ask, with the structured
71
+ question tool where the editor has one:
72
+
73
+ - Is a file missing — a workflow you run that this list does not show?
74
+ - Is a file misclassified, or one you do not want touched?
75
+
76
+ Go on only with the list the human confirms.
77
+
78
+ ## 3. Find what is already there
79
+
80
+ For each confirmed file, at each step it drives:
81
+
82
+ - **Hook present.** The file already names the skill at that step, so there
83
+ is nothing to do.
84
+ - **Embedded primitives text.** The file carries the rules itself, for
85
+ example `intent:` tag mechanics, `evaluations:` rows, status flips,
86
+ provenance line formats, an Intent impact block, or `evals`/`guard`/`proofs`
87
+ under an older executable name. That is a second home that will drift.
88
+ Propose replacing it with the hook (§ 4).
89
+ - **Nothing.** Propose a hook.
90
+
91
+ If you can't tell whether a passage is primitives text or the app's own rule
92
+ in similar words, ask. Never guess at a deletion.
93
+
94
+ ## 4. Propose and confirm, one file at a time
95
+
96
+ For each file, show:
97
+
98
+ - **Where:** the heading and the line the hook follows. Place it at the step
99
+ where the work happens: the gate before drafting, the verify step after
100
+ each task, the close-out at the end. Never in an appendix the agent reads
101
+ after the fact.
102
+ - **What:** the exact text to insert.
103
+ - **Replacing:** the passage to remove, verbatim, next to the hook that
104
+ replaces it.
105
+
106
+ Ask: apply, change the wording or placement, or skip this file. Write only
107
+ on "apply", and show the edit again after any change. A replacement and an
108
+ addition in the same file are approved separately, because the human may want
109
+ the hook without losing their own text.
110
+
111
+ ## 5. Rules and always-loaded files
112
+
113
+ An editor that attaches rules by path, as Cursor does from `.cursor/rules/`,
114
+ loads a skill only when something names it. Offer one stub per path pattern.
115
+ Each stub names only the skill to load:
116
+
117
+ | Path pattern | Skill named |
118
+ |---|---|
119
+ | `docs/primitives/**` | `primitives-format` |
120
+ | `docs/primitives/**`, `spec/**/*.rb` | `running-primitives-checks` |
121
+ | `spec/**/*.rb`, `docs/primitives/**` | `tagging-intent` |
122
+
123
+ ```markdown
124
+ ---
125
+ description: >-
126
+ Intent tags on RSpec examples — load the tagging-intent skill when specs
127
+ interact with a docs/primitives/ tree.
128
+ globs: spec/**/*.rb, docs/primitives/**
129
+ alwaysApply: false
130
+ ---
131
+
132
+ # Tagging intent
133
+
134
+ When the app has a `docs/primitives/` tree, follow the **`tagging-intent`**
135
+ skill before writing, moving, merging, or deleting a spec. No tree → nothing
136
+ here applies.
137
+ ```
138
+
139
+ In `CLAUDE.md` or `AGENTS.md`, add one line to the section that lists skills
140
+ or workflow. Don't add a new section that restates the tree. The same
141
+ confirm-first flow as § 4 applies.
142
+
143
+ ## 6. Verify and report
144
+
145
+ - Every hook names a skill that is in the import directory, and, where it
146
+ cites one, a `§` heading that skill really has. Grep each one.
147
+ - `git status` shows changes only in the confirmed files and in stubs the
148
+ human approved. No imported skill is modified.
149
+ - Report three lists: files changed (hook added or passage replaced), files
150
+ skipped and why, and hook-map steps no file hosts. For example: "no review
151
+ skill found, so `reviewing-primitives` is not wired." The third list is the
152
+ gap the human still owns.
153
+
154
+ ## Hook map
155
+
156
+ | Workflow step | Hook names | Place it |
157
+ |---|---|---|
158
+ | Shaping a feature or writing a requirements spec | `planning-with-primitives` § In a requirements spec | before approaches are proposed |
159
+ | The spec's intent block | `planning-with-primitives` § Intent (in the spec) | where the spec template lists outcomes |
160
+ | Writing a plan | `planning-with-primitives` § Primitives gate | before any task is drafted |
161
+ | The plan header | `planning-with-primitives` § Intent impact block | in the header template |
162
+ | Plan tasks | `planning-with-primitives` § Citing clauses in tasks | in the task template and the self-review |
163
+ | Plan approved | `planning-with-primitives` § At final approval | after the plan's last review approves |
164
+ | Plan revised | `planning-with-primitives` § When the plan is revised | in the revision procedure |
165
+ | Handing work to a reviewer | `running-primitives-checks` § Handing the output to a reviewer | where the reviewer's inputs are assembled |
166
+ | Starting to run a plan | `closing-out-primitives` § Before starting work | before the first task |
167
+ | Implementing one task from an excerpt | `closing-out-primitives` § Working from an excerpt | at task start |
168
+ | Finishing one task | `closing-out-primitives` § Verifying one task | before the task reports done |
169
+ | Fixing finished work after feedback | `closing-out-primitives` § When finished work is revised | in the fix loop |
170
+ | Finishing a plan | `closing-out-primitives` § Close-out pass, then `closing-out-primitives` § What to report | after the last task approves |
171
+ | Reviewing a plan or a change | `reviewing-primitives` § Inputs, `reviewing-primitives` § Checks, `reviewing-primitives` § Report section | in the review checklist and the report template |
172
+ | Refactoring specs | `reviewing-primitives` § Auditing tagged examples in a spec refactor | before any example moves or merges |
173
+ | Writing tests | `tagging-intent` | at the end of the spec checklist |
174
+ | Pre-handoff checks | `running-primitives-checks` | where the app's other checks are listed |
175
+
176
+ An agent definition that runs one of these steps itself gets the same hook
177
+ as the skill for that step. An agent that only delegates to a skill that is
178
+ already hooked needs nothing.
179
+
180
+ ## Related
181
+
182
+ - **No tree yet:** `bootstrapping-primitives`
183
+ - **The tree's format:** `primitives-format`
184
+ - **The commands the hooks invoke:** `running-primitives-checks`
@@ -0,0 +1,169 @@
1
+ ---
2
+ name: maintaining-primitives
3
+ description: >-
4
+ Maintain the primitives tree under docs/primitives/ — capability docs with
5
+ intent clauses, evaluations, append-only provenance, plus the human-owned
6
+ compilation.md. Operations: capture (backfill an existing feature —
7
+ backfilling-primitives), trace ("why is X like this"), update (sync
8
+ status/evaluations/provenance), lint (health pass). Not for app code or plans; adoption setup:
9
+ bootstrapping-primitives; checks: running-primitives-checks.
10
+ ---
11
+
12
+ # Maintaining primitives (durable intent, evaluations, provenance)
13
+
14
+ <objective>
15
+ Keep the durable primitives tree under **`docs/primitives/`** healthy outside
16
+ the standard planning and execution write points: point backfills at
17
+ `backfilling-primitives`, answer "why is X like this" with citations, sync
18
+ docs after off-workflow changes, and run health passes.
19
+ </objective>
20
+
21
+ **Announce:** "I'm using the maintaining-primitives skill."
22
+
23
+ Structure, ownership, and size limits: the **`primitives-format`** skill
24
+ (read it before touching any path under `docs/primitives/`). CLI semantics
25
+ (`evals` / `guard` / `proofs`): the **`running-primitives-checks`** skill.
26
+ Skeletons: **`references/templates.md`**. One-time adoption (tree scaffold +
27
+ `compilation.md` interview): **`bootstrapping-primitives`**.
28
+
29
+ ## When to use
30
+
31
+ - **Backfilling** a capability doc for an existing feature (`capture`) — the
32
+ procedure is the **`backfilling-primitives`** skill.
33
+ - Answering **"why is X like this?"** with citations (`trace`).
34
+ - **Syncing** a doc after work landed outside the standard workflows (`update`).
35
+ - A **health pass** over the tree (`lint`).
36
+
37
+ **When not to use:** Writing plans (`planning-with-primitives` owns Intent
38
+ and Shape authorship during planning), executing plans
39
+ (`closing-out-primitives` owns the close-out pass), or app implementation.
40
+ Those workflows write to the tree at their own defined points — this skill
41
+ covers everything outside them.
42
+
43
+ Layout, ownership, and the three-file reading contract are
44
+ `primitives-format` § Layout / § Reading contract. The
45
+ one exception is **`lint`**, which sweeps every doc by design.
46
+
47
+ ## Operations
48
+
49
+ | Op | Intent |
50
+ |----|--------|
51
+ | **capture** | Backfill a capability doc for an existing feature — the procedure is the **`backfilling-primitives`** skill. |
52
+ | **trace** | Read `index.md` → the capability doc → answer with citations to clause IDs, provenance lines, and spec paths. If the answer predates the doc, say so — provenance before the backfill line lives in git. |
53
+ | **update** | Sync one doc: status (including human-directed deprecation — `status: deprecated`, a provenance line saying why, and the index line moved to the Deprecated stub section), `evaluations:` against real spec homes and their `intent:` tags, one provenance line per event. Update `index.md` in the same change. Close with **`agent_primitives guard`** and read your own diff back (below). |
54
+ | **lint** | Run **`agent_primitives evals`** first, then the judgment checks below across the tree (the one whole-tree operation — exempt from the three-file contract); report findings, fix mechanical ones, leave judgment calls to the human. |
55
+
56
+ **Structural reshaping** — splitting an oversized capability, merging, or
57
+ renaming — is a human-approved **`update`**: redistribute the Intent clauses
58
+ to the new docs (tombstone pointers from the old doc, IDs never reused), carry
59
+ provenance forward by link rather than rewriting history, and sync `index.md`
60
+ in the same change. Lint only *reports* the split tripwire; the human decides;
61
+ an `update` pass executes.
62
+
63
+ ### Close every writing pass by reading your own diff back
64
+
65
+ Any operation or skill that **wrote** to the tree ends with:
66
+
67
+ ```bash
68
+ agent_primitives guard --base <the commit the pass started from>
69
+ ```
70
+
71
+ It is notice-only and never fails, and it is the one check aimed at the pass
72
+ itself rather than at the tree: what did this change do to promises that already
73
+ existed. A maintainer holds the widest write access of any agent here, so it is
74
+ also the agent whose edits most need reading back.
75
+
76
+ - **Expected, and worth reporting**: `intent/deactivated` for a human-directed
77
+ deprecation, `proof/changed` after a spec home moved, `evaluation/relayered`
78
+ where the human approved the new layer.
79
+ - **Fix before reporting**: `evaluation/dropped` or `proof/removed` on a clause
80
+ that is still active — a sync pass that removes proof from a live promise has
81
+ gone past syncing.
82
+ - **Stop and hand to the human**: `intent/rewritten`, `intent/vanished`,
83
+ `provenance/rewritten`. Clauses are human-co-owned and provenance is
84
+ append-only; a maintainer that rewrote either has edited the record rather
85
+ than maintained it. Report the notice verbatim, restore what you overwrote,
86
+ and let the human decide. Never discharge one of these by writing the
87
+ provenance entry that silences it — the entry states a decision, and the
88
+ decision is not yours.
89
+
90
+ ### lint — run the tool, then judge
91
+
92
+ **Step 1 — `agent_primitives evals`.** It settles everything mechanical
93
+ (`running-primitives-checks` § Checked mechanically).
94
+
95
+ ```bash
96
+ agent_primitives evals # exits 1 on findings
97
+ agent_primitives evals --format json # when you want to summarise a large tree
98
+ ```
99
+
100
+ Report its findings as-is — they have file:line and a code, so do not restate
101
+ them in prose. Fix the unambiguous ones (a stale path, a missing tag). Leave
102
+ anything that changes what a clause *means* to the human. Its in-flight
103
+ warnings (`clause/in-flight`, `tag/in-flight` — `running-primitives-checks`
104
+ § Checked mechanically) are an honest state — never "fixed" into silence. `clause/unproven` is closed by
105
+ writing the spec, never by editing the clause out of the doc.
106
+
107
+ **Step 2 — the judgment checks the tool cannot make:**
108
+
109
+ - **Umbrella clauses** — a clause built on *manage*, *handle*, *support*, or an
110
+ `and` joining two different actions
111
+ (`primitives-format` § Intent clauses). Mechanical
112
+ hint: a clause needing four evaluations is usually a clause needing
113
+ splitting. Report it as a proposed split with the per-action sentences written
114
+ out — the ids are a human call.
115
+ - **Rows that do not prove their clause** — for each `built` clause, read its
116
+ wording against its tagged examples and ask whether breaking the clause would
117
+ turn one of them red
118
+ (`tagging-intent` § What counts as proving a clause).
119
+ Quantifiers are where the rot collects. Report it as an unproven clause with
120
+ the missing case named; narrowing the clause instead is a human call. Check
121
+ the reverse too — an evaluation that could be deleted with the clause still
122
+ fully proven is a padded row.
123
+ - Every capability doc listed in `index.md`, and vice versa; statuses agree.
124
+ - **`index.md` lines that do not discriminate** — the tool checks a line
125
+ exists, not that it earns its place
126
+ (`primitives-format` § Finding the right capability).
127
+ Read the list as a stranger deciding which doc to open: two lines that could
128
+ describe each other's capability are a finding, as is a missing `Owns:` on a
129
+ capability whose filename is not a resource name.
130
+ - **Names that fight the flat namespace**
131
+ (`primitives-format` § Style) — propose renames
132
+ sparingly and say the cost out loud: the filename is what `intent:` tags
133
+ name, so a rename retags every proving example.
134
+ - An `amending` doc that is actually **abandoned**. `status/plan-missing`
135
+ catches a plan file that is gone, but only a reader can tell that nobody is
136
+ running a plan that is still on disk. Check its age and whether any branch
137
+ still touches it. Unwinding one is a human call
138
+ (`primitives-format` § Evaluations).
139
+ - A `built` doc with an **unmarked amendment** — its newest provenance line is
140
+ `planned`, the plan is still running, and its new clauses fail
141
+ `clause/unproven`. This is common in trees from before `amending` existed.
142
+ Propose `status: amending` with `plan:` and the index line; the status is the
143
+ human's call.
144
+ - **Size tripwires and prose padding inside the limits** —
145
+ `primitives-format` § Size discipline and § Style.
146
+ - No content that belongs elsewhere: app code, plan tasks, restated app
147
+ conventions, stray files outside the four allowed types.
148
+ - **Process noise in provenance** — run mechanics have no home in the tree
149
+ (`primitives-format` § Provenance). Report as a
150
+ finding; provenance is append-only, so the fix is a human call, not a
151
+ rewrite.
152
+
153
+ ## Delegation
154
+
155
+ A trace, update, or lint pass may be handed to a subagent the app defines for
156
+ primitives passes, if any; this skill stays canonical. That subagent starts
157
+ with no context, so its prompt needs the operation, the paths, and the
158
+ constraints pasted in. A backfill is not delegated — it needs the human
159
+ (`backfilling-primitives`).
160
+
161
+ ## Related
162
+
163
+ - **`primitives-format`** — structure, ownership, size limits.
164
+ - **`running-primitives-checks`** — `evals` / `guard` / `proofs` reference.
165
+ - **`bootstrapping-primitives`** — one-time tree scaffold + `compilation.md`.
166
+ - **`backfilling-primitives`** — backfills a capability doc for an existing feature, interviewing the human.
167
+ - **`planning-with-primitives`** — creates/amends Intent and Shape at planning.
168
+ - **`closing-out-primitives`** — close-out pass writes `evaluations:`, status, provenance.
169
+ - **`reviewing-primitives`** — `primitives:` findings check traceability and eval coverage.