# exec

Canonical URL: https://developers.iagenify.com/sdk/agent/permissions/categories/exec/
Language: en

Running a command. Asked in every mode but full, and the only category whose « always » is written to disk — so a command approved once stays approved in later sessions.

Status: asked even in auto · always is on disk · the widest reach

| ask | auto | plan | full |
| --- | --- | --- | --- |
| asked | asked | refused | allowed |

## The tools {#tools}

| Tool | When |
| --- | --- |
| `bash` | Always — one command, or a list of them. |
| `terminal` | Only `{ action: "kill" }`. Listing and reading output are [read](/sdk/agent/permissions/categories/read). |

## Why auto does not open it {#why}

Every other category has a boundary the engine imposes: a path cannot leave the workspace, a storage is one you passed, an address is checked. A command has none — it runs with whatever the account on that machine can do, including everything outside the workspace. It is the one tool whose reach is the machine's, not the agent's.

## What exactly is approved {#what-is-approved}

| Call | The key |
| --- | --- |
| `bash { command: "npm test" }` | that command, exactly |
| `bash { commands: ["npm ci", "npm run build"] }` | the whole sequence, joined — approving it does not approve either one alone |
| `terminal { action: "kill" }` | the tool, for the session |

> **A sequence is approved as a sequence**
>
> The user saw three commands and said yes to those three in that order. Letting any one of them run alone later would be approving something they never read.

## Where « always » goes {#persistence}

| Case | Remembered |
| --- | --- |
| A single command on a real computer | In `~/.iagenify/permissions.json` — across sessions and applications |
| A sequence of commands | For the session only |
| A shell supplied by your application | For the session only |
| `terminal kill` | For the session only |

Only the first is durable, and deliberately so: a one-off sequence, and a shell that is not this machine's, have no business in a permanent list on this computer.

## A narrow allow list {#pattern}

```javascript
const SAFE = /^(npm (ci|test|run (build|lint))|git (status|diff|log)( .*)?)$/;

onPermission: async ({ category, args }) => {
  if (category !== "exec") return "once";
  const command = args.commands ? args.commands.join(" && ") : args.command;
  return SAFE.test(command) ? "once" : "deny";
}
```

Return `once` rather than `always` when you are matching on the arguments: `always` on a command writes *that* command to disk, which is fine, but the pattern above is what keeps the decision in your code.

- [Persistence](/sdk/agent/permissions/persistence): The file, and how to clear it.
- [bash](/sdk/agent/tools/bash): The tool itself.

```python
import re

SAFE = re.compile(r"^(npm (ci|test|run (build|lint))|git (status|diff|log)( .*)?)$")

def on_permission(request):
    if request["category"] != "exec":
        return "once"
    return "once" if SAFE.match(request["args"].get("command", "")) else "deny"
```
