Skip to content

Least privilege for coding agents: what to allow, what to ask about, and what to deny

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.

Published by Contextingo.

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

LevelExamples
Allow without askingRead files in the repository; run the test and lint commands; git status and git diff
Ask each timeInstall packages; write outside the repository; use the network; git commit; git push
DenyRead 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 and keeping secrets out of context.

Questions

Good to know.

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.

Nothing learned is lost. Nothing unchecked is done.