Is putting rules in AGENTS.md or CLAUDE.md enough?
No. Those files are context the model reads. Use deny rules, sandboxes and scoped tokens for anything that must not happen. [1]
Guide
A practical way to limit what Claude Code, Codex and other coding agents can read, change and reach: separate the layers, start read-only, use scoped tokens with expiries, sandbox the runtime, and test the boundary.
Give each agent its own credential and the smallest access its task needs, set by the systems it touches rather than by instructions in a prompt. In practice that means four things: start every agent read-only, use scoped tokens with an expiry instead of personal keys, run the agent in a sandbox that limits files and network, and test that a forbidden action actually fails. Then widen access one step at a time, when the work needs it.
"Access" covers several layers, and each one is controlled in a different place. Settling the access on one layer leaves the others open.
Instructions in CLAUDE.md or AGENTS.md are context, not enforcement. Claude Code's own docs say to use a hook or a deny rule when an action must be blocked regardless of what the model decides. [1][2]
| Layer | Question | Where it is controlled |
|---|---|---|
| Local machine | Which files, commands and network hosts can the agent process use? | The agent's own permission settings and sandbox |
| Code hosting | Which repositories and branches can it read or push to? | Tokens and apps on GitHub, GitLab and similar |
| Outside services | Can it read Sentry errors, Slack threads or Linear issues? Can it write to them? | The service's token or OAuth scope, or a grant on top of it |
| Team context | Which conversations, tasks and shared memory can it see? | Workspace or channel membership |
| Approvals | Which actions wait for a person? | Approval settings in the agent or the tool |
Begin each new agent, or each new kind of task, with read-only access, then add writes once you've seen how it behaves.
A personal token gives the agent everything you can do. Issue a credential for the agent and the task instead.
Permission prompts and sandboxes do different jobs. A prompt asks; a sandbox enforces at the operating-system level even if the model is tricked.
Require a person for deploys, merges to main, destructive database changes, payments and messages to customers. Keep this list short so approvals mean something.
Don't trust a configuration you haven't attacked.
The steps above work on one machine. On a team, the harder part is the outside services. Several people's agents need some access to a tracker like Linear, and each agent should get the access it needs and no more.
In ARLI, each teammate brings their own agent into one pod, and each agent is a named member with an owner. The person who connected Linear grants read access to one agent:
The agent's local permissions and sandbox are still set in its own runtime. A ARLI grant covers the connected service; it doesn't change what the agent can do on your laptop.
Sources, checked 2026-10-27.
1. Claude Code docs, "How Claude remembers your project" · 2. Claude Code docs, "Configure permissions" · 3. Claude Code docs, "Common workflows" · 4. OpenAI Codex docs, Sandboxing · 5. GitHub Docs, Managing your personal access tokens · 6. NIST glossary, least privilege
No. Those files are context the model reads. Use deny rules, sandboxes and scoped tokens for anything that must not happen. [1]
No. Give each agent a fine-grained token limited to the repositories and permissions it needs, with an expiry. It still acts as the person who created it; for a separate agent identity, use a GitHub App installation token or a machine user. [5]
A prompt asks a person before an action. A sandbox blocks the action at the operating-system level whatever the model decides. Use both. [2][4]
Issue a read-only credential for that agent. In ARLI, the person who connected Linear can grant one agent read access to it.
Each teammate brings their own agent into one pod, and each agent is a named member with an owner.
AI Agent Permissions and Tokens: Scope Runtime Access Safely · AI Agent Sandboxing: Reduce the Blast Radius of Untrusted Input · AI Agent Approval Boundaries: What Review Can and Cannot Authorize · Prompt Injection Defense for AI Agents: Contain the Capability, Not Just the Prompt