silcrow 0.2.1

Deterministic CLI for a citable, checkable graph of laws in a git tree.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
# Silcrow

Silcrow is an agent overlay that scaffolds coding agents while they build, with no silent drift between the rules and their code over the long run.

It sits on top of the agent CLI you already use, Claude Code, Codex, Cursor or another, and replaces none of them. It instructs the agent through its own CLI, `silcrow agent` and the messages of each command, and checks the agent's work with `check`, the git hooks and `diff`.

An agent changes code faster than anyone rereads it, and a rule you gave it once lives on only in a chat and in the code. The next change, by the same agent or another, can break that rule without anyone seeing it.

So the agent consolidates each business decision you state into structured documentation, laws and their clauses in markdown notes under `docs/decisions/`, and marks and zones the code that carries each one. Silcrow pins every zone to the code it reads and to the text of its law.

When either side moves, `silcrow check` fails until someone reads the code against its law. `silcrow diff` prints the change rule by rule, each behaviour change beside the rule it touches, every rule retired or deleted, then what no rule governs, and `silcrow check` in CI names each change for the person who merges, the merge being the approval. Silcrow does not prove the code right. It makes sure no change to a rule, or to the code under it, gets past a person unseen.

Silcrow governs its own code this way, and [Lade](https://github.com/zifeo/lade) and [Substantial](https://github.com/zifeo/substantial) run on it.

## Example

You tell the agent: "Refunds over 500 need a second approval, and nobody approves their own refund. A refund goes back to how the customer paid." It writes the note and marks the code. After `silcrow fix`, step 2 of [the loop](#the-loop), `docs/decisions/refunds.md` reads:

> # Refunds
>
> Refunds send money out of the company, so a large one needs a second pair of eyes, and the money goes back the way it came in.
>
> **§ <a id="c09206qct">c09206qct</a> A refund over 500 is paid only after a second person approves it.**
>
> - (a) The person who requested the refund cannot be its approver.
>
> **§ <a id="hsqwqt1vn">hsqwqt1vn</a> A refund goes back to the payment method the customer paid with.**

and `src/refunds.ts` reads:

```ts
const LIMIT = 500;

export function canPay(refund: Refund): boolean {
  // § c09206qct@w1wb7
  if (refund.amount <= LIMIT) {
    return true;
  }
  // § c09206qct.a@cnxg2
  const approvers = refund.approvals.filter((who) => !samePerson(who, refund.requestedBy));
  // § end c09206qct.a
  return approvers.length >= 1;
}

function samePerson(a: string, b: string): boolean {
  return a === b;
}

export function refundTarget(order: { paidWith: string }): string {
  // § hsqwqt1vn@962xz
  return order.paidWith;
}
```

- A **law** is one rule: a bold sentence opened by `§` and an id, which is a hash of the sentence. A law the public documentation promises its readers opens `§!`, a public promise, and owes a marker in that documentation besides its code. A **clause** is a lettered item under it, or a row of a table under its head whose first cell is `(a)`, addressed as `c09206qct.a`. A letter is never reused.
- A **marker** is a `§` comment on its own line inside the code that carries a law or a clause. `//`, `#`, `--` or a `/* */` closed on the same line wraps it, and in a page of the public documentation it is `<!-- § c09206qct.a -->`. A `§` after code on the same line fails `check`, and text inside a string is never a marker. [Languages](#languages) gives the constructs a grammar adds, in JSX, Rust macros, YAML, Cedar and Dockerfiles.
- Its **span** is the code it covers: the whole construct that holds it, statements above the marker included, here the function `canPay`, or the lines from the marker down to its `§ end`. A marker on the line above a module-level function spans it. The clause span is cut out of the law span around it. A marker that no span holds fails `check`, and so do two markers on one span, or on two spans that overlap without one holding the other: each address gets the code that carries it. Place a marker in the block that holds its clause first, and add a `§ end` only when the rest of the block is not governed by the clause.
- A **`§ one`** marker spans only the statement or member right below it: a statement, a field, an argument, a match arm or case clause, an enum variant, an object or dict entry, a class member, or in Markdown the next block element. It lists every address that statement carries, `// § one c09206qct.a, 4mzp1x8kd`, and each gets its own pin. Use it only when that statement carries the whole clause: a value computed there and used further down takes the block. It needs a tested grammar and a statement or member the grammar parses, or an entry of a Rust macro. It takes no `§ end`, and fails `check` when its list names an address twice or a law beside its own clause.
- Its **pin** is the digest after `@`. It hashes the span, the code before it in its function, the project functions the span calls by name, as [Following](#following) narrows them, the constants that either names, the imports of those names, and the text of its law's sentence, of the lines under its head and of its clause. `fix` and `accept` write it, never a person.

What fails which pin in these two files:

- `LIMIT = 1000` fails `c09206qct` and `c09206qct.a`. Both read the constant, the clause through the `if` before its span.
- An edit of the filter, or of the body of `samePerson`, which the clause span calls, fails `c09206qct.a` alone.
- `>= 2` on the last line of `canPay` fails `c09206qct` alone.
- An edit of the text of clause (a) fails `c09206qct.a`. An edit of the law's sentence fails both pins, and its id no longer hashes it: for a change of form, `silcrow accept c09206qct` remints the id, rewrites every pointer to it and re-pins every pin of the law, its clause markers included, naming each. `silcrow accept c09206qct.a` re-pins that clause alone, and [Check and accept](#check-and-accept) takes several at once.
- An edit of `refundTarget` fails `hsqwqt1vn` alone.
- Reformatting, a comment, renaming `who`, `refund`, or `samePerson` with its call, or moving `samePerson` within the file fails nothing.

When the agent later makes `samePerson` compare lowercase, as in [the loop](#the-loop), `silcrow diff` shows the reviewer the law, the clause, its span and the callee that changed, here through delta:

![silcrow diff in a terminal, side by side: law c09206qct and its clause (a) as one hunk of the decision note, the span of the clause, and the patch of the followed callee samePerson, which now compares lowercase](docs/assets/diff.png)

## The loop

1. **You state the rules**, as above.
2. **The agent writes the note and marks the code.** It never picks an id: it writes a provisional name, `**§ +second-approval A refund over 500 ...**`, a `(+)` in place of each letter, and markers that name them, `// § +second-approval.a`. Then:

   ```console
   $ silcrow fix
     MINT +second-approval -> c09206qct
     MINT +target -> hsqwqt1vn
     LETTER c09206qct.a
     REWRITE docs/decisions/refunds.md
     REWRITE src/refunds.ts
     PIN src/refunds.ts

   ✓ Fixed. Run `silcrow check`.
   ```

   The files now read as in the example. `check` fails while a provisional name or a `(+)` is left, and the `pre-commit` hook runs `fix` and `check` on every commit.

   A rule decided before its code is a draft: `**§? +second-approval A refund over 500 ...**` for a law, `**§!? ...**` for a public promise, `- (+)? ...` for a clause. A draft is declared, cited and listed, owes no marker, and `check` prints it with its age under `Not implemented, not pinned:`, as neither an error nor a warning, and `stats` names the oldest. Once its code and its marker exist, `fix` drops the `?`, which moves no id and no pin.
3. **Weeks later, a change.** "The requester can still approve their own refund when the email case differs." The agent makes `samePerson` compare lowercase. The clause span calls it, so:

   ```console
   $ silcrow check
     ERR src/refunds.ts:8: § c09206qct.a changed since its pin @cnxg2: the followed callee `samePerson` in src/refunds.ts reads otherwise since the last commit that held this pin. Read it against its law or clause with `silcrow diff`, then run `silcrow accept c09206qct.a`.

   ✗ Graph is broken. 3 reference(s) resolved, 1 error(s), 0 warning(s).
   ```

4. **The agent reads the span against clause (a).** The clause still holds, so it accepts the new code:

   ```console
   $ silcrow accept c09206qct.a
     REPIN src/refunds.ts § c09206qct.a
   ✓ Re-pinned § c09206qct.a.
   ```

   Had the clause no longer held, it would fix the code, or strike the law and write a successor.
5. **The reviewer runs `silcrow diff`.** Under `c09206qct`, a behaviour change accepted, they read the clause, the new pin, and the patch of `samePerson`, as in the picture above. `silcrow diff --md` prints the same entry as a packet, which [Review with `diff`](#review-with-diff) shows. The reviewer can be another agent, as [Review by another agent](#review-by-another-agent) shows. Merging ratifies it.
6. **CI runs `silcrow check --all` on the pull request.** It compares against the branch the pull request targets, names each change for the person who merges under the packet of the review, and passes, since the merge is the approval, as [CI](#ci) details:

   ```console
   $ silcrow check --all
   # Silcrow: 1 change(s) named for the person who merges

   - [.] § c09206qct: 1

   # Silcrow review against 0e9c74a1be675508fe13104e0578ff3f8bbcdc70
   ...
   Changed since the comparison point, named for the person who merges, as the packet above shows:
     [.] § c09206qct, 1 change(s):
       [.] src/refunds.ts:8: § c09206qct.a carries @ghxv4, and 0e9c74a1b pinned it here as @cnxg2: it was re-pinned.

   ✓ Graph is closed. 3 reference(s) resolved, 0 error(s), 0 warning(s), 1 change(s) named.
   ```

## Install

Prebuilt binaries for macOS (x86_64, aarch64) and Linux (x86_64, aarch64, gnu and musl) are attached to each [GitHub release](https://github.com/zifeo/silcrow/releases), with a `.sha256` beside each archive. The installer picks yours, checks the checksum, failing when it is missing or does not match, and moves `silcrow` to `/usr/local/bin`, with `sudo` if that folder is not writable:

```sh
curl -fsSL https://raw.githubusercontent.com/zifeo/silcrow/main/installer.sh | bash
```

Variables on the `bash` side of the pipe change it: `VERSION=0.2.1` pins a release, `OUT_DIR=~/.local/bin` changes the folder, `PLATFORM=x86_64-unknown-linux-musl` overrides detection. From crates.io:

```sh
cargo install silcrow --locked
```

Then, at the root of a git repository:

```console
$ silcrow install
wrote /home/dev/shop/.agents/skills/silcrow/SKILL.md
wrote /home/dev/shop/AGENTS.md
wrote /home/dev/shop/.git/hooks/pre-commit
wrote /home/dev/shop/.git/hooks/post-merge
wrote /home/dev/shop/.git/hooks/post-rewrite
wrote /home/dev/shop/.git/hooks/commit-msg
wrote /home/dev/shop/.git/hooks/pre-merge-commit
wrote /home/dev/shop/.git/hooks/pre-push
```

It names only the files it writes, so a second run prints nothing. That is the whole setup. Your agent reads `AGENTS.md`, finds the Silcrow block and the skill, and runs `silcrow agent` for the protocol, so you never name Silcrow in a prompt. The protocol tells it that every file it writes states the product as it is or as a person decided it will be: a decided promise not built yet is a draft, a dated record states the past as past, a current limit is written as the supported scope, and a promise nobody decided goes to the tracker.

This is the block `install` writes at the top of `AGENTS.md`, in full. The rest of the file is yours, and `install` leaves it as it is:

```html
<silcrow notes="docs/decisions/**/*.md" default-branch="main" code="**/*" docs="" tests="conventions" test-markers="error" note-words="error:3000">
This repo follows [Silcrow](https://github.com/zifeo/silcrow).
Decisions: `docs/decisions/**/*.md`. Usage: `silcrow help`.
Engineering principles:
- Locality: keep behavior, data, and decisions close to where they are used, and fix a shared defect once at its source.
- Explicitness: make inputs, outputs, dependencies, and failure modes visible.
- Economy: use the smallest mechanism that completely solves the problem, reusing existing code before adding any, and finish every caller, test, and fixture it touches.
- Stability: preserve observable behavior, including error handling and validation, across refactors unless a law changes it.
- Decisions: state each law as a business decision, in plain and abstract words a person can reason about and steer behavior with, never as a restatement of the code, and leave out any value or detail with no reason behind it.
- Verifiability: prefer deterministic behavior that can be checked directly, leave a test for new non-trivial logic, and name what was skipped or left unchecked.
- Order: make it work, then make it right, then make it fast only when a measured need or a law demands it.
</silcrow>
```

The principles are generic guidance for the agent, never parsed or cited. The skill, `.agents/skills/silcrow/SKILL.md`, is a pointer that tells the agent to run `silcrow agent`, so the protocol comes from the binary and never goes stale.

The attributes of the opening tag are the whole configuration of a project. `install` writes all seven, keeps the values you set and writes the value below for one the block omits: edit them in place.

| Attribute | Values | Written by `install` | What it decides |
| --- | --- | --- | --- |
| `notes` | patterns from the project root, split on spaces, gitignore style | `docs/decisions/**/*.md` | Which Markdown files are decision notes. A pattern opening with `!` excludes, and the last pattern that matches a file decides: `notes="docs/**/*.md !docs/archive/**"` reads every note under `docs/` but the archive. |
| `default-branch` | a branch | `origin/HEAD`, else the current branch | The branch changes land on, which `diff` compares against, and whose history keeps the ids, letters and aliases a law once held. |
| `code` | patterns, as `notes` | `**/*` | The files whose markers pay the code duty: every active clause, or law with none, owes a marker in one. A Markdown file never pays it. |
| `docs` | patterns, as `notes` | none | The public documentation, a manual, guide, API spec or FAQ, in any language with a comment syntax, `docs="website/docs/**/*.html"` for a site: every active public promise, a law written `§!`, owes a marker of itself or of a clause in one, and fails `check` while the list is empty. A plain law owes code alone and may carry a documentation marker too. A file it matches is documentation even when `code` matches it, and a marker in any other Markdown file that is not a decision note fails `check`. In MDX a marker is `{/* § <id> */}`. |
| `tests` | patterns, as `notes`, or `conventions` | each language's convention | The test code, which a pin reads apart from the code it tests and `stats` counts apart: by default a file under `tests/`, Go `*_test.go`, Python `test_*.py` and `*_test.py`, JavaScript and TypeScript `*.test.*`, `*.spec.*` and `__tests__/`, Java and Kotlin `src/test/`. `conventions` names them. A written list replaces the conventions, and Rust items compiled only for tests stay test code. |
| `test-markers` | `error`, `warn` or `allow`, then rules `<glob>:<value>` | `error` | What `check` does with a marker in test code: `error` fails it, naming the attribute, `warn` keeps it valid with a warning, and `allow` keeps it valid. Under `warn` and `allow` it pays the code duty as any other. Each rule sets the value for the test files its glob matches, the last match winning: `error tests/conformance/**:allow` admits markers in a conformance suite alone. Allow them where a test is the one carrier of a law, as when the deciding code is a compiled module or another repository's service, and keep markers on the deciding code everywhere else. |
| `note-words` | a positive integer, after `error:` or `warn:` | `error:3000` | The words a decision note holds at most, counted as the whitespace-separated tokens of its file. `check` fails a longer note, or warns on it under `warn:`, and says to split it by sub-topic into a directory of the same name, `docs/decisions/refunds/` for `refunds.md`. |

A block that omits an attribute fails `check`, which names it and `install`. An unknown attribute or a value `check` cannot read fails it, and `install` too, which then writes nothing. A block that a commit holds is read in the names and values it was written in, so a comparison and the history read across a rename. Nothing else is configured: no other file or flag sets a project's policy, and what a pin follows is set in the code, by the marks under [Following](#following).

`silcrow upgrade` replaces the binary with the latest release, after a confirm that `--yes` skips, and `--version 0.2.1` picks one. See [How do upgrades work?](#faq) for the release notice.

## Adopt an existing project

A project with code, docs and tests already made its decisions. Tell the agent to adopt it, and `silcrow agent adopt` gives it the method:

- Writers draft the laws, one per note in parallel. A verifier of a stronger model, or at least a fresh context, gets the code and the docs but never the writers' conclusions, and tries to refute each law. A gap finder names each promise no law covers.
- It reads the promises and the docs first, then the tests, then the code: code says what happens, the docs and tests say what is promised.
- It adopts with `docs=""` first. Once the laws are true and reviewed, it asks you which public documentation the project has, names it in `docs` and marks `§!` only the laws those docs promise. A business rule that must not be public stays a plain `§`.
- A law is written for the person who reviews it, in the form `silcrow agent author` gives any note: present tense, active voice, one of the five EARS shapes, no RFC 2119 capitals, a table for clauses that vary along an axis.
- A law needs a reason a source independent of the adoption states and someone who relies on it, and says what the product does or supports, never only what it does not.
- A gap between code and docs is settled by rule, a documented promise winning over the code. Only a business choice no rule settles comes to you, with its evidence.
- `docs/silcrow-adoption.md` keeps the ledger by hand: what was decided, what was removed, and the questions left for you.
- It stops when every promise maps to a law and a fresh review finds no false law and no wrong carrier, or at a cap on rounds. It never installs hooks in a checkout whose hooks another tree shares, and never writes outside the project.

## What a pin reads

A pin reads a closure of whole syntactic units around its span, as the [Example](#example) shows. Silcrow never models what a language means by a name, and narrows one only by its text. The rules and the closed list of what narrows a name are [docs/decisions/contract.md](docs/decisions/contract.md), what normalises away is [docs/decisions/contract/normalisation.md](docs/decisions/contract/normalisation.md), and the list of what is not read is [docs/decisions/limits.md](docs/decisions/limits.md).

Beyond the pins, `check`, `diff` and the check in CI catch:

- an edit of the text of a law or a clause, or of the context between its head and its clauses, even when no pin hashes it;
- a law, a clause or an alias anchor deleted without a strike, which `diff` lists first;
- a marker a law owes missing, a pointer to an id that does not exist, a marker on a retired clause;
- a merge that git sees as clean, where one side changed a law and the other changed a marker of it;
- every re-pin and every removed pin, which `diff` shows, `log` counts and the check in CI names.

Nothing catches whether the code does what the law says, code that carries a rule but has no marker, two laws that contradict each other, a commit no Silcrow hook ran on (see [Hooks](#hooks)), or a reviewer who approves without reading. The Quint model under `spec/` checks the lifecycle of laws and pointers, not the code duty: its replay against the binary sets aside a missing code marker, as it sets aside a drift.

Formatting, whitespace, comments and trailing commas do not move a pin, nor does the rename of a local, nor the rename of a followed function or constant with all its calls and reads where no import line spells its name. A formatter does not either: quote style, parentheses and braces that change nothing, a block rustfmt wraps around a match arm, the layout, grouping and order of import lines, a setext heading or a bullet character read as what they render or run, measured on rustfmt, ruff format, `ruff check --select I --fix` and deno fmt. The few rewrites that still move a pin are listed in [docs/decisions/limits.md](docs/decisions/limits.md). Reading whole units costs noise rather than missed reads:

- An edit above a span in its function drifts it, so every marker of a long function drifts on an edit near its top.
- Moving code or a file, or renaming a function across files, drifts the callers whose imports it rewrites, since an import is read as its tokens, and the callers whose cone it enters or leaves.
- Declaring a second function of a name a span calls drifts the span, since the name then reads neither.
- Renaming a recursive function, a boundary or a `silcrow:technical` function drifts its callers, since a call into a cycle, a boundary or a function Silcrow does not follow keeps its name.
- Renaming a project type also drifts its readers, since types stay in the digest. So does renaming a local that a Rust format string captures, a Python parameter a caller may bind by name, or a name bound in a class body.

## Languages

In git every tracked or unignored file is walked, under `target/` or `node_modules/` too; outside git those directories are skipped. A symbolic link is skipped, whatever it points to. Tested grammars are parsed with Tree-sitter.

| Language | Extensions |
| --- | --- |
| Rust | `.rs` |
| Python | `.py` |
| JavaScript, JSX | `.js`, `.jsx`, `.mjs`, `.cjs` |
| TypeScript | `.ts`, `.mts`, `.cts` |
| TSX | `.tsx` |
| HTML | `.html`, `.htm` |
| CSS | `.css` |
| HCL | `.hcl`, `.tf`, `.tfvars` |
| Bash | `.sh`, `.bash` |
| YAML | `.yaml`, `.yml` |
| Cedar | `.cedar` |
| Dockerfile | `.dockerfile`, `.containerfile` |
| Prisma | `.prisma` |
| JSONC | `.jsonc` |
| Markdown | `.md`, `.markdown`, `.mdx` |

Some grammars give a marker a construct of its own:

- Among the children of a JSX element, a marker is `{/* § c09206qct.a */}` on its own line and spans the child right below it, as `§ one` does: a prop of that child moves its pin, a sibling after it does not, and a sibling before it does, as code before its span.
- In the token tree of a Rust macro, a marker spans the tokens below it up to the next `,` or `;`, or through a `{ }` block after `=>`: a `tokio::select!` arm or a `json!` entry. One inside a field initializer or before a match arm guard spans that field or arm.
- A marker above a Cedar policy spans it, and in a Dockerfile the instruction right below it.
- In YAML a marker spans the mapping entry or sequence item right below it, nested entries included. Its pin also reads, from the document root down, the key of each entry around its span, the position of each sequence item around it and the scalar entries of each mapping around it, `name: api` among them, but not their nested blocks: moving `privileged: true` under another key or container, or renaming its container, moves the pin, and an edit of a sibling `env` block does not. Put the marker of a rule about one container above its item, `- name: api`. A key repeated in a mapping that holds or encloses a span fails `check`, since most YAML readers keep the last one.

A `.yaml` or `.yml` file under a `templates` directory reads as a Helm template: YAML whose Go template actions `{{ }}` read as their text, an action alone on its line as a line of its own. One that does not parse as YAML once its actions are set aside fails `check`, and a `.tpl` helper gets the fallback.

A file named `Dockerfile` or `Containerfile`, or `Dockerfile.<suffix>`, reads as a Dockerfile, and `tsconfig.json`, `tsconfig.<name>.json`, `jsconfig.json` and `deno.json`, whose readers accept comments and trailing commas, read as JSONC. Any other `.json` file is strict JSON, which has no comment to hold a marker, so it gets the fallback, as a `.json5` file does.

Every other extension, Go, Java, Kotlin, C, C++ and Ruby included, gets a fallback pin over the text from the marker to the end of the file, or to its `§ end` line, so any edit in that stretch drifts it, and a `§ one` marker there fails `check`. `fix` and `check` warn once per file and link an issue to request the grammar:

```text
WRN svc/pay.go: `Go` has no tested grammar, so its pins use a fallback heuristic. Each span runs to the end of the file, or to its `§ end` line, so a pin is coarse and will drift often. Tested languages: rust (.rs), python (.py), javascript (.js, .jsx, .mjs, .cjs), typescript (.ts, .mts, .cts), tsx (.tsx), html (.html, .htm), css (.css), hcl (.hcl, .tf, .tfvars), bash (.sh, .bash), yaml (.yaml, .yml), cedar (.cedar), dockerfile (.dockerfile, .containerfile), prisma (.prisma), jsonc (.jsonc), markdown (.md, .markdown, .mdx). Search existing requests: https://github.com/zifeo/silcrow/issues?q=is%3Aissue+Add+tested+grammar%3A+Go  Request support: https://github.com/zifeo/silcrow/issues/new?title=Add+tested+grammar%3A+Go
```

Avoid the fallback for code that carries laws.

## Following

A law is often carried out by a function and the helpers it calls, so a pin follows the project functions its span calls by name, and what those call in turn, each by its shape: renaming a helper or its locals, making it `pub` or `export`, or editing a TypeScript type leaves callers alone. A Python annotation moves them, since pydantic, FastAPI and dataclasses read it at run time: one in a followed body, and a field annotation of a class the span constructs by calling it. A field read through an instance, `refund.amount`, or a class named only as a type moves nothing, as [docs/decisions/limits.md](docs/decisions/limits.md) states. A call through a value Silcrow cannot name, `x.f()` or a trait method, is not followed: call a helper by name, through its type or class, or through `self`, `this` or `cls`. A span whose every statement is such a call to a name the project declares, with only names and fields of names as its arguments, guards nothing and fails `check`: move the marker onto the code that acts, or mark the call `silcrow:follow`. A call whose arguments hold any other expression carries what they decide, and so does a call to a library function, `min(amount, cap)`, by its name. A name that more than one function answers, after its own file, its qualifier and, in Rust, the workspace crate its path or `use` line starts at narrow it, follows none, Rust `cfg` twins aside. Enums are not followed. Constants are.

A TypeScript or JavaScript import through a path alias, `@/lib/cap`, reads the project file it names when the nearest `tsconfig.json` `compilerOptions.paths` or `deno.json` `imports` maps its prefix to one path. A call follows only into its cone: the directory of the caller's file and every directory below it. Code beside or below the rule is part of it, and a shared helper elsewhere is part of it only once you mark it `silcrow:functional`. [docs/decisions/contract.md](docs/decisions/contract.md) states the rules.

A function whose own marker covers its whole body is a boundary: its pin already guards it, so callers do not follow it, and `check` warns with their laws when it drifts. Four marks change what is followed. Each is a comment on the line before a function or a call:

| Mark | Where | Effect |
| --- | --- | --- |
| `// silcrow:technical` | before a function | No caller follows it. For logging, formatting and other plumbing. |
| `// silcrow:functional` | before a function | Every caller follows it, even when it is a boundary or outside the caller's cone. |
| `// silcrow:skip` | before a call | That call is not followed. |
| `// silcrow:follow` | before a call | That call is followed, even into a boundary or outside the cone. A method called on a value, `this.policy.allows(r)`, follows the one method of its name in the project, other than the one it sits in. A marked call that names none, a library call or a call on a value such as `once(x).map(fee)`, passes the mark to the calls and names it holds, down to those that name a function, class or constant of the project. A mark that reaches none fails `check`, naming the rule that refuses it and a form that would pass, such as `crate_a::ensure(..)` or `use crate_a::ensure;`. |

| Symptom | What to do |
| --- | --- |
| My pins drift too often. | Keep one law to one function. Mark shared plumbing `silcrow:technical`, or give it its own law so it becomes a boundary. Close a stretch with `// § end <address>` when the rest of the block is not governed by the clause. Mark the clause the code implements, not the whole law. |
| I want to see which pins read the most. | Run `silcrow stats`: per law, the bytes each pin reads and the bodies it follows, and the bodies the most pins follow. |
| A business rule changed and nothing failed. | Check that the helper sits in the caller's cone, that no other function shares its name, and that it is neither `technical` nor a boundary: mark it `silcrow:functional`, or put `silcrow:follow` before the one call that needs it. Check that [docs/decisions/limits.md](docs/decisions/limits.md) does not list the change as not read. |

`silcrow agent code` gives your agent the same guidance.

## Review with `diff`

`silcrow diff` compares your work with the point where it left the default branch, or with any revision or range you pass. The rule is the unit, not the file. It prints one entry per law the change touched, riskiest first: deleted, retired and removed laws, then accepted behaviour changes, then new laws and other text changes. Under each law come its sentence and each clause the change touched, and under each of those every place that moved for it, in any file or language: the span on both sides, the code before the span, the followed callees that changed, and the doc sections that carry it. A changed callee, or YAML keys above a span, that more than one place reads shows once, first, under shared causes, with each law and pin that reads it and the `accept` of exactly those addresses, one command per project, and each place names it instead of repeating its patch. It ends with the changes no law governs.

Here the branch of the loop also struck `hsqwqt1vn` and declared a successor that allows store credit, in the code and in a new guide page, and it added a currency suffix to a formatter no law governs. `silcrow diff --md` prints:

````markdown
# Silcrow review against 0e9c74a1be675508fe13104e0578ff3f8bbcdc70

3 laws: 1 retired, 1 behaviour change accepted, 1 new. 2 files changed under no law.

Each section is one law. Read its text, then each place under it: the spans, the code before them, the followed callees and the doc sections that changed. Judge whether they still do what the text says. Then judge whether a change under no law carries a rule that lacks a law or a marker.

## § hsqwqt1vn: retired

Decision note `docs/decisions/refunds.md`.

Check: does nothing still rely on hsqwqt1vn, and does its successor, if any, carry what still holds?

~~A refund goes back to the payment method the customer paid with.~~

<details>
<summary>Patch of hsqwqt1vn</summary>

```diff
diff --git a/docs/decisions/refunds.md b/docs/decisions/refunds.md
--- a/docs/decisions/refunds.md
+++ b/docs/decisions/refunds.md
@@ -1,1 +0,0 @@ text of hsqwqt1vn
-A refund goes back to the payment method the customer paid with.
```

</details>

* `src/refunds.ts:19`: span of hsqwqt1vn, removed.

```diff
diff --git a/src/refunds.ts b/src/refunds.ts
--- a/src/refunds.ts
+++ b/src/refunds.ts
@@ -18,4 +17,0 @@ span of hsqwqt1vn, removed
-export function refundTarget(order: { paidWith: string }): string {
-
-  return order.paidWith;
-}
```

## § c09206qct: behaviour change accepted

Decision note `docs/decisions/refunds.md`.

Check: does the code below still do what c09206qct.a says?

> A refund over 500 is paid only after a second person approves it.

### c09206qct.a: behaviour change accepted

> The person who requested the refund cannot be its approver.

* `src/refunds.ts:8`: span of c09206qct.a, accepted (@cnxg2 → @ghxv4). A callee changed: its patch is below.

```diff
diff --git a/src/refunds.ts b/src/refunds.ts
--- a/src/refunds.ts
+++ b/src/refunds.ts
@@ -9,1 +9,1 @@ span of c09206qct.a, accepted
   const approvers = refund.approvals.filter((who) => !samePerson(who, refund.requestedBy));
@@ -14,3 +14,3 @@ followed callee samePerson
 function samePerson(a: string, b: string): boolean {
-  return a === b;
+  return a.toLowerCase() === b.toLowerCase();
 }
```

## § ngd1hef99: new

Decision note `docs/decisions/refunds.md`.

Check: does the code below do what ngd1hef99 says, and does every place that carries it hold a marker?

**A refund goes back to the payment method the customer paid with, or to store credit when the customer asks for it.**

<details>
<summary>Patch of ngd1hef99</summary>

```diff
diff --git a/docs/decisions/refunds.md b/docs/decisions/refunds.md
--- a/docs/decisions/refunds.md
+++ b/docs/decisions/refunds.md
@@ -0,0 +1,1 @@ text of ngd1hef99
+A refund goes back to the payment method the customer paid with, or to store credit when the customer asks for it.
```

</details>

* `docs/guide/refunds.md:5`: doc section of ngd1hef99, added.

```diff
diff --git a/docs/guide/refunds.md b/docs/guide/refunds.md
--- /dev/null
+++ b/docs/guide/refunds.md
@@ -0,0 +3,4 @@ doc section of ngd1hef99, added
+## Where the money goes
+
+
+The refund goes back to the card or account you paid with, or to store credit if you ask for it.
```

* `src/refunds.ts:19`: span of ngd1hef99, added.

```diff
diff --git a/src/refunds.ts b/src/refunds.ts
--- a/src/refunds.ts
+++ b/src/refunds.ts
@@ -17,0 +18,7 @@ span of ngd1hef99, added
+export function refundTarget(order: { paidWith: string; wantsCredit: boolean }): string {
+
+  if (order.wantsCredit) {
+    return "store-credit";
+  }
+  return order.paidWith;
+}
```

## Changes under no law

No marker covers these lines and no pin reads them. Check: does any of them carry a rule that lacks a law or a marker?

* `docs/guide/refunds.md`: +1 -0
* `src/format.ts`: +1 -1

```diff
diff --git a/docs/guide/refunds.md b/docs/guide/refunds.md
--- /dev/null
+++ b/docs/guide/refunds.md
@@ -0,0 +1,1 @@
+# Refunds
diff --git a/src/format.ts b/src/format.ts
--- a/src/format.ts
+++ b/src/format.ts
@@ -2,1 +2,1 @@
-  return (cents / 100).toFixed(2);
+  return (cents / 100).toFixed(2) + " EUR";
```
````

- **retired**: the law was struck in the note, so it reads as dead where it was declared, and its marker went with it.
- **behaviour change accepted**: the clause is unchanged, so its text reads as it stands, and the code under it moved. This is the entry to read before approving. A patch beside the span shows the code before it or an attribute around it when either changed, then each followed callee that changed, and the reason names a changed import line.
- **new**: the successor and each place that now carries it, the code and the guide section.
- **reminted from `<old>` to `<new>`**: `accept` reminted the law after a change of its words and kept the old id as an alias anchor. It is one entry under the new id, its text as ~~old~~ **new**.
- A law or a clause whose text moved shows on the structure its note writes, each changed run of words as ~~old~~ **new**, a table as a table and a list as a list with each changed row or item marked, a fenced block as its text before and after, with the raw patch folded under it. **context changed** shows the prose between the head and the clauses on both sides.
- A law removed after its strike was merged reads as removed after a published strike, and one deleted with no strike as deleted without a strike, with its last text and code, so nothing disappears unseen.
- **Changes under no law** lists each changed line that no marker covers and no pin reads, here the title of the new guide and the formatter. An import line a pin reads is still listed here, a known limit.

A patch leaves out marker lines, so a re-pin alone moves no line, and the place names the move of its pin once. Without `--md`, only the patches remain, with no prose and no status: per law its text as one hunk of its note, then its code, on a TTY through delta side by side, which paints each place in its language, or the pager when delta is absent. `--json` prints JSON with the same structure, `laws` with their `clauses`, then `ungoverned`, each file with its counts and `hunks`. The clause above reads:

```json
{
  "address": "c09206qct.a",
  "letter": "a",
  "status": "accepted",
  "text": {
    "old": "The person who requested the refund cannot be its approver.",
    "new": "The person who requested the refund cannot be its approver."
  },
  "changes": [],
  "locations": [
    {
      "path": "src/refunds.ts",
      "doc": false,
      "pins": [
        {
          "kind": "accepted",
          "lines": [8, 8],
          "old": "  // § c09206qct.a@cnxg2\n  const approvers = refund.approvals.filter((who) => !samePerson(who, refund.requestedBy));\n  // § end c09206qct.a\n",
          "new": "  // § c09206qct.a@ghxv4\n  const approvers = refund.approvals.filter((who) => !samePerson(who, refund.requestedBy));\n  // § end c09206qct.a\n",
          "why": "A callee changed: its patch is below."
        }
      ],
      "reads": [],
      "callees": [
        {
          "name": "samePerson",
          "path": "src/refunds.ts",
          "old": "function samePerson(a: string, b: string): boolean {\n  return a === b;\n}",
          "new": "function samePerson(a: string, b: string): boolean {\n  return a.toLowerCase() === b.toLowerCase();\n}"
        }
      ]
    }
  ]
}
```

Every report of `list`, `stats`, `diff` and `check` prints text wherever stdout goes, and JSON under `--json`. The arguments of `diff` are revisions alone, as `git diff` takes them: `silcrow diff HEAD~3` compares a revision with the worktree, `silcrow diff main feature` or `silcrow diff main..feature` the two ends, and `silcrow diff main...feature` the merge-base with `feature`. `silcrow diff --law c09206qct` keeps one law, `--law c09206qct.a` one clause, repeatable, and drops the changes under no law, and an address no law of either side declares fails. In a monorepo, `silcrow diff --all` reads every project, the root and each nested one, as one review with paths from the root. A plain `silcrow diff` names each nested project the comparison touched and left unread.

## Review by another agent

One agent makes the change and another reviews it before a person merges. The reviewer needs no context of the first session: the packet holds each rule beside what moved for it, and the `Check:` line of each entry is the question to answer. `silcrow agent review` prints the protocol to the reviewing agent:

1. Run `silcrow diff --md` on the branch, or `silcrow diff --md <ref>` from where the change started.
2. Spawn one fresh finder per law, given its entry and the repository, never the author's summary, and one more for the changes under no law. A finding quotes the clause it breaks and cites the `path:line` that breaks it. Holds is a full answer.
3. Spawn one fresh verifier per finding, given the law and the cited code, never the finder's reasoning. Only a confirmed finding is kept.
4. Report each law as holds, or does not hold with its confirmed findings ranked blocking, important or minor.
5. After a fix, review again only what it touched. Stop when a round confirms nothing new, or after three rounds.

The reviewer never runs `accept` or `fix` on the change under review, with or without `--write`: a re-pin approves it, and a release build writes without `--write`. On the packet above, a verdict reads like this:

> - `hsqwqt1vn`, retired: holds. No place still returns `paidWith` alone, and `ngd1hef99` carries the rule.
> - `c09206qct.a`, accepted: holds. `samePerson` now compares lowercase, so the requester still cannot approve, whatever the case.
> - `ngd1hef99`, new: holds in `src/refunds.ts:19` and `docs/guide/refunds.md:5`.
> - Under no law, important: `src/format.ts:2` fixes the currency of every amount to EUR. That is a rule without a law: declare it or drop it.

## Log

```console
$ silcrow log c09206qct --verbose
[c09206qct] A refund over 500 is paid only after a second person approves it.
  declared  2026-11-17  (4 seconds ago)
  markers  code 2  doc 0  remint 0  accept 0  re-pin 1
  re-pin  b407016  Dev, 17 Nov 2026  c09206qct.a
[c09206qct] declare, Dev, 17 Nov 2026
  + A refund over 500 is paid only after a second person approves it.
```

The genealogy comes from `git log -S`, with no store beside the tree. It follows a law across rewordings and counts every re-pin, and `--verbose` lists them.

## History

`silcrow stats --history` measures whether the laws pay for themselves, from git alone. It reads the first-parent history of the default branch, or the range you pass, `silcrow stats --history v0.1.0..main`, and `--since 2026-09-01` keeps the commits after a date. Per law and clause it counts the re-pins, each under the first cause that holds, as `diff` reads it: `remint` of the address or of the hashing scheme, `span`, `prefix` for the code before the span in its function or the attributes that govern it, `callee`, `import`, `text` of the law or clause, `other` for any other read, and `unread` for a span this binary cannot read in an old commit. Beside them:

- `with_test`: the re-pins whose commit also wrote a marker of the same address, new or re-pinned, in test code.
- `neither`: the re-pins with no change to their own span and no test change, remints and unread spans aside. It is the closest history comes to an accept by reflex.

Per ISO week it counts the commits, those that change a line inside a span, the re-pins by cause, the laws and clauses declared and struck, and the markers added. It ends with the laws and clauses never re-pinned in the range, and the marker lines of the tree against its other lines, per language.

History holds only what was committed: a drift that `check` stopped before the commit never reaches it, so the measure shows what the markers cost, not all they caught.

## Squash

On a branch, a note is a journal: a law can be born and struck before anyone else reads it. `silcrow squash`, run before the merge or on `main` right after, deletes a struck law that was never published. A struck clause becomes `(c) **Retired.**`, which keeps its letter taken. One that was never published and still has an active sub-clause stays as written. A published struck law stays for the removal below. No hook runs it.

## Removing a law cleanly

1. On a branch, strike the law in place, `**§ b02drqepj ~~A refund under 50 is paid the same day.~~**`, then run `silcrow accept b02drqepj`. It deletes the markers of the law and re-pins the code around them:

```console
$ silcrow accept b02drqepj
  UNMARK [.] src/refunds.ts:35 § b02drqepj
✓ Removed the markers of § b02drqepj. Its struck text stays until the published tree holds the strike: run `silcrow accept b02drqepj` again after the merge.
```

2. Merge. Every other branch now reads the law as retired.
3. On a new branch, run it again:

```console
$ silcrow accept b02drqepj
  REMOVE docs/decisions/refunds.md:15 § b02drqepj
✓ Removed § b02drqepj.
```

It deletes the law with its clauses and every line that only referred to it, and refuses while a sentence elsewhere still cites it. `diff` lists it as removed after a published strike. The id is never minted again.

## Eject

`silcrow eject` removes the markers, the follow marks, the `§` and ids in the notes, the `AGENTS.md` block, the skill pointer and the hooks it wrote. Each active law stays as a bold sentence, so the notes remain the record of why the code is the way it is. Struck laws and clauses, tombstones and adoptions go. Preview it first:

```console
$ silcrow eject --dry-run
silcrow: dry-run: nothing will be written
  EJECT AGENTS.md
  EJECT docs/decisions/refunds.md
  EJECT src/refunds.ts
  DELETE .agents/skills/silcrow/SKILL.md
  DELETE .git/hooks/commit-msg
  DELETE .git/hooks/post-merge
  DELETE .git/hooks/post-rewrite
  DELETE .git/hooks/pre-commit
  DELETE .git/hooks/pre-merge-commit
  DELETE .git/hooks/pre-push
--- a/docs/decisions/refunds.md
+++ b/docs/decisions/refunds.md
@@ -3,7 +3,7 @@
-**§ <a id="c09206qct">c09206qct</a> A refund over 500 is paid only after a second person approves it.**
+**A refund over 500 is paid only after a second person approves it.**
...
```

The diff of each file it writes follows the list. A hook or skill file that is not Silcrow's is left alone. Git history is never touched.

## Hooks

| Hook | What it does |
| --- | --- |
| `pre-commit` | Runs `fix` on the staged files, restages them, then runs `check` on the index, so the commit records what was checked. A bare marker that stands for a pin `HEAD` held, while its span hashes to another digest, stays bare and fails the commit, naming `accept`. It refuses a partially staged file that `fix` would rewrite, and a refused commit writes nothing. On a branch that is not shared, neither the default branch nor one a remote-tracking ref names, as `git branch -r` lists them, it prints each error as a warning and lets the commit through, writing nothing `fix` rewrote. |
| `commit-msg` | Appends `Silcrow-Scheme: <scheme>` when history does not already record the scheme of this binary, and `Silcrow-Op: remint` on a commit that only moves digests, ids and alias anchors after a scheme change, so `log` can skip it. |
| `pre-merge-commit` | Runs `check` on a merge as the index holds it, before git commits it. It refuses a failing merge into a shared branch, the default branch included, and on a branch that is not shared warns as `pre-commit` does. |
| `pre-push` | Runs `check` on the commit of each shared branch a push updates, the default branch or one the remote already holds, and refuses the push when one fails. A new branch goes through, for review. |
| `post-merge` | Runs `check` after a pull or merge, and fails on a law changed by one side and its marker by the other. It reports, it does not roll back. |
| `post-rewrite` | Runs `check` after a rebase or `commit --amend`. |

So what a branch that is not shared let through reaches the default branch neither by a merge commit nor by a push, and a fast-forward, which runs no hook, is checked by the push that shares it. Each hook is a three-line script that runs `exec silcrow hook <event>`. `install` writes the six files in `.git/hooks/`. Where a hook manager runs your hooks, `core.hooksPath` set, a `hook.*` git config entry, or a hook file that hk, husky, lefthook or pre-commit wrote, `install` writes no hook and fails, naming the manager and the line `silcrow hook <event> "$@"` to add for each event, and `install --dry-run` and `check` name the same. Every linked worktree runs the hooks of the common git directory, which belong to the main checkout: from a linked worktree, `install` writes the block and the skill pointer and no hook, and names the main checkout to run it in, as `check` does for a hook that differs.

Silcrow manages only its own hooks. A hook file it did not write is never overwritten and never counts as installed: `install` writes the others, then fails, naming each such file with the line `silcrow hook <event> "$@"` to add where that tool runs your hooks, and the copy of your git template that `git init` made as that copy. Silcrow cannot tell whether that hook runs it.

Run Silcrow last, after your formatters and the linters that fix in place (`cargo fmt`, `cargo clippy --fix`, `ruff format`, `ruff check --fix`, Prettier, `eslint --fix`), so it checks the code they leave. With the [pre-commit](https://pre-commit.com) framework, that is the last entry of `.pre-commit-config.yaml`:

```yaml
  - repo: local
    hooks:
      - id: silcrow
        name: silcrow
        entry: silcrow hook pre-commit
        language: system
        pass_filenames: false
        always_run: true
```

A formatter rewrite moves no pin, but for the few [docs/decisions/limits.md](docs/decisions/limits.md) lists. A linter autofix rewrites code into code Silcrow does not prove equal, so it may drift a pin, read and accepted as any drift. On a branch that is not shared the hook only warns: read each such drift with `silcrow diff --law <address>` before you push, then accept them in one call.

Git runs `pre-commit` only for `git commit`, `commit-msg` for `git commit` and `git merge`, `pre-merge-commit` for a `git merge` that makes a merge commit, `pre-push` for `git push`, and `post-rewrite` for a rebase and `commit --amend`. A `cherry-pick` or a `revert` that applies cleanly, and `git am`, run none of the commit hooks, so the commit they land is not checked until it is pushed: run `silcrow check` after one. The hooks read the index, so a file git does not track is not read there: `check` run by hand warns when a pin follows a body in such a file.

While a conflict is unresolved, a path git holds unmerged or a `<<<<<<<` … `=======` … `>>>>>>>` block, `check`, `fix`, `accept`, `list` and `diff` fail before they read the graph, naming the merge, rebase or cherry-pick in progress and each conflicted file with its first conflict line. Two branches that each re-pinned one marker conflict on its line alone: `silcrow fix --write` first resolves exactly those blocks, writing each such marker bare and naming its address to read and `accept`, since neither digest may hash the merged code: never resolve such a conflict by taking one side's `@digest`. Read each with `silcrow diff --law <address>`, then accept them all in one call, `silcrow accept <address> <address>...`. `git add` each file once it is resolved.

Hooks are local to a clone, so run `silcrow check --all` in CI either way. A hook is reported by `check`, which the hooks run, and by `install`, which writes them, never under `CI` or where the git root holds no Silcrow block. `silcrow install --dry-run` lists every hook, block or skill file that differs from this binary, and a skill named `silcrow` in the home directory of an agent, which may load in place of the pointer, and writes nothing.

<details>
<summary>Monorepos</summary>

Every directory whose `AGENTS.md` carries the block is a project, with its own notes and policy. A project's tree stops at the next project, so two projects can carry the same id. A nested project starts as an `AGENTS.md` with a Silcrow block in its folder: write it there, then run `silcrow install` in that folder to complete it. From a folder that holds no block, `install` writes the block of the enclosing project. The hooks and the skill pointer are written once, at the git root.

A marker for a law of another project names its path from the git root:

```python
def total(xs):
    # § libs/money:k924mpp7r@x101z
    return sum(xs)
```

It is checked and pinned against that project's text, so an edit of the law there fails the pin here. A project that must implement another's law adopts it with a paragraph that is only the bold head, `**§ libs/money:k924mpp7r**`, and then owes markers for it. Every verb acts on the nearest project, and `silcrow -C <dir> <verb>` runs it as if started in `<dir>`, as `git -C` does. `check --all`, `fix --all`, `list --all`, `diff --all`, `eject --all` and `accept --drifted --all` act on every project. When `fix --all` fails in one project, it still fixes the others, then fails naming each project that failed. `silcrow agent monorepo` gives your agent this guide in short.

</details>

## CI

```yaml
check:
  runs-on: ubuntu-24.04
  steps:
    - uses: actions/checkout@v6
      with:
        fetch-depth: 0
    - run: curl -fsSL https://raw.githubusercontent.com/zifeo/silcrow/main/installer.sh | VERSION=0.2.1 OUT_DIR="$RUNNER_TEMP" bash
    - run: $RUNNER_TEMP/silcrow check --all
```

`uses: zifeo/silcrow@v0.2.1` with `version: 0.2.1` installs the same binary through the installer and puts it on `PATH`, and the image `ghcr.io/zifeo/silcrow:0.2.1` holds it for a container job.

GitLab has no job summary, so `--review-out <file>` writes the packet to a file, empty when there is nothing to review, and the job keeps it as an artifact the merge request links:

```yaml
silcrow:
  image: alpine:3
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  variables:
    GIT_DEPTH: 0
  script:
    - apk add --no-cache bash curl git
    - curl -fsSL https://raw.githubusercontent.com/zifeo/silcrow/main/installer.sh | VERSION=0.2.1 OUT_DIR=/usr/local/bin bash
    - silcrow check --all --review-out silcrow-review.md
  artifacts:
    paths: [silcrow-review.md]
    expose_as: "Silcrow review"
    when: always
```

The merge is the approval, so the check stays plain. With `CI` set, as CI services set it, `check` compares against the merge-base of `HEAD` and the merge target the forge names: `GITHUB_BASE_REF` on GitHub, `CI_MERGE_REQUEST_DIFF_BASE_SHA`, else `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`, on GitLab, `BITBUCKET_PR_DESTINATION_BRANCH`, `SYSTEM_PULLREQUEST_TARGETBRANCH` on Azure Pipelines, `CHANGE_TARGET` on Jenkins, `BUILDKITE_PULL_REQUEST_BASE_BRANCH` and `CI_COMMIT_TARGET_BRANCH` on Woodpecker, a branch read as `origin/<branch>`. `--base <ref>` names the point anywhere. A check that compares reads every project and prints the `diff --md` packet whenever it holds a change under a law, a pin whose digest held while what it reads moved included, and on GitHub appends it to the job summary, where the person who merges reads it, or writes it to the file `--review-out` names. Under the packet comes one line per change a person must see, grouped per law: a pin that moved or was added, a law reworded, deleted or reminted, the context of a law, a new law or clause, a draft, a public promise made or made plain, an attribute of the block. Those pass, and only what breaks the graph fails, so a legitimate `accept` never turns CI red. A head on an id a removed law carried, and a clause on a burned letter, still fail.

A job with no merge target, a push to `main`, checks coherence and says in one line that it compared nothing. A target the clone does not hold fails and names the fetch, and so does a shallow clone, since the check reads the history of the target for the ids and letters a removed law held: hence `fetch-depth: 0`. `silcrow check --all` also fails on a marker in a file outside every project.

## Check and accept

A project adopted over months keeps errors on its default branch that nobody has repaired yet. So a local `check` prints first the findings of your change, then under `Already there at the fork point with the default branch, <commit>, in files this change left as they were:` the rest, with the same exit status, since a debt is still an error. A finding is yours when it names no file, when the file it names changed since the fork point, the merge-base with the default branch, in a commit, the index or the worktree, or when it is a drifted pin that reads a changed file: its own, a body it follows or the note of its law. When your change adds, deletes or renames a file or edits a block, a drifted pin that held at the fork point is yours too, since a new homonym, a removed body or a new test glob moves it through no file it reads, and `--path` of that file keeps it. Where no fork point can be read, one line says why the findings are not grouped. A comparing check prints one list.

`--path <file>`, repeatable, keeps the findings in that file, read from the working directory, and each drifted pin that reads it, so an edit of a helper shows the drift it causes in its callers. A path that names no file, or a file no project reads as code, a decision note or its `AGENTS.md`, fails. A filtered run neither prints, counts nor fails on a finding outside the filter, and its summary line names the filter. `silcrow -C <dir> check` checks one project alone.

Accept only the drift your change caused, after reading it with `silcrow diff --law <address>`. `silcrow accept <a> <b> ...` re-pins several addresses in one reading of the tree, and writes nothing when one fails, or would remint or remove a law, which is accepted alone. `silcrow accept --drifted --path src/refunds.ts`, repeatable, takes the drifted pins that read those files, and no other pin of their addresses, by the same all-or-nothing rule: the drift of the files you touched. `silcrow accept --drifted` takes every drifted pin of the project, `--all` of every project, for when every drift is yours to approve: after `silcrow fix --remint`, or a refactor you just read in `diff`. The check in CI still names each re-pin.

`silcrow check --json` prints the findings as one JSON object, with the same exit status. A comparing check prints its packet on stderr, so stdout holds the object alone. Fields may be added, and none is renamed or removed:

```json
{
  "closed": false,
  "filter": "--path src/refunds.ts",
  "counts": { "resolved": 12, "errors": 1, "warnings": 0, "drafts": 0, "named": 0 },
  "findings": [
    {
      "kind": "error",
      "project": ".",
      "path": "src/refunds.ts",
      "line": 8,
      "address": "c09206qct.a",
      "cause": "the followed callee `samePerson` in src/refunds.ts reads otherwise",
      "text": "src/refunds.ts:8: § c09206qct.a changed since its pin @cnxg2: ...",
      "own": true
    }
  ]
}
```

- `closed` is `true` exactly when the exit status is 0.
- `filter` names the filter flags, or is `null`.
- `kind` is `error`, `warning`, `draft` or `named`, a change a comparing check names for the person who merges.
- `project` is the project path of the finding, or `null` for one of the workspace, such as a marker outside every project. `path`, relative to that project, `line` and `address`, the first law or clause it names, are those the finding names, or `null`.
- `cause` is what moved under a drifted pin, as its text names it, or `null`.
- `text` is the line the text report prints.
- `own` is `true` for a finding of your change, `false` for one already there at the fork point, and `null` where no fork point can be read.

## FAQ

**Why are ids hashes and not readable names?**
The id is a hash of the carrying sentence, nine characters. Two branches that write the same sentence get the same id, with no counter to coordinate, and moving a note or a file breaks nothing. Agents do not need readable ids, and people read the sentence, which `list`, `diff` and `log` always print next to it. Rewording a sentence changes its hash: `silcrow accept <id>` rewrites every pointer, and a published id stays as an alias so old links resolve.

**Can the agent re-pin until `check` passes?**
It can run `accept`, and every accept is visible: `diff` lists it as a behaviour change accepted, `log` counts it, and the check in CI names it for the person who merges. The skill tells the agent to read the span against its clause first and to fix the code when the clause no longer holds. Deleting a digest is no way around it: `fix` leaves a marker bare when it stands for a pin `HEAD` held in its file, or at the old path of a renamed file, and its span changed since. A digest is 25 bits, so it guards against accidental drift, not against a deliberate search for a span that matches an old digest.

**Do I write the notes?**
No. You say the rule, the agent writes the note. You read the law text in `diff`, and `silcrow list` prints every active law. `silcrow list --path src/refunds.ts:9` prints only the laws and clauses whose pins read that line, through their span, the code before it or a callee they follow, then the drafts of the same notes, and the agent runs it before it edits a file.

**Is there a GitHub Action?**
Not one that reviews. A product on top of Silcrow is for later. Today, install the binary in a job and run `check --all`, which compares a pull request against its merge target, as in [CI](#ci).

**How do upgrades work?**
`silcrow upgrade` downloads the release asset for your platform from GitHub, fails unless the `.sha256` beside it matches, as the installer does, and replaces the running binary after a confirm. At a terminal, a command checks for a newer release at most once a day, with a two-second timeout. When there is one, it prints one line on stderr, at most once an hour:

```text
silcrow: release 0.2.1 is out, this is 0.2.0. Run `silcrow upgrade` to install it.
```

Nothing is checked in CI, when stderr is not a terminal, or in a development build. A failed check never fails the command.

`silcrow --version` names the hashing scheme beside the version, `silcrow 0.2.1, hashing scheme 25 rust=26 js=26 python=26 yaml=26`. The scheme is versioned by part: `core` for what every pin reads, `md` for law text and Markdown, and one part per language, JavaScript and TypeScript as one, Helm templates under `helm` beside `yaml`, and files with no tested grammar under `fallback`. A pin reads `core`, `md` and the parts of its file's language. The trailer writes the version most parts share, then each part at another, `Silcrow-Scheme: 25 yaml=26`, and the single number of an older release reads as every part at that number. When a release hashes a part with another version than the last `Silcrow-Scheme` trailer of your history, every pin that reads that part reads as drifted, and no other. `silcrow upgrade`, run inside a project, and every `check` until the change lands print the steps first, naming each part that moved, and change no finding: run `silcrow fix --remint`, with `--all` in a monorepo, commit that alone, then read each drift left with `silcrow diff --law <address>` and accept them all in one call, `silcrow accept <address> <address>...`, or `silcrow accept --drifted` once every drift is read. A pin `--remint` leaves drifted by its code, which no remint settles, and it says so.

**What happens to my existing hooks?**
Keep your hook manager and add `silcrow hook <event> "$@"` to it. See [Hooks](#hooks).

**How do I remove Silcrow?**
`silcrow eject`. The notes stay as plain prose, the markers go. See [Eject](#eject).

**Does it slow commits?**
Little. A run keeps what it derived from each file under `silcrow/cache` in the git directory, untracked, and a later run parses only the files whose text changed. On a repository of 1,200 files a `check` with nothing changed takes about half a second, and the `pre-commit` hook about a second and a half. The cache never changes what a run prints, and deleting it only costs the next run time. `SILCROW_CACHE=off` runs without it, and `SILCROW_CACHE_VERIFY=1` derives every reused answer again and fails on any difference, as [docs/decisions/cache.md](docs/decisions/cache.md) states. With nothing reused, on a host of about 1,500 files and 270 laws, a release build measured 4 to 8 seconds for `check`, and about 6 seconds for `accept --drifted` over 1,500 drifted pins.

**My pins drift too often.**
See the symptom table in [Following](#following).

**Does it send anything over the network?**
Only the daily release check at a terminal, and `silcrow upgrade`. Comparisons are local git.

## License

[MPL-2.0](LICENSE)