Sub topic 3
User, Project, and Organization Settings: Who Wins
Assume you can use a terminal, understand basic Git, and have seen an AI coding agent edit files or run commands. This chapter focuses on how permission settings combine across environments.
Configuration layers and precedence
Permission settings often come from three layers:
| Layer | Typical purpose | Usual effect |
|---|---|---|
| Organization | Security limits | Sets rules that projects and users cannot weaken |
| Project | Repository-specific defaults | Controls behavior for one codebase |
| User | Personal preferences | Applies where stricter settings do not override it |
A common policy model is that the most restrictive applicable rule wins. An organization can deny network access, a project can require approval for file writes, and a user can allow read-only commands. The exact precedence differs by product, so verify the effective policy rather than assuming that a local setting wins.
External tools and servers
An external tool or server is another trust boundary. It may read databases, call APIs, or change cloud resources. Give it only the operations and data required for the task. Prefer an explicit allowlist over “allow all tools,” and require approval for new servers or high-impact operations.
Keep secrets out of reach
Do not expose long-lived tokens, private keys, or production credentials to an agent unless the task requires them. A secret placed in an environment variable can still be read by a command the agent runs. Use short-lived credentials, restricted identities, secret managers, and separate development accounts. Prevent secrets from entering prompts, logs, diffs, and tool responses.
Scripts and CI
Headless agents cannot answer approval prompts. Configure CI to fail closed, use an isolated workspace, and grant a narrowly scoped service identity. Separate planning from execution when possible. Require a human review before deployment, merging, or infrastructure changes.
Review diffs, logs, and version control
Review the complete Git diff, not only the files the agent mentions. Check command logs for network access, credential use, and unexpected paths. Run tests in a clean environment, then commit changes in small, understandable units. Version control provides recovery, but it does not undo external effects such as sent requests or changed cloud resources.
Choosing a mode
Choose settings based on impact and reversibility:
- Use read-only mode for unfamiliar repositories or sensitive code.
- Use approval-required mode for normal edits and commands.
- Allow routine tests only when the workspace and test data are isolated.
- Use autonomous mode only for bounded, reversible tasks.
- Keep destructive commands, production access, secrets, and external writes denied or separately approved.
Exercise
What is a suitable starting mode for an agent editing a new repository while using a development database?
Show answer
Approval-required mode, with read-only access to secrets, restricted database credentials, and review of every diff and external write.