@useanvil/claude-code 0.9.1 → 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.
- package/CHANGELOG.md +703 -0
- package/README.md +128 -38
- package/dist/Anvil +0 -0
- package/dist/claude-approve.js +23 -0
- package/dist/claude-conditions.js +19 -12
- package/dist/claude-helpers.js +9 -9
- package/dist/claude-hook-core.js +88 -80
- package/dist/claude-hook.js +38 -37
- package/dist/claude-meter.js +52 -48
- package/dist/claude-powershell.cjs +17 -17
- package/dist/claude-sync.js +26 -26
- package/dist/cli/claude-main.js +5392 -2510
- package/docs/coding-agents/YOUR-RULES.md +507 -654
- package/package.json +1 -1
|
@@ -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
|
|
4
|
-
|
|
5
|
-
|
|
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,
|
|
23
|
-
|
|
24
|
-
services,
|
|
25
|
-
|
|
26
|
-
model. Budgets limit what Claude Code spends,
|
|
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,
|
|
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,
|
|
32
|
-
|
|
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
|
-
|
|
38
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
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,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
126
|
-
adds the rules (`e` edits, `a` adds one more, esc drops it). The box reads each part itself
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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,
|
|
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)
|
|
220
|
-
daylight-saving day reads as the wall clock does. Typed, a time
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
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
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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 |
|
|
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
|
|
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 |
|
|
276
|
-
| `model: never …` refusing a switch | Claude Code 2.1.251 or later
|
|
277
|
-
| a cap on helpers at once | Claude Code 2.1.318 or later (it reports helpers starting and stopping) |
|
|
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
|
|
279
|
-
|
|
280
|
-
- **An older Claude Code
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
- **
|
|
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
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
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. **
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
442
|
-
|
|
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
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
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:
|
|
527
|
-
|
|
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
|
-
- **
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
- **
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
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
|
|
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
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
|
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
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
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
|
-
|
|
689
|
-
|
|
690
|
-
- **
|
|
691
|
-
|
|
692
|
-
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
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
|
|
716
|
-
|
|
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
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
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,
|
|
739
|
-
Claude Code's sandbox
|
|
740
|
-
script that builds its path
|
|
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
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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
|
-
- **
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
- **Linux needs bubblewrap and socat**, and on Ubuntu an AppArmor that lets bubblewrap run
|
|
753
|
-
|
|
754
|
-
- **Network, git, Docker and localhost work as before.** The sandbox covers Bash and what it starts
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
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
|
|
767
|
-
|
|
768
|
-
alone.
|
|
769
|
-
|
|
770
|
-
- **New sessions only
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
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
|
-
|
|
784
|
-
|
|
785
|
-
- **What it replaced is said
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
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
|
|
803
|
-
own record
|
|
804
|
-
|
|
805
|
-
|
|
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
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
- **
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
-
|
|
821
|
-
|
|
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
|
|
828
|
-
|
|
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
|
-
│ ›
|
|
663
|
+
│ › Type a rule in plain English, or drop CLAUDE.md here │
|
|
837
664
|
╰───────────────────────────────────────────────────────────────────────────╯
|
|
838
|
-
|
|
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
|
-
|
|
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
|
|
682
|
+
↑↓ choose space change ⌫ remove esc done ~/.anvil/rules.md
|
|
854
683
|
```
|
|
855
684
|
|
|
856
|
-
- **
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
- **
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
- **
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
- **
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
- **
|
|
899
|
-
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
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
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
- **
|
|
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
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
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.
|