< Back to articles

Claude Code permissions: who decides what an AI agent can do

Claude Code permissions: who decides what an AI agent can do

Before you let an AI agent commit to your repository, you should know one thing: the polite request in CLAUDE.md not to delete anything won't stop anyone. What Claude Code is actually allowed to do isn't decided by the model or by your CLAUDE.md. It is decided by the permission system you did or didn't configure.

Quote from the talk: Permissions are enforced by the program, not the model.

📋 TL;DR

  • Permissions are enforced by the program (Claude Code), not by the model, and that holds for any AI agent. CLAUDE.md and the prompt only influence what Claude tries to do. What it is allowed to do is decided by the rules.
  • Read-only tools (Read, Grep, LS) run without asking. Bash keeps asking until you tell it "don't ask again", which is written permanently to settings.json. File edits ask too, but that "yes" only lasts for the session.
  • Rules live on four levels: user, project (committed to git), local (gitignored) and managed (company policy that nobody edits).
  • Evaluation goes in the order deny → ask → allow. The first match wins, and a deny anywhere beats an allow anywhere.
  • Wildcards in rules are treacherous: a space, && or a plain shell variable can get around even a sensibly written deny rule.
  • Claude Code has six permission modes, from plan to bypassPermissions. David Bilík swapped the default bypass for auto mode, where a separate classifier judges the riskier actions.
  • Hooks give you the deterministic check a classifier doesn't: the same input gives the same verdict, every time.
  • Besides permissions in Claude Code, also apply least privilege to the tools themselves: API keys, GitLab tokens and Redmine access.

🧠 A mental model: what Claude tries and what it is allowed to do

The most important sentence of the whole talk is about the difference between a wish and enforcement. When you write "don't do this" into CLAUDE.md, it's just a polite request. Nothing guarantees the program will follow it, because the model can overlook it or read it differently at any moment. A prohibition in permissions is a different league: Claude Code actually enforces it, no matter what the model happens to think.

In practice it comes in three forms, depending on the type of tool. Read-only tools like Read, Grep or LS run without asking unless you explicitly forbid them. Bash asks until you choose "Yes, don't ask again" once. That choice is written to the allow list in settings.json and lasts permanently. File edits offer only "Allow in this session", an approval valid until the end of the session; in a new conversation Claude asks again.

Why is "don't ask again" never offered for some bash commands? Either the command is all Yes/No and a rule can't be safely written for it, or it has too many subcommands or constructs like watch / find -exec that the rule evaluator can't reliably assess. In those cases the system would rather ask every time than risk a badly written rule.

💡
Session-only vs. permanent

The difference isn't random: a bash command can be written down as a clear rule pattern, while approval of a specific file edit can't. That's why Claude Code never saves it permanently, and you have to confirm it again in every new session.

📂 Where the rules live

The rules aren't in one place. Claude Code looks for them on four levels of settings.json, each for a different purpose:

  • User: ~/.claude/settings.json. Your personal settings, valid in every project you open.
  • Project: .claude/settings.json. Committed to git, valid for the whole team on that project.
  • Local: .claude/settings.local.json. Also your personal settings, but only for that project, and it's in .gitignore by default, so it suits tinkering and experiments you don't want to push into the shared config.
  • Managed: company policy. Nobody can override it, not even a project administrator.

These four levels are read in an exact order: managed settings, then command-line flags, then local project settings, then project (shared) settings and finally user settings. Each lower level can add what the higher one is missing, but it can't override what managed or a higher level has already decided.


⚖️ Deny, ask, allow: who wins

For every action there are three possible verdicts: allow, ask, deny. Evaluation always goes in the same order: deny is checked first (across all levels of settings.json at once), then ask, then allow. The first rule that matches decides, and evaluation ends there. A more specific rule on another level has no chance of jumping ahead: if you have a deny in user settings and allow the same action in project settings, the deny simply wins. A managed deny is also absolutely final; nothing overrides it.

A typical rule definition in settings.json looks like this:

{
  "permissions": {
    "allow": [
      "Bash(npm run *)",
      "Bash(git commit *)"
    ],
    "deny": [
      "Bash(git push *)"
    ]
  }
}

🕳️ When an asterisk doesn't mean what you think

Wildcards in rules are a source of more confusion than you'd expect. The space matters: Bash(ls *) and Bash(ls*) are two different rules, and the second, without the space, lets through commands you'd expect to stay forbidden. On the other hand, compound commands are fortunately parsed correctly: ls * joined by && with rm -rf . is evaluated as two separate commands, so rm -rf doesn't get through even if ls itself is allowed.

Arguments are worse: rules match text, not intent, so you can't rely on them completely. A typical example is a ban on downloading from GitHub:

"deny": ["Bash(curl https://github.com/*)"]

# and yet this gets through:
curl -X GET https://github.com/...
curl http://github.com/... # without https
URL=https://github.com && curl $URL # via a variable

When you want to really forbid something, you usually have to write several variants of the rule at once to cover these workarounds. And if you want certainty, asterisks aren't enough, which we'll get to with hooks.


Book a consultation

🚦 Permission modes: from plan to no brakes

Claude Code has six permission modes, ordered from the most oversight to the fewest prompts: plan (no edits, you just watch what Claude would do), default, acceptEdits, auto, dontAsk and bypassPermissions. David Bilík deliberately didn't go into detail on the other four. He focused on the two extremes and the most interesting cases, auto and bypassPermissions. Both aim to reduce the number of prompts, but they do it in completely different ways.

bypassPermissions is without brakes: it skips every question and safety check, and tool calls simply run. It doesn't protect you against prompt injection or a model mistake. It only makes sense in an isolated throwaway container or VM where it doesn't even matter if something goes wrong. Under root, Claude Code won't even start this mode.

auto skips routine questions, but sends every riskier action to a separate classifier model, which judges it on its own. It blocks things like curl | bash, data exfiltration, deploys to production or a force-push to main. The classifier generally trusts your repository and your own remotes, and when it's unsure, it falls back to classic asking.

Diagram of the Claude Code decision process: rule check, read-only hit, classifier and tool execution

Bilík said goodbye to the default bypassPermissions and tried auto mode as his personal default. By his own experience it works well: even an instruction given at the start of a session ("don't do this") was something the classifier managed to respect for the whole conversation. Still, in his words it is "still slightly nondeterministic", so where you need a hard guarantee, you can't do without a rule in settings.json.

“For me, auto mode is a pretty good compromise between Claude constantly asking you about something and it having no brakes at all.”

David Bilík, CTO at Ackee
The six Claude Code permission modes ordered from plan to bypassPermissions, with auto and bypassPermissions highlighted

🪝 Hooks: a deterministic guard when the classifier isn't enough

The most deterministic way to tell Claude Code what it can and can't do is a PreToolUse hook. It's your own script that runs before every tool call and, based on its return value, decides whether the action goes through. The same input always gives the same verdict, and no classifier is involved.

A typical pattern: you allow Bash broadly, and the hook blocks only the small set of truly dangerous commands (exit code 2 = block). Hooks can also only tighten rules, never loosen them: deny and ask rules from settings.json take precedence even over a hook, and no user can bypass a managed hook.

⚠️
bypassPermissions only in isolation

Before you reach for bypassPermissions, make sure you're running in an environment where it doesn't matter: a throwaway container or VM, not your work machine with access to production credentials.


🔑 The other side of the coin: permissions of the tools themselves

Everything described above deals with permissions from Claude Code's point of view: how to make your life easier without endless clicking through prompts. But there is another side of the coin: the permissions of the tools Claude uses, whether that's an MCP server or a CLI tool like glab.

The same principle of least privilege applies here as with people: a tool should always have only the smallest permission it needs to do its job. The same logic applies to users themselves: not everyone has admin rights in GitLab. It's not about distrusting colleagues but about limiting the blast radius: if someone gets hold of your account or token, they should be able to do only a fraction of what unlimited access would allow.

On GitLab, the new Fine-Grained Access Tokens, which GitLab made available in beta in 2026, helped with this. When creating a Personal Access Token you can now choose between the old "legacy" mode and the new fine-grained mode, where you scope the token to specific projects and specific permissions on them: repository, merge requests, CI/CD and so on. The token then typically belongs in the .env file of the given project and is used, for example, by glab when authenticating to GitLab.

Comparison of a fine-grained access token in GitLab with a classic API key in Redmine

Redmine is unfortunately more complicated. Redmine gives one API key per account and doesn't let you scope it to specific projects or actions. It's a limitation of the platform that anyone using Redmine for API integrations runs into. A typical consequence: such a key is used for years unchanged, because there's no reason (or easy way) to rotate it. A workable workaround is to create a separate user with access only to the projects the agent needs and use that user's API key instead of your own; activity in Redmine then appears as the activity of that account, not yours. But there is no universal solution for Redmine. It's a limitation of the platform itself, not a temporary gap that will soon disappear.

Frequently asked questions

No. For Bash commands, "don't ask again" is written to settings.json and lasts permanently. For file edits you only get "Allow in this session": the permission lasts until the end of that session, and in a new one Claude asks for it again.
When a command is hard to describe with a rule (it has many subcommands, it can be written in many ways, or it matches an explicitly forbidden pattern), the rule evaluator can't assess it reliably, so it errs on the safe side and asks every time.
No, it fits better in an isolated container or VM where it doesn't even do harm if something goes wrong. It turns off absolutely all checks, so it doesn't protect against prompt injection or a model mistake.
No, it only skips routine questions; every riskier action is then judged by a separate classifier model. It's a step safer than bypassPermissions but still not fully deterministic. For a hard boundary you need a rule or a hook.
On GitLab, use the new Fine-Grained Access Tokens and scope them only to the projects and permissions the agent really needs. For Redmine there is no universal solution. What helps is creating a separate user with limited access only to the needed projects and using that user's API key instead of your own.

🎯 Key takeaways

Permissions in Claude Code aren't a detail you settle with one "no, don't do this" in CLAUDE.md. They're real rules, evaluated in an exact order (deny, ask, allow), and they live on four levels of settings.json, from your laptop to company policy.

A real defense combines several levels at once: sensibly set rules for what Claude may try without asking, a permission mode that suits the context (bypassPermissions only in an isolated container, auto as a reasonable compromise for everyday work), and, where you need certainty, a hook with deterministic custom code rather than a classifier that can occasionally get it wrong.

Don't forget the other side of the coin either: the permissions of the tools Claude uses. GitLab has had fine-grained access tokens available since 2026, while with Redmine you have to help yourself with your own head and a separate account with limited access.

If you're interested in building a whole agentic workflow on similar foundations, take a look at the comparison of Cursor and Claude Code or at how to share AI know-how between teams through Claude Code plugins.

Subscribe to the newsletter

More notes from running Claude Code at Ackee are in our newsletter. Subscribe and the next one lands straight in your inbox.

David Bilík
David Bilík
Android Team Lead

Are you interested in working together? Let’s discuss it in person!