Sub topic 10
User, Project, and Organization Settings: Who Wins
This chapter assumes you know the allow, ask, and deny decisions, and that you can write simple allow and deny rules. It covers what happens when several settings files give different answers for the same action.
Why settings come in layers
A coding agent rarely reads one settings file. Permission rules usually come from several places, each with a different owner:
- User settings live in your home directory. They hold your personal habits, such as commands you always approve.
- Project settings live in the repository. They are shared with your team through version control and describe what is sensible for that codebase.
- Organization settings are set by an administrator, often through a managed file or a policy service. They hold company-wide limits.
Each layer answers a different question. You know your own tolerance for risk. The project knows which test and build commands are normal. The organization knows what must never happen, such as sending code to an unapproved host.
How layers combine
Most agents merge rules from all layers into one list. They do not pick a single file. Two principles keep the result safe.
- Deny beats allow. If any layer denies an action, it stays denied, even if another layer allows it.
- Higher authority overrides lower authority. Organization settings outrank project settings, and project settings usually outrank user settings. A lower layer can add restrictions but cannot remove ones set above it.
The exact order differs between tools, so check your agent's documentation. The shape below is the common one.
A worked example
Suppose the three layers contain these rules.
| Layer | Allow | Deny |
|---|---|---|
| Organization | none | `curl *` |
| Project | `pytest*`, `npm install` | `git push --force*` |
| User | `curl *`, `git status` | none |
The merged result behaves like this:
pytest -qis allowed by the project.git statusis allowed by the user.curl https://example.comis denied. Your user rule allows it, but the organization denies it, and deny wins.npm installis allowed, because the project's rule is shared with everyone who clones the repository.
The last case needs care. A project file travels with the repository, so a cloned repository from an untrusted source can ship its own allow rules. Many agents therefore ask you to trust a project before they apply its settings. Treat a project's allow rules as written by someone else, because they are.
Common errors
- Assuming your user setting wins. A personal allow rule cannot override an organization deny. If a command keeps being blocked, look for a higher layer.
- Debugging the wrong file. The effective rule set is the merge of all layers. Use your agent's command for showing active settings, if it has one, instead of reading one file.
- Committing broad allow rules to a project. A rule such as
*in a shared file grants everyone who opens the repository the same autonomy. Keep project allow rules narrow and review them like code. - Expecting a rule change to apply mid-session. Some agents read settings only at startup. Restart the session after editing.
A merge sketch
This Python function mirrors the logic above. Each layer is a dictionary with allow and deny lists. The layers are merged, then deny is checked before allow.
from fnmatch import fnmatch
def decide_layered(command: str, layers: list[dict]) -> str:
deny = [p for layer in layers for p in layer.get("deny", [])]
allow = [p for layer in layers for p in layer.get("allow", [])]
if any(fnmatch(command, p) for p in deny):
return "deny"
if any(fnmatch(command, p) for p in allow):
return "allow"
return "ask"
org = {"deny": ["curl *"]}
project = {"allow": ["pytest*"], "deny": ["git push --force*"]}
user = {"allow": ["curl *", "git status"]}
layers = [org, project, user]
print(decide_layered("curl https://example.com", layers)) # deny
print(decide_layered("pytest -q", layers)) # allow
print(decide_layered("npm install", layers)) # askThis sketch has a single merged list, so the order of layers does not matter for deny. Real agents add rules that let a higher layer lock a setting, so lower layers cannot change it at all.
Exercise
Your user settings allow git push*. The organization settings deny git push --force*. The project settings say nothing about git. What happens when the agent runs git push --force origin main, and what happens with git push origin main?
Show answer
The force push is denied, because a deny rule in any layer wins over an allow rule, and the organization's pattern matches. The plain git push origin main does not match the deny pattern and matches your user allow rule, so it is allowed.