Sub topic 11
Limiting what agentic tools can do
This chapter assumes you know the Git and pull request workflow, have used an AI coding assistant, and have a basic idea of what a CI pipeline does. Earlier chapters covered approved tools and automated guardrails. Here we set permission limits for tools that act on their own.
Why agentic tools need their own limits
A chat assistant suggests code, and a person decides what to do with it. An agentic tool runs shell commands, edits files, calls APIs, and sometimes loops until a task is done. Each action happens before any human reads a diff. A mistaken command or a prompt hidden in a fetched web page can do damage immediately.
The policy goal is simple: the tool should never hold more access than the task needs. This is the principle of least privilege, applied to software that makes its own decisions.
Three layers of limits
Treat permissions as layers. Each layer catches what the one above it misses.
- Tool permission rules. Decide which actions run automatically, which need a person to approve, and which are denied.
- Environment limits. Run the tool where a mistake has a small blast radius.
- Repository protections. The agent can propose changes but cannot bypass review. Branch protection and required checks from the previous chapter apply to agent commits too.
Sorting actions into tiers
Write the tiers into the policy so nobody has to guess.
| Tier | Examples | Rule |
|---|---|---|
| Allow automatically | Read files in the repo, run the test suite, run the linter | No prompt needed |
| Ask first | Install a dependency, edit CI config, run a database migration | A person approves each time |
| Deny | Push to `main`, read `.env` files, delete outside the working directory, deploy to production | Never allowed for the agent |
Keep the "allow" list short and specific. Allowing npm test is safer than allowing "any npm command", because a package script can run arbitrary code.
Writing the rules down
Many agentic tools read a project settings file with allow and deny lists. The exact format differs by tool, so check your approved tool's documentation. The example below is illustrative.
# agent-permissions.yml (illustrative; adapt to your tool's format)
allow:
- read: "src/**"
- run: "npm test"
- run: "npm run lint"
ask:
- run: "npm install *"
- edit: ".github/**"
deny:
- read: ".env*"
- edit: "auth/**"
- run: "git push *"
- run: "rm -rf *"Commit this file and put it under CODEOWNERS, so changing the agent's permissions needs the same review as changing /auth/.
Environment limits
Rules inside the tool depend on the tool behaving correctly. Add limits that do not:
- Use a dedicated development container or a disposable virtual machine.
- Give the agent its own low-privilege credentials, never a developer's personal token.
- Restrict network access to the package registry and your Git host where possible.
- Keep production secrets out of the environment entirely.
Common errors
- Approving prompts by habit. After the twentieth "allow this command?" prompt, people click yes without reading. Keep the allow list good enough that prompts are rare and meaningful.
- Treating fetched content as trusted. Text in an issue, web page, or dependency README can contain instructions aimed at the agent. Limit what the agent can do after reading untrusted content.
- Reusing personal credentials. The agent then acts with your full access, and audit logs cannot tell you from it.
- Unreviewed settings changes. A permissions file anyone can edit silently is not a limit.
Exercise
An agent is configured to allow npm * so it can run tests without prompting. Why is this a policy weakness, and what would you allow instead?
Show answer
npm * includes npm install and npm run for any script, and package install scripts or custom scripts can execute arbitrary code. Allow only the specific commands needed, such as npm test and npm run lint, and put installs in the "ask first" tier.
Exercise
Name two controls outside the agent tool itself that limit the damage if the tool ignores its own rules.
Show answer
Any two of: running in a sandbox or container, using low-privilege dedicated credentials, restricting network access, and branch protection with required reviews and status checks.