Most teams let a coding agent into the repository the way they plug in a new laptop charger. Someone installs it, it works, and nobody writes down what it is allowed to do. A month later someone asks whether the agent can read the production database URL, and nobody knows.
I do not think the answer is a policy document. Policy documents get read once. What works is one rules file, in the repository, that says what an agent may run, which hosts it may call, what it may not read, and what needs a person to say yes. Every tool the team uses, whether that is Cursor, Codex, Claude Code or the agent inside Android Studio, gets pointed at the same file.
This post is the shape of that file and how to keep it alive.
Start from no, then add
An allow-list only works if the default is no. If the file lists the dangerous things and allows everything else, it is out of date the day someone installs a new CLI. So the file starts empty and grows. Each line is something a person decided the agent may do.
Keep it in the repository root, under version control, reviewed like code. One file per repository is fine. Once you have more than a handful of repositories, a shared base file for the company with a short local file on top is better.
What the agent may run
List the commands, not the categories. “Build tools” means nothing to a reviewer. pnpm test, pnpm lint, git status and git diff mean something.
- Read-only commands that inspect the repository:
git log,git diff,ls,rg. - The project's own scripts for building, testing and formatting.
- Package installs from the lockfile only. A new dependency never goes in without approval.
Leave out anything that pipes a download into a shell, anything that rewrites git history on a shared branch, and anything that talks to a cloud account. Those go in the approval section, or nowhere.
Be specific about arguments where it matters. git push to a feature branch and git push --force to main are not the same command, even though they start with the same word.
Which hosts it may call
An agent that can run a shell can reach the network. So the network list is not optional. Write down the hosts the work genuinely needs: your package registry, your git host, the documentation sites the team reads. That list is usually short.
Everything else is blocked. Not because every other host is hostile, but because a request to an unknown host is the easiest way for data to leave the machine. If an agent reads a file with a customer's data and then calls an address nobody recognises, you want that to fail, loudly.
If your tooling cannot enforce a host list, enforce it underneath the agent: a proxy, a firewall rule on the development container, or a sandbox with no network by default. The rules file still records the intent, so a reviewer can compare what is written with what is enforced.
Which files and environment variables it may not read
This is the section people skip, and it is the one that matters most. A coding agent reads files to understand the code. It does not need your .env to understand the code.
- Environment files:
.env,.env.local,.env.productionand their friends. - Key material: anything under
~/.ssh, cloud credential folders, certificate and key files. - Environment variables by name or pattern: database URLs, service keys, payment provider keys, anything ending in
_SECRETor_TOKEN. - Exports of real data: database dumps, customer spreadsheets, logs copied from production.
If the agent needs a value to run a test, give it a test value in a file made for that. Do not give it the real one and hope.
What needs a person to approve
Some actions are fine, but not unattended. Write them down, so the agent stops and asks, and so the person being asked knows what they are agreeing to.
- Adding or upgrading a dependency.
- Pushing to a remote, opening a pull request, or commenting on one.
- Running a database migration, even against a local copy.
- Any command that reaches a cloud account, a payment provider or a mail service.
- Deleting files outside the working tree.
Approval means a human reads the exact command before it runs. A setting that approves everything for the session is not approval. It is a slower way of saying yes to all of it.
An example file
This is an example for your team to edit, not the native format of any product. Each tool reads its rules differently, so treat this file as the source of truth and translate it into each tool's settings. Keep the translations next to it in the repository, so a reviewer can check both.
# agent-rules.yaml (example, edit for your team)
owner: platform-team
default: deny
shell:
allow:
- git status
- git diff
- git log
- pnpm install --frozen-lockfile
- pnpm test
- pnpm lint
approve:
- git push
- pnpm add
- pnpm db:migrate
network:
allow:
- registry.npmjs.org
- github.com
never_read:
files:
- '.env*'
- '**/*.pem'
- '~/.ssh/**'
env:
- DATABASE_URL
- '*_SECRET'
- '*_TOKEN'
Short is the point. If the file grows past a page, someone has started writing a policy essay inside it.
How a new tool gets onto the list
The list changes, and it should. A developer will find a tool that saves them an hour a day. The question is how it gets in.
- Open a pull request that adds the command or host, with one line on why.
- Say what it can touch. Does it write files, call the network, read secrets?
- The owner of the file reviews it, the same way they would review a CI change.
- Once merged, update each tool's settings to match.
The same rule applies to the agents themselves. A coding agent that cannot be pointed at this file, or that ignores it, is not allowed on a company machine. That sounds strict. It is the only version of the rule that survives a busy week.
A check you can do this week
Pick one repository and one agent the team already uses. Open its settings and write down, honestly, what it is allowed to run today, which hosts it can reach and whether it can read .env. Then ask the agent to list the names of the environment variables it can see, without the values. If the list surprises you, you have found the first lines of your file.
Do not try to cover every repository at once. One file, one owner, one review. Then copy it.
Where Alongside fits
We help engineering teams put agents to work without handing them the keys: we write the rules file with you, enforce it underneath the tools, and review what each agent can reach. More on our security and compliance engineering work.
If you want a second pair of eyes on your first rules file, write to hi@alongside.team.



