Sub topic 1
Coding Agent Permissions and Approval Modes
Prerequisites
Assume you can use a terminal, understand basic Git commands, and have seen an AI coding assistant edit files or run commands.
How a Coding Agent Acts: The Model, the Tools, and the Loop
A coding agent combines a language model with tools. The model proposes a next step, such as reading a file or running a test. A controller checks that proposal against permissions. If permitted, the controller calls the tool and returns its result to the model. The loop continues until the task is complete, blocked, or stopped by the user.
Sorting Actions by Risk
Classify an action by what it can change or expose:
- Read retrieves files or command output. It usually has low risk, but reading secrets is dangerous.
- Write creates or changes files. A bad edit can break the project.
- Execute runs a program or shell command. It may delete data or install software.
- Network sends data or downloads content. It can expose code or credentials.
- Destructive deletes, overwrites, force-pushes, or changes systems irreversibly.
Risk depends on context. Reading a public source file differs from reading an environment file containing credentials.
Allow, Ask, or Deny
A permission decision has three common results:
- Allow runs the action without another prompt.
- Ask pauses for explicit approval.
- Deny blocks the action.
A safe policy normally evaluates deny rules first. It then checks allow rules. Anything unmatched falls back to asking.
from fnmatch import fnmatch
DENY = ["rm -rf *", "git push --force*"]
ALLOW = ["git status", "git diff*", "pytest*"]
def decide(command: str) -> str:
if any(fnmatch(command, pattern) for pattern in DENY):
return "deny"
if any(fnmatch(command, pattern) for pattern in ALLOW):
return "allow"
return "ask"Approval Modes from Read-Only to Fully Autonomous
Read-only mode permits inspection but blocks edits and execution. Supervised mode allows useful actions while asking before risky ones. Autonomous mode approves most actions, which is convenient but increases the impact of mistakes and prompt injection. Choose the least permissive mode that still supports the task.
Exercise
Which result should an unfamiliar command receive by default?
Show answer
Ask. Deny known dangerous actions, allow narrowly understood safe actions, and ask about everything else.