Repo Access Configuration for Cloud Coding Agents
How to scope tokens, secrets, and sandboxes for autonomous agents.

Cloud coding agents need a purpose-built access model. The assumptions that keep a developer's credentials safe no longer hold when an agent runs unattended. A developer authenticates interactively. Their session is tied to their identity, and when something goes wrong they can intervene. It executes commands, consumes credentials, and makes changes on its own. That single difference changes the entire security calculus, because the credential is no longer a gate a person walks through. It is a key handed to an autonomous process.
There is a second structural mismatch. An agent with read-write database access could execute a DELETE when the task only required a SELECT. The model does not distinguish between the permission it has and the permission it needs, unless the configuration enforces that distinction on its behalf.
The blast radius of a misconfigured agent credential is correspondingly larger. An organization-wide personal access token used by an agent exposes every repository in the organization, not just the one the task touches. And the informal local habits developers rely on do not translate to agent workloads: a .env file in an agent's working directory is readable, modifiable, and committable by that agent. The rest of this piece is about building the right model, not about layering stricter policies onto the old one. Repo access configuration for cloud agents is a distinct engineering discipline.
Scoping repository credentials to the task rather than the team
The first discipline is to scope credentials to the specific repository a task requires, with a limited lifetime. Personal access tokens are where many teams start, but for agent workloads they carry the broadest permissions and the longest exposure window. A personal access token is tied to a user account and can carry broad permissions across an entire organization. An agent running with one inherits the same repository access as the developer who created it, which means the agent's effective reach has nothing to do with its actual task.
Deploy keys narrow the scope meaningfully. The public key is registered on a single repository and grants no access to unrelated repos. If the credential is misused or exposed, the blast radius is confined to that one repository. This is the first step away from the team-level default and toward the task-level minimum.
Short-lived tokens from apps or CI integrations are better still. These expire after a fixed window, which limits how long an exposed credential remains usable even if it is stolen. Combining short-lived tokens with repository-scoped permissions is the strongest baseline for agent workloads: the token can only reach one repository, and only for a bounded period.
Organization-wide tokens are a meaningful risk in agent workloads specifically. They give an agent access to repositories unrelated to its task, which enlarges the potential impact of any misuse. The right question to ask when provisioning agent credentials is simple and should be asked every time: what is the minimum repository access this specific task requires?

Injecting secrets at runtime rather than storing them in the working directory
Repository credentials are only one class of secret an agent touches. Database credentials, API keys, and service tokens all face the same problem: anything stored in the agent's working directory is something the agent can read, modify, or commit. A .env file sitting in the working tree is fully accessible to the agent and can leak through a commit, a build artifact, or an injected instruction. The operational complement to credential scoping is runtime injection.
Runtime injection delivers secrets as environment variables or secret files at execution time, without hardcoding them in the repository or the Dockerfile. The secret never lands in the filesystem where the agent operates. It exists only in the process environment for the duration of the task, which means there is nothing on disk for the agent to read back or commit.
The same principle extends to what the secrets themselves are allowed to do. Dedicated credentials per agent workload should replace shared production credentials reused across services. The scoping matrix applies across every service the agent touches. For internal services, scope to the service account and required network access, and avoid broad access to unrelated services.
Cursor's scoped secrets model illustrates how a harness implements this pattern. Secrets configured for one environment are not accessible from any other. An agent working on a payments service has access to payment API credentials, while the same team's agent on the documentation site does not. That separation is the point: the agent receives exactly the secrets its task requires, delivered at runtime, and nothing more.
Using worktrees and isolated execution environments to contain what an agent can reach
Credential scoping limits which secrets an agent holds. Filesystem and execution isolation limits what the agent can do with those secrets and what else it can reach on the same machine. These are separate layers, and both matter.
The agent's working directory should contain only the minimum files needed for the task, not the entire project tree. Worktrees are the baseline. Isolated VMs or containers are the stronger boundary. Private keys and certificates should live outside the agent's working directory entirely, and read-only mounts can give an agent reference access to another project's code without write access.
Network isolation is as critical as filesystem isolation, and filesystem-only isolation is insufficient on its own. An agent with network access can still exfiltrate data or call out to arbitrary URLs even if its file writes are sandboxed. Claude Code's sandbox mode demonstrates the correct design: it uses two independent isolation layers, filesystem and network, precisely because both are required for effective sandboxing.
The distinction between containers and microVMs matters at scale. Each cloud coding agent runs in its own dedicated Linux microVM, hardware-virtualized, with its own cloned repository and injected credentials. Isolation is per-agent, not per-team, so the failure domain is a single task rather than every task running under a shared environment.

Setting per-agent permissions so each agent's access matches its actual task
Within a correctly isolated environment, agents still need explicit permission tiers that distinguish what they can do automatically from what requires human approval. Blanket "allow all" is the permission equivalent of an organization-wide personal access token. Shell access is the agent's most powerful and most dangerous capability. An agent that can run arbitrary commands is functionally equivalent to a user with elevated system access, because the shell is the gateway to every other capability. That is where the tiered model starts. Package installation or system modification is critical and should be denied or strictly limited.
GitHub Copilot's coding agent permission model applies this pattern at the organizational level, with a per-repository setting available for workflow approval. Specific repositories can allow automatic modifications while others require human approval before any change is made. The granularity matters: a team can treat its documentation repos differently from its production services.
AGENTS.md in the Codex ecosystem and CLAUDE.md in the Claude ecosystem function as permission-adjacent configuration. These files instruct the agent about project conventions, testing commands, branch naming policies, and areas of the codebase to avoid. Well-written instruction files reduce the need for the agent to infer boundaries it should respect. They live in the repository root and are versioned alongside the code, which makes the agent's behavioral constraints auditable.
The strongest objection to this model is that approval gates slow agents down. That misses the point. Tiered approval targets the high-risk operations, network calls and system modification, and leaves the routine work of file reads and writes within scope untouched. Approval overhead is concentrated exactly where the risk is, which is the right trade-off.
Prompt injection as a repo-access attack surface, and how configuration contains it
Prompt injection is the mechanism by which a correctly configured agent can still be made to misuse its access. It is not a model-level safety problem alone. The access configuration is the primary defense.
Agents do not just generate text. They take actions, and an injected instruction that would be harmless in a chat interface can trigger a shell command, a credential read, or a file deletion in an agent context. Web content fetched by the agent, documentation pages or API responses, can embed redirect instructions.
The configuration decisions from the preceding sections are what contain the blast radius of a successful injection. Filesystem isolation means injected file modifications affect only the temporary copy, not the originals. Per-operation approval tiers break the injection chain at the point of exfiltration, because a network request still requires human confirmation regardless of what the injected instruction says.
Two further configuration decisions reinforce this containment. MCP tool whitelisting ensures only authorized MCP servers are available to the agent, since tool descriptions from unreviewed servers are themselves an injection surface. And AGENTS.md or CLAUDE.md instruction hardening writes explicit security boundaries into the repo-level instruction file, making the agent's intended scope machine-readable and harder to override with injected instructions.
How harness and agent choice affects what access configuration is possible
The access controls available to a team are bounded by what their chosen execution environment actually supports. Choosing an environment is choosing a permission ceiling, and the relevant evaluation dimensions are specific. And supported agents determine whether the team can run Claude Code, Codex, Cursor, and OpenCode, or whether the environment is tied to a single agent.
Codex cloud illustrates how a specific harness answers these dimensions. The environment is destroyed after the PR is created. Tasks start from a shared published environment's prepared filesystem, and each task retains its own uncommitted files and VM state, recoverable for up to seven days, though no state is shared between separate tasks. Repository integration is GitHub-only. That offers strong isolation and network control, but limited flexibility for teams needing persistent workspaces or non-GitHub repositories.
OpenCode takes a different approach. GitHub Codespaces offers yet another model: each Codespace runs in its own VM, built from a dev container configuration in the repository, accessible in the browser, VS Code, or over SSH with the GitHub CLI. It suits GitHub-native teams wanting a dev container per repository.
The key insight is that these are not interchangeable. A team that needs per-agent microVM isolation cannot get it from an environment that shares a runner. A team that needs non-GitHub repositories is constrained to environments that support them. The harness choice is a configuration decision in its own right.
Validating the configuration before delegating real tasks
Access configuration is a hypothesis until an agent runs against it. Validation means testing credential scope, secret delivery, isolation boundaries, and permission tiers under real task conditions before any production delegation begins. The most reliable approach is to assign the same scoped, reproducible task to each candidate environment from the same repository snapshot. Inspect command output, test results, and any artifacts such as logs or browser recordings rather than only the diff.
Credential validation asks specific questions. Does the agent have access only to the repositories the task requires, not the whole organization? Are secrets delivered as runtime variables or files, not committed or present in the working directory? Does the agent's database or API credential carry only the permissions the task requires? Do credentials for one environment reach agents running in a different environment? They should not.
Isolation validation is equally concrete. Can the agent make outbound network calls that the task does not require? It should not be able to. Are file writes contained to the task's worktree or sandbox copy, not the main workspace? If you pause and resume, does the environment survive with the workspace intact, including files, installed packages, and branch state?
Permission tier validation checks the gating behavior. Does a network request trigger human confirmation rather than auto-executing? Are package install or system modification commands blocked or gated as expected? Does the AGENTS.md or CLAUDE.md instruction file reflect the current codebase conventions and boundaries? Finally, record the human time required to get the agent's output ready for review. That figure becomes the baseline for measuring whether the configuration is working as intended and whether delegation is actually reducing engineering load.
Configuration is not a one-time step. As agents are assigned new task types, new repositories, or new service integrations, each new access surface needs the same scoping, injection, and isolation review. Teams that get this right for the first agent workload have a repeatable pattern they can apply as delegation expands, which is the foundational step that makes everything after it reliable.


