@useanvil/claude-code 0.9.0 → 0.10.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.
@@ -1,15 +1,18 @@
1
1
  # Your rules, caps, budgets and model rules
2
2
 
3
- Anvil checks every action Claude Code takes. This guide is the rest of what it can do for you: your own rules in plain
4
- words, limits on what the agent does and spends, and the model each kind of work runs on. Everything here is changed in
5
- your own terminal, never from inside Claude Code.
3
+ Anvil checks every action Claude Code takes. This guide covers the rest: your own rules in plain words, limits on what
4
+ the agent does and spends, and the model each kind of work runs on. You change all of it in your own terminal, never
5
+ from inside Claude Code.
6
6
 
7
7
  | To | Run |
8
8
  |---|---|
9
9
  | see every rule and limit, and what each does now | `anvil claude rules` |
10
10
  | change them one by one, with arrow keys | `anvil claude rules edit` |
11
11
  | add one in plain words | `anvil claude rules add "hold: deploys"` |
12
+ | turn your CLAUDE.md into rules | `anvil claude rules import` |
13
+ | remove one | `anvil claude rules remove <id>` |
12
14
  | apply a rules.md you edited | `anvil claude sync` |
15
+ | turn one of Anvil's own rules off, or back on | `anvil claude off <name>` · `anvil claude enforce <name>` |
13
16
  | see where each limit stands this week | `anvil claude report` |
14
17
  | print this guide | `anvil claude help rules` |
15
18
 
@@ -19,30 +22,47 @@ this guide in its own words.
19
22
 
20
23
  ## What a rule covers, and what it doesn't
21
24
 
22
- A rule is about a **kind of action** Claude takes: pushes to main, force-pushes, deletes, throwing away uncommitted
23
- work, database destroys, deploys, publishing, printing secrets, running as root, killing processes, writes to other
24
- services, paid compute, tunnels, copying a database here, crypto transactions, background jobs, helper agents, `.env`
25
- files, and app changes. On each you can hold, block, watch or switch off; cap how often it happens; or tie it to a
26
- model. Budgets limit what Claude Code spends, whatever it does.
25
+ A rule is about a **kind of action** Claude takes: pushes to main, deploys, new dependencies, deletes, production
26
+ accounts, database destroys, force-pushes, throwing away uncommitted work, `.env` files, publishing, app changes,
27
+ writes to other services, changes outside the project, printing secrets, helper agents, paid compute, background jobs,
28
+ running as root, killing processes, tunnels, copying a database here, and crypto transactions. On each you can hold,
29
+ block, watch or switch off; cap how often it happens; or tie it to a model. Budgets limit what Claude Code spends,
30
+ whatever it does.
27
31
 
28
- Words are read three ways, the first that places them wins, and the same in the screen's box, `rules add` (a rule on
29
- one app, a file or folder, or one target included) and a rules.md you edit by hand:
32
+ Words are read three ways, and the first that places them wins, in the box, `rules add` and rules.md alike:
30
33
 
31
- 1. **A command** (`docker push`, `kubectl delete`, `crontab -e`) is read by the hook's own classifier, the way the hook
32
- reads it when Claude runs it, so the rule holds what the hook will see. The reading is kept with the line.
34
+ 1. **A command** (`docker push`, `kubectl delete`, `crontab -e`) is read by the hook's own classifier, so the rule
35
+ holds what the hook will see when Claude runs it.
33
36
  2. **Plain words** are read by each kind's names and the phrases people use: "deploys", "delete the database" (a
34
37
  database destroy, not every delete), "copy the production database" (a copy, not a destroy).
35
38
  3. **Anything else** goes once to your own Claude Code (Haiku, through your login), unless you run with `--no-model`.
36
39
 
37
- Asking for your OK in words is the hold verb, wherever it sits: `never deploy to live without asking`, `Stripe refunds
38
- need my approval`, `ask first` and `unless I say ok` all hold.
40
+ The reading is kept with the line, so a later `sync` never changes what an unchanged line means.
41
+
42
+ **Say it however you'd say it.** The box takes the asking off and reads the rule inside; your words set the verb:
43
+
44
+ | Said | Becomes |
45
+ |---|---|
46
+ | "hold …", "ask before …", "ask first", "unless I say ok", "need my approval", "check with me", "wait for me", "without asking", "without my OK" | a hold |
47
+ | "block …", "never …", "don't …", "don't let Claude …", "stop it from …", "shouldn't", "no pushes …", "aren't allowed anymore" | a block |
48
+ | "watch …", "keep track of them", "a heads up whenever …" | a watch |
49
+ | "off …" | off |
50
+
51
+ Asking for your OK wins wherever it sits: `never deploy to live without asking` is a hold; "even with my OK" keeps a
52
+ block. In the box, other words hold. An amount, a recipient, a part or a time said inside the asking is read as if said
53
+ plainly, never dropped: "I'd like Stripe refunds over $500 to wait for me" holds refunds over $500.
54
+
55
+ **Not a rule, and said so:** an everyday command (`npm ci`, `git commit`, `running tests`: "runs as always: it isn't
56
+ one of the risky kinds"), advice (`write tests first`: "advice for Claude goes in CLAUDE.md"), a file it can't place as
57
+ a path (`modifying config files`: "name the file or folder as a path"), and every file (`touch any file`: "that's every
58
+ file: hold a kind instead"). `npm install` typed alone is the rule on new dependencies. A push that names no branch
59
+ (`don't push without asking`) can't be held yet: Anvil holds pushes to main, not other branches, and says so.
39
60
 
40
61
  ### Narrowed rules: one app, one file or folder, one target
41
62
 
42
- A rule can name part of a kind (docs/coding-agents/IMPROVING-CUSTOM-RULES.md). It only adds a stop beside the others:
43
- it never makes another rule, Always on, a cap or a budget weaker. Whatever it can't read, it holds, and the held
44
- message says why ("Anvil can't tell which environment this deploys to"). The box shows what still runs, and what the
45
- rule matched, before you add it.
63
+ A rule can name part of a kind. It only adds a stop: it never makes another rule, one of Anvil's own, a cap or a budget
64
+ weaker. What it can't read, it holds, and the held message says why ("Anvil can't tell which environment this deploys
65
+ to"). Before you add it, the box shows what it matched and what still runs. The conditions below work the same way.
46
66
 
47
67
  | Typed | What it holds | What still runs |
48
68
  |---|---|---|
@@ -54,15 +74,15 @@ rule matched, before you add it.
54
74
  | `hold pushes to main in billing-api` | pushes to main and `gh pr merge` in that repository, read from the checkout's remotes | pushes to main elsewhere |
55
75
  | `hold deletes outside the project` | `rm -rf ../other-project` | `rm -r src/old` |
56
76
 
57
- An app is known by its MCP server's name, the claude.ai connectors you've connected, the Claude app's connectors (by
58
- the names the app keeps for them), its API's host and its CLI: names only, never a server's command, settings or key.
59
- A secrets file (`.env.production`) is already covered by the secrets kinds, and the line says so. Claude Code's own
60
- `Edit(…)` and `Read(…)` rules do files too, without the one-time OK; a script that builds its paths as it runs is seen
61
- by neither.
77
+ An app is known by its MCP server's name, the claude.ai and Claude app connectors you've connected, its API's host and
78
+ its CLI: names only, never a server's command, settings or key. A secrets file (`.env.production`) is already covered
79
+ by the secrets kinds, and the line says so. Claude Code's own `Edit(…)` and `Read(…)` rules cover files too, without
80
+ the one-time OK. Neither sees a script that builds its paths as it runs; a `block:` on a folder also locks it at the
81
+ operating system (Locked folders, below).
62
82
 
63
83
  ### Every rule you type gets one of three answers, said first
64
84
 
65
- The box, `rules add`, the rule's row and `sync` answer in the same words:
85
+ The box, `rules add`, the rule's row and `sync` all answer in these words:
66
86
 
67
87
  | State | What it means | Enter in the box, or `rules add` |
68
88
  |---|---|---|
@@ -70,11 +90,11 @@ The box, `rules add`, the rule's row and `sync` answer in the same words:
70
90
  | ▲ **Catch** | it works, with one difference, said before anything else | adds it anyway; its row keeps the catch |
71
91
  | ? **Can't yet** | Anvil can't do part of it, and offers the closest rule it can | adds the closest (`rules add` prints it as a command to run); with nothing near, adds nothing |
72
92
 
73
- The catches:
93
+ Words the box adds nothing for (advice, or a rule with nothing near) can go where Claude reads them: once enter has
94
+ said why, tab adds them, once, under "Added from Anvil" in your CLAUDE.md (`~/.claude/CLAUDE.md`, or the project's
95
+ beside a project's rules). Claude reads it; Anvil doesn't enforce it, and the line says so.
74
96
 
75
- A rule only stops what it names. Words that let part of it through ("don't hold refunds under $50", "ones under $50
76
- have my OK") or stop everything but one thing ("block everything minus deploys", "Claude may only deploy") are can't
77
- yet: Anvil never reads them as a stop on the part they leave out, and never offers one.
97
+ **Catches**, each said first:
78
98
 
79
99
  | Typed | Said first |
80
100
  |---|---|
@@ -83,14 +103,14 @@ yet: Anvil never reads them as a stop on the part they leave out, and never offe
83
103
  | production: `hold deploys to production` | "A deploy that doesn't say where it goes waits for your OK too: Anvil can't tell it isn't production." |
84
104
  | a command: `kubectl delete` | "It holds every deploy, not only "kubectl delete": Anvil's rules are per kind." |
85
105
 
86
- Can't yet, and the closest rule offered:
106
+ **Can't yet**, and the closest rule offered. A rule only stops what it names: words that let part of it through ("don't
107
+ hold refunds under $50") or stop everything but one thing ("Claude may only deploy") are Can't yet, never read as a
108
+ stop on the part they leave out. A condition Anvil can't read yet is left out of the closest, so it is never narrower
109
+ than what you typed: `hold Stripe refunds over 10%` offers `hold: Stripe refunds`.
87
110
 
88
111
  | Typed | Said | Closest |
89
112
  |---|---|---|
90
113
  | `hold changes to the Roadmap database in Notion` | Anvil can't narrow Notion changes to one database (Roadmap). | `hold: Notion changes` |
91
- | `hold Stripe refunds over 10%` | Anvil can't limit Stripe refunds by a share of a payment ("10%"). | `hold: Stripe refunds` |
92
- | `hold deploys during the launch` | Anvil can't read "during the launch" as a time yet (Anvil can't tell when that is). | `hold: deploys` |
93
- | `hold deploys on Fridays if it's a big change` | Anvil reads "on Fridays" but can't narrow a rule by the other words beside it. | `hold: deploy` |
94
114
  | `hold Stripe changes except refunds` | Anvil can't leave "refunds" out of a rule on Stripe. | `hold: Stripe changes`, refunds included |
95
115
  | `hold Gmail and Slack changes` | One app per rule. | `hold: Gmail changes` and `hold: Slack changes` |
96
116
  | `hold Strype changes` | No app called "Strype" is connected here. | `hold: Stripe changes` |
@@ -101,68 +121,32 @@ Can't yet, and the closest rule offered:
101
121
  | `hold Stripe reads` | Anvil holds what Stripe changes: its reads always run. | none |
102
122
  | `hold emails to clients`, with no clients defined | Say who your clients are in rules.md first (their domains or addresses) ("clients"). | `hold: emails Claude sends` |
103
123
 
104
- A word your rules use can be defined once, on a line of its own: `- define: clients = @acme.com, @globex.com`. The
105
- rules screens list your definitions under your rules; a project's rules read yours, the project's own winning. Two
106
- words Anvil reads itself: `define: my company = acme.com` (for "anyone outside the company") and `define: my currency
107
- = USD` (the currency a refund is read in).
108
-
109
- A closest is never narrower than what you typed: it leaves out only the part Anvil can't read, so it covers that part
110
- too. A rules.md line you write by hand is never changed for you: a line Anvil can't do stays an error that `sync`
111
- names. A line applied before as a rule on its kinds ("hold: deploys on Fridays", applied when Anvil couldn't read a
112
- time) keeps holding every one after an update, and says how to narrow it: add the line again (`rules add`).
124
+ A rules.md line you write by hand is never changed for you: one Anvil can't do stays an error that `sync` names, and
125
+ one applied before on its whole kind ("hold: deploys on Fridays", from before Anvil read times) keeps holding every
126
+ one after an update, and says how to narrow it: add the line again (`rules add`).
113
127
 
114
- Say it however you'd say it. The box takes the asking off and reads the rule inside it, with the verb you said:
115
- "I'd like Stripe refunds over $500 to wait for me" and "Refunds in Stripe above $500 — please check with me" hold;
116
- "Gmail shouldn't be emailing anyone outside the company", "weekends: no pushes to main" and "pushes to main aren't
117
- allowed anymore" block; "Stripe payouts under $50 are fine but keep track of them" and "I'd like a heads up whenever
118
- Claude posts in #general" watch. "Without asking" or "without my OK" makes a rule a hold, never a block; "even with my
119
- OK" keeps it a block. Only the asking is taken off: an amount, a recipient, a part or a time said inside it is read
120
- as it would be said plainly, never dropped.
128
+ **Definitions.** Define a word once, on a line of its own: `- define: clients = @acme.com, @globex.com`. The rules
129
+ screens list definitions under your rules; a project's rules read yours, the project's own winning. Anvil reads some
130
+ itself: `my company = acme.com` (for "anyone outside the company"), `my currency = USD` (the currency a refund is read
131
+ in), and `production` and `project folders` (used by two of Anvil's own rules: The screen).
121
132
 
122
133
  #### Enter reads it back, part by part
123
134
 
124
135
  Where Claude Code is installed, enter reads what you typed back before anything is saved. "Block deploys. Publishes
125
- too." is two rules; a part Anvil can't make a rule of is listed as "Not covered yet" beside your own words. Enter again
126
- adds the rules (`e` edits, `a` adds one more, esc drops it). The box reads each part itself, and asks your Claude Code
127
- (Haiku, through your own login) only for a part it can't read. One rule the box reads whole, with nothing else said,
128
- is added at once.
129
-
130
- On two fresh sealed sets of plain speech it read 71 and 68 of 90 right, against 40 and 32 for the box alone, and left
131
- far fewer parts unsaid. `ANVIL_READBACK=0` turns it off; with no Claude Code, or `--no-model`, the box answers on its
132
- own as before.
133
-
134
- #### When the box can't say it: your Claude Code rewrites it (held, not on yet)
135
-
136
- Held: on two fresh sealed sets of plain speech the step made no rule lost or softer, but read too few right (66/90 and
137
- 32/90; the bar is 79), and attacks still find softer rewrites it would offer. `ANVIL_REWRITE_STEP=1` turns it on to try
138
- it; without it, enter reads the words back (above) or the box answers as before, tab adds nothing, and `rules import` uses neither
139
- the step nor the box's reading (below; it writes each line in the box's words, the asking taken off). What it does
140
- when on:
141
-
142
- Enter on words the box answers ? **Can't yet** for, can't place, or isn't sure it read whole asks your own Claude Code
143
- (Haiku, through your own login: one call, no tools, from an empty folder) to say them as one rules.md line. The box says
144
- "Your Claude Code is rewriting it" while it waits; esc stops it. The line it writes is read by the box itself, as if you
145
- had typed it, and shown with what it will do before anything is added: "✓ Your Claude Code rewrote it: hold: slack
146
- posts in #deploys", then "Slack posts in #deploys wait for your OK", enter adds it.
147
-
148
- It is offered only when it is no softer than what you typed. The box's own answer stays when the line would:
149
- - weaken the verb you said ("never stop blocking …" and "I'll never approve …" stay blocks; "let me cancel them first"
150
- stays a hold), or keep a hold where no reader can tell how you asked;
151
- - leave out, turn around or add a condition: over stays over, outside stays outside, who it goes to never becomes who
152
- sends it, what it mentions or whose people they are; "or" between two conditions never becomes both at once;
153
- - be narrower than your words: an example, an exception or what you let through made the rule ("hold every Stripe
154
- change over $500, think refunds"), a rule you said holds every one narrowed ("whatever the amount — over $500 is what
155
- scares me"), one more thing you added left out ("payouts are just as bad");
156
- - name another app, change, kind, part or target, or a part your words only relate to ("billing-api forks");
157
- - keep an amount of something else ("refunds on any order over $500"), a total ("over $500 in a given week") or a rough
158
- amount as one change's, a time said in another zone or place ("after 6pm pacific"), or a span of days as single days.
159
-
160
- What it left out must be a story or a reason. A closest it gives for words it can't say whole is offered only when it is
161
- broader than the words and no wider than the box's own. With no Claude Code here, the box answers as before.
162
-
163
- The box also looks twice at what it reads by itself: where its own reading would be refused had your Claude Code
164
- written it ("it keeps posting in the deploys channel on slack" read as every deploy; "over $500 or after 6pm" read as
165
- both at once), it says "Anvil isn't sure it read all of that", enter asks your Claude Code, and tab adds what the box read.
136
+ too." is two rules; a part Anvil can't make a rule of is listed as "Not covered yet" beside your words. Enter again
137
+ adds the rules (`e` edits, `a` adds one more, esc drops it). The box reads each part itself and asks your Claude Code
138
+ only about a part it can't read; one rule read whole, with nothing else said, is added at once. `ANVIL_READBACK=0`
139
+ turns this off; with no Claude Code, or `--no-model`, the box answers on its own.
140
+
141
+ #### Your Claude Code rewrites what the box can't say (off by default)
142
+
143
+ `ANVIL_REWRITE_STEP=1` turns this on. It is off by default: it doesn't yet read enough lines right, and crafted input
144
+ can still draw a softer rewrite from it. With it on, words the box can't do, can't place, or isn't sure it read whole
145
+ go to your Claude Code (one call, no tools, from an empty folder) for one rules.md line, which the box reads as if you
146
+ typed it and shows before adding ("✓ Your Claude Code rewrote it: hold: slack posts in #deploys"). It is offered only
147
+ when no softer than your words (the same verb or stronger, every condition kept, nothing narrower, no other app, kind,
148
+ part or target, nothing left out but a story or a reason); otherwise the box's own answer stays. Where the box doubts
149
+ its own reading, it says "Anvil isn't sure it read all of that": enter asks your Claude Code, tab adds what it read.
166
150
 
167
151
  ### Conditions: an amount
168
152
 
@@ -174,16 +158,16 @@ A rule on a money app's money changes (refunds, charges, payments, payouts, tran
174
158
  | `ask before Stripe charges of $1,000 or more` | a charge of $1,000 or more | smaller charges |
175
159
  | `block PayPal payouts above €1,000` | a payout over €1,000 | smaller payouts in euros |
176
160
 
177
- The amount is read from the call itself: Stripe's, PayPal's and Square's tools, their APIs through curl, and their
178
- CLIs, and Shopify's refunds through its Admin API (money.ts, each field taken from the app's published schema), in the
179
- currency's smallest unit (Stripe's `5000` is $50.00, or ¥5,000 in yen). What it can't read, it holds, saying why: a
180
- full refund (it names no amount), another currency (Anvil has no exchange rates), a variable or a script, a batch, a
181
- URL curl expands into many requests. A refund moves its payment's currency, which its call doesn't name, so it is read
182
- in yours only where you defined it (`define: my currency = USD`); typed, the box offers the line. A Shopify refund is
183
- in its order's currency, which its call doesn't name either: Anvil reads it as yours, the same way. An invoice is read
184
- by its whole total, where a call carries it all (PayPal's draft and its full update): sending one, or any other call
185
- on it, waits. Can't yet: a share ("over 10%"), an amount on what isn't money ("deploys over $500"), Stripe's and
186
- Square's invoices (their totals are added up apart from any one call), Shopify's other changes, amounts in tokens.
161
+ - **Read from the call:** Stripe's, PayPal's and Square's tools, APIs (through curl) and CLIs, and Shopify's refunds
162
+ through its Admin API, in the currency's smallest unit (Stripe's `5000` is $50.00, or ¥5,000 in yen).
163
+ - **Held, saying why:** a full refund (it names no amount), another currency (Anvil has no exchange rates), a variable
164
+ or a script, a batch, a URL curl expands into many requests. A refund moves its payment's currency (a Shopify
165
+ refund, its order's), which the call doesn't name, so it is read in yours only once you define it
166
+ (`define: my currency = USD`); typed, the box offers the line.
167
+ - **Invoices** are read by their whole total where a call carries it all (PayPal's draft and its full update); sending
168
+ one, or any other call on it, waits.
169
+ - **Can't yet:** a share ("over 10%"), an amount on what isn't money ("deploys over $500"), Stripe's and Square's
170
+ invoices (their totals are added up apart from any one call), Shopify's other changes, amounts in tokens.
187
171
 
188
172
  ### Conditions: who a send reaches
189
173
 
@@ -195,18 +179,16 @@ Square's invoices (their totals are added up apart from any one call), Shopify's
195
179
  | `never email anyone outside the company`, with `define: my company = acme.com` | an email with any recipient outside acme.com | emails only to acme.com |
196
180
  | `ask before inviting john@acme.com on Google Calendar` | an invite naming him | invites to others |
197
181
 
198
- Who a send reaches is read from the call: an email's and an invite's to, cc and bcc, from the app's own tools and
199
- APIs. What it can't read, it holds: a reply or a draft sent by its id (it reaches whoever the thread or draft names), a
200
- list or a relay that may reach anyone, an address built when the line runs, an address in letters from another
201
- alphabet. Anvil never guesses your company: typed, the box offers the one in your git email when it is a work address,
202
- said first; written by hand, a line needs `define: my company`. Written by hand, what it can't read yet holds every
203
- send, its catch said first ("It holds them whoever they go to…"), never an error. Can't yet: a word you haven't
204
- defined, and who a text or a chat post reaches.
182
+ - **Read from the call:** an email's and an invite's to, cc and bcc, from the app's own tools and APIs.
183
+ - **Held:** a reply or draft sent by its id (it reaches whoever the thread or draft names), a list or relay that may
184
+ reach anyone, an address built when the line runs, an address in letters from another alphabet.
185
+ - **Your company is never guessed.** Typed, the box offers the one in your git email when it is a work address; by
186
+ hand, a line needs `define: my company`. By hand, what Anvil can't read yet holds every send, its catch said first.
187
+ - **Can't yet:** a word you haven't defined, and who a text or a chat post reaches.
205
188
 
206
189
  ### Conditions: a time
207
190
 
208
- Any rule (a kind, an app, a target, files) can hold only at some times, on this Mac's own clock and time zone, as a
209
- cap's day is.
191
+ Any rule (a kind, an app, a target, files) can hold only at some times, by this Mac's clock and time zone.
210
192
 
211
193
  | Typed | What it holds | What still runs |
212
194
  |---|---|---|
@@ -216,17 +198,18 @@ cap's day is.
216
198
  | `block force-pushes on weekends` | Saturday and Sunday | weekdays |
217
199
  | `hold deploys outside work hours`, with `define: work hours = Mon–Fri 9am–6pm` | evenings, nights and weekends | work hours |
218
200
 
219
- A night crosses midnight ("between 10pm and 6am" is the evening of one day and the morning of the next), and a
220
- daylight-saving day reads as the wall clock does. Typed, a time your rules haven't defined ("work hours") is offered
221
- with the line. What it can't read holds: a call with no time, or a time zone the clock can't read (a `TZ` Node
222
- doesn't know, or an abbreviation like `PST` that Node names while reading UTC). Can't yet: an event ("during the
223
- launch"), a date ("on December 3rd"), a time with another condition beside it ("on Fridays if it's a big change").
201
+ - A night crosses midnight ("between 10pm and 6am" is the evening of one day and the morning of the next); a
202
+ daylight-saving day reads as the wall clock does. Typed, a time you haven't defined ("work hours") is offered with
203
+ the line.
204
+ - **Held:** a call with no time, or a time zone the clock can't read (a `TZ` Node doesn't know, or an abbreviation like
205
+ `PST` that Node names while reading UTC).
206
+ - **Can't yet:** an event ("during the launch"), a date ("on December 3rd"), a time with another condition beside it
207
+ ("on Fridays if it's a big change").
224
208
 
225
209
  ### Conditions: part of an app
226
210
 
227
- A rule on an app can name one part of it, and then holds only what happens there
228
- (docs/coding-agents/IMPROVEMENTS-TO-CUSTOM-RULES-FOR-CLAUDE.md). Like every narrowed rule it only adds a stop, and what
229
- it can't place, it holds, saying why ("Anvil can't tell whether channel C0UNSEEN11 is #general").
211
+ A rule on an app can name one part of it, and then holds only what happens there; what it can't place, it holds,
212
+ saying why ("Anvil can't tell whether channel C0UNSEEN11 is #general").
230
213
 
231
214
  | Typed | What it holds | What still runs |
232
215
  |---|---|---|
@@ -235,62 +218,44 @@ it can't place, it holds, saying why ("Anvil can't tell whether channel C0UNSEEN
235
218
  | `watch Linear issues in the Payments team` | issues in it, by its name, key, id, or an issue's key (`PAY-12`) | another team's |
236
219
  | `hold Jira issues in the PAY project` | issues in it, by its key, id or name, or an issue's key | another project's |
237
220
 
238
- Slack and Linear send ids (`C04Q8…`, a team's UUID), not names. Anvil learns which is which from what Claude Code has
239
- already seen here: an app's own reply when Claude lists channels or teams, in Claude Code's session logs on this Mac.
240
- It reads them where you are, sends nothing, and keeps what it read in `~/.anvil/claude/state/part-ids.json`. Ids are
241
- read again on `sync` and whenever the rules screen opens, and applied then without asking, since no rule's words
242
- changed. Until Anvil has seen the part's id, the catch comes first ("Anvil hasn't seen #general's ID yet: a Slack post
243
- it can't place waits for your OK until it has"). A channel renamed since is held by either name. A project's
244
- `.anvil/rules.md`, which may be committed, keeps no other channel's id.
245
-
246
- Anything else holds rather than runs: an id Anvil hasn't seen, a field it can't read, a call that names the part in a
247
- field Anvil doesn't read, a gh command outside a checkout, or a Slack webhook (made for one channel its URL doesn't
248
- name). Written by hand, a part Anvil can't read keeps the app's rule, its catch said first. Typed, it is Can't yet:
249
- `#general and #random` (one per rule), `except #random`, `the main channel` (a part is named by its name).
250
-
251
- Not a rule at all, and said so: an everyday command (`npm install`, `git commit`, `running tests`: "runs as always: it
252
- isn't one of the risky kinds"), advice (`write tests first`, `be careful with payments`: "advice for Claude goes in
253
- CLAUDE.md"), a file it can't place as a path (`modifying config files`: "name the file or folder as a path"), and every
254
- file (`touch any file`: "that's every file: hold a kind instead"). A rule can't weaken Always on.
255
-
256
- How well the box reads what people type is measured, not guessed: sets of 90 lines written by people who never saw
257
- the reader, each scored once (tests/coding-agents/typed-rules.test.ts, typed-rules-sealed.test.ts). Kinds: 85 of 90 on
258
- the second set, where the reader before read 40. Rules on one app, by the three answers: 79 and 81 of 90 on the first
259
- two sets written for them (87.8% and 90.0%), and 84 and 87 of 90 (93.3% and 96.7%) on two
260
- more written after the fixes those showed, scored once on the reviewed reader. Rules with a condition, written short
261
- and direct: 79, 82 and 84 of 90 for an amount, who a send reaches and a time, and 73 for part of an app (most of its
262
- misses name parts of apps Anvil doesn't read yet). Written as people talk ("claude keeps doing stripe refunds, make
263
- them wait for me"), 44 to 75 of 90 on fresh sets: what the box can't place is Can't yet with the closest rule, or, on
264
- enter, read by your own Claude Code. None of those reads as a weaker rule than the words.
221
+ Slack and Linear send ids (`C04Q8…`, a team's UUID), not names. Anvil learns them from replies Claude Code has already
222
+ seen here (Claude listing channels or teams) in its session logs on this Mac, sends nothing, and keeps them in
223
+ `~/.anvil/claude/state/part-ids.json`, read and applied again, unasked, on `sync` and when the screen opens. Until it
224
+ has seen a part's id, the catch comes first ("Anvil hasn't seen #general's ID yet: a Slack post it can't place waits for
225
+ your OK until it has"). A renamed channel is held by either name. A project's `.anvil/rules.md`, which may be
226
+ committed, keeps no other channel's id.
227
+
228
+ - **Held, not run:** an id Anvil hasn't seen, a field it can't or doesn't read, a gh command outside a checkout, a
229
+ Slack webhook (made for one channel its URL doesn't name). By hand, a part Anvil can't read keeps the app's rule,
230
+ its catch said first.
231
+ - **Can't yet, typed:** `#general and #random` (one per rule), `except #random`, `the main channel` (name it).
265
232
 
266
233
  ## What each limit needs
267
234
 
268
- Every screen that shows a limit says what it does now, or why it can't: "can't be measured", "can't count helpers",
269
- "not checked here", each with the fix. What decides it:
235
+ Where a limit can't work, every screen that shows it says why ("can't be measured", "can't count helpers", "not checked
236
+ here"), names the Claude Code by version and path, and gives its update command.
270
237
 
271
- | Limit | Needs | Where it can't work, the screens say |
272
- |---|---|---|
273
- | your rules, caps, a helper's model | Claude Code 2.1.295 or later | |
274
- | a model rule (`model: opus for deploys`) | Claude Code 2.1.304 or later records each request's model; before it, only the reply that carries the call is read, where it is written as it streams (the desktop app, headless runs), never in the terminal | "under Claude Code 2.1.300 (its path) it can't hear the model in the terminal, only where replies are written as they stream" |
275
- | a budget that refuses the next message, a task budget | Claude Code 2.1.153 or later, on every Claude Code `anvil claude on` finds | an older one, by version and path, and "update it, then run anvil claude on" |
276
- | `model: never …` refusing a switch | Claude Code 2.1.251 or later (PreModelSwitch); a message on that model is refused from 2.1.153 | "refused: a message on it, and a switch to it except under Claude Code 2.1.200 (its path)", with its update command |
277
- | a cap on helpers at once | Claude Code 2.1.318 or later (it reports helpers starting and stopping) | "except under Claude Code 2.1.300 (its path)", with its update command |
278
- | a plan budget (`80% of my weekly limit`) | a reading of your plan: Claude Code's status line, or its `/usage`, which Anvil asks | why there is none, and the fix (below) |
279
-
280
- - **An older Claude Code skips what it doesn't know.** Every Claude Code measured from 2.1.153 on skips a settings
281
- entry for an event it doesn't know and runs the rest (IMPROVEMENTS-TO-90 §3, probe 2), so `on` adds the entries a
282
- budget, a helper cap and a `never` rule listen to wherever every Claude Code it finds is 2.1.153 or later. An older
283
- one there, or one whose version can't be read, keeps them all out; the screens name it. Each event is heard from the
284
- release that runs it, and `on` and Home name a Claude Code too old for one, with the command that updates it.
285
- - **The desktop app** reads the same settings, so every rule, cap and budget works there, a plan budget included: with
286
- no status line there, Anvil asks Claude Code's own `/usage` for your plan's use, in the background.
287
- - **The Claude Code plugin** (instead of `anvil claude on`) checks actions, refuses a message on a model your rules
288
- say never and a `/model` switch to it (Claude Code 2.1.251 or later), and starts task budgets; helpers at once can't
289
- be counted under it. Where `anvil claude on` also runs in a session, the plugin steps aside for each event `on`'s
290
- entries hear, so each is answered once.
238
+ | Limit | Needs |
239
+ |---|---|
240
+ | your rules, caps, a helper's model | Claude Code 2.1.295 or later |
241
+ | a model rule (`model: opus for deploys`) | Claude Code 2.1.304 or later; before it, only where replies are written as they stream (the desktop app, headless runs), never in the terminal |
242
+ | a budget that refuses the next message, a task budget | Claude Code 2.1.153 or later, on every Claude Code `anvil claude on` finds |
243
+ | `model: never …` refusing a switch | Claude Code 2.1.251 or later; a message on that model is refused from 2.1.153 |
244
+ | a cap on helpers at once | Claude Code 2.1.318 or later (it reports helpers starting and stopping) |
245
+ | a plan budget (`80% of my weekly limit`) | a reading of your plan: Claude Code's status line, or its `/usage`, which Anvil asks (Budgets) |
246
+
247
+ - **An older Claude Code keeps the newer entries out.** `on` adds the entries a budget, a helper cap and a `never` rule
248
+ listen to only where every Claude Code it finds is 2.1.153 or later (which skips an event it doesn't know). An older
249
+ one, or one whose version can't be read, keeps them all out, and the screens name it.
250
+ - **The desktop app** reads the same settings, so everything here works there; a plan budget is read from `/usage`.
251
+ - **The Claude Code plugin** (instead of `anvil claude on`) checks actions, refuses a message on a `never` model and a
252
+ `/model` switch to it, and starts task budgets, but can't count helpers at once. Beside `on`, it steps aside for each
253
+ event `on` hears, so each is answered once.
291
254
 
292
255
  ## The file: `.anvil/rules.md`
293
256
 
257
+ Your own rules live in `~/.anvil/rules.md`; a project's live in its `.anvil/rules.md`, which adds to yours.
258
+
294
259
  ```markdown
295
260
  # Anvil rules for this repo
296
261
  - hold: push or merge to main
@@ -300,13 +265,10 @@ Every screen that shows a limit says what it does now, or why it can't: "can't b
300
265
  - cap: at most 3 deploys a day
301
266
  ```
302
267
 
303
- - **Format.** One rule per line: a verb, a colon, then plain words.
304
- - A list marker (`-`, `*`, `1.`) is optional.
305
- - Other lines are notes, and `#` headings are fine.
306
- - A line that looks like a rule but isn't read as one (`**hold:**`, `holds:`, `-hold:`, `> hold:`, `hold deploys`)
307
- is reported with its number.
308
- - Lines inside a code block (```) or an HTML comment are never read as rules, as the rendered file shows them.
309
- - **What each verb does:**
268
+ - **Format.** One rule per line: a verb, a colon, then plain words. A list marker (`-`, `*`, `1.`) is optional; other
269
+ lines are notes, and `#` headings are fine. A line that looks like a rule but isn't read as one (`**hold:**`,
270
+ `holds:`, `-hold:`, `> hold:`, `hold deploys`) is reported with its number. Lines inside a code block or an HTML
271
+ comment are never rules, as the rendered file shows them.
310
272
 
311
273
  | Verb | What it does |
312
274
  |---|---|
@@ -317,14 +279,7 @@ Every screen that shows a limit says what it does now, or why it can't: "can't b
317
279
  | `cap:` | a limit on what the agent does (Caps, below) |
318
280
  | `budget:` | a limit on what Claude Code spends, in your own rules.md only (Budgets, below) |
319
281
 
320
- - **Reading.** Each line is read once, by `sync`, the screen, `rules import` or `rules add`.
321
- - The reader is the one `rules import` uses: Anvil's matcher plus each kind's own names ("deploys", "push-main",
322
- "paid compute").
323
- - A line the matcher can't read goes to the developer's own Claude Code (`--no-model` keeps every line on the
324
- machine).
325
- - A line read before keeps its reading, so a sync never changes what an unchanged line means.
326
- - **What sync shows, and what it refuses.** `sync` shows every line and what it became, out of `anvil claude sync`'s
327
- real output:
282
+ - **What sync shows, and refuses.** `sync` shows every line and what it became, out of its real output:
328
283
 
329
284
  ```
330
285
  .anvil/rules.md in ~/code/app · 4 rules, 1 cap
@@ -336,37 +291,20 @@ Every screen that shows a limit says what it does now, or why it can't: "can't b
336
291
  → cap · 3 deploys a day
337
292
  ```
338
293
 
339
- It refuses three kinds of line, each by line number and with the reason:
340
- - a kind Anvil can't see ("hold: tidy commit messages");
341
- - a floor rule that a `watch:` or `off:` line would weaken ("protected is always on");
342
- - a cap it can't count exactly: two numbers for one window ("2 deploys and 3 publishes a day"), one window twice, or
343
- money said in words ("two thousand dollars of Stripe refunds").
344
-
345
- It also explains lines that need it:
346
- - A line owned by a stronger one in the same file says so ("deploy is held by line 8").
347
- - A line narrower than its kind says it covers every one.
348
- - A project's file is named with its folder, so two projects' files never look the same.
349
- - **Applying.**
350
- - **Nothing applies without a yes.** It applies only on yes, or with `--yes`. Without a terminal and without `--yes`,
351
- `sync` shows the change, applies nothing, and exits 1.
352
- - **Lines that can't be enforced.** With `--yes`, the lines that can be enforced are applied. `sync` exits 1 naming
353
- the rest.
354
- - **Validation.** Anvil's own policy validator checks the result before it is offered.
355
- - **What is enforced, and where it lives.**
356
- - **The sealed copy.** When a person applies a rules.md, its compiled form is kept under `~/.anvil/claude/applied/`.
357
- Those are Anvil's own files, sealed like the mode file. That copy is the only thing the hook enforces for a place
358
- with a rules.md.
359
- - **The repo copy is never enforced.** `.anvil/rules.json` beside the file is the same compiled form, for reading.
360
- Committing it is harmless: one committed, pulled or switched by git is never enforced as it is. An older rules.json
361
- from before rules.md is the exception (below).
362
- - **Every new copy needs a yes.** What a person applies is kept per folder. A fresh clone, a second clone or another
363
- git worktree needs its own `anvil claude sync` and yes. Until then the hook says its rules.md "isn't applied yet in
364
- this folder".
365
- - **Older rules files.** A rules.json from before rules.md (no rules.md beside it) moves into rules.md on the first
366
- apply there, every rule as it ran, shown with the rest. Until then it is read as it is at each compile a person
367
- runs. The agent's `anvil claude on`, which recompiles, is held.
368
- - **Tampering.** A sealed copy changed outside Anvil stops the compile: the previous rules stay until `sync`
369
- re-applies it.
294
+ It refuses, by line number and with the reason, a kind Anvil can't see ("hold: tidy commit messages"), a `watch:` or
295
+ `off:` line on one of Anvil's own rules ("protected is Anvil's own rule: switch it in anvil claude rules edit"), and a
296
+ cap it can't count exactly (two numbers for one window, one window twice, money in words). It says when a stronger
297
+ line owns a line ("deploy is held by line 8") and when a line narrower than its kind covers every one.
298
+ - **Nothing applies without a yes,** or `--yes`. Without a terminal and without `--yes`, `sync` shows the change,
299
+ applies nothing, and exits 1. With `--yes`, the lines that can be enforced are applied, and `sync` exits 1 naming the
300
+ rest. Anvil's policy validator checks the result before it is offered.
301
+ - **The hook enforces a sealed copy.** Applying keeps the compiled rules, sealed, under `~/.anvil/claude/applied/`: all
302
+ the hook enforces for a place with a rules.md. The `.anvil/rules.json` beside the file is the same, for reading; one
303
+ committed, pulled or switched by git is never enforced as it is. A sealed copy changed outside Anvil stops the
304
+ compile, and the previous rules stay until `sync` re-applies it. A rules.json from before rules.md moves into
305
+ rules.md, every rule as it ran, on the first write or apply there.
306
+ - **Each folder needs its own yes.** A fresh clone, a second clone or another git worktree needs its own `sync` and
307
+ yes. Until then the hook says its rules.md "isn't applied yet in this folder", never that rules hold.
370
308
  - **A changed file never silently stops protecting.** A `rules.md` that changed, was removed, or can't be read keeps
371
309
  the rules applied from it before, and every call is still judged. The hook says so once per session, and `status`
372
310
  says the same:
@@ -376,72 +314,62 @@ Every screen that shows a limit says what it does now, or why it can't: "can't b
376
314
  › apply it: anvil claude sync
377
315
  ```
378
316
 
379
- A folder whose rules.md was never applied is told that ("isn't applied yet in this folder"), never that rules hold.
380
- - **Quick saves never apply what nobody saw.** These all apply the whole file:
381
- - `rules add`;
382
- - `rules import`;
383
- - `rules remove`;
384
- - the screen's save.
385
-
386
- So each refuses while the file has edits nobody has applied, and saves nothing:
387
-
388
- ```
389
- ~/.anvil/rules.md has changes that aren't applied yet, so nothing was saved. Review and apply them first: anvil claude sync
390
- ```
391
-
392
- - **The agent can't change the rules.** All of these are changes to Anvil, held on the always-on floor:
393
- - its edits to either rules.md, either rules.json, the applied copies, or the caps ledger;
394
- - running `anvil claude sync`;
395
- - running `rules add`, `rules import` or `rules remove`;
396
- - running the bare `anvil claude` (Home) or `anvil claude rules edit` (the screen).
397
- - **Imports and removal.**
398
- - `rules import` reads your CLAUDE.md files (Anvil's CLAUDE.md reader decides which lines are rules, with your
399
- Claude Code unless `--no-model`) and shows each rule beside its line, said as rules.md makes of the line it writes
400
- (what `sync` shows): `→ block: force push · blocks every force-push`, or `▲ hold: deploying to production · holds
401
- deploys to production` with rules.md's catch ("a deploy that doesn't say where it goes waits for your OK too").
402
- A line rules.md can't take as written ("name the repository") is `?` with rules.md's reason and takes the closest
403
- rule (`block: push-main`), as the box offers one. Never ✓: Anvil doesn't claim a line asked for exactly that. Then
404
- it asks `↵ hold these N now
405
- · w watch first · q save nothing`. Enter writes their own `block:` and `hold:` lines, in force at once; `w` writes
406
- `watch:` lines; `q` saves nothing. Anvil's validator checks them before it asks. With no terminal it saves nothing
407
- and says how; `--yes` writes `watch:` lines (a script never holds unasked). Each rule once: the same words on two
408
- lines with the stronger verb; a rule on a whole kind covers a narrower one of the same verb, and the skipped line
409
- names the one that covers it; a line that gives a block and a hold adds both; one already in rules.md is never added
410
- again, and one there with a weaker verb is named, to change there. After `w`, a rule rules.md reads narrower than its
411
- kinds is held by changing `watch:` to `hold:` and `sync`, never `enforce` (that holds the whole kind). Lines that
412
- are advice stay in CLAUDE.md, counted ("Not enforced: N lines are guidance").
413
- - Reading each CLAUDE.md line with the rules box instead (✓ ▲ ?, narrowed to what the line names: "Never delete or
414
- edit anything in `migrations/`." as a rule on that folder) is held, not on yet: on 40 real CLAUDE.md files it found
415
- too few of their rules and made some weaker. `ANVIL_REWRITE_STEP=1` turns it on to try it.
416
- - `rules add "…"` writes a `watch:` line into rules.md, so Anvil watches what it would stop first, and applies it.
417
- - An older `rules.json` moves into rules.md on the first write or apply.
418
- - `rules remove <id>` removes the line that makes that rule in the file as it is now.
317
+ - **Quick saves never apply what nobody saw.** `rules add`, `rules import`, `rules remove` and the screen's save each
318
+ apply the whole file, so while it has edits nobody applied, each saves nothing and says "~/.anvil/rules.md has
319
+ changes that aren't applied yet, so nothing was saved. Review and apply them first: anvil claude sync".
320
+ - **The agent can't change the rules.** Its edits to either rules.md, either rules.json, the applied copies or the caps
321
+ ledger, and its runs of `sync`, `rules add`, `rules import`, `rules remove`, the bare `anvil claude` (Home) or
322
+ `rules edit`, are changes to Anvil, held by Anvil's own rule Change Anvil (on by default; with it off, Claude could).
323
+
324
+ ### Import, add and remove
325
+
326
+ `rules import` reads your CLAUDE.md files; Anvil's CLAUDE.md reader decides which lines are rules (with your Claude
327
+ Code, unless `--no-model`). A line that names a file or folder ("never hand-edit `src/gen/*.ts`") becomes a rule on it.
328
+
329
+ - **It shows each rule beside its line**, as `sync` reads the line it writes:
330
+ `→ block: force push · blocks every force-push`, or `▲ hold: deploying to production · holds deploys to production`
331
+ with its catch. A line rules.md can't take as written ("name the repository") is `?`, with the reason and the closest
332
+ rule (`block: push-main`). Never ✓: Anvil doesn't claim a line asked for exactly that.
333
+ - **Then it asks:** enter ("Enforce them now") writes their own `block:` and `hold:` lines, in force at once; `w`
334
+ ("Watch them first") writes `watch:` lines; esc or `q` saves nothing. A narrow or plain terminal asks in one line:
335
+ `↵ hold these N now · w watch first · q save nothing`.
336
+ - **With no terminal** it saves nothing, and says how. `--yes` writes `watch:` lines (a script never holds unasked),
337
+ except on a kind Anvil holds part of from the start or one of its own rules covers: there "never" saves `block:` and
338
+ "ask before" saves `hold:`, so a line never leaves Anvil weaker than its default, and the output says why.
339
+ - **Each rule once.** Two lines with the same words keep the stronger verb; a rule on a whole kind covers a narrower
340
+ one with the same verb (the skipped line names it); a line that gives a block and a hold adds both. A rule already in
341
+ rules.md is never added again; one there with a weaker verb is named, to change there.
342
+ - **After `w`**, hold a rule narrower than its kinds by changing `watch:` to `hold:` and running `sync`, never
343
+ `enforce` (that holds the whole kind).
344
+ - **What stays in CLAUDE.md:** advice, counted ("Not enforced: N lines are guidance"); lines Anvil can't hold yet, with
345
+ why ("Anvil can't hold commits yet"); and a list of what may go ahead ("Fine without asking: …").
346
+ - **Reading each line with the rules box** (✓ ▲ ?) is off by default: on real CLAUDE.md files it found too few rules
347
+ and made some weaker. `ANVIL_REWRITE_STEP=1` turns it on.
348
+
349
+ `rules add "…"` writes a `watch:` line, so Anvil watches what it would stop first, and applies it; on a kind Anvil
350
+ holds part of from the start, or one its own rules cover, the line keeps its verb, as with `--yes`.
351
+ `rules remove <id>` removes the line that makes that rule.
419
352
 
420
353
  ## The precedence, written once
421
354
 
422
355
  When more than one thing speaks to a kind, this decides it:
423
356
 
424
- 1. **The always-on stops**, whatever anything says.
425
- 2. **The strongest explicit choice for a kind:**
426
- - a `rules.md` line in scope (block, hold, watch or off);
427
- - a switch on this machine: `anvil claude enforce` / `ghost` for the kind, the screen, or the dashboard;
428
- - `anvil claude enforce` for every kind, which counts as a choice for each kind, so a later `watch:` or `off:` line
429
- never quietly weakens it.
430
-
431
- block > hold > watch > off. A project's file adds to yours.
432
- 3. **Anvil's default (watch)**, only where nothing says anything.
433
- - So `off: sudo` silences a kind that is only watched by default.
434
- - It can't override `anvil claude enforce sudo`, or `enforce` for every kind. The line says so when it is applied,
435
- and the screen won't switch a kind off while `enforce` covers every kind.
436
- 4. **The kill switch** makes every rule at most watched. The always-on stops still block. Caps count, but never hold.
357
+ 1. **Anvil's own rules**, whatever anything says, until you turn one off on the rules screen or with
358
+ `anvil claude off <name>`. One that is off is left out; everything below still judges the call.
359
+ 2. **The strongest explicit choice for a kind**, block > hold > watch > off: a `rules.md` line in scope (a project's
360
+ adds to yours); a switch on this machine (`anvil claude enforce` / `ghost` for the kind, the screen, or the
361
+ dashboard); or `anvil claude enforce` for every kind, which counts as a choice for each, so a later `watch:` or
362
+ `off:` line never quietly weakens it.
363
+ 3. **Anvil's default (watch)**, only where nothing says anything. So `off: sudo` silences a kind only watched by
364
+ default, but can't override `anvil claude enforce sudo` or `enforce` for every kind, and says so when applied.
365
+ 4. **The kill switch** makes every rule at most watched. Anvil's own that are on still stop. Caps and budgets keep
366
+ counting but stop nothing, model rules stop nothing, and no helper's model is switched; the screens say so.
437
367
 
438
368
  ## Caps
439
369
 
440
- A cap lets the agent do something, just not too often or too much.
441
- - **Under the limit**, the call runs with no prompt.
442
- - **At the limit**, the next one is held on the same path as any hold: Yes/No in the terminal, or a deny and one-time
443
- code elsewhere.
444
- - **An OK** lets that one call through, counted, and does not raise the limit.
370
+ A cap lets the agent do something, just not too often or too much. Under the limit, the call runs with no prompt. At
371
+ the limit, the next one is held like any hold: Yes/No in the terminal, or a deny and one-time code elsewhere. An OK
372
+ lets that one call through, counted, without raising the limit.
445
373
 
446
374
  | Kind | Written | Counts | Resets |
447
375
  |---|---|---|---|
@@ -451,96 +379,71 @@ A cap lets the agent do something, just not too often or too much.
451
379
  | Money | `cap: at most $2,000 of Stripe refunds a day` · `cap: no more than €1,000 in Stripe payouts per week` | what each call moves, in the cap's currency, read as a rule's amount is (Conditions: an amount) | local midnight; Monday 00:00 |
452
380
  | Two limits | `cap: 2 deploys a day and 1 an hour` · `cap: 3 force-pushes a day, 10 a week` | each limit on its own, as two caps | each its own |
453
381
 
454
- A money cap catches many small refunds that add up to a lot, which a threshold can't. It adds every amount a line
455
- moves, each refund once. An amount it can't read (a full refund, another currency, a variable) holds the call, saying
456
- so, and takes no place; one you OK counts the whole cap, so what is left is never overstated. The screens say it in
457
- money ("$1,200 of $2,000 used"), never as an estimate.
458
-
459
- - **What counts.**
460
- - Counted: each capped action Anvil reads in a call. `vercel --prod && vercel --prod` is 2 deploys, and so is the
461
- same pair joined by `;`, `&` or `||`, inside `bash -c` or `ssh`, or a literal list (`for e in a b`). A call let
462
- through, an approved one, and a prompt answered Yes all count. A command that runs another several times in a way
463
- Anvil doesn't read counts as written (What it doesn't do).
464
- - A line that would cross a cap partway is held whole, saying what it adds: "cap reached: 2 deploys a day (1 used
465
- today + 2 in this call; resets at midnight)".
466
- - What can't be counted is held, saying so, and takes no place: a line of 16 actions or more (Anvil lists 16 in one
467
- line, so it can't tell 16 from more); a line that repeats what it runs a number of times Anvil can't read (a `for`
468
- loop over a list it can't list, like `{1..50}`, `$(…)`, a glob or a variable; `while`, `until`, `select`, zsh's
469
- `repeat`, `xargs`, `parallel`, `watch`, `find -exec`; a function written `name() { … }` that calls itself), also
470
- inside what a shell runs from a quoted word (`bash -c '…'`, `eval`, `ssh host '…'`), even when the loop isn't around
471
- the capped part; and an MCP tool's shell line of several commands. One you OK counts the whole cap.
472
- - Not counted: a call held with a code. One asked in Claude Code's prompt counts until it is answered.
473
- - Freed: a call Claude Code refused gives its place back. That is a No at its prompt (Anvil's hold or its own
474
- question, in the terminal, the desktop app, or headless's "needs approval"), a deny by a permission rule or another
475
- hook, or auto mode's refusal.
476
- - It is read from the fields Claude Code writes beside the call's result (`toolDenialKind`), never from its words,
477
- which a command can print. That refusal must be the call's only result. A helper agent's call is read in its own
478
- file; one whose file isn't there keeps its place.
479
- - It is read before the next tool call of its own session runs (its main thread's or a helper's), and at other
480
- sessions' calls too (up to 4 more session files a check for places given back and 4 for counts, the newest
481
- first). Claude Code writes a call's result
482
- before then, so a call that ran is settled as run before a later call of its session could change its record. The
483
- place comes back when the refused call's own thread (its session, or its helper agent) makes its next call: then
484
- it isn't running.
485
- - Only where Claude Code can still refuse: under Bypass nothing of its own asks, so a call counts as it runs, even
486
- one a deny rule or another hook refuses there.
487
- - A place given back is checked again for 6 hours. If Claude Code then writes another result for the call, the call
488
- counts again.
489
- - A count with no answer after 6 hours keeps its place (an Anvil hold asked in the prompt is read while its window
490
- lasts). A Yes read after midnight still counts on the day the call ran.
491
- - **Two limits on one line** are two caps. `cap: 2 deploys a day and 1 an hour` counts each limit; a hold names the
492
- one reached, or both. A limit that names nothing counts what the one beside it does ("1 an hour" counts deploys).
493
- One window twice is refused. Helper agents at once stay on a line of their own.
494
- - **Numbers.** Digits ("1,000") or words ("a hundred", "twenty-five", "a dozen"). Money is written in digits ("$2,000"):
495
- in words it is refused, never read as that many calls.
496
- - **Held for another reason.** A call held by another rule that would also go over a cap names both in the one reason
497
- ("…; and cap reached: 1 deploy a day"), so one OK covers both, and the approved call counts.
498
- - **Safe across sessions.**
499
- - The counts live in an append-only ledger, one file per local day, under `~/.anvil/claude/caps`.
500
- - Each call appends its reservation first, then counts only what is ahead of it, so two sessions can't both take the
501
- last place.
502
- - Every reservation ahead counts, whatever clock its session read.
503
- - A day's file is found by calendar date, so a 25-hour day (clocks going back) is still read.
504
- - **A cap that can't be counted holds the call.** When the ledger can't be written or read, or a day's count is over
505
- 4 MB, the call is held ("couldn't check your cap …"). It never runs on a part count.
506
- - **Each file's caps are its own.** A project's "2 deploys a day" counts only that project's calls. Two projects'
507
- identical caps are two counts.
508
- - **Paid-compute caps are estimates and say so.** Anvil sees the command that starts compute, never the bill.
509
- - It reads the machines (`--count`, `--num-nodes`, gcloud's instance names), the hours (`--max-run-duration`,
510
- `--hours`), and a GPU (`--gpus`, `--accelerator`, a GPU machine type).
511
- - What a start doesn't state counts as 1. A line with several starts counts each, at the line's largest figures
512
- (never fewer). The cap's line in `status` says "an estimate".
513
- - A GPU cap counts every paid-compute start. Anvil can't tell from a command that a machine has no GPU (a type it
514
- doesn't know, like p4d, g5 or ND, may have one), so it never assumes so: it holds sooner, never later.
515
- - A dollar cap needs your own price ("GPU hour = $2"). Without one it is refused: Anvil never guesses a price.
516
- - "At once" is counted per day for machines, and the line says so (helper agents at once are counted live: below).
517
- - **Where caps show.**
518
- - `status` shows each cap that applies where it runs (yours, and that project's), its use and when it resets: a line
519
- with two limits shows two. `/anvil` shows yours.
520
- - Replay replays each cap over your history in time order, counting a line's actions as the hook does for count and
521
- money caps: "cap 2 force-pushes a day: reached on 1 day, 1 call would have waited for your OK". Paid compute counts
522
- once there for a call that leads with a start (1 machine or hour, or one at your price), whatever it names.
382
+ A money cap catches many small refunds that add up, which a threshold can't. It adds every amount a line moves, each
383
+ refund once; an amount it can't read holds the call, saying so, and takes no place. One you OK counts the whole cap, so
384
+ what is left is never overstated. The screens say it in money ("$1,200 of $2,000 used"), never as an estimate.
385
+
386
+ - **What counts.** Each capped action Anvil reads in a call: `vercel --prod && vercel --prod` is 2 deploys, as is the
387
+ pair joined by `;`, `&` or `||` (`a || a` is 2: Anvil can't know which runs), inside `bash -c` or `ssh`, or in a
388
+ literal list (`for e in a b`). Calls let through, approved, or answered Yes all count. A line that would cross a cap
389
+ partway is held whole: "cap reached: 2 deploys a day (1 used today + 2 in this call; resets at midnight)".
390
+ - **What can't be counted is held,** saying so, and takes no place; one you OK counts the whole cap. That is a line of
391
+ 16 actions or more, an MCP tool's shell line of several commands, and a line that repeats something a number of
392
+ times Anvil can't read, even when the loop isn't around the capped part
393
+ (`for f in *.yml; do lint "$f"; done && vercel deploy` waits too): a `for` over `{1..50}`, `$(…)`, a glob or a
394
+ variable, `while`, `until`, `select`, zsh's `repeat`, `xargs`, `parallel`, `watch`, `find -exec`, or a function
395
+ written `name() { … }` that calls itself, also inside a quoted word a shell runs (`bash -c '…'`, `eval`, `ssh`).
396
+ - **Not counted:** a call held with a code. One asked in Claude Code's prompt counts until it is answered.
397
+ - **A refused call gives its place back:** a No at Claude Code's prompt (Anvil's or its own, anywhere), a deny by a
398
+ permission rule or another hook, or auto mode's refusal. Anvil reads it from Claude Code's own record beside the
399
+ call's result, never from words a command prints. Under Bypass nothing of Claude Code's own asks, so a call counts as
400
+ it runs. A place given back is checked again for 6 hours; a count with no answer after 6 hours keeps its place.
401
+ - **Two limits on one line:** a hold names the one reached, or both; a limit that names nothing counts what the one
402
+ beside it does ("1 an hour" counts deploys). One window twice is refused. Helpers at once stay on a line of their own.
403
+ - **Numbers** are digits ("1,000") or words ("a hundred", "a dozen"). Money is written in digits ("$2,000"); in words
404
+ it is refused, never read as that many calls.
405
+ - **Held for another reason too:** the one reason names both ("…; and cap reached: 1 deploy a day"), so one OK covers
406
+ both, and the approved call counts.
407
+ - **Safe across sessions.** Counts live in an append-only ledger under `~/.anvil/claude/caps`, one file per local day;
408
+ each call reserves its place first, so two sessions can't both take the last one. A ledger that can't be written or
409
+ read, or a day's count over 4 MB, holds the call ("couldn't check your cap …"): it never runs on a part count.
410
+ - **Each file's caps are its own.** A project's "2 deploys a day" counts only that project's calls.
411
+ - **Paid-compute caps are estimates, and say so** in `status`: Anvil sees the command, never the bill. It reads
412
+ machines (`--count`, `--num-nodes`, gcloud's instance names), hours (`--max-run-duration`, `--hours`) and a GPU
413
+ (`--gpus`, `--accelerator`, a GPU machine type); what a start doesn't state counts as 1, and a line with several
414
+ starts counts each at its largest figures. A GPU cap counts every start, since a type Anvil doesn't know (p4d, g5,
415
+ ND) may have one. A dollar cap needs your price ("GPU hour = $2"); Anvil never guesses one. "At once" counts machines
416
+ per day (helpers at once are counted live).
417
+ - **Where caps show.** `status` shows each cap that applies where it runs, its use and when it resets; `/anvil` shows
418
+ yours. Replay replays each cap over your history ("cap 2 force-pushes a day: reached on 1 day, 1 call would have
419
+ waited for your OK").
523
420
 
524
421
  ## Budgets
525
422
 
526
- A budget limits what Claude Code itself spends: its model use, in dollars, new tokens or a share of your plan. It is
527
- yours, so it lives in `~/.anvil/rules.md`: a project's file can't hold one, and says so.
423
+ A budget limits what Claude Code itself spends: model use in dollars, new tokens or a share of your plan. It is yours,
424
+ so it lives in `~/.anvil/rules.md`; a project's file can't hold one, and says so.
528
425
 
529
426
  | Written | Counts | Resets |
530
427
  |---|---|---|
531
428
  | `budget: $50 a day` · `budget: $250 a week` | dollars at API prices: Claude Code's own figure where its status line runs, or once a session ends; until then, Anvil's estimate at list price (the desktop app) | local midnight; Monday 00:00 |
532
- | `budget: $20 a task` | the same, for one message and everything Claude does until it stops (a helper reporting back continues it) | your next message |
429
+ | `budget: $20 a task` | the same, for one message and everything Claude does until it stops (a helper reporting back continues it); set mid-task, it counts from your next message | your next message |
533
430
  | `budget: 5M new tokens a day` | input, output and cache writes (cache reads left out) | as dollars |
534
431
  | `budget: 80% of my weekly limit` · `budget: 90% of my 5-hour limit` | the share Claude Code reports: to its status line in the terminal, and to its `/usage`, which Anvil asks where no status line feeds it (the desktop app) | when the plan's window does |
535
432
 
536
- - **Every session counts.** A day's or a week's budget is every Claude Code session's on this computer: their spend,
537
- and the work each has in progress (replies under way, helpers running, launches being made), so two sessions can't
538
- pass it together. A task's budget is its own session's.
539
- - **Near it, held a little early.** A reply under way always finishes, so Anvil holds when what's spent and what's
540
- running could pass the budget, saying so: "nearly spent … and what's running could pass it". A helper is priced as
541
- Claude Code will cache it (about half when another helper on the same model replied in the last 5 minutes); before any
542
- helper has run on this computer its size is a guess, and the hold says that too.
433
+ - **Adding one.** `anvil claude rules add 'budget: $50 a day'` (it shows the line and asks first; `--yes` skips the
434
+ question), the rules screen's box, or a line in `~/.anvil/rules.md` and then `anvil claude sync`.
435
+ - **Every session counts.** A day's or week's budget covers every Claude Code session on this computer: their spend and
436
+ the work each has in progress (replies under way, helpers running, launches being made), so two sessions can't pass
437
+ it together. A task's budget is its own session's.
543
438
  - **At 80%**, Claude Code says so once a window: `🔹 Anvil 🔹 $40 of today's $50 used`.
439
+ - **It holds a little early, so it stops at its number.** A reply under way always ends, so each check also counts
440
+ what's running: two more replies of the main chat and of each running helper, priced as their latest, and at a
441
+ helper's launch its first reply (mostly the cache write of its instructions) and the launches just before it. A helper
442
+ is priced as Claude Code will cache it (about half when another on the same model replied in the last 5 minutes);
443
+ before any has run here its size is a guess, and the hold says so. When what's spent and what's running could pass
444
+ the budget, it holds now ("today's budget is nearly spent: 15K of 20K new tokens, and what's running could pass it";
445
+ a refused message says "the next replies could pass it"). The guess for running replies counts for at most half the
446
+ budget, so nothing is held before half is used; a launch counts whole. A budget can still end over by about a reply.
544
447
  - **Spent**, the next message is refused before it reaches the model, and the next action is held, each with a
545
448
  one-time code:
546
449
 
@@ -553,72 +456,37 @@ yours, so it lives in `~/.anvil/rules.md`: a project's file can't hold one, and
553
456
  anvil claude rules edit
554
457
  ```
555
458
 
556
- `anvil claude allow <code>`, in your own terminal, lets that task go on past that budget: send the message again, or
557
- let Claude try again, and Claude is told you allowed it. The OK reaches this window only (a new day, week or plan
558
- window asks again), up to one more budget's worth, and an hour at most, whichever ends first; then the next action is
559
- held again, with a new code. Another budget spent in the same task still stops it, with its own code. Your next
560
- message is a new task, checked again. A held action gets a code, never Claude Code's Yes/No prompt: one OK covers
561
- the task within those bounds, and the stop is the same everywhere (under Bypass, the desktop app runs a call the hook
562
- asks about). The other holds that budget left waiting in the session go with the OK, so `allow` and Home show one,
563
- not one per message.
564
- - **It stops at its number, not a few replies past it.** Anvil acts between steps, never inside a reply: a reply under
565
- way always ends, and each thread then writes one more reading what came back. So each check also counts what's
566
- running: two replies of the main chat and of each helper running (a helper that has finished counts nothing),
567
- priced as their latest replies were, and at a helper's launch that helper's first reply (most of it the cache write
568
- of its instructions) and the launches let through just before it. When what's spent and what's running could pass
569
- the budget, it holds now:
570
-
571
- ```
572
- 🔹 Held by Anvil for your OK 🔹 today's budget is nearly spent: 15K of 20K new tokens, and what's running could pass it · …
573
- 🔹 Held by Anvil for your OK 🔹 the helpers starting could pass today's budget: 4K of 20K new tokens used · …
574
- ```
575
-
576
- A message refused this way says "the next replies could pass it".
577
- The guess about replies already running counts for at most half the budget, so a budget is never held before half of
578
- it is used; a launch, which can still be refused, is counted whole. Measured live, three helpers launched at once
579
- against 20K new tokens a day: 39,993 before (100% over), 17,695 now (the third launch held). What a reply under way
580
- spends can't be known until it ends, so a budget can still end a little over, by about a reply. A plan's share
581
- needs no reserve: a few replies are a hundredth of a point of a week. Other sessions running at the same time are
582
- not counted in a session's reserve.
583
- - **A model Anvil has no price for still counts.** It is priced at the newest model of its family (a new Opus at Opus
584
- 5.5's prices), else at the most expensive Anvil knows, and every total and hold says so: "~$3.30 of $1
585
- (claude-opus-6: estimated at Opus 5.5's prices)". A dollar budget never stops counting because a model is new.
586
- - **What can't be measured is said, and never enforced.** A plan's share Claude Code can't report here (an API key,
587
- a Claude Code without `/usage`), a meter that can't be read: Claude Code shows "your budget … can't be measured here: … ·
588
- not enforced" once a session, and `rules add`, Home, `report`, `anvil claude rules` and the rules screen say it too,
589
- with the fix, never "Claude stops". A task budget counts from the message that starts a task: one set mid-task says
590
- it counts from your next message. A false stop costs more trust than a missed one.
591
- - **Your plan's share, read.** In the terminal, Claude Code hands it to Anvil's status line after every reply. Where
592
- no status line feeds Anvil (the desktop app, or your own status line kept by `anvil claude on`), Anvil asks Claude
593
- Code's own `/usage` in the background: a few seconds, no model call and nothing spent, at most every 5 minutes (2
594
- near your budget), only while a plan budget is set. Anvil never reads your sign-in: Claude Code does, and a reading
595
- counts only for the account it signed in as (an API key's session is never held by your plan). A session's
596
- first message after an hour or more away goes on while the reading comes; the next check uses it. `rules add` and
597
- `report` ask at once, so they show where your week stands.
598
- - **Except a day too large to count.** A day of the meter over 32 MB (about 100,000 replies: a loop, or something
599
- writing to it) never reads as $0: the budget holds, with the same code, saying it "can't be counted". Replies that
600
- used nothing are never written to the meter.
601
- - **Nowhere to keep the OK, nothing stopped.** If the hold can't be recorded (Anvil's folder can't be written, a full
602
- disk), the budget says it is spent and that Anvil can't record an OK, and lets the message or action through rather
603
- than leave you with no way on.
604
- - **Claude can't feed the meter.** Anvil's own hook files run by hand (`node ~/.anvil/claude/bin/claude-hook.js`) and
605
- `anvil claude statusline` run by Claude are held, always: Claude Code runs both itself, never through a tool call, so
606
- what Claude would feed them is made up. An agent that copies Anvil's files elsewhere, or reads its seal key, can still
607
- forge what they record: the integrity design accepts that, and budgets are a spending guard, not a security floor.
608
- - **Your messages are never read.** The message hook reads the session's id, its file and its folder, never the
609
- message. Where a Claude Code older than 2.1.153 is found, `on` writes no message hook: a spent budget holds the next
610
- action only, an OK lasts an hour, and Claude learns of an OK only from you. The Claude Code plugin has the message
611
- hook too (from this release).
612
- - **The kill switch** leaves budgets counting but stopping nothing, as it does caps.
613
- - **Where budgets show.** Home's state line (`On · $12 of $50 today · 9 checked today`; past it, with an OK still
614
- running, "going on with your OK until 4:12 PM"), `anvil claude report` and `anvil claude rules` (each limit with what
615
- it does now and where it stands), the rules screen (a Budgets section), the screen `on` ends with, and Proof (stops
616
- by "your budget").
617
- - **Adding one.** `anvil claude rules add "budget: $50 a day"` (it shows what the line became and asks first; `--yes`
618
- skips the question), the rules screen's box, or a line in `~/.anvil/rules.md` and then `anvil claude sync`.
619
- - **A budget is not a cap.** A cap counts what the agent does (deploys, deletes, paid compute at your price). A budget
620
- counts what Claude Code spends. A line that reads as the other says which to write: `cap: $50 a day` gets "what
621
- Claude Code spends is a budget: write budget: $50 a day".
459
+ `anvil claude allow <code>`, in your own terminal, lets that task go on: send the message again, or let Claude retry,
460
+ and Claude is told you allowed it. The OK covers this window only (a new day, week or plan window asks again), up to
461
+ one more budget's worth and an hour at most; then the next action is held with a new code. Another budget spent still
462
+ stops the task, and your next message is a new task. A held action gets a code, never Claude Code's Yes/No prompt, so
463
+ the stop is the same everywhere (under Bypass, the desktop app runs a call the hook asks about). Other holds the
464
+ budget left waiting go with the OK.
465
+ - **A model Anvil has no price for still counts,** at the newest model of its family (a new Opus at Opus 5.5's
466
+ prices), else the most expensive Anvil knows, and every total and hold says so: "~$3.30 of $1 (claude-opus-6:
467
+ estimated at Opus 5.5's prices)".
468
+ - **What can't be measured is said, and never enforced.** Where Claude Code can't report a plan's share (an API key, a
469
+ Claude Code without `/usage`) or the meter can't be read, Claude Code shows "your budget … can't be measured here: …
470
+ · not enforced" once a session, and `rules add`, Home, `report`, `anvil claude rules` and the rules screen say so
471
+ with the fix, never "Claude stops".
472
+ - **Your plan's share** reaches Anvil's status line after every reply in the terminal. Elsewhere (the desktop app, or
473
+ your own status line kept by `on`), Anvil asks Claude Code's `/usage` in the background: a few seconds, no model call,
474
+ nothing spent, at most every 5 minutes (2 near your budget), only while a plan budget is set. Anvil never reads your
475
+ sign-in; a reading counts only for the account Claude Code signed in as (an API key's session is never held by your
476
+ plan). A first message after an hour away goes on while the reading comes. `rules add` and `report` ask at once.
477
+ - **A day too large to count holds.** A meter day over 32 MB (about 100,000 replies) holds, as "can't be counted".
478
+ - **Nowhere to keep the OK, nothing stopped.** If the hold can't be recorded (a full disk), the budget says so and lets
479
+ the message or action through rather than leave you with no way on.
480
+ - **Claude can't feed the meter.** Anvil's hook files run by hand and `anvil claude statusline` run by Claude are always
481
+ held: Claude Code runs both itself. An agent that copies Anvil's files elsewhere, or reads its seal key, can still
482
+ forge what they record: budgets are a spending guard, not a security boundary.
483
+ - **Your messages are never read.** The message hook reads the session's id, file and folder, never the message. Where
484
+ a Claude Code older than 2.1.153 is found, `on` writes no message hook: a spent budget holds the next action only, an
485
+ OK lasts an hour, and Claude learns of an OK only from you. The Claude Code plugin has the message hook too.
486
+ - **Where budgets show.** Home's state line (`On · $12 of $50 today · 9 checked today`), `anvil claude report`,
487
+ `anvil claude rules`, the rules screen, the screen `on` ends with, and Proof (stops by "your budget").
488
+ - **A budget is not a cap.** A cap counts what the agent does; a budget, what Claude Code spends. A line that reads as
489
+ the other says which to write: `cap: $50 a day` gets "what Claude Code spends is a budget: write budget: $50 a day".
622
490
 
623
491
  ## Helper agents
624
492
 
@@ -633,88 +501,60 @@ The agents Claude launches (the Agent tool) have rules of their own:
633
501
  | `hold: helper agents` | every launch waits for your OK |
634
502
 
635
503
  - Claude Code takes sonnet, opus, haiku or fable. A rule naming a type wins over one for every helper; a project's over
636
- yours. A fork helper always keeps the session's model: it passes as it came, and Anvil says so once a session.
504
+ yours. A fork helper always keeps the session's model, and Anvil says so once a session. Only a launch's type and
505
+ model are read, never its prompt or a helper's reply; each switch is kept 40 days for Proof.
637
506
  - Where your own permission rules deny helper launches, Anvil adds nothing; where they ask first, the switch rides on
638
- that ask, and the at-once cap still counts the launch: past it, it is held with the cap's reason. Under the kill
639
- switch nothing is switched.
640
- - The at-once count needs Claude Code 2.1.318 or later (it reports helpers starting and stopping). Under an older one,
641
- and under the plugin alone, Anvil says it can't count, and never holds; `on` and Home name the older one with the
642
- command that updates it. A launch put to you in Claude Code's prompt keeps
643
- its place until you answer (a No gives it back; 30 minutes at most). A workflow's helpers count too. A helper that
644
- never reports stopping (stopped with Esc, a crash) stops counting 30 minutes after it last did anything.
645
- - Only a launch's type and model are read, never its prompt or a helper's reply. Each switch is kept 40 days for Proof.
646
- - **With no rule at all**, more than 20 helper launches in 10 minutes in one session wait for your OK: always on, like
647
- the delete bursts (ALWAYS-ON.md). Your OK lets that burst go on; the next 20 run without asking. A cap of yours is
648
- different: past it, each launch needs its own OK.
507
+ that ask, and the at-once cap still counts the launch.
508
+ - **Counting helpers at once** needs Claude Code 2.1.318 or later; under an older one, or the plugin alone, Anvil says
509
+ it can't count, and never holds. A launch waiting at Claude Code's prompt keeps its place until you answer (a No
510
+ gives it back; 30 minutes at most); a workflow's helpers count too. A helper that never reports stopping (Esc, a
511
+ crash) stops counting 30 minutes after it last did anything.
512
+ - **With no rule at all**, more than 20 helper launches in 10 minutes in one session wait for your OK (Anvil's own
513
+ **Launch helpers in a burst**, on by default). Your OK lets that burst go on, and the next 20 run without asking;
514
+ past a cap of yours, each launch needs its own OK.
649
515
 
650
516
  ## The main chat's model
651
517
 
652
- No tool can switch the main chat's model, and its `model` setting is your own choice, so Anvil never switches it. It
653
- holds an action made on the wrong model, or refuses a switch:
518
+ No tool can switch the main chat's model, and its `model` setting is your choice, so Anvil never switches it: a model
519
+ rule holds an action made on the wrong model, or refuses a switch. (Helpers differ: Claude Code lets a hook rewrite a
520
+ launch, so `model: haiku for exploring` switches them.)
654
521
 
655
522
  | Written | Does |
656
523
  |---|---|
657
524
  | `model: opus for deploys` | a deploy is held unless the model making it is Opus (any kind of action: `for pushes to main`, `for publishing a package`) |
658
525
  | `model: never opus[1m]` | a switch to Opus 1M is refused, and so is a message in a session on it (started there by the desktop app's picker or `claude --model`); `model: never opus` refuses Opus in any form |
659
526
 
660
- - **Held on the wrong model:**
661
-
662
- ```
663
- 🔹 Held by Anvil for your OK 🔹 deploys need Opus; this session is Sonnet · switch: /model opus
664
- ```
665
-
666
- Switch with `/model opus` and ask Claude to try again: the next try runs. Or let it run once on the model it is on:
667
- Yes in Claude Code's prompt, or `anvil claude allow <code>` where the hold has a code (the desktop app, Bypass).
668
- - **Which model made the call** is read twice from Claude Code's session file: its latest request line, written as
669
- each request goes out (Claude Code 2.1.304 or later), and the reply, which names the model that answered and the
670
- request it answers. In the desktop app and a headless run, the reply carrying the call lands a moment after the check
671
- starts, and Anvil waits for it (half a second at most); in the terminal it is written after the check, so there a
672
- request line written right after another with no reply between must name the same model, unless a change is recorded
673
- or heard (`/model`, Claude Code's fallbacks, plan mode, a switch Anvil heard); after a reply, the request alone is the
674
- reading, since the model changes between replies in ways Claude Code records nowhere first. Two readings that differ
675
- hold the call, and the hold names both. With no request line, the reply is read (Claude Code 2.1.304 or later, its
676
- record off; before 2.1.304 only the reply that carries the call, where it streams).
677
- With neither, the call isn't held: every call the rule names says Anvil can't hear the model, and so do the rules
678
- screen, Home and the status line, for a week. A helper agent's call is judged by the helper's model, from its own
679
- file. (MODELS.md has the measurements.)
680
- - **A switch refused** is refused wherever Claude Code switches: `/model` in the terminal, the desktop app's model
681
- picker, an SDK's `set_model`. Claude Code says "Model switch blocked by a PreModelSwitch hook" with the rule. It
682
- needs Claude Code 2.1.251 or later, and the switch entry, which `anvil claude on` adds where every Claude Code it finds
683
- is 2.1.153 or later (and the plugin carries from this release): elsewhere `rules add` and the screens say a `never`
684
- isn't refusing yet, and name the Claude Code to update.
527
+ - **Held on the wrong model:** "deploys need Opus; this session is Sonnet · switch: /model opus". Switch with
528
+ `/model opus` and ask Claude to try again, or let it run once on the model it is on: Yes in Claude Code's prompt, or
529
+ `anvil claude allow <code>` where the hold has a code (the desktop app, Bypass).
530
+ - **Which model made the call** is read from Claude Code's session file: its latest request line (2.1.304 or later)
531
+ and the reply, which names the model that answered. Two readings that differ hold the call, naming both. With
532
+ neither, the call isn't held: every call the rule names says Anvil can't hear the model, and so do the rules screen,
533
+ Home and the status line, for a week. A helper's call is judged by the helper's model, from its own file.
534
+ - **A switch refused** is refused wherever Claude Code switches (`/model`, the desktop app's picker, an SDK's
535
+ `set_model`): Claude Code says "Model switch blocked by a PreModelSwitch hook" with the rule. Where Claude Code is too
536
+ old for it (What each limit needs), `rules add` and the screens say a `never` isn't refusing yet.
685
537
  - **A session already on a model your rules say never** (it started there: no hook can stop that) is told at its first
686
538
  action: "this session runs on Opus 1M, which your rules say never · switch with /model".
687
- - **What the words cover.** A model rule holds the kinds its words name, and `rules add` says which: "pushes need
688
- Opus" covers a push or merge to main and a force-push; a push to a feature branch isn't a kind Anvil checks, so it
689
- runs on any model. `anvil claude rules` lists each rule by its kinds.
690
- - **Two rules no one model meets** (`model: opus for deploys` and `model: sonnet for pushes to main`: a call that does
691
- both is held on any model) are said as the second is added, by `rules add` and the box.
692
- - **Rules:** one model rule per kind, and one `never` per model. A `never` that forbids what a guard needs is refused,
693
- with the line it contradicts. A model rule names a model as `/model` does: `opus`, not one version
694
- (`never claude-opus-4-8` is refused, since a rule on Opus would also refuse the Opus you run), and for an action
695
- never `opus[1m]`. A rule is per kind: `model: opus for deploys on Fridays` holds every deploy made on another model,
696
- and says so. Words that only say where ("in this repo") are the file's to decide. A project's model rules apply
697
- inside that project only, and its rule for a kind wins over yours there. Where no switch could run a held call (two
698
- kinds on two models, or a `never` that refuses the switch), the hold says so and offers only to allow it once. The
699
- kinds always stopped can't take one. The kill switch leaves model rules stopping nothing, and the screens say so.
700
- - **Where they show:** `anvil claude rules` (with caps and budgets, each with what it does now), the rules screen
701
- (⌫ twice removes one, the box adds one), Proof (`your model rule`) and `report`.
702
- - **Claude's writes to its session files are held.** A write to a session's file, a helper's, or the folders holding
703
- them (a redirect, `tee`, `sed -i`, `cp` or `mv` onto one, `rm`, a pattern of them, a variable an `ls` or `find` there
704
- fills, a writer `xargs` or `find -exec` hands them, `node -e` or `python -c` naming one or handed one, `sh -c`
705
- handed one by position, an archive
706
- unpacked into their folder, the Write and Edit tools) is a change to the agent's controls, held from the first call.
707
- Memory notes, reading, copying out and month-old housekeeping stay open. Code or a script that finds the path itself
708
- can still write one, as it can any file; the two readings then still have to agree, so one forged line no longer flips
709
- a guard.
710
- - **Helpers versus the main chat.** `model: haiku for exploring` switches helper agents (Claude Code lets a hook
711
- rewrite a launch). `model: opus for deploys` never switches anything: it holds.
539
+ - **What the words cover.** A model rule holds the kinds its words name, and `rules add` says which: "pushes need Opus"
540
+ covers a push or merge to main and a force-push; a push to a feature branch isn't a kind Anvil checks, so it runs on
541
+ any model.
542
+ - **Writing them.** One model rule per kind, and one `never` per model; a `never` that forbids what a guard needs is
543
+ refused, naming the line it contradicts. Name a model as `/model` does, `opus` rather than a version:
544
+ `never claude-opus-4-8` is refused, since a rule on Opus would also refuse the Opus you run. For an action, never
545
+ `opus[1m]`. Words that only say where ("in this repo") are the file's to decide; a project's model rules apply inside
546
+ it only, and win over yours there. Two rules no one model meets (`model: opus for deploys` beside
547
+ `model: sonnet for pushes to main`) are said as the second is added; where no switch could run a held call, the hold
548
+ offers only to allow it once (the kinds always stopped can't take one).
549
+ - **Where they show:** `anvil claude rules` (by kind), the rules screen, Proof (`your model rule`) and `report`.
550
+ - **Claude's writes to its session files are held** from the first call, by any tool or command Anvil can read, as
551
+ changes to the agent's controls; memory notes, reading, copying out and month-old housekeeping stay open. A script
552
+ that finds the path itself can still write one, but the request line and the reply then still have to agree.
712
553
 
713
554
  ## Locked folders, smart spend and a second opinion
714
555
 
715
- Three more things a rule can say. Write the line, or say it in your own words: `rules add` and the rules box read both,
716
- show the line it becomes and what it does, and save nothing until you say yes. `anvil claude off` takes each one out
717
- again and puts every settings byte back.
556
+ Three more things a rule can say, as the line or in your own words: `rules add` and the box show the line and what it
557
+ does, and save nothing until you say yes. `anvil claude off` takes each out again and puts every settings byte back.
718
558
 
719
559
  | Say | It becomes | What it does |
720
560
  |---|---|---|
@@ -722,12 +562,10 @@ again and puts every settings byte back.
722
562
  | "use smart spend", "Sonnet does the work, Opus advises" | `model: smart` | new terminal sessions: Sonnet works, Opus advises |
723
563
  | "get a second opinion before deploys", "check with Opus before publishing" | `second opinion: deploys` | Claude asks the advisor before the first deploy in a task |
724
564
 
725
- Who approves decides. "Ask me before deploys" and "get my OK before deploys" stay a hold: you approve, not the advisor.
726
- "Use opus for deploys" is a model rule (`model: opus for deploys`), "never use opus" is `model: never opus`, and "keep
727
- spending under $50 a day" is a budget. Words that mention the advisor or Opus that Anvil can't place are never saved as
728
- a watch: Anvil offers the exact line ("Did you mean second opinion: deploys?") and saves nothing without it. Where your
729
- Claude Code is here, `rules add` asks it about such a line first (Haiku, through your login); it can choose between
730
- the two forms, never add a kind your words don't name.
565
+ Who approves decides: "ask me before deploys" stays a hold, "use opus for deploys" is a model rule, "never use opus" is
566
+ `model: never opus`, and "keep spending under $50 a day" is a budget. Words about the advisor or Opus that Anvil can't
567
+ place are never saved as a watch: Anvil offers the exact line ("Did you mean second opinion: deploys?") and saves
568
+ nothing without it. Your Claude Code, where it is here, may pick the form, never add a kind your words don't name.
731
569
 
732
570
  ### A rule on a folder locks it
733
571
 
@@ -735,27 +573,25 @@ the two forms, never add a kind your words don't name.
735
573
  - block: edits to ~/Documents/
736
574
  ```
737
575
 
738
- Nothing to turn on. A `block:` on a file or folder is kept twice: the hook blocks every write to it that it can read, and
739
- Claude Code's sandbox makes the operating system refuse a write there from Bash that the hook can't read, such as a
740
- script that builds its path while it runs. Proof names the rule: `locked by your rule: <rule> · the sandbox refused a
741
- write to <path>`.
576
+ Nothing to turn on. A `block:` on a file or folder is kept twice: the hook blocks every write to it that it can read,
577
+ and Claude Code's sandbox has the operating system refuse a Bash write there that the hook can't read, such as a
578
+ script that builds its path as it runs. Proof names the rule:
579
+ `locked by your rule: <rule> · the sandbox refused a write to <path>`.
742
580
 
743
- - **Approval prompts stay as they were**, in every permission mode. Anvil turns off Claude Code's "auto-allow inside the
744
- sandbox" and adds no folder to its write list (Claude Code would take one as leave to change files there unasked). A
745
- command that writes outside the project and its temp folders (a global install, a cache in your home folder) is
746
- refused in the sandbox, then rerun outside it and asked as any command is (bypass mode just reruns). The hook judges
747
- each rerun: one right after a refusal on a locked path is held.
581
+ - **Approval prompts stay as they were**, in every permission mode: Anvil turns off "auto-allow inside the sandbox"
582
+ and adds no folder to its write list. A command that writes outside the project and its temp folders (a global
583
+ install, a cache in your home folder) is refused in the sandbox, then rerun outside it and asked as usual (bypass
584
+ mode just reruns); a rerun right after a refusal on a locked path is held.
748
585
  - **The rules listing says, per rule,** `locked`, `partly locked: <why>`, or `held by Anvil, not locked: <why>`.
749
- - **What stays with the hook alone:** a pattern (`*.lock`, `migrations/` at any depth), a `hold:` (a lock would refuse
750
- the write your OK lets run), a `watch:` or a rule with a condition, a folder at a project's root in your own file,
751
- native Windows, and a sandbox you turned off yourself (it stays off, and the screens say so).
752
- - **Linux needs bubblewrap and socat**, and on Ubuntu an AppArmor that lets bubblewrap run: the screens say which is
753
- missing, and what to install. Without them the hook still blocks what it can read.
754
- - **Network, git, Docker and localhost work as before.** The sandbox covers Bash and what it starts; Read, Edit, Write
755
- and MCP tools are the hook's.
756
- - **A project with its own sandbox settings.** Where they turn the sandbox off, your locks hold there by the hook alone
757
- (`held by Anvil only in this project`). Where it has a sandbox of its own, Anvil's open network settings merge into it
758
- (Claude Code adds every file's allowed sites together): the screens there say so, and how to keep it as set.
586
+ - **The hook alone covers** a pattern (`*.lock`, `migrations/` at any depth), a `hold:` (a lock would refuse the write
587
+ your OK lets run), a `watch:` or a rule with a condition, a folder at a project's root in your own file, native
588
+ Windows, and a sandbox you turned off yourself (it stays off, and the screens say so).
589
+ - **Linux needs bubblewrap and socat**, and on Ubuntu an AppArmor that lets bubblewrap run; the screens say what to
590
+ install. Without them the hook still blocks what it can read.
591
+ - **Network, git, Docker and localhost work as before.** The sandbox covers only Bash and what it starts.
592
+ - **A project's own sandbox settings:** where they turn it off, your locks hold there by the hook alone
593
+ (`held by Anvil only in this project`); where they set one up, Anvil's open network settings merge in, and the
594
+ screens say how to keep it as set.
759
595
 
760
596
  ### `model: smart`: Sonnet works, Opus advises
761
597
 
@@ -763,32 +599,28 @@ write to <path>`.
763
599
  - model: smart
764
600
  ```
765
601
 
766
- Anvil writes `model: "sonnet"` and `advisorModel: "opus"` into Claude Code's settings. Claude Code's advisor tool then
767
- lets Sonnet ask Opus mid-task. Anthropic's figure: about 12% cheaper per coding task, and slightly better than Sonnet
768
- alone.
769
-
770
- - **New sessions only.** A session running now keeps its model.
771
- - **Your own file only.** In a project's rules.md it is refused, as a budget is, and so is a `model: never sonnet` or
772
- `never opus` beside it.
773
- - **The desktop app keeps its own model.** It starts every session on the model picked in its menu, so there smart can't
774
- make Sonnet work: pick Sonnet in the app. The advisor setting still reaches it, and the screens say so.
775
- - **Never "on" before a session shows it.** Until one does, every screen says `advisor: Opus · set: seen at your next
776
- session`; after a session with the advisor, `advisor: Opus · on`.
777
- - **When Claude Code doesn't attach the advisor** for your account (its rollout, your plan's credits, or a telemetry
778
- setting), the next session from your terminal, the desktop app or an editor shows it, and from then on every screen
779
- says "Claude Code didn't attach the advisor for this account: smart runs Sonnet alone", with how to have your own
780
- model back. Anvil never switches it back for you. A `claude -p` or Agent SDK run can show it on, never off.
602
+ Anvil writes `model: "sonnet"` and `advisorModel: "opus"` into Claude Code's settings, so Sonnet asks Opus mid-task
603
+ through Claude Code's advisor tool. Anthropic's figure: about 12% cheaper per coding task, and slightly better than
604
+ Sonnet alone.
605
+
606
+ - **New sessions only**, and **your own file only**: in a project's rules.md it is refused, as a budget is, and so is a
607
+ `model: never sonnet` or `never opus` beside it.
608
+ - **The desktop app keeps its own model**: it starts every session on the model picked in its menu, so pick Sonnet
609
+ there. The advisor setting still reaches it, and the screens say so.
610
+ - **"On" only once a session shows it** (`advisor: Opus · set: seen at your next session` until then). If Claude Code
611
+ doesn't attach the advisor for your account (its rollout, your plan's credits, or a telemetry setting), every screen
612
+ then says "Claude Code didn't attach the advisor for this account: smart runs Sonnet alone", with how to have your
613
+ own model back; Anvil never switches it back for you. A `claude -p` or Agent SDK run can show it on, never off.
781
614
  - **A setting that keeps it off is named** on `/anvil` and the status line: `DISABLE_TELEMETRY` or
782
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` (any value, "0" too), `DO_NOT_TRACK`, `CLAUDE_CODE_DISABLE_FEATURE_FLAGS`
783
- or `DISABLE_GROWTHBOOK` (each measured live), and `CLAUDE_CODE_DISABLE_ADVISOR_TOOL`,
784
- `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` or a cloud that doesn't offer it.
785
- - **What it replaced is said.** Over a stronger model of yours: `Was Opus: Sonnet works now, Opus advises; remove the
786
- line to get Opus back.` A project whose own `.claude/settings.json` sets `model` wins in that project, and the screens
787
- there say the one way that works: take `model` out of that file.
788
- - **What it costs is counted.** The meter counts the advisor's tokens at Opus's rates, so budgets include them; Proof's
789
- Spend line and `report` show its share (`· advisor $0.12`).
790
- - **Removing the line gives your own values back**, byte for byte when nothing else changed the file. A value you change
791
- yourself after Anvil set it (`/model` saves one) is yours from then on.
615
+ `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` (any value, "0" too), `DO_NOT_TRACK`, `CLAUDE_CODE_DISABLE_FEATURE_FLAGS`,
616
+ `DISABLE_GROWTHBOOK`, `CLAUDE_CODE_DISABLE_ADVISOR_TOOL`, `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`, or a cloud that
617
+ doesn't offer it.
618
+ - **What it replaced is said:** `Was Opus: Sonnet works now, Opus advises; remove the line to get Opus back.` A
619
+ project whose `.claude/settings.json` sets `model` wins there, and the screens say to take `model` out of that file.
620
+ - **What it costs is counted.** The advisor's tokens count at Opus's rates, so budgets include them; Proof's Spend line
621
+ and `report` show its share (`· advisor $0.12`).
622
+ - **Removing the line gives your own values back**, byte for byte when nothing else changed the file. A value you
623
+ change after Anvil set it (`/model` saves one) is yours from then on.
792
624
  - A `budget:` or `model:` line, and a budget's 80% note, suggest it in one line where it isn't on. It is never a switch.
793
625
 
794
626
  ### `second opinion: <kind>`: ask the advisor before a risky action
@@ -799,147 +631,168 @@ alone.
799
631
 
800
632
  Any kind Anvil names: deploys, publishing, deletes, database changes, pushes to main, force-pushes, sudo, and the rest
801
633
  `anvil claude rules` lists. The first such action in a task is refused, and Claude reads: "Ask the advisor about this
802
- deploy first. If it advises against it, don't rerun: tell the user. Nothing ran." The rerun runs only once Claude Code's
803
- own record of the session shows the advisor asked, and answering, after the refusal; then that kind is done for the
804
- task, and a new message is a new task. A rerun without the advisor's answer is refused once more, then waits for your
805
- OK, with a one-time code. Each thread is its own: a helper agent's question to the advisor never lets the main
806
- session's deploy through, nor the other way round.
634
+ deploy first. If it advises against it, don't rerun: tell the user. Nothing ran." The rerun runs once Claude Code's
635
+ own record shows the advisor asked and answering after the refusal; then that kind is done for the task. A rerun
636
+ without the advisor's answer is refused once more, then waits for your OK with a one-time code. Each thread is its
637
+ own: a helper asking the advisor never lets the main session's deploy through, nor the reverse.
807
638
 
808
639
  - **In the terminal, every such action waits for your OK.** The terminal writes Claude's reply only after Anvil checks
809
- the call, so Anvil can't see the advisor's answer before the rerun: Claude is told to ask the advisor and tell you
810
- what it advises, and you decide. The desktop app, `claude -p` and the SDK write the reply as it streams: there Anvil
811
- sees the answer.
812
- - **No advisor in the session** (a reason above): each such action waits for your OK too. You are the second opinion.
813
- - **Your budget comes first.** Before Claude is sent to the advisor, Anvil prices the ask: the advisor reads the whole
814
- conversation uncached, about $0.64 at 150K tokens with Opus advising, twice that with Fable. A budget already spent,
815
- or one that ask would pass (with what's running), holds the action by the budget, and Claude is told not to ask. A
816
- plan's share (a % of your week) doesn't count the advisor's price.
817
- - **A hold on the same kind still holds.** A second opinion decides no kind's verb: beside `hold: deploys`, Claude asks
818
- the advisor first, and the deploy then waits for your OK. `rules add`, adding a hold on deploys, publishing, database
819
- changes or pushes to main, suggests a second opinion on it in one line, once for each kind.
820
- - **In the exact line, name the kind as Anvil does** (`database changes`, not `migrations`); in your own words,
821
- `rules add` maps it for you. If no advisor is set, the rule sets Opus; one you set yourself stays.
822
- - Proof lists each rerun as `advisor asked, then let through`, and each rerun without it as `rerun without the advisor:
823
- held`. The pause before it is no stop: no count of what Anvil stopped includes it.
640
+ the call, so Anvil can't see the advisor's answer: Claude asks the advisor and tells you what it advises, and you
641
+ decide. The desktop app, `claude -p` and the SDK write the reply as it streams, so there Anvil sees the answer.
642
+ - **No advisor in the session** (a reason above): each such action waits for your OK. You are the second opinion.
643
+ - **Your budget comes first.** The advisor reads the whole conversation uncached: about $0.64 at 150K tokens with Opus
644
+ advising, twice that with Fable. A budget already spent, or one that ask would pass (with what's running), holds the
645
+ action by the budget, and Claude is told not to ask. A plan's share doesn't count the advisor's price.
646
+ - **A hold on the same kind still holds:** beside `hold: deploys`, Claude asks the advisor first, then the deploy waits
647
+ for your OK. Adding a hold on deploys, publishing, database changes or pushes to main, `rules add` suggests a second
648
+ opinion in one line, once per kind.
649
+ - **Name the kind as Anvil does** in the exact line (`database changes`, not `migrations`); in your own words,
650
+ `rules add` maps it. If no advisor is set, the rule sets Opus; one you set yourself stays.
651
+ - Proof lists each rerun as `advisor asked, then let through` or `rerun without the advisor: held`. The pause before
652
+ it is no stop: no count of what Anvil stopped includes it.
824
653
 
825
654
  ## The screen: `anvil claude rules edit`
826
655
 
827
- This is real output, at 80×24 (redesigned 2026-11-17): your own `~/.anvil/rules.md` holding `hold: push or merge to
828
- main`, `block: force-pushes`, `budget: $50 a day` and `cap: at most 3 deploys a day`, the cursor on push-main:
656
+ This is real output at 80×24: your own `~/.anvil/rules.md` holding `hold: push or merge to main`,
657
+ `block: force-pushes`, `budget: $50 a day` and `cap: at most 3 deploys a day`, the cursor on push-main:
829
658
 
830
659
  ```
831
660
  Anvil. Claude Code · Rules this week: 0 checked · 0 held
832
661
 
833
- ✕ ■ Always on 2 blocked · 5 held · spend counted no mode turns these off
834
-
835
662
  ╭─ Add a rule ──────────────────────────────────────────────────────────────╮
836
- │ › ▌ Type a rule in plain English │
663
+ │ › Type a rule in plain English, or drop CLAUDE.md here │
837
664
  ╰───────────────────────────────────────────────────────────────────────────╯
838
- For example "hold pushes to main" "budget: $50 a day"
839
-
840
- ── Your rules ─────────────────────────────── 2 on · 2 limits · 18 watching ─
841
-
842
- On stopped before they run
843
- ✕ force-push block force-push · line 2
844
- › ■ push-main hold push or merge to main · line 1 ⌫ removes
665
+ ↑ Import your CLAUDE.md
666
+ Try "ask before deploys" "$50 a day" "block edits to ~/Documents"
845
667
 
846
- Caps
847
- ● 3 deploys a day past it, the next waits for your OK · 0 of 3 used
848
- resets at midnight
849
- ↓ 19 more
668
+ ── Rules ────────────────────────────────────────────── 24 on · 14 watching ─
850
669
 
670
+ On
671
+ ✕ Force-push other branches block line 2
672
+ › ■ Push or merge to main hold line 1
673
+ ● 3 deploys a day on 0 of 3 used
674
+ ● $50 a day on $0.00 of $50
675
+ ● Wipe your home folder or project on
676
+ ● Delete folders on database folders only
677
+ ● Delete outside your project on
678
+ ↓ 31 more
851
679
 
680
+ Push or merge to main: each one waits for your OK.
852
681
 
853
- ↑↓ choose space change enter add esc done ~/.anvil/rules.md
682
+ ↑↓ choose space change ⌫ remove esc done ~/.anvil/rules.md
854
683
  ```
855
684
 
856
- - **Four keys**, and the footer names them: ↑↓ choose a row, space changes it, enter adds what you typed, esc is done
857
- (with words typed, esc clears them first). Ctrl-C leaves too. **Each change is saved as it is made**, through the
858
- path its own command takes, and leaving says what changed.
859
- - **A rule you wrote turns down as well as up.** Space on it changes its own line in your rules.md and says so
860
- ("changed hold: deploys → off: deploys"): a rule on a kind goes hold → off → watch → hold, a block first to a hold; a
861
- rule on one app, file or target goes hold ↔ watch. ⌫ twice removes it. Anything else keeping it stronger (`enforce`
862
- for every kind, your workspace) is said right there.
863
- - **Typing a rule.** Letters go into the Add a rule box. Under it, faint, a few examples, until Anvil understands the
864
- words; then what the rule will do ("✓ every deploy waits for your OK"), and enter adds it to the file the screen
865
- edits. Nothing typed is ever an error while you type: what can't be used is said once you press enter.
866
- - "hold …", "block …", "watch …" and "off …" set the line's verb ("hold pushes to main" is written `hold: pushes to
867
- main`); "never …", "don't …", "don't let Claude …" and "stop it from …" block; "ask before it …" and other words
868
- hold.
869
- - A command is read the way the hook reads it (above): `kubectl delete` says "✓ every deploy waits for your OK".
870
- - What can't be a rule says why on enter: a command Anvil lets run, one app, one file or folder, or advice for
871
- CLAUDE.md (the table above). While you type, the same is a faint hint, never an error.
872
- - A count ("at most 3 deploys a day") is a cap, a sum ("$50 a day") a budget, `model: …` a model rule. A second
873
- dollars-a-day budget is refused, as the file would refuse it.
874
- - Words Anvil's own reader can't place go, on enter, to your Claude Code (Haiku, through your own login), once; its
875
- reading is kept with the line, so a sync never sends it again. With no Claude Code, they are taken as advice, and
876
- the box says so.
877
- - A budget is yours, not one project's: in a project, the box gives the command that adds it to your own file.
878
- - **Changing a kind:** space cycles off → watch → hold → off.
879
- - **Removing:** with the box empty, ⌫ on a line you wrote asks; ⌫ again removes it. Only a line in the file the screen
880
- edits (the project's when there is one): a line in your own file says to change it there.
881
- - **Importing CLAUDE.md:** type `import` and press enter. When a CLAUDE.md has rules Anvil can hold and your rules.md
882
- has none, Home's "Get started" offers "Import N rules from your CLAUDE.md" too; the import shows each rule beside its
883
- line and asks before it saves anything (above).
884
- - **Edited outside the screen:** when the file has changes nobody has applied, the box says so, and enter applies them
885
- as `sync` does. Until then a change that would write that file saves nothing, and says why.
886
- - **Where your rules live** is named in the footer: a link to the file in terminals that open one (iTerm2, VS Code,
887
- WezTerm, Ghostty, Warp). It is the file to edit, export or share: rules.md is plain Markdown, like CLAUDE.md.
888
- - **The Always on box** lists what no mode turns off: the blocks, the holds (helper bursts since 2026-11-17: more
889
- than 20 helper launches in 10 minutes, ALWAYS-ON.md), and that the meter counts what every Claude Code session
890
- spends, with today's figure once there is one ("$4.10 today", or your plan's share of the week).
891
- - **It fits your terminal.** The title, the add box, the keys and any note stay in view. One list, sorted (what is on
892
- first, blocks then holds; then the caps, budgets, model and helper rules; then what is watched; then what is off),
893
- scrolls around the cursor, and "↓ 19 more" counts the rules out of sight. Below about 30 rows the always-on box
894
- folds to one line (it shows whole on a taller terminal, and in `anvil claude rules`). A limit's state wraps under its
895
- own column and is never cut.
896
- - **Each limit says what it does now.** "past it, the next waits for your OK", "can't be measured: …" with its fix, "off:
897
- the kill switch is on". A limit set in another project isn't listed: a line under the list counts them.
898
- - **Each row shows what the hook does.**
899
- - A kind a rules.md line sets can't be switched weaker than the line by a key. The screen says which line, and how to
900
- change it.
901
- - A watched "never" line switched on shows as the block it is.
902
- - Space can't turn a kind off while `enforce` covers every kind.
903
- - The line a row names is the strongest one across both files.
904
- - **A save reports what is now true.**
905
- - Every write takes the path its own command takes. Hold and watch go through `enforce` and `ghost`. Off is an `off:`
906
- line in your rules.md, with the kind's switch taken away. Added and dropped lines are applied the way `sync`
907
- applies them.
908
- - After each save, each changed kind is read back as the hook now judges it. "✓ Saved · push-main waits for your OK",
909
- or, when something stronger still decides it, "▲ sudo stays held: `anvil claude enforce` for every kind holds it".
910
- - **Without a terminal** (piped, CI), or inside Claude Code (`CLAUDECODE=1`), it prints once and changes no rule or
911
- mode.
912
- - **Built with** Node built-ins only, at 80 columns, with colour only on a terminal without NO_COLOR.
685
+ - **One cursor, in one place.** It starts in the Add a rule box; ↓ goes to Import, then the rules, ↑ comes back, and
686
+ it goes round. The footer names the keys that work there: enter adds what you typed or opens Import, space changes a
687
+ rule. Esc is done (typed words are cleared first), as is Ctrl-C. A letter typed anywhere goes in the box; there, space
688
+ and ⌫ never change a rule. **Each change is saved as it is made**, through its own command's path, and leaving says
689
+ what changed.
690
+ - **One list, one word for where each rule stands.** On, Watching and Off. Anvil's own rules say `on` or `off`; the
691
+ rest say what you would type: `block`, `hold`, `watch` or `off`. Blue stops Claude, grey doesn't. The line under the
692
+ list says the chosen row in full.
693
+ - **Rules about one thing are together.** Under On: yours, then your limits (caps, budgets, model and helper rules),
694
+ then Anvil's own; in each, files, git, data and what is live, secrets, this machine, runaway loops, and Anvil itself.
695
+ Watching and Off keep the same order.
696
+ - **Anvil's own rules are on by default.** The ones that matter most first, each by its name on the screen and the
697
+ name the commands take:
698
+ - **Wipe your home folder or project**, **Force-push main** and **Kill every process** (`protected`): blocked
699
+ outright, never held for an OK.
700
+ - **Add a new dependency** (`new-dependency`): asks before a package the project's manifests don't declare is added,
701
+ installed globally, or downloaded by `npx`, `pnpm dlx`, `bunx` or `uvx`. What the project declares, an install
702
+ from the lockfile (`npm ci`) and the project's own tools run. It is a kind Anvil holds from the start, not one of
703
+ its own rules: space offers `h` hold all, `w` watch all and `o` off, and `off new-dependency` writes `off:
704
+ new-dependency` in your rules.md.
705
+ - **Delete outside your project** (`outside-folder`): asks before a delete or move lands outside the project, its
706
+ worktrees and the folders you add (`define: project folders = ../shared-lib`). Temp folders and caches run. Writes
707
+ and edits outside are their own kind (`outside-project`), watched. A line of yours, "never delete anything outside
708
+ the project", blocks every delete and move there, with this rule on or off.
709
+ - **Show secrets files in the chat** (`env-in-chat`): asks before a read, print or search shows a `.env`, a private
710
+ key or `credentials.json`, and tells Claude how to list the names alone, which runs. Using one runs. A line of
711
+ yours on one secrets file covers every secrets-file read, and says so. "Hold anything that opens .env.production"
712
+ is your own line: this rule never holds a copy.
713
+ - **Throw away uncommitted work** (`uncommitted`): asks before `git reset --hard`, discarding every change, `git
714
+ clean -f`, a forced checkout or switch, or dropping a stash, only when git says there is something to lose, and
715
+ names it ("would throw away 3 changed files"). With a submodule in reach, `git rm -rf .` and `git worktree remove
716
+ --force` always ask.
717
+ - **Change production** (`prod-changes`): asks before a change through a production account, profile, context, env
718
+ file, host or token, and before a deploy or destroy whose target reads production. Reads run. Name your own with
719
+ `define: production = acme-main, 123456789012`.
720
+ - **The worst of a kind, from the start:** cluster and cloud destroys, remote and production database destroys,
721
+ printing cloud credentials, deleting a database's data folder, deleting a GitHub repo or a live service, database
722
+ wipes through a connected app, and **Risky steps on production** that Claude's own description names. A row that
723
+ holds part of its kind says which part ("database folders only"; "only the worst" where the terminal is narrow).
724
+ - **Use your account keys** (`credentials`, `secrets-expose`): reading or writing your account key files, and
725
+ committing or sending a secrets file.
726
+ - **Change Anvil** (`agent-controls`): any change to Anvil, or to Claude Code's permissions, hooks and settings.
727
+ - **Delete or repeat in a burst** and **Launch helpers in a burst** (`delete-burst`, `repeat`, `helper-burst`).
728
+ - **Anything Anvil can't check** (`could-not-check`, `too-long-to-check`).
729
+ - **Turning one off asks first.** Space on one of Anvil's own says "This is an Anvil default. Turn it off?", and only
730
+ `o`, pressed by itself once the question is drawn, turns it off (never a paste, a dropped file or an earlier key). On
731
+ a kind that holds part of what it covers, it offers `h` hold all, `w` watch all and `o` off. Space on one that is off
732
+ turns it back on. Two warn as they are asked: with **Change Anvil** off Claude could turn off your other rules (the
733
+ screen's top says so while it is), and with **Anything Anvil can't check** off a command Anvil can't read runs. Off
734
+ is that rule alone. No rules file, `ghost`, workspace or Claude turns one off, and modes changed outside Anvil leave
735
+ every one on.
736
+ - **Adding a rule shows it.** The cursor stays in the box, ready for the next one. Under it: what was added; in the
737
+ list, which scrolls to it: ✓, its mode and "just added". ↓ goes to it, to change it.
738
+ - **Where Anvil isn't on, nothing is said to be on.** Never turned on, off, on for another project only, or Claude
739
+ Code's hooks off: the screen says nothing is checked and how to fix it, and "set" in place of "on".
740
+ - **A rule you wrote turns down as well as up.** Space changes its own line in your rules.md and says so ("changed
741
+ hold: deploys → off: deploys"): a rule on a kind goes hold → off → watch → hold, a block first to a hold; a rule on
742
+ one app, file or target goes hold ↔ watch. Anything keeping it stronger (`enforce` for every kind) is said there.
743
+ - **A budget is a row once you add one.** Space changes it in place: type the amount, ←→ change the period (a day, a
744
+ week or a task; for a share of your plan, weekly or 5-hour), enter saves, esc leaves it as it was. It starts from the
745
+ amount in the file, never a rounded one, and is never written over another line if the file changed meanwhile.
746
+ - **Typing a rule.** Once you type, the line under the box says what the rule will do ("✓ every deploy waits for your
747
+ OK"), and enter adds it to the file the screen edits. Nothing is an error while you type: what can't be used is said
748
+ on enter. A count ("at most 3 deploys a day") is a cap, a sum ("$50 a day") a budget, `model: …` a model rule; a
749
+ second dollars-a-day budget is refused, and in a project a budget gives the command that adds it to your own file.
750
+ With no Claude Code, words Anvil's reader can't place are taken as advice, and the box says so.
751
+ - **Said roughly, it offers the closest rule.** Words nothing reads, said whole as a budget, a limit on helpers, a
752
+ folder to lock, secrets or production to protect, or a name misspelled by a letter, get "Did you mean …?" with the
753
+ line, and enter adds it: `50 a day`, `max 5 helpers`, `save money` (smart spend), `hold deplyos`. Words that ask
754
+ for less ("no limit on spending", "stop asking before deploys") get nothing; "turn off …" and "let Claude …" say
755
+ how a rule is turned off.
756
+ - **Removing:** on a line you wrote, with the box empty, ⌫ asks and ⌫ again removes it. Only a line in the file the
757
+ screen edits (the project's when there is one); a line in your own file says to change it there.
758
+ - **Importing CLAUDE.md:** "Import your CLAUDE.md" (or typing `import`) lists the ones here and takes a file dragged
759
+ onto the window or a path you type (a folder: its CLAUDE.md). Any .md or .txt file dropped in the box, or several
760
+ lines pasted, is read the same way. Each asks before saving (Import, add and remove, above); back here, what it added
761
+ is marked, and what it didn't says why ("Not added: 7 are advice for Claude"). With a CLAUDE.md here and no rule yet,
762
+ the screen opens on Import, and Home offers "Import N rules from your CLAUDE.md".
763
+ - **Locking a folder:** type "lock a folder" (or `block: edits to `) and enter, then type the folder or drop it on the
764
+ window; it goes in quotes unless its name is plain, so it is read as one folder.
765
+ - **Edited outside the screen:** when the file has changes nobody applied, the box says so, and enter applies them as
766
+ `sync` does. Until then a change that would write that file saves nothing, and says why.
767
+ - **Where your rules live** is named in the footer, a link in terminals that open one (iTerm2, VS Code, WezTerm,
768
+ Ghostty, Warp). rules.md is plain Markdown, like CLAUDE.md: edit, export or share it.
769
+ - **It fits your terminal**, 64×11 and up, with colour only without NO_COLOR. The title, box, keys and any question
770
+ stay in view; the list scrolls around the cursor, and "↓ 31 more" counts rows out of sight.
771
+ - **Each row says what the hook does now.** A limit doing just what its name says is "on", with its use; any other says
772
+ so whole ("past it, the next waits for your OK", "can't be measured: …" with its fix, "off: the kill switch is on"),
773
+ and one that needs you isn't counted as on. A key can't switch a kind weaker than a rules.md line sets it (the screen
774
+ names the line), nor off while `enforce` covers every kind. A watched "never" line switched on shows as the block it
775
+ is. A line under the list counts limits set in other projects.
776
+ - **A save reports what is now true.** Hold and watch go through `enforce` and `ghost`; off is an `off:` line in your
777
+ rules.md, with the kind's switch taken away; added and dropped lines apply as `sync` applies them. Each changed kind
778
+ is read back as the hook judges it: "✓ Saved · push-main waits for your OK", or "▲ sudo stays held:
779
+ `anvil claude enforce` for every kind holds it".
780
+ - **Without a terminal** (piped, CI), or inside Claude Code (`CLAUDECODE=1`), it prints once and changes nothing.
913
781
 
914
782
  ## What it doesn't do
915
783
 
916
- - **A line with a loop in it holds a cap's call.** Anvil can't tell from the text whether the loop is around the capped
917
- part, so `for f in *.yml; do lint "$f"; done && vercel deploy` waits for your OK too. A literal list (`for e in a b`)
918
- counts each.
919
- - **A capped action that runs only if another fails still counts.** `a || a` is two: Anvil can't know which runs.
920
- - **A place comes back on Claude Code's own record of the refusal.** That record is in Claude Code's session file,
921
- which Anvil can't seal. It is read before the session's next call, but something that rewrites the file before then
922
- can make a call that ran read as refused: a command already running when the result is written (left running in the
923
- background, or a helper's call still running), or another session's call while 4 or more other session files (a
924
- helper's file is one) have newer counts waiting, or newer places given back (Self-protection's open items).
925
- - **Some commands that repeat another aren't read as repeating.** `fd … --exec`, workspace runners (`pnpm -r exec`,
784
+ - **A place comes back on Claude Code's own record of the refusal**, in its session file, which Anvil can't seal.
785
+ Something that rewrites the file before the session's next call can make a call that ran read as refused: a command
786
+ still running when the result is written (in the background, or a helper's call), or another session's call while 4
787
+ or more other session files (a helper's is one) have newer counts or places waiting.
788
+ - **Some commands that repeat another aren't read as repeating:** `fd … --exec`, workspace runners (`pnpm -r exec`,
926
789
  `npm exec --workspaces`, `lerna exec`, `git submodule foreach`), a function written `function name { … }`, functions
927
- that call each other, and a self-call after any `}` in the function's body (a `${VAR}` included) are counted as Anvil
928
- reads the line: once, a few times, or not at all (`lerna exec` and `git submodule foreach` hide the command they
929
- run), never held for repeating. A cap on what they run counts them low.
930
- - **Paid-compute caps are estimates.** Anvil reads the command that starts compute, never the bill. "At once" is
931
- counted per day for machines, and a GPU cap counts every paid-compute start.
932
- - **A cap or a model rule is per kind.** Words after its kind ("3 deploys a day for prod only") aren't read: it counts
933
- every call of that kind, and says so when you add it.
934
- - **`off:` can't beat a switch.** It can't weaken `anvil claude enforce` for a kind or for every kind; the applied line
935
- says so, and the screen won't switch it off.
936
- - **Each folder needs its own yes.** A second clone or a git worktree starts with none of its rules applied (the hook
937
- says so) until `anvil claude sync` there.
938
- - **Approving the agent's held `sync` applies everything pending.** The list of what changed goes to the agent's
939
- output; to review it yourself, run `anvil claude sync` in your own terminal.
940
- - **A script can drive a terminal itself.** An agent that writes a script which opens its own terminal and drives the
941
- rules screen isn't held: the hook sees the command, not what a script does. Every documented way to change rules is
942
- held.
943
- - **`/anvil` doesn't show a project's rules.** The slash command runs without the project's folder: its line counts
944
- your own rules and caps.
945
- - **A budget can end a little over,** by about a reply: a reply under way always ends (Budgets, above).
790
+ that call each other, and a self-call after any `}` in the body (a `${VAR}` included). They count as written (once,
791
+ a few times, or not at all: `lerna exec` and `git submodule foreach` hide what they run), so a cap counts them low.
792
+ - **A cap or a model rule is per kind.** Words after the kind aren't read: "3 deploys a day for prod only" counts every
793
+ deploy, and `model: opus for deploys on Fridays` holds every deploy made on another model. Each says so when added.
794
+ - **Approving the agent's held `sync` applies everything pending.** The list of changes goes to the agent's output; to
795
+ review it yourself, run `anvil claude sync` in your own terminal.
796
+ - **A script can drive a terminal itself.** An agent's script that opens its own terminal and drives the rules screen
797
+ isn't held: the hook sees the command, not what a script does. Every documented way to change rules is held.
798
+ - **`/anvil` doesn't show a project's rules.** It runs without the project's folder, so it counts only your own.