Agent Permission Rules That Hold Up in Practice
Agent permission rules are how you stop answering the same permission prompt for the hundredth time without giving an agent the run of your machine. A good set is short, biased toward denial where it matters, and narrow where it allows. A bad set is one wildcard that approves everything, written on a tired afternoon. This guide covers how rules are evaluated in Claude Code, how to write patterns that mean what you intend, how to scope and expire them, and how shared rules work in Forkit for a team's agents.
How agent permission rules are evaluated
Start with the mechanics, because they decide what a rule can and cannot do.
In Claude Code, rules live in settings files under permissions, in three lists: allow, ask and deny. Anthropic's docs give the order: deny rules are checked first, then ask, then allow, and the first match in that order decides. Specificity does not matter. Two consequences:
- A broad deny beats a narrow allow.
deny: Bash(aws *)blocksaws s3 lseven if you allowed that exact command. - You cannot carve an exception out of a deny rule with an allow rule.
Rules in managed settings sit above user and project settings. A PreToolUse hook that says "allow" does not override a deny or ask rule.
Forkit's command rules follow the same principle for a team: a matching deny always wins.
Write the deny rules first
List what must never run without a person looking. Keep it short and concrete.
{
"permissions": {
"deny": [
"Bash(git push --force *)",
"Bash(rm -rf *)",
"Read(./.env)",
"Read(./secrets/**)"
]
}
}
Think in categories:
- Destruction: recursive deletes, force pushes, dropping databases.
- Secrets: reading key files and environment files.
- Exfiltration: arbitrary network tools, if your sandbox does not already block them.
- Production: deploy commands, anything with a production flag.
Deny rules are your floor. Everything else is tuning.
Then build the allowlist from evidence
Do not guess what to allow. Run with prompts on for a few days and note what you approve every time. Those are your allow rules. The usual list:
{
"permissions": {
"allow": [
"Bash(npm run test *)",
"Bash(npm run lint)",
"Bash(npm run build)",
"Bash(git status)",
"Bash(git diff *)"
]
}
}
An allowlist built this way is grounded in what your agents really do.
Make command globs narrow
A pattern allows everything it matches, including commands you did not think of.
Bash(npm *)allowsnpm test. It also allowsnpm publishandnpm install some-package-you-have-never-heard-of.Bash(npm run test *)allows what you meant.Bash(*)is not a rule. It is the absence of rules.
Guidelines for command globs:
- Anchor on the subcommand.
git diff *, notgit *. - Avoid trailing wildcards on commands that take a target.
npm run migrate *matches staging and production alike. - Remember that commands compose. The docs have sections on compound commands and wrappers; a rule that allows a harmless command should not be read as allowing whatever is chained to it. Test your rule against
cmd && something-else. - Prefer scripts. If you find yourself allowing a complex command line, put it in a script with a fixed name and allow the script.
Rule scope: repository, agent, person, time
A rule without scope applies everywhere, forever. Narrow it along four dimensions.
Repository. "Tests are fine" may be true in one repository and expensive in another. Project-level settings in Claude Code scope rules to a repository. Forkit's command rules can carry a repository.
Agent. A rule can apply to one named agent. The agent that handles database work may be allowed to run migrations on a local database; others not.
Person. In Forkit, a member's rules cover only that member's own agents. Workspace owners can write rules for everyone. So one person's convenience does not become team policy by accident.
Time. Some permissions are needed for one task. "Allow for an hour" lets a burst of similar commands through and then closes again. Forkit offers that as an answer, alongside allow once and always.
The marketing copy on Forkit's site sums up the idea: answers turn into rules with one click, scoped to a repo, an agent or an hour.
Least privilege, applied to commands
The principle of least privilege says to grant only what the task needs. For agents that means:
- Allow commands, not shells.
- Allow paths, not the filesystem.
- Allow for the task's duration, not permanently.
- Review what is granted.
Vercel's and GitHub's security writing for agents makes the same argument from the credential side: assume the agent can be steered by something it reads, and limit what it can do when that happens.
Keep one category beyond any rule
Some actions should reach a person no matter how the rules are written, because the cost of a wrong automatic "yes" is too high and because rules accumulate mistakes over time.
Forkit hard-codes this. Requests that touch production, secrets or money always reach a person. No allow rule answers them. The orchestrator agent cannot answer them. A person can allow them only once, never "always", and they are never grouped with similar requests.
If you write your own system, do the same. Decide the category, detect it conservatively, and make it immune to rules.
How shared rules work in Forkit
Local settings files serve one machine. A team needs rules that follow every agent.
When Claude Code is about to ask for permission, Forkit's hook sends the request to the server, where command rules are the first layer:
- A rule is a decision (allow or deny), a tool, and a glob matched against the command or the repo-relative path.
- A matching deny wins at once. A matching allow answers at once, and the agent continues without anyone being asked.
- Rules can be limited to a repository and to an agent's name, and can carry an expiry.
- Each rule records how often it has been used and when it was last used.
- Choosing "always" when answering a request creates a rule from that answer.
Requests that no rule answers go on to an orchestrator agent, if an owner has set one, and then to a person.
Maintain the rules
Rules decay. Look at them on a schedule.
- Delete unused rules. A rule nobody has hit in two months is risk without benefit. Usage counts make these easy to find.
- Tighten rules that are hit a lot. A rule with thousands of uses deserves a second look at its pattern.
- Turn repeated answers into rules. If the same request reaches a person five times, it should be a rule, or a deliberate decision not to make one.
- Review after incidents. When something ran that should not have, find the rule that let it.
Mistakes to avoid
- One wildcard rule to make the prompts stop.
- Allow rules written from imagination instead of from a log of prompts.
- Deny rules so broad that agents cannot work, which pushes people to bypass mode.
- Rules that live only on one person's laptop when five people run agents.
- Treating a rule as permanent.
Related: Claude Code permission modes compared, human-in-the-loop approval for coding agents and production access for AI agents.
Where Forkit fits
Forkit keeps a team's command rules in one place, applies them to every connected agent, creates new ones from the answers people give, and never lets a rule answer for production, secrets or money. It is free to try. More at forkit-mcp.com.