Beyond Git Worktree

API Key in a Dotfile vs Managed Agent Environment the Engineering Tradeoffs Are Not Close

Dotfiles store keys, but only managed environments contain agents.

· 8 min read
Cover illustration for “API Key in a Dotfile vs Managed Agent Environment the Engineering Tradeoffs Are Not Close”
Cloud Agents · November 14, 2026 · 8 min read · 1,768 words

For an engineering team running Claude Code and another vendor’s coding agent without managing virtual infrastructure, the decisive requirement is a managed execution environment with session-scoped credentials, enforced permissions, attributable logs, and external budget controls. A dotfile stores a key but supplies none of those controls.

Why an API key inside an agent session is a different kind of risk than one sitting in a dotfile

A developer pastes an API key into a system prompt or tool configuration and treats it like a key in ~/.zshrc. In the dotfile threat model, the secret is at rest, and the central concern is someone reading or leaking the file. Inside a tool-using agent, the credential becomes available to a process that interprets instructions, invokes tools, and produces outputs. The security boundary has moved beyond the file.

This distinction follows from the work agents perform. Long-running workflows involve reasoning across successive steps, interpreting results, and choosing what to do next. If the credential authorizes systems that take action, its exposure puts those actions and the data those systems return within reach. Where the key travels during execution and who or what can read the outputs matter for security.

The specific ways agent execution multiplies credential exposure beyond what the dotfile threat model covers

Conversation history is the first path through that expanded boundary. A key included in a prompt can persist in the context window and in stored conversation logs, remaining available as the agent chooses subsequent tool calls. Persistence changes the duration of the exposure. The credential is no longer present only at the moment an authenticated request needs it.

An authenticated request can then introduce a second path through error handling. A failed call may return request metadata that is logged or surfaced in the agent’s output. Generated code provides a separate route outward. An agent that knows a credential value may embed it in a script, configuration file, or other artifact it creates. That output can retain the secret independently of the conversation that produced it.

Tool call logs add another recording point because an invocation can record its inputs, including a credential passed as a parameter. Persistent memory creates the fifth channel. Summaries or retrieved context containing credential values may be written into a store that outlives the session. These channels can carry the key at the same time, so protecting the original file does not protect every copy they create.

Documented vulnerabilities confirm that these channels are exploited, not theoretical

Documented vulnerabilities in coding-agent infrastructure include project-load configuration that acts before trust prompts and server-side request forgery in the HTTP plumbing that agents trust. In the second, trusted request handling becomes the route through which an attacker can redirect activity. A securely stored credential does not by itself constrain either path once the executing system can use it.

The distinction between an exploitable vulnerability and an observed attack remains important. These cases show execution paths that an attacker can exploit, but they do not show that every exposed credential was stolen. Patching an affected implementation is necessary. However, a patch for one instance does not establish that all project-loading paths respect trust boundaries or that all trusted HTTP components constrain requests correctly. Those are properties of the execution environment that require controls beyond protecting a file.

When many agents use the same API key, an anomalous action cannot be attributed from that credential alone to a particular agent, session, or trigger. The key identifies a shared authority. That loss of attribution turns a security mechanism into a governance problem because an audit must establish who authorized an action and which session performed it.

Why the governance problem for agent credentials cannot be solved by the same controls that work for conventional secrets

Conventional secret management assumes a relatively fixed scope, a known call path, and a human or deterministic process using the credential. Agents disrupt those assumptions together. An agent asked to “prepare a quarterly report” may read from a CRM, access financial databases, fetch competitor data from the web, generate visualizations, and email the result. Each step has its own scope. The sequence emerges at runtime from the model’s decisions.

So a credential used for a narrow set of tasks during testing may allow more kinds of activity in production. A prompt can discourage that activity, but it cannot enforce a permission boundary. Rotation does not solve this problem either. Rotating a shared key leaves the agents holding it exposed during the rotation interval, while a read-only credential constrains only the system enforcing that permission. It does not establish that a larger workflow lacks access to another tool capable of writing or sending the retrieved information.

Stephanie Jarmak’s August 2026 monograph, Engineering Reliable Coding Agents: Evaluating and Operating the System Around the Model, treats permissions as a dependency in the reliability chain. Weaknesses there can invalidate conclusions made downstream about an agent’s behavior. Governance therefore needs evidence about actual execution. The control model must connect authorization to the session that exercised it.

What agents do to token spend that the dotfile model makes invisible until it's too late

The same runtime indeterminacy that complicates permissions also complicates cost. A multi-step agent chooses more work as results arrive, while its current context may not show how much it has spent against an external budget. A budget instruction gives the model a constraint to consider without creating an independent mechanism that measures spending and refuses further calls.

A raw API key supplies no such enforcement point between the agent and the API. Gateway-layer controls introduce one. Per-agent budgets can throttle requests as limits approach and pause or terminate activity when a limit is breached. Because these controls sit outside the model, enforcement does not depend on whether the agent remembers or follows a budgeting instruction. The same layer can coordinate prompt-caching optimizations instead of leaving cost management to individual sessions.

At team scale, the problem also spans services. When agents chain tools without shared quotas, each component may see only part of the cost path. A workflow can exceed its budget across that seam. Spend control therefore needs a separate system with evidence of consumption and authority over subsequent calls. Otherwise, the bill may be the first clear sign that autonomous execution went over its budget.

What organizations that run agents at scale actually built, and why it converges on the same architecture

Production coding-agent architectures have converged on isolated execution, curated tool access, and scoped, session-specific credentials. One pattern uses pre-warmed development environments that are cut off from production and the internet, with tools chosen for the agent to use through a central MCP server. Isolation changes what autonomy can safely mean. The agent can execute within a bounded environment without requiring permission for every command, while the infrastructure limits what systems and tools it can reach. Least privilege resides in the available toolset.

Another pattern uses fresh, disposable sandboxes built from filesystem snapshots, with session state stored separately so it can survive sandbox restarts. Combined with session-specific credentials, this pattern avoids treating a long-lived developer machine and its accumulated authority as the default agent runtime.

The monograph explains why these decisions belong in a reliability discussion. It identifies the harness, execution state, retrieval, memory, permissions, review interfaces, and resource allocation as dependencies around the model. A Case-Bundle Operating Model for Coding Agents in OpenFOAM-Based CFD describes a similar separation in another engineering field, with reviewed case bundles and separate modes for development and replay. Routine execution uses engineering context that has been reviewed and leaves engineering judgment in place. Across different organizations and domains, the common answer is a bounded runtime governed by explicit, reviewable configuration.

Treating agent configuration as versioned code is what makes credential governance enforceable rather than aspirational

That architecture becomes governable when credential scope, tool access, and budget limits are defined in version-controlled configuration reviewed like other code. The pattern externalizes agent behavior in the same way Terraform configuration externalizes infrastructure. Changes become visible before they reach execution. A pull request can show which authority is being added, who reviewed it, when it was merged, and how to roll it back. A private dotfile does not supply that shared review process.

But version control alone does not enforce policy. The execution environment must apply the reviewed configuration as a hard limit. A credential scope described in a prompt remains dependent on model behavior, while a scope enforced by infrastructure becomes a gate. Declarative security policies deployed through CI/CD can extend that gate to execution-time isolation. The governing principle is that the reviewed policy and the policy actually applied during a session must be the same.

Permissions become an explicit, testable input rather than a condition discovered only after the agent acts. Humans are Missing from AI Coding Agent Research names task alignment, verifiability, steerability, and adaptability as aspects of how humans and agents work well together. Versioned configuration supports verifiability and steerability by making authorized behavior inspectable before execution.

How do teams run Claude Code and Codex without managing VMs, and what must the managed environment provide?

A managed environment for team-scale coding agents must provide more than hosted compute. Its credential lifecycle should mint session-scoped credentials and revoke them when the session ends. Revocation limits the credential’s useful lifetime. It removes the continuing authority of a leaked static key, while actions taken during the session and information already exposed remain unchanged. Isolation and scoped tool access must bound what the credential can authorize while it remains valid.

Attribution must accompany that lifecycle. Per-session credentials should connect activity to a session, trigger, and person, while logs connect tool calls, diffs, and outputs to the same execution. Reviewed configuration must then define the permission boundary, with infrastructure enforcing it.

Cost enforcement belongs at the API gateway. Caps per session, developer, and time period can govern requests before the next LLM call is made, with throttling as limits approach. Observability must also be native to the execution system rather than reconstructed from scattered local artifacts. Building an equivalent audit trail around dotfile-keyed sessions requires bespoke instrumentation that must be maintained as agent behavior changes. A managed environment earns its engineering advantage by supplying that surrounding system.

Support for both coding agents is only the starting point, followed by isolated execution, session-specific authority, reviewable policy, attributable records, and externally enforced budgets. The monograph’s central distinction applies directly because models are deployed as systems, and reliability depends on that surrounding system. Running a coding agent on a laptop with a dotfile key is a prototype. Running it on managed infrastructure with governance is production.

Sources

  1. Engineering Reliable Coding Agents: Evaluating and Operating the System Around the Model
  2. A Case-Bundle Operating Model for Coding Agents in OpenFOAM-Based CFD
  3. Humans are Missing from AI Coding Agent Research
  4. [2609.33371] API Secrets Should Never Become Tokens in the LLM's Vocabulary: A Threat Analysis of API Credential Handling in LLM Agent Systems and an Empirical Evaluation of a Vault-Mediated Execution Boundary
Filed underCloud Agents

More in Cloud Agents