Sub topic 2
Sorting Actions by Risk: Read, Write, Execute, Network, Destructive
This chapter assumes you are comfortable in a terminal, know basic git, and have used an AI coding assistant that edits files or runs commands. It builds on the tool loop from the previous chapter. The model asks for a tool call, and the agent runs it. Before deciding which calls need your approval, you need a way to sort them by what they can do.
Why sort actions at all
Permission systems rarely judge each call from scratch. They group actions into categories and give each category a default. A read of a source file and a recursive delete both arrive as tool calls, but they carry very different consequences. Sorting by risk lets you relax the safe categories and tighten the dangerous ones.
The five categories
| Category | Examples | Main risk | Reversible? |
|---|---|---|---|
| Read | Open a file, list a directory, search code | Exposes data to the model | Yes, nothing changes |
| Write | Edit or create a file | Wrong or unwanted changes | Usually, with version control |
| Execute | Run a shell command or script | Anything the command can do | Depends on the command |
| Network | Fetch a URL, call an API, push to a remote | Data leaves the machine, or untrusted content comes in | Rarely |
| Destructive | `rm -rf`, `git push --force`, dropping a database | Permanent loss | No |
Read
Reads look harmless, but they are not free of risk. Anything the agent reads may be sent to the model provider, so reading .env or an SSH key exposes secrets. Reads also bring untrusted text into the model's context, which matters for prompt injection later in this tutorial. Most agents still allow reads inside the project by default.
Write
Writes change files. Inside a git repository, a bad edit is easy to inspect with git diff and undo. Outside version control, or outside the project directory, the same edit may be permanent. The location of the write matters as much as the write itself.
Execute
Execution is the broadest category. A shell command can read, write, use the network, or delete. git status and rm -rf build are both "execute." Because the category contains the others, the exact command has to be examined, which is why rule patterns get their own chapter.
Network
Network actions move data across the machine boundary. Outbound calls can leak code or credentials. Inbound content, such as a web page, can carry hidden instructions. Commands like curl and git push belong here even though they run through the shell.
Destructive
Destructive is a property that cuts across the other categories. A write can overwrite a file, an execute can delete a directory, and a network call can force-push over remote history. Treat this as the category where you cannot recover. These actions normally deserve a deny rule or an explicit prompt every time.
Classifying a command
The following sketch labels a shell command by its first word. It is deliberately naive, to show the idea.
DESTRUCTIVE = ("rm -rf", "git push --force", "drop table")
NETWORK = ("curl", "wget", "ssh", "git push", "git fetch")
READ = ("cat", "ls", "grep", "git status", "git diff")
def classify(command: str) -> str:
lowered = command.lower()
if lowered.startswith(DESTRUCTIVE):
return "destructive"
if lowered.startswith(NETWORK):
return "network"
if lowered.startswith(READ):
return "read"
return "execute"
for cmd in ["git status", "curl example.com", "rm -rf build", "make test"]:
print(f"{cmd:20} -> {classify(cmd)}")It prints read, network, destructive, and execute. Anything unrecognized falls into execute, which is the safer default.
Common errors
- Treating all execute calls as equal.
lsandrmneed different handling. - Forgetting that reads can expose secrets.
- Assuming version control protects writes outside the repository.
- Forgetting that a command can belong to several categories at once.
Exercise
The agent wants to run git push --force origin main. Which categories does it fall into, and what default would you choose?
Show answer
It is execute (a shell command), network (it contacts a remote), and destructive (it overwrites remote history). Because it cannot be undone, the default should be deny, or at least ask every time.