A harness is the program that drives a model, Claude Code for one. Before it edits a file, runs a command or fetches a page, it asks leave, in the words of the Agent Client Protocol: a request that names one of ten kinds of tool (read, edit, delete, move, search, execute, think, fetch, switch_mode, other) and the files it touches. An agent kind’s permission rules are the organization’s answer, written once for every agent of the kind.
The rules are stored with the kind, checked when the kind is defined, and shown by af kind show. The agent runner that puts a harness’s requests to them is a later part of step 12 and is not built: nothing answers a request by these rules yet, so a kind that names them is stating what it will be held to.
A rule
A rule has a tool, optional paths and a decision:
| Field | What it says |
|---|---|
tool |
One of the ten kinds above, or forge:NAME for one of the forge’s own tools, such as forge:land |
paths |
At most 8 globs of at most 256 bytes, inside the workspace. A star stays in a directory and two stars cross them; a backslash escapes. No leading slash, and no . or .. part. Left out, the rule is about every request of its tool. A forge tool’s call names no file, so a rule on one has no paths |
decision |
allow, deny, ask, guide or transform |
A kind names at most 32 rules, and at most 16 KiB of them written out, so that a request for the kind always fits one entry of the log.
Which rule decides
The rules are read in order and the first that matches decides. A rule matches a request of its tool; if it has paths, the request must also name at least one file, and:
- an
allowmatches only if every file the request names is inside one of its globs; - any other decision matches if any one file is.
The difference is deliberate. A request that touches two files, one of them guarded by a deny or a guide, is not allowed past the guard by a wider allow further down. A file outside the workspace, or one that reaches out of it with .., is inside no glob, so it is never allowed by a rule with paths.
A request that no rule matches goes to the first ask rule of the kind, whatever its tool, and is denied if the kind has none. The forge never gives a standing grant: a harness’s allow_always is not an answer a rule can make.
The five decisions
Allow and deny answer at once.
Ask puts the request to someone and waits. to is a person (an agent ID in hex), a team (the identity provider’s group name) or an agent kind, which must exist. waitSeconds is at most 3600, and default, allow or deny, is what silence takes, recorded as defaulted with no answerer. Nothing requires a person: a kind of agents can be asked.
Guide refuses and says why. The harness is told no, and its next prompt carries the rule’s message, at most 512 bytes. That text is only what the rule says, never an argument of the call or anything the agent wrote, so a refusal cannot be used to carry text into a prompt. A turn gets one follow-up: each rule that refused in the turn adds its message once, however many times the harness tried, and at most 32 are kept.
Transform lets a call of one of the forge’s own tools go on with its arguments rewritten: set a field to a value, remove one, or clamp a count to a maximum. A harness’s own tool cannot be transformed, because an ACP permission answer has no way to carry a changed input, so a rule that tries is refused. The rewritten call is checked again by the folder, class and cap rules, as if the agent had sent it so.
An error is a no
If the forge cannot evaluate a rule, whatever the reason, the request is denied and the denial is recorded as a permissionError. It is never allowed. A location that is malformed, a rewrite that does not apply and a rule that is not whole are each a denial that says so.
What the forge refuses when a kind is defined
A rule is checked when a kind is asked for and again when it is approved. The forge refuses:
- a rule that is not whole: a glob outside the workspace, more rules or longer text than the caps, a
transformof a harness’s tool, paths on a forge tool; - rules past the 16 KiB total;
- an
askto an agent kind that does not exist (a kind may ask its own agents); - a rule that can never match, naming it and the earlier rule that decides first.
The last check catches a mistake that a reader of the list would miss: an allow of edit after a deny of edit with no paths is dead text, and the author meant something else. It is a limit of what can be decided from the rules alone, so it is sound where it refuses and incomplete where it allows. It refuses a rule when an earlier rule is of the same tool and either names no paths, or names every glob the later one names (and an allow earlier covers only an allow later, since a deny can match a request that the allow does not). It does not know that src/** covers src/a.rs: a rule that overlaps another by what the globs match, not by how they are written, is accepted. The kind’s first ask is never refused, since it is the answer to every request that nothing matches.
Write the rules
The rules are a JSON list, read from a file, or from standard input with -, which an agent writes and nobody edits. af kind request --permissions FILE takes them, and [] takes them all away. As with every field of a kind, a request that leaves them out keeps the current ones.
$ af-server --dev
...$ source ~/af-dev/dev/env
$ printf 'You write code under src.\n' > coder.md
$ cat > rules.json <<'END'
> [
> {"tool": "read", "decision": "allow"},
> {"tool": "edit", "paths": ["src/**"], "decision": "allow"},
> {"tool": "edit", "paths": [".github/**"], "decision": {"guide": {"message": "Workflow files are changed by the platform team: ask them."}}},
> {"tool": "execute", "decision": {"ask": {"to": {"team": "reviewers"}, "waitSeconds": 600, "default": "deny"}}},
> {"tool": "fetch", "decision": "deny"}
> ]
> END
$ af kind request coder --purpose "writes code under src" --program claude-code --instructions coder.md --role writer --folder src --lifetime 2h --permissions rules.json
done: it took effect at once, on your word as an administratoraf kind show prints them in order, one to a line, as the forge reads them:
$ af kind show coder
coder version 1 (current)
id a2c672583718f9fcb25d28e5cdda6e9a226eb30c9af686390607bfcdf3a05201
state active
purpose writes code under src
born of a person's or an agent's birth
program claude-code
models none
roles writer
folders src
classes none
acts none
lives 2h
budget none
egress none
permissions 5 rules, the first that matches decides
1. read: allow
2. edit on src/**: allow
3. edit on .github/**: guide with "Workflow files are changed by the platform team: ask them."
4. execute: ask team reviewers, and without an answer in 600 s deny
5. fetch: deny
instructions 26 bytes, sha256 cf60f98f6e23aaa5686d6669b6b3f8c80358501efaa0eeaa6ac0a96718b7aee6
versions 1A rule that can never match is refused before anything is signed, and the refusal names both rules:
$ cat > dead.json <<'END'
> [
> {"tool": "edit", "decision": "deny"},
> {"tool": "read", "decision": "allow"},
> {"tool": "edit", "paths": ["src/**"], "decision": "allow"}
> ]
> END
$ af kind request coder --permissions dead.json
Error: permission rule 2 can never match: rule 0 decides every request it would
[1]And a question to a kind that is not there is refused by the forge, which holds the kinds:
$ cat > ask.json <<'END'
> [{"tool": "execute", "decision": {"ask": {"to": {"kind": "reviewer"}, "waitSeconds": 600, "default": "deny"}}}]
> END
$ af kind request coder --permissions ask.json
Error: PermissionDenied: a permission rule asks agents of the kind "reviewer", and there is no agent kind of that name
[1]See Define the kinds of agents you run for the rest of af kind, and Agent kinds, models and grades for what a kind is.