# Least privilege for coding agents: allow, ask or deny

Canonical: [Least privilege for coding agents: allow, ask or deny](https://contextingo.com/blog/least-privilege-coding-agents)

Locale: en

Purpose: A coding agent can read files, run commands and use the network. A three-level policy of allow, ask and deny keeps the speed and limits the risk.

Content updated: 2026-09-25

Source revision: content.ts 2026-09-25

Maintenance owner: the Contextingo site owner

[Topic map](https://contextingo.com/llm/topics/blog.md) · [Complete scoped map](https://contextingo.com/sitemap.md)

Claude Code and Codex CLI can read and write files and run shell commands. Both can ask before they do, and both have settings to allow or deny specific actions. The question is what to put where.

## A three-level policy

| Level | Examples |
|---|---|
| Allow without asking | Read files in the repository; run the test and lint commands; `git status` and `git diff` |
| Ask each time | Install packages; write outside the repository; use the network; `git commit`; `git push` |
| Deny | Read secret files; `rm -rf` on broad paths; force-push; changing deploy or CI credentials |

## Principles

- **Start strict, relax with evidence.** Allow a command after you have seen it used safely a few times.
- **Prefer narrow rules.** Allow `npm test` rather than all of `npm`.
- **Separate the environment.** Work in a development environment with development keys, not on a machine with production access.
- **Keep the acceptance step with a person.** An agent should not be able to approve its own work.

## Review the settings

Settings files can be shared in the repository. Treat them like code: review changes, and read them again when someone joins.

Related: [prompt injection in coding agents](/blog/prompt-injection-coding-agents) and [keeping secrets out of context](/blog/keep-secrets-out-of-coding-agent-context).

## Questions

### Do the tools ask before running commands by default?

Both ask in their default modes. Check the mode you run in, because some modes skip prompts.

### Is a sandbox enough?

It limits the damage of a command. It does not check whether the change is right, so review still applies.
