@useanvil/claude-code 0.0.0-stage → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,701 @@
1
+ # Your rules, caps, budgets and model rules
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.
6
+
7
+ | To | Run |
8
+ |---|---|
9
+ | see every rule and limit, and what each does now | `anvil claude rules` |
10
+ | change them one by one, with arrow keys | `anvil claude rules edit` |
11
+ | add one in plain words | `anvil claude rules add "hold: deploys"` |
12
+ | apply a rules.md you edited | `anvil claude sync` |
13
+ | see where each limit stands this week | `anvil claude report` |
14
+ | print this guide | `anvil claude help rules` |
15
+
16
+ This guide spells commands as the SDK's (`anvil claude …`). With `@useanvil/claude-code` the command is `anvil-claude`
17
+ (`anvil-claude rules edit`), or `npx @useanvil/claude-code rules edit` through npx; `anvil-claude help rules` prints
18
+ this guide in its own words.
19
+
20
+ ## What a rule covers, and what it doesn't
21
+
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.
27
+
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:
30
+
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.
33
+ 2. **Plain words** are read by each kind's names and the phrases people use: "deploys", "delete the database" (a
34
+ database destroy, not every delete), "copy the production database" (a copy, not a destroy).
35
+ 3. **Anything else** goes once to your own Claude Code (Haiku, through your login), unless you run with `--no-model`.
36
+
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.
39
+
40
+ ### Narrowed rules: one app, one file or folder, one target
41
+
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.
46
+
47
+ | Typed | What it holds | What still runs |
48
+ |---|---|---|
49
+ | `hold Stripe changes` | Stripe's MCP tools that change something, writes to `api.stripe.com`, the `stripe` CLI | Stripe reads, every other app |
50
+ | `never send email through Gmail` | sends, replies and forwards through Gmail | drafts (a draft is a change too: `hold Gmail changes` holds them) |
51
+ | `at most 5 Stripe refunds a day` | the sixth Stripe refund that day | everything else, uncounted |
52
+ | `don't touch migrations/` | Write, Edit, MultiEdit and NotebookEdit there; `>`, `tee`, `sed -i`, `cp`, `mv`, `rm` into it | reads, writes elsewhere |
53
+ | `hold deploys to production` | `vercel --prod`, `railway up -e production`, `fly deploy` (its default may be production), any deploy it can't place | `vercel deploy` (a preview), `fly deploy -a api-staging` |
54
+ | `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
+ | `hold deletes outside the project` | `rm -rf ../other-project` | `rm -r src/old` |
56
+
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.
62
+
63
+ ### Every rule you type gets one of three answers, said first
64
+
65
+ The box, `rules add`, the rule's row and `sync` answer in the same words:
66
+
67
+ | State | What it means | Enter in the box, or `rules add` |
68
+ |---|---|---|
69
+ | ✓ **Ready** | it does what you asked; under it, what still runs | adds it |
70
+ | ▲ **Catch** | it works, with one difference, said before anything else | adds it anyway; its row keeps the catch |
71
+ | ? **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
+
73
+ The catches:
74
+
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.
78
+
79
+ | Typed | Said first |
80
+ |---|---|
81
+ | an app not connected here: `hold Shopify refunds` | "Shopify isn't connected to Claude Code here: this covers its API now, and its tools once you connect it." Its row says "not connected yet" until you connect it. |
82
+ | a category: `never send emails` | "It covers the 23 email apps Anvil knows, not just Gmail, and mail sent from the terminal." |
83
+ | 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
+ | a command: `kubectl delete` | "It holds every deploy, not only "kubectl delete": Anvil's rules are per kind." |
85
+
86
+ Can't yet, and the closest rule offered:
87
+
88
+ | Typed | Said | Closest |
89
+ |---|---|---|
90
+ | `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
+ | `hold Stripe changes except refunds` | Anvil can't leave "refunds" out of a rule on Stripe. | `hold: Stripe changes`, refunds included |
95
+ | `hold Gmail and Slack changes` | One app per rule. | `hold: Gmail changes` and `hold: Slack changes` |
96
+ | `hold Strype changes` | No app called "Strype" is connected here. | `hold: Stripe changes` |
97
+ | `never more than 5 Stripe refunds a day` | A rule doesn't count, a cap does. | `cap: at most 5 Stripe refunds a day` |
98
+ | `hold deploys to staging` | Anvil holds by production, not staging. | `hold: deploy` |
99
+ | `hold Zorblax invoices` | Anvil doesn't know an app called "Zorblax", and none by that name is connected here: connect it to Claude Code, then add the rule. | none |
100
+ | `hold Stripe reads` | Anvil holds what Stripe changes: its reads always run. | none |
101
+ | `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` |
102
+
103
+ A word your rules use can be defined once, on a line of its own: `- define: clients = @acme.com, @globex.com`. The
104
+ rules screens list your definitions under your rules; a project's rules read yours, the project's own winning. Two
105
+ words Anvil reads itself: `define: my company = acme.com` (for "anyone outside the company") and `define: my currency
106
+ = USD` (the currency a refund is read in).
107
+
108
+ A closest is never narrower than what you typed: it leaves out only the part Anvil can't read, so it covers that part
109
+ 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`
110
+ names. A line applied before as a rule on its kinds ("hold: deploys on Fridays", applied when Anvil couldn't read a
111
+ time) keeps holding every one after an update, and says how to narrow it: add the line again (`rules add`).
112
+
113
+ Say it however you'd say it. The box takes the asking off and reads the rule inside it, with the verb you said:
114
+ "I'd like Stripe refunds over $500 to wait for me" and "Refunds in Stripe above $500 — please check with me" hold;
115
+ "Gmail shouldn't be emailing anyone outside the company", "weekends: no pushes to main" and "pushes to main aren't
116
+ allowed anymore" block; "Stripe payouts under $50 are fine but keep track of them" and "I'd like a heads up whenever
117
+ Claude posts in #general" watch. "Without asking" or "without my OK" makes a rule a hold, never a block; "even with my
118
+ 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
119
+ as it would be said plainly, never dropped.
120
+
121
+ ### Conditions: an amount
122
+
123
+ A rule on a money app's money changes (refunds, charges, payments, payouts, transfers) can hold only the big ones.
124
+
125
+ | Typed | What it holds | What still runs |
126
+ |---|---|---|
127
+ | `hold Stripe refunds over $500` | a refund over $500 ("a $900.00 refund is over your $500 line") | refunds of $500 or less |
128
+ | `ask before Stripe charges of $1,000 or more` | a charge of $1,000 or more | smaller charges |
129
+ | `block PayPal payouts above €1,000` | a payout over €1,000 | smaller payouts in euros |
130
+
131
+ The amount is read from the call itself: Stripe's, PayPal's and Square's tools, their APIs through curl, and their
132
+ CLIs, and Shopify's refunds through its Admin API (money.ts, each field taken from the app's published schema), in the
133
+ 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
134
+ full refund (it names no amount), another currency (Anvil has no exchange rates), a variable or a script, a batch, a
135
+ URL curl expands into many requests. A refund moves its payment's currency, which its call doesn't name, so it is read
136
+ in yours only where you defined it (`define: my currency = USD`); typed, the box offers the line. A Shopify refund is
137
+ in its order's currency, which its call doesn't name either: Anvil reads it as yours, the same way. An invoice is read
138
+ by its whole total, where a call carries it all (PayPal's draft and its full update): sending one, or any other call
139
+ on it, waits. Can't yet: a share ("over 10%"), an amount on what isn't money ("deploys over $500"), Stripe's and
140
+ Square's invoices (their totals are added up apart from any one call), Shopify's other changes, amounts in tokens.
141
+
142
+ ### Conditions: who a send reaches
143
+
144
+ | Typed | What it holds | What still runs |
145
+ |---|---|---|
146
+ | `never email bob@acme.com` | emails Claude sends to bob@acme.com | emails to anyone else |
147
+ | `hold emails to anyone at globex.com` | an email to an address at globex.com or its subdomains (never acme.com.evil.io) | emails elsewhere |
148
+ | `hold emails to clients`, with `define: clients = @globex.com, @initech.com` | an email to any of them | emails elsewhere |
149
+ | `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 |
150
+ | `ask before inviting john@acme.com on Google Calendar` | an invite naming him | invites to others |
151
+
152
+ 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
153
+ 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
154
+ list or a relay that may reach anyone, an address built when the line runs, an address in letters from another
155
+ alphabet. Anvil never guesses your company: typed, the box offers the one in your git email when it is a work address,
156
+ said first; written by hand, a line needs `define: my company`. Written by hand, what it can't read yet holds every
157
+ send, its catch said first ("It holds them whoever they go to…"), never an error. Can't yet: a word you haven't
158
+ defined, and who a text or a chat post reaches.
159
+
160
+ ### Conditions: a time
161
+
162
+ 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
163
+ cap's day is.
164
+
165
+ | Typed | What it holds | What still runs |
166
+ |---|---|---|
167
+ | `hold deploys on Fridays` | deploys on Fridays, all day | deploys on other days |
168
+ | `never push to main after 6pm` | pushes and merges to main from 6pm to midnight | the same before 6pm |
169
+ | `watch deploys at night` | deploys from 10pm to 6am, said with its hours | deploys in the day |
170
+ | `block force-pushes on weekends` | Saturday and Sunday | weekdays |
171
+ | `hold deploys outside work hours`, with `define: work hours = Mon–Fri 9am–6pm` | evenings, nights and weekends | work hours |
172
+
173
+ A night crosses midnight ("between 10pm and 6am" is the evening of one day and the morning of the next), and a
174
+ daylight-saving day reads as the wall clock does. Typed, a time your rules haven't defined ("work hours") is offered
175
+ 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
176
+ doesn't know, or an abbreviation like `PST` that Node names while reading UTC). Can't yet: an event ("during the
177
+ launch"), a date ("on December 3rd"), a time with another condition beside it ("on Fridays if it's a big change").
178
+
179
+ ### Conditions: part of an app
180
+
181
+ A rule on an app can name one part of it, and then holds only what happens there
182
+ (docs/coding-agents/IMPROVEMENTS-TO-CUSTOM-RULES-FOR-CLAUDE.md). Like every narrowed rule it only adds a stop, and what
183
+ it can't place, it holds, saying why ("Anvil can't tell whether channel C0UNSEEN11 is #general").
184
+
185
+ | Typed | What it holds | What still runs |
186
+ |---|---|---|
187
+ | `hold Slack posts in #general` | posts, replies and uploads to #general, by its name or its id | a channel Anvil knows is another, a DM |
188
+ | `hold GitHub changes in billing-api` | gh and GitHub's tools acting there: `-R`, `owner`/`repo`, a pull request's URL; a gh command that names no repository, by the checkout it runs in | any other repository |
189
+ | `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 |
190
+ | `hold Jira issues in the PAY project` | issues in it, by its key, id or name, or an issue's key | another project's |
191
+
192
+ Slack and Linear send ids (`C04Q8…`, a team's UUID), not names. Anvil learns which is which from what Claude Code has
193
+ already seen here: an app's own reply when Claude lists channels or teams, in Claude Code's session logs on this Mac.
194
+ It reads them where you are, sends nothing, and keeps what it read in `~/.anvil/claude/state/part-ids.json`. Ids are
195
+ read again on `sync` and whenever the rules screen opens, and applied then without asking, since no rule's words
196
+ changed. Until Anvil has seen the part's id, the catch comes first ("Anvil hasn't seen #general's ID yet: a Slack post
197
+ it can't place waits for your OK until it has"). A channel renamed since is held by either name. A project's
198
+ `.anvil/rules.md`, which may be committed, keeps no other channel's id.
199
+
200
+ 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
201
+ field Anvil doesn't read, a gh command outside a checkout, or a Slack webhook (made for one channel its URL doesn't
202
+ 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:
203
+ `#general and #random` (one per rule), `except #random`, `the main channel` (a part is named by its name).
204
+
205
+ Not a rule at all, and said so: an everyday command (`npm install`, `git commit`, `running tests`: "runs as always: it
206
+ isn't one of the risky kinds"), advice (`write tests first`, `be careful with payments`: "advice for Claude goes in
207
+ CLAUDE.md"), a file it can't place as a path (`modifying config files`: "name the file or folder as a path"), and every
208
+ file (`touch any file`: "that's every file: hold a kind instead"). A rule can't weaken Always on.
209
+
210
+ How well the box reads what people type is measured, not guessed: sets of 90 lines written by people who never saw
211
+ the reader, each scored once (tests/coding-agents/typed-rules.test.ts, typed-rules-sealed.test.ts). Kinds: 85 of 90 on
212
+ 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
213
+ two sets written for them (87.8% and 90.0%), and 84 and 87 of 90 (93.3% and 96.7%) on two
214
+ more written after the fixes those showed, scored once on the reviewed reader. Rules with a condition, written short
215
+ 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
216
+ misses name parts of apps Anvil doesn't read yet). Written as people talk ("claude keeps doing stripe refunds, make
217
+ 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
218
+ enter, read by your own Claude Code. None of those reads as a weaker rule than the words.
219
+
220
+ ## What each limit needs
221
+
222
+ Every screen that shows a limit says what it does now, or why it can't: "can't be measured", "can't count helpers",
223
+ "not checked here", each with the fix. What decides it:
224
+
225
+ | Limit | Needs | Where it can't work, the screens say |
226
+ |---|---|---|
227
+ | your rules, caps, a helper's model | Claude Code 2.1.295 or later | |
228
+ | a model rule (`model: opus for deploys`) | Claude Code 2.1.304 or later, which records each request's model | "except under Claude Code 2.1.300 (its path), which records no model" |
229
+ | a budget that refuses the next message, a task budget, a cap on helpers at once, `model: never …` | Claude Code 2.1.318 or later, on every Claude Code `anvil claude on` finds | the old one, by version and path, and "update it, then run anvil claude on" |
230
+ | 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) |
231
+
232
+ - **An older Claude Code anywhere holds the newer events back.** `on` adds the entries a budget, a helper cap and a
233
+ `never` rule listen to only when every Claude Code it finds takes them: one an older one can't read could cost the
234
+ hooks that guard. The screens name the one that keeps them out.
235
+ - **The desktop app** reads the same settings, so every rule, cap and budget works there, a plan budget included: with
236
+ no status line there, Anvil asks Claude Code's own `/usage` for your plan's use, in the background.
237
+ - **The Claude Code plugin** (instead of `anvil claude on`) checks actions only: a budget holds the next action, but no
238
+ message is refused, a task budget can't start counting, helpers at once can't be counted and a `/model` switch isn't
239
+ refused. `anvil claude on` hears all of them.
240
+
241
+ ## The file: `.anvil/rules.md`
242
+
243
+ ```markdown
244
+ # Anvil rules for this repo
245
+ - hold: push or merge to main
246
+ - block: force-pushes
247
+ - watch: deploys
248
+ - off: sudo
249
+ - cap: at most 3 deploys a day
250
+ ```
251
+
252
+ - **Format.** One rule per line: a verb, a colon, then plain words.
253
+ - A list marker (`-`, `*`, `1.`) is optional.
254
+ - Other lines are notes, and `#` headings are fine.
255
+ - A line that looks like a rule but isn't read as one (`**hold:**`, `holds:`, `-hold:`, `> hold:`, `hold deploys`)
256
+ is reported with its number.
257
+ - Lines inside a code block (```) or an HTML comment are never read as rules, as the rendered file shows them.
258
+ - **What each verb does:**
259
+
260
+ | Verb | What it does |
261
+ |---|---|
262
+ | `block:` | stops the kinds the line names, outright: no OK lets it through |
263
+ | `hold:` | stops them until you say OK, once |
264
+ | `watch:` | records what they would have stopped; nothing is stopped. A watched line keeps what its words say for when its kind is switched on ("Never …" blocks) |
265
+ | `off:` | not even watched |
266
+ | `cap:` | a limit on what the agent does (Caps, below) |
267
+ | `budget:` | a limit on what Claude Code spends, in your own rules.md only (Budgets, below) |
268
+
269
+ - **Reading.** Each line is read once, by `sync`, the screen, `rules import` or `rules add`.
270
+ - The reader is the one `rules import` uses: Anvil's matcher plus each kind's own names ("deploys", "push-main",
271
+ "paid compute").
272
+ - A line the matcher can't read goes to the developer's own Claude Code (`--no-model` keeps every line on the
273
+ machine).
274
+ - A line read before keeps its reading, so a sync never changes what an unchanged line means.
275
+ - **What sync shows, and what it refuses.** `sync` shows every line and what it became, out of `anvil claude sync`'s
276
+ real output:
277
+
278
+ ```
279
+ .anvil/rules.md in ~/code/app · 4 rules, 1 cap
280
+ line 2 hold: push or merge to main
281
+ → hold · push or merge to main (push-main)
282
+ line 5 off: sudo
283
+ → off · run as root, or run code it cannot read (sudo)
284
+ line 6 cap: at most 3 deploys a day
285
+ → cap · 3 deploys a day
286
+ ```
287
+
288
+ It refuses three kinds of line, each by line number and with the reason:
289
+ - a kind Anvil can't see ("hold: tidy commit messages");
290
+ - a floor rule that a `watch:` or `off:` line would weaken ("protected is always on");
291
+ - a cap it can't count exactly, or two limits on one cap line.
292
+
293
+ It also explains lines that need it:
294
+ - A line owned by a stronger one in the same file says so ("deploy is held by line 8").
295
+ - A line narrower than its kind says it covers every one.
296
+ - A project's file is named with its folder, so two projects' files never look the same.
297
+ - **Applying.**
298
+ - **Nothing applies without a yes.** It applies only on yes, or with `--yes`. Without a terminal and without `--yes`,
299
+ `sync` shows the change, applies nothing, and exits 1.
300
+ - **Lines that can't be enforced.** With `--yes`, the lines that can be enforced are applied. `sync` exits 1 naming
301
+ the rest.
302
+ - **Validation.** Anvil's own policy validator checks the result before it is offered.
303
+ - **What is enforced, and where it lives.**
304
+ - **The sealed copy.** When a person applies a rules.md, its compiled form is kept under `~/.anvil/claude/applied/`.
305
+ Those are Anvil's own files, sealed like the mode file. That copy is the only thing the hook enforces for a place
306
+ with a rules.md.
307
+ - **The repo copy is never enforced.** `.anvil/rules.json` beside the file is the same compiled form, for reading.
308
+ Committing it is harmless: one committed, pulled or switched by git is never enforced as it is. An older rules.json
309
+ from before rules.md is the exception (below).
310
+ - **Every new copy needs a yes.** What a person applies is kept per folder. A fresh clone, a second clone or another
311
+ git worktree needs its own `anvil claude sync` and yes. Until then the hook says its rules.md "isn't applied yet in
312
+ this folder".
313
+ - **Older rules files.** A rules.json from before rules.md (no rules.md beside it) moves into rules.md on the first
314
+ apply there, every rule as it ran, shown with the rest. Until then it is read as it is at each compile a person
315
+ runs. The agent's `anvil claude on`, which recompiles, is held.
316
+ - **Tampering.** A sealed copy changed outside Anvil stops the compile: the previous rules stay until `sync`
317
+ re-applies it.
318
+ - **A changed file never silently stops protecting.** A `rules.md` that changed, was removed, or can't be read keeps
319
+ the rules applied from it before, and every call is still judged. The hook says so once per session, and `status`
320
+ says the same:
321
+
322
+ ```
323
+ ▲ .anvil/rules.md changed · the rules applied before still hold
324
+ › apply it: anvil claude sync
325
+ ```
326
+
327
+ A folder whose rules.md was never applied is told that ("isn't applied yet in this folder"), never that rules hold.
328
+ - **Quick saves never apply what nobody saw.** These all apply the whole file:
329
+ - `rules add`;
330
+ - `rules import`;
331
+ - `rules remove`;
332
+ - the screen's save.
333
+
334
+ So each refuses while the file has edits nobody has applied, and saves nothing:
335
+
336
+ ```
337
+ ~/.anvil/rules.md has changes that aren't applied yet, so nothing was saved. Review and apply them first: anvil claude sync
338
+ ```
339
+
340
+ - **The agent can't change the rules.** All of these are changes to Anvil, held on the always-on floor:
341
+ - its edits to either rules.md, either rules.json, the applied copies, or the caps ledger;
342
+ - running `anvil claude sync`;
343
+ - running `rules add`, `rules import` or `rules remove`;
344
+ - running the bare `anvil claude` (Home) or `anvil claude rules edit` (the screen).
345
+ - **Imports and removal.**
346
+ - `rules import` (CLAUDE.md) and `rules add "…"` write `watch:` lines into rules.md, so Anvil watches what they'd stop
347
+ first, and apply them.
348
+ - An older `rules.json` moves into rules.md on the first write or apply.
349
+ - `rules remove <id>` removes the line that makes that rule in the file as it is now.
350
+
351
+ ## The precedence, written once
352
+
353
+ When more than one thing speaks to a kind, this decides it:
354
+
355
+ 1. **The always-on stops**, whatever anything says.
356
+ 2. **The strongest explicit choice for a kind:**
357
+ - a `rules.md` line in scope (block, hold, watch or off);
358
+ - a switch on this machine: `anvil claude enforce` / `ghost` for the kind, the screen, or the dashboard;
359
+ - `anvil claude enforce` for every kind, which counts as a choice for each kind, so a later `watch:` or `off:` line
360
+ never quietly weakens it.
361
+
362
+ block > hold > watch > off. A project's file adds to yours.
363
+ 3. **Anvil's default (watch)**, only where nothing says anything.
364
+ - So `off: sudo` silences a kind that is only watched by default.
365
+ - It can't override `anvil claude enforce sudo`, or `enforce` for every kind. The line says so when it is applied,
366
+ and the screen won't switch a kind off while `enforce` covers every kind.
367
+ 4. **The kill switch** makes every rule at most watched. The always-on stops still block. Caps count, but never hold.
368
+
369
+ ## Caps
370
+
371
+ A cap lets the agent do something, just not too often or too much.
372
+ - **Under the limit**, the call runs with no prompt.
373
+ - **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
374
+ code elsewhere.
375
+ - **An OK** lets that one call through, counted, and does not raise the limit.
376
+
377
+ | Kind | Written | Counts | Resets |
378
+ |---|---|---|---|
379
+ | Count | `cap: at most 3 deploys a day` · `cap: 1 release a week` | calls of those kinds that Anvil let run | local midnight; Monday 00:00 |
380
+ | Burst | `cap: 20 deletes a minute` · `cap: 3 force-pushes an hour` | the same, in a rolling window | rolling |
381
+ | Paid compute | `cap: 2 GPU hours a day` · `cap: 4 cloud machines at once` · `cap: $50 a day of paid compute, GPU hour = $2` | what paid-compute starts name | local midnight |
382
+ | 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 |
383
+
384
+ A money cap catches many small refunds that add up to a lot, which a threshold can't. An amount it can't read (a full
385
+ refund, another currency, a variable) holds the call, saying so, and takes no place; one you OK counts the whole cap,
386
+ so what is left is never overstated. The screens say it in money ("$1,200 of $2,000 used"), never as an estimate.
387
+
388
+ - **What counts.**
389
+ - Counted: a call let through, an approved one, and a prompt answered Yes.
390
+ - Not counted: a held call.
391
+ - Freed: a prompt answered No frees its place. The answer is read from the first result Claude Code wrote for that
392
+ call, so a line the agent appends later can't change it. A Yes read after midnight still counts on the day the
393
+ call ran.
394
+ - Two limits (What it doesn't do, below): a call Anvil let through and Claude Code's own prompt then refused still
395
+ counts, and several capped actions in one command line count once.
396
+ - **Held for another reason.** A call held by another rule that would also go over a cap names both in the one reason
397
+ ("…; and cap reached: 1 deploy a day"), so one OK covers both, and the approved call counts.
398
+ - **Safe across sessions.**
399
+ - The counts live in an append-only ledger, one file per local day, under `~/.anvil/claude/caps`.
400
+ - Each call appends its reservation first, then counts only what is ahead of it, so two sessions can't both take the
401
+ last place.
402
+ - Every reservation ahead counts, whatever clock its session read.
403
+ - A day's file is found by calendar date, so a 25-hour day (clocks going back) is still read.
404
+ - **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
405
+ 4 MB, the call is held ("couldn't check your cap …"). It never runs on a part count.
406
+ - **Each file's caps are its own.** A project's "2 deploys a day" counts only that project's calls. Two projects'
407
+ identical caps are two counts.
408
+ - **Paid-compute caps are estimates and say so.** Anvil sees the command that starts compute, never the bill.
409
+ - It reads the machines (`--count`, `--num-nodes`, gcloud's instance names), the hours (`--max-run-duration`,
410
+ `--hours`), and a GPU (`--gpus`, `--accelerator`, a GPU machine type).
411
+ - What a start doesn't state counts as 1. The cap's line in `status` says "an estimate".
412
+ - A GPU cap counts every paid-compute start. Anvil can't tell from a command that a machine has no GPU (a type it
413
+ doesn't know, like p4d, g5 or ND, may have one), so it never assumes so: it holds sooner, never later.
414
+ - A dollar cap needs your own price ("GPU hour = $2"). Without one it is refused: Anvil never guesses a price.
415
+ - "At once" is counted per day for machines, and the line says so (helper agents at once are counted live: below).
416
+ - **Where caps show.**
417
+ - `status` shows each cap that applies where it runs (yours, and that project's), its use and when it resets.
418
+ `/anvil` shows yours.
419
+ - Replay replays each cap over your history in time order ("cap 2 force-pushes a day: reached on 1 day, 1 call would
420
+ have waited for your OK").
421
+
422
+ ## Budgets
423
+
424
+ A budget limits what Claude Code itself spends: its model use, in dollars, new tokens or a share of your plan. It is
425
+ yours, so it lives in `~/.anvil/rules.md`: a project's file can't hold one, and says so.
426
+
427
+ | Written | Counts | Resets |
428
+ |---|---|---|
429
+ | `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 |
430
+ | `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 |
431
+ | `budget: 5M new tokens a day` | input, output and cache writes (cache reads left out) | as dollars |
432
+ | `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 |
433
+
434
+ - **Every session counts.** A day's or a week's budget is every Claude Code session's on this computer: their spend,
435
+ and the work each has in progress (replies under way, helpers running, launches being made), so two sessions can't
436
+ pass it together. A task's budget is its own session's.
437
+ - **Near it, held a little early.** A reply under way always finishes, so Anvil holds when what's spent and what's
438
+ running could pass the budget, saying so: "nearly spent … and what's running could pass it". A helper is priced as
439
+ Claude Code will cache it (about half when another helper on the same model replied in the last 5 minutes); before any
440
+ helper has run on this computer its size is a guess, and the hold says that too.
441
+ - **At 80%**, Claude Code says so once a window: `🔹 Anvil 🔹 $40 of today's $50 used`.
442
+ - **Spent**, the next message is refused before it reaches the model, and the next action is held, each with a
443
+ one-time code:
444
+
445
+ ```
446
+ 🔹 Today's budget is spent 🔹 $50.12 of $50 · resets at midnight
447
+ › To keep going, run this in a terminal (not in this chat):
448
+ anvil claude allow 7k2m9xqa
449
+ › Then send your message again.
450
+ › To change the budget instead, run in a terminal:
451
+ anvil claude rules edit
452
+ ```
453
+
454
+ `anvil claude allow <code>`, in your own terminal, lets that task go on past that budget: send the message again, or
455
+ let Claude try again, and Claude is told you allowed it. The OK reaches this window only (a new day, week or plan
456
+ window asks again), up to one more budget's worth, and an hour at most, whichever ends first; then the next action is
457
+ held again, with a new code. Another budget spent in the same task still stops it, with its own code. Your next
458
+ message is a new task, checked again. A held action gets a code, never Claude Code's Yes/No prompt: one OK covers
459
+ the task within those bounds, and the stop is the same everywhere (under Bypass, the desktop app runs a call the hook
460
+ asks about). The other holds that budget left waiting in the session go with the OK, so `allow` and Home show one,
461
+ not one per message.
462
+ - **It stops at its number, not a few replies past it.** Anvil acts between steps, never inside a reply: a reply under
463
+ way always ends, and each thread then writes one more reading what came back. So each check also counts what's
464
+ running: two replies of the main chat and of each helper running (a helper that has finished counts nothing),
465
+ priced as their latest replies were, and at a helper's launch that helper's first reply (most of it the cache write
466
+ of its instructions) and the launches let through just before it. When what's spent and what's running could pass
467
+ the budget, it holds now:
468
+
469
+ ```
470
+ 🔹 Held by Anvil for your OK 🔹 today's budget is nearly spent: 15K of 20K new tokens, and what's running could pass it · …
471
+ 🔹 Held by Anvil for your OK 🔹 the helpers starting could pass today's budget: 4K of 20K new tokens used · …
472
+ ```
473
+
474
+ A message refused this way says "the next replies could pass it".
475
+ The guess about replies already running counts for at most half the budget, so a budget is never held before half of
476
+ it is used; a launch, which can still be refused, is counted whole. Measured live, three helpers launched at once
477
+ against 20K new tokens a day: 39,993 before (100% over), 17,695 now (the third launch held). What a reply under way
478
+ 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
479
+ needs no reserve: a few replies are a hundredth of a point of a week. Other sessions running at the same time are
480
+ not counted in a session's reserve.
481
+ - **What can't be measured is said, and never enforced.** A plan's share Claude Code can't report here (an API key,
482
+ a Claude Code without `/usage`), a model with no price, a meter that can't be read: Claude Code shows "your budget … can't be measured here: … ·
483
+ not enforced" once a session, and `rules add`, Home, `report`, `anvil claude rules` and the rules screen say it too,
484
+ with the fix, never "Claude stops". A task budget counts from the message that starts a task: one set mid-task says
485
+ it counts from your next message. A false stop costs more trust than a missed one.
486
+ - **Your plan's share, read.** In the terminal, Claude Code hands it to Anvil's status line after every reply. Where
487
+ no status line feeds Anvil (the desktop app, or your own status line kept by `anvil claude on`), Anvil asks Claude
488
+ Code's own `/usage` in the background: a few seconds, no model call and nothing spent, at most every 5 minutes (2
489
+ near your budget), only while a plan budget is set. Anvil never reads your sign-in: Claude Code does, and a reading
490
+ counts only for the account it signed in as (an API key's session is never held by your plan). A session's
491
+ first message after an hour or more away goes on while the reading comes; the next check uses it. `rules add` and
492
+ `report` ask at once, so they show where your week stands.
493
+ - **Except a day too large to count.** A day of the meter over 32 MB (about 100,000 replies: a loop, or something
494
+ writing to it) never reads as $0: the budget holds, with the same code, saying it "can't be counted". Replies that
495
+ used nothing are never written to the meter.
496
+ - **Nowhere to keep the OK, nothing stopped.** If the hold can't be recorded (Anvil's folder can't be written, a full
497
+ disk), the budget says it is spent and that Anvil can't record an OK, and lets the message or action through rather
498
+ than leave you with no way on.
499
+ - **Claude can't feed the meter.** Anvil's own hook files run by hand (`node ~/.anvil/claude/bin/claude-hook.js`) and
500
+ `anvil claude statusline` run by Claude are held, always: Claude Code runs both itself, never through a tool call, so
501
+ what Claude would feed them is made up. An agent that copies Anvil's files elsewhere, or reads its seal key, can still
502
+ forge what they record: the integrity design accepts that, and budgets are a spending guard, not a security floor.
503
+ - **Your messages are never read.** The message hook reads the session's id, its file and its folder, never the
504
+ message. Before 2.1.318 there is no message hook: a spent budget holds the next action only, an OK lasts an hour,
505
+ and Claude learns of an OK only from you. The same goes where Anvil runs as the Claude Code plugin (no `anvil claude
506
+ on`): the plugin has no message hook.
507
+ - **The kill switch** leaves budgets counting but stopping nothing, as it does caps.
508
+ - **Where budgets show.** Home's state line (`On · $12 of $50 today · 9 checked today`; past it, with an OK still
509
+ running, "going on with your OK until 4:12 PM"), `anvil claude report` and `anvil claude rules` (each limit with what
510
+ it does now and where it stands), the rules screen (a Budgets section), the screen `on` ends with, and Proof (stops
511
+ by "your budget").
512
+ - **Adding one.** `anvil claude rules add "budget: $50 a day"` (it shows what the line became and asks first; `--yes`
513
+ skips the question), the rules screen's box, or a line in `~/.anvil/rules.md` and then `anvil claude sync`.
514
+ - **A budget is not a cap.** A cap counts what the agent does (deploys, deletes, paid compute at your price). A budget
515
+ counts what Claude Code spends. A line that reads as the other says which to write: `cap: $50 a day` gets "what
516
+ Claude Code spends is a budget: write budget: $50 a day".
517
+
518
+ ## Helper agents
519
+
520
+ The agents Claude launches (the Agent tool) have rules of their own:
521
+
522
+ | Written | Does |
523
+ |---|---|
524
+ | `model: sonnet for helper agents` | every helper runs on Sonnet, whatever Claude asks for |
525
+ | `model: haiku for exploring` | Explore helpers only (also `planning`, or a type in backticks: `` `reviewer` ``) |
526
+ | `cap: at most 5 helper agents at once` | the next launch waits for your OK while 5 run in the session |
527
+ | `cap: 20 helper agents an hour` | an ordinary cap (above) |
528
+ | `hold: helper agents` | every launch waits for your OK |
529
+
530
+ - Claude Code takes sonnet, opus, haiku or fable. A rule naming a type wins over one for every helper; a project's over
531
+ yours. A fork helper always keeps the session's model: it passes as it came, and Anvil says so once a session.
532
+ - Where your own permission rules deny helper launches, Anvil adds nothing; where they ask first, the switch rides on
533
+ that ask, and the at-once cap still counts the launch: past it, it is held with the cap's reason. Under the kill
534
+ switch nothing is switched.
535
+ - The at-once count needs Claude Code 2.1.318 or later (it reports helpers starting and stopping). Elsewhere, and under
536
+ the plugin alone, Anvil says it can't count, once, and never holds. A launch put to you in Claude Code's prompt keeps
537
+ its place until you answer (a No gives it back; 30 minutes at most). A workflow's helpers count too. A helper that
538
+ never reports stopping (stopped with Esc, a crash) stops counting 30 minutes after it last did anything.
539
+ - 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.
540
+ - **With no rule at all**, more than 20 helper launches in 10 minutes in one session wait for your OK: always on, like
541
+ the delete bursts (ALWAYS-ON.md). Your OK lets that burst go on; the next 20 run without asking. A cap of yours is
542
+ different: past it, each launch needs its own OK.
543
+
544
+ ## The main chat's model
545
+
546
+ No tool can switch the main chat's model, and its `model` setting is your own choice, so Anvil never switches it. It
547
+ holds an action made on the wrong model, or refuses a switch:
548
+
549
+ | Written | Does |
550
+ |---|---|
551
+ | `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`) |
552
+ | `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 |
553
+
554
+ - **Held on the wrong model:**
555
+
556
+ ```
557
+ 🔹 Held by Anvil for your OK 🔹 deploys need Opus; this session is Sonnet · switch: /model opus
558
+ ```
559
+
560
+ 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:
561
+ Yes in Claude Code's prompt, or `anvil claude allow <code>` where the hold has a code (the desktop app, Bypass).
562
+ - **Which model made the call** is read from Claude Code's session file: its latest request line, written as each
563
+ request goes out (Claude Code 2.1.304 or later), so it is this reply's own model. A helper agent's call is judged by
564
+ the helper's model, from its own file. Where the model can't be told (an older Claude Code), Anvil says so once and
565
+ never holds.
566
+ - **A switch refused** is refused wherever Claude Code switches: `/model` in the terminal, the desktop app's model
567
+ picker, an SDK's `set_model`. Claude Code says "Model switch blocked by a PreModelSwitch hook" with the rule. It
568
+ needs Claude Code 2.1.318 or later, where `anvil claude on` adds the switch entry: on an older one, `rules add` and
569
+ the screens say a `never` isn't refusing yet.
570
+ - **A session already on a model your rules say never** (it started there: no hook can stop that) is told at its first
571
+ action: "this session runs on Opus 1M, which your rules say never · switch with /model".
572
+ - **What the words cover.** A model rule holds the kinds its words name, and `rules add` says which: "pushes need
573
+ 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
574
+ runs on any model. `anvil claude rules` lists each rule by its kinds.
575
+ - **Rules:** one model rule per kind, and one `never` per model. A `never` that forbids what a guard needs is refused,
576
+ with the line it contradicts. A model rule names a model as `/model` does: `opus`, not one version
577
+ (`never claude-opus-4-8` is refused, since a rule on Opus would also refuse the Opus you run), and for an action
578
+ never `opus[1m]`. A rule is per kind: `model: opus for deploys on Fridays` holds every deploy made on another model,
579
+ and says so. Words that only say where ("in this repo") are the file's to decide. A project's model rules apply
580
+ inside that project only, and its rule for a kind wins over yours there. Where no switch could run a held call (two
581
+ kinds on two models, or a `never` that refuses the switch), the hold says so and offers only to allow it once. The
582
+ kinds always stopped can't take one. The kill switch leaves model rules stopping nothing, and the screens say so.
583
+ - **Where they show:** `anvil claude rules` (with caps and budgets, each with what it does now), the rules screen
584
+ (⌫ twice removes one, the box adds one), Proof (`your model rule`) and `report`.
585
+ - **A guard against the wrong model, not a security floor.** Claude could write a false request line into its own
586
+ session file in the reply that deploys, and Anvil can't tell such a line from Claude Code's own. A direct write to
587
+ the file reads as writing a secrets file (`secret-file-write`); one made through a variable or a script doesn't.
588
+ - **Helpers versus the main chat.** `model: haiku for exploring` switches helper agents (Claude Code lets a hook
589
+ rewrite a launch). `model: opus for deploys` never switches anything: it holds.
590
+
591
+ ## The screen: `anvil claude rules edit`
592
+
593
+ This is real output, at 80×24 (redesigned 2026-11-17): your own `~/.anvil/rules.md` holding `hold: push or merge to
594
+ main`, `block: force-pushes`, `budget: $50 a day` and `cap: at most 3 deploys a day`, the cursor on push-main:
595
+
596
+ ```
597
+ Anvil. Claude Code · Rules this week: 0 checked · 0 held
598
+
599
+ ✕ ■ Always on 2 blocked · 5 held · spend counted no mode turns these off
600
+
601
+ ╭─ Add a rule ──────────────────────────────────────────────────────────────╮
602
+ │ › ▌ Type a rule in plain English │
603
+ ╰───────────────────────────────────────────────────────────────────────────╯
604
+ For example "hold pushes to main" "budget: $50 a day"
605
+
606
+ ── Your rules ─────────────────────────────── 2 on · 2 limits · 18 watching ─
607
+
608
+ On stopped before they run
609
+ ✕ force-push block force-push · line 2
610
+ › ■ push-main hold push or merge to main · line 1 ⌫ removes
611
+
612
+ Caps
613
+ ● 3 deploys a day past it, the next waits for your OK · 0 of 3 used
614
+ resets at midnight
615
+ ↓ 19 more
616
+
617
+
618
+
619
+ ↑↓ choose space change enter add esc done ~/.anvil/rules.md
620
+ ```
621
+
622
+ - **Four keys**, and the footer names them: ↑↓ choose a row, space changes it, enter adds what you typed, esc is done
623
+ (with words typed, esc clears them first). Ctrl-C leaves too. **Each change is saved as it is made**, through the
624
+ path its own command takes, and leaving says what changed.
625
+ - **A rule you wrote turns down as well as up.** Space on it changes its own line in your rules.md and says so
626
+ ("changed hold: deploys → off: deploys"): a rule on a kind goes hold → off → watch → hold, a block first to a hold; a
627
+ rule on one app, file or target goes hold ↔ watch. ⌫ twice removes it. Anything else keeping it stronger (`enforce`
628
+ for every kind, your workspace) is said right there.
629
+ - **Typing a rule.** Letters go into the Add a rule box. Under it, faint, a few examples, until Anvil understands the
630
+ words; then what the rule will do ("✓ every deploy waits for your OK"), and enter adds it to the file the screen
631
+ edits. Nothing typed is ever an error while you type: what can't be used is said once you press enter.
632
+ - "hold …", "block …", "watch …" and "off …" set the line's verb ("hold pushes to main" is written `hold: pushes to
633
+ main`); "never …", "don't …", "don't let Claude …" and "stop it from …" block; "ask before it …" and other words
634
+ hold.
635
+ - A command is read the way the hook reads it (above): `kubectl delete` says "✓ every deploy waits for your OK".
636
+ - What can't be a rule says why on enter: a command Anvil lets run, one app, one file or folder, or advice for
637
+ CLAUDE.md (the table above). While you type, the same is a faint hint, never an error.
638
+ - A count ("at most 3 deploys a day") is a cap, a sum ("$50 a day") a budget, `model: …` a model rule. A second
639
+ dollars-a-day budget is refused, as the file would refuse it.
640
+ - Words Anvil's own reader can't place go, on enter, to your Claude Code (Haiku, through your own login), once; its
641
+ reading is kept with the line, so a sync never sends it again. With no Claude Code, they are taken as advice, and
642
+ the box says so.
643
+ - A budget is yours, not one project's: in a project, the box gives the command that adds it to your own file.
644
+ - **Changing a kind:** space cycles off → watch → hold → off.
645
+ - **Removing:** with the box empty, ⌫ on a line you wrote asks; ⌫ again removes it. Only a line in the file the screen
646
+ edits (the project's when there is one): a line in your own file says to change it there.
647
+ - **Importing CLAUDE.md:** type `import` and press enter. When a CLAUDE.md is there and you have no rules yet, the box
648
+ says so.
649
+ - **Edited outside the screen:** when the file has changes nobody has applied, the box says so, and enter applies them
650
+ as `sync` does. Until then a change that would write that file saves nothing, and says why.
651
+ - **Where your rules live** is named in the footer: a link to the file in terminals that open one (iTerm2, VS Code,
652
+ WezTerm, Ghostty, Warp). It is the file to edit, export or share: rules.md is plain Markdown, like CLAUDE.md.
653
+ - **The Always on box** lists what no mode turns off: the blocks, the holds (helper bursts since 2026-11-17: more
654
+ than 20 helper launches in 10 minutes, ALWAYS-ON.md), and that the meter counts what every Claude Code session
655
+ spends, with today's figure once there is one ("$4.10 today", or your plan's share of the week).
656
+ - **It fits your terminal.** The title, the add box, the keys and any note stay in view. One list, sorted (what is on
657
+ first, blocks then holds; then the caps, budgets, model and helper rules; then what is watched; then what is off),
658
+ scrolls around the cursor, and "↓ 19 more" counts the rules out of sight. Below about 30 rows the always-on box
659
+ folds to one line (it shows whole on a taller terminal, and in `anvil claude rules`). A limit's state wraps under its
660
+ own column and is never cut.
661
+ - **Each limit says what it does now.** "past it, the next waits for your OK", "can't be measured: …" with its fix, "off:
662
+ the kill switch is on". A limit set in another project isn't listed: a line under the list counts them.
663
+ - **Each row shows what the hook does.**
664
+ - 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
665
+ change it.
666
+ - A watched "never" line switched on shows as the block it is.
667
+ - Space can't turn a kind off while `enforce` covers every kind.
668
+ - The line a row names is the strongest one across both files.
669
+ - **A save reports what is now true.**
670
+ - Every write takes the path its own command takes. Hold and watch go through `enforce` and `ghost`. Off is an `off:`
671
+ line in your rules.md, with the kind's switch taken away. Added and dropped lines are applied the way `sync`
672
+ applies them.
673
+ - After each save, each changed kind is read back as the hook now judges it. "✓ Saved · push-main waits for your OK",
674
+ or, when something stronger still decides it, "▲ sudo stays held: `anvil claude enforce` for every kind holds it".
675
+ - **Without a terminal** (piped, CI), or inside Claude Code (`CLAUDECODE=1`), it prints once and changes no rule or
676
+ mode.
677
+ - **Built with** Node built-ins only, at 80 columns, with colour only on a terminal without NO_COLOR.
678
+
679
+ ## What it doesn't do
680
+
681
+ - **A call refused at Claude Code's own prompt still counts against a cap.** Anvil counts a call when it lets it run;
682
+ if Claude Code then asks its own question and you answer No, Anvil never sees the answer. Under Bypass there is no
683
+ such question.
684
+ - **Several capped actions in one command count once.** `vercel deploy && vercel deploy` uses one place: the hook
685
+ judges a command, not each step inside it.
686
+ - **Paid-compute caps are estimates.** Anvil reads the command that starts compute, never the bill. "At once" is
687
+ counted per day for machines, and a GPU cap counts every paid-compute start.
688
+ - **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
689
+ every call of that kind, and says so when you add it.
690
+ - **`off:` can't beat a switch.** It can't weaken `anvil claude enforce` for a kind or for every kind; the applied line
691
+ says so, and the screen won't switch it off.
692
+ - **Each folder needs its own yes.** A second clone or a git worktree starts with none of its rules applied (the hook
693
+ says so) until `anvil claude sync` there.
694
+ - **Approving the agent's held `sync` applies everything pending.** The list of what changed goes to the agent's
695
+ output; to review it yourself, run `anvil claude sync` in your own terminal.
696
+ - **A script can drive a terminal itself.** An agent that writes a script which opens its own terminal and drives the
697
+ rules screen isn't held: the hook sees the command, not what a script does. Every documented way to change rules is
698
+ held.
699
+ - **`/anvil` doesn't show a project's rules.** The slash command runs without the project's folder: its line counts
700
+ your own rules and caps.
701
+ - **A budget can end a little over,** by about a reply: a reply under way always ends (Budgets, above).