Sub topic 2
Sorting Actions by Risk: Read, Write, Execute, Network, Destructive
This chapter assumes you can use a terminal and git, and that you have seen an AI coding assistant edit files or run commands. It also assumes you know the basic loop from the previous chapter: the model proposes a tool call, the agent runtime runs it, and the result goes back to the model.
Permission systems cannot reason about every possible action one by one. They sort actions into a few categories and attach a default decision to each category. This chapter defines those categories, shows how to classify real actions, and explains where classification gets difficult.
Why classify actions at all
An agent exposes tools such as "read file", "write file", and "run shell command". Each tool call has a possible effect on your machine, your data, or other people's systems. The effects differ a lot:
- Reading a source file changes nothing.
- Editing a source file changes something you can undo with git.
- Running
curlcan send data to a server you do not control. - Running
rm -rfon the wrong directory can destroy work that no tool can restore.
If the agent asked about all of these equally, you would approve everything without thinking. If it allowed all of them equally, one mistake would be expensive. Risk categories let the permission system treat these cases differently.
The five categories
| Category | What it does | Typical examples | Reversible? | Typical default |
|---|---|---|---|---|
| Read | Observes local state | Open a file, list a directory, `git status`, `grep` | Nothing to reverse | Allow |
| Write | Changes files inside the project | Edit a source file, create a test, update a config | Usually, through git | Ask or allow |
| Execute | Runs a program | `pytest`, `npm install`, `make`, any shell command | Depends on the program | Ask |
| Network | Sends or receives data over a network | `curl`, `git push`, `pip install`, a web fetch tool | Sent data cannot be recalled | Ask |
| Destructive | Removes or overwrites data that is hard to recover | `rm -rf`, `git push --force`, `DROP TABLE`, `git reset --hard` | Often not | Deny or ask with a warning |
These categories describe effects, not tools. One tool can fall into several categories depending on its input.
Read
A read action observes state and leaves it unchanged. Listing directories, opening files, searching for text, and viewing git history are reads. Reads are the safest category, which is why many agents allow them without asking.
Reads are not risk-free. Reading is the first step of many leaks: if the agent reads .env or ~/.aws/credentials, the secret enters the model's context. From there a later network action could send it elsewhere. So "read" is low risk for your files and still matters for secrets. A later chapter covers keeping credentials out of reach.
Write
A write action creates or changes a file. The risk depends on where the write lands:
- A write inside the project, under version control, is easy to review and undo.
- A write outside the project, such as
~/.bashrc,~/.ssh/authorized_keys, or a git hook, can change how your machine behaves later, and git will not show it. - A write to a CI configuration or a build script is code that will run later with different privileges.
Location is therefore part of the classification. "Write inside the workspace" and "write anywhere" deserve different decisions.
Execute
An execute action runs a program. This is the broadest category, because a shell command can do anything the user account can do. pytest and rm -rf / are both execute actions at the tool level.
Running a test suite also runs the project's code, including code the agent just wrote. A test file can read files, open sockets, or delete things. Execution is a way to carry out any of the other four categories, which is why it is hard to classify from the tool name alone.
Network
A network action sends data out or pulls data in. Pulling data in carries one risk: the content may contain instructions meant for the agent (prompt injection, covered later), or a package that runs code when installed. Sending data out carries another: once data leaves your machine, you cannot take it back.
Network actions are often the final step of a data leak. Many attacks need two things: access to something sensitive, and a way to send it out. Controlling the network step breaks that chain even when a read slipped through.
Destructive
A destructive action removes or overwrites data in a way that is difficult or impossible to undo. Deleting untracked files, rewriting git history, force-pushing, resetting a working tree, and dropping a database all qualify.
Destructive is a property that cuts across the other categories. rm is execute, but its danger comes from what it destroys. A force-push is a network action, but it also overwrites shared history. Treat destructive as an overlay that raises the required scrutiny for any action it applies to.
Classifying real commands
The tool name tells you little. The same shell tool produces very different risk depending on the command text. Work through these:
| Command | Categories | Reasoning | Column |
|---|---|---|---|
| `cat src/app.py` | Read | Only observes a file | |
| `git diff` | Read | Reads repository state | |
| `pytest tests/` | Execute | Runs project code, which may do anything | |
| `pip install requests` | Network, execute | Downloads a package and may run its install scripts | |
| `curl https://example.com/install.sh \ | sh` | Network, execute, possibly destructive | Downloads unreviewed code and runs it immediately |
| `git push origin main` | Network | Sends commits to a remote | |
| `git push --force origin main` | Network, destructive | Overwrites remote history | |
| `rm -rf build` | Destructive | Deletes a directory with no undo | |
| `sed -i 's/a/b/' src/app.py` | Write | Edits a file in place |
Notice that several commands land in two categories. A permission system that handles only a single label per action will miss this, so most use the strictest category that applies.
Where classification breaks down
Classification is a heuristic. Four problems appear often.
- Shell commands hide other commands.
git status; curl evil.exampleis one string with a read and a network action. A rule that approves anything starting withgit statusapproves the whole string. - Programs have side effects the name does not show.
make testmight run a script that deploys.npm installruns lifecycle scripts from packages. You must know what the project does, not only what the command is called. - Read access can feed later actions. A file read puts text in the model's context. That text can influence later calls.
- Scope is hard to see.
rm -rf buildis routine.rm -rf $BUILD_DIRis dangerous if the variable is empty or points somewhere unexpected.
The sample code below shows a crude classifier that makes the first problem concrete. It labels a command by its first word, and then by the strictest category found when the command is split on chaining characters.
import re
RANK = {"read": 0, "write": 1, "execute": 2, "network": 3, "destructive": 4}
FIRST_WORD = {
"cat": "read", "ls": "read", "grep": "read",
"sed": "write", "touch": "write",
"pytest": "execute", "make": "execute",
"curl": "network", "git": "read",
"rm": "destructive",
}
def classify_one(part: str) -> str:
words = part.split()
if not words:
return "read"
label = FIRST_WORD.get(words[0], "execute") # unknown programs count as execute
if words[0] == "git" and len(words) > 1:
if words[1] == "push":
label = "destructive" if "--force" in words else "network"
return label
def classify(command: str) -> str:
parts = [p for p in re.split(r"[;&|\n]+", command) if p.strip()]
labels = [classify_one(p) for p in parts]
return max(labels, key=RANK.__getitem__) if labels else "read"
print(classify("cat README.md")) # read
print(classify("git status; curl example.com")) # network
print(classify("git push --force origin main")) # destructiveThis is still incomplete. It does not handle command substitution such as $(...), aliases, scripts that call other programs, or variables. Treat it as a teaching aid. The point is the design choice: unknown programs default to execute, not read, and compound commands take the strictest label.
Using categories to set defaults
A common starting point maps categories to decisions:
- Allow reads inside the project.
- Ask for writes outside the project and for all execute and network actions that no rule covers.
- Deny destructive patterns you never want from an agent, and require explicit approval for the rest.
The next chapter turns these defaults into the three decisions of allow, ask, and deny.
Exercise
Classify git status && npm install && git push --force. Give every category that applies, and name the one that should set the strictest handling.
Show answer
It contains a read (git status), execute and network (npm install downloads packages and may run install scripts), and network plus destructive (git push --force sends data and overwrites remote history). Destructive sets the strictest handling, because force-pushing can erase shared history that cannot be recovered locally. A rule that approved git status* would wrongly approve the whole string.
Exercise
A write to src/app.py and a write to ~/.bashrc are both "write" actions. Why might a permission system give them different decisions?
Show answer
src/app.py is inside the project, so git shows the change and can undo it. ~/.bashrc is outside the workspace, runs in every new shell, and is not tracked by the project's git history, so a bad change affects the machine later and is hard to notice. Location changes the risk.