# Terminal

The Invoke Terminal gives the Agent the ability to run shell commands on your system. You have complete control over what commands can run automatically, which require your approval, and which are blocked entirely.

## [Command Execution Flow](/content/docs/terminal#command-execution-flow/index.html)

When the Agent wants to run a command, Invoke checks your rules in this order:

```
Agent requests command
        ↓
Check Blocklist → If matched: BLOCKED (cannot run)
        ↓
Check Allowlist → If matched: AUTO-RUN (no approval needed)
        ↓
Require Approval → Wait for your confirmation
```

The blocklist always takes priority. A command in both lists will be blocked.

## [Command Rules](/content/docs/terminal#command-rules/index.html)

### [Allowlist (Auto-Approve)](/content/docs/terminal#allowlist-auto-approve/index.html)

Commands in the allowlist run **immediately without asking** for permission. Use this for commands you trust and use frequently.

**Examples:**

- `git` — Allows all git commands (git status, git push, git pull, etc.)
- `npm test` — Allows running tests
- `ls` — Allows listing directory contents

### [Blocklist (Always Block)](/content/docs/terminal#blocklist-always-block/index.html)

Commands in the blocklist **can never run**, even if you try to approve them. Use this for dangerous operations you want to prevent.

**Examples:**

- `rm -rf` — Prevents recursive force deletion
- `sudo` — Blocks elevated privilege commands
- `chmod 777` — Prevents insecure permission changes

### [Unlisted Commands (Manual Approval)](/content/docs/terminal#unlisted-commands-manual-approval/index.html)

Commands not in either list require your **explicit approval** before running. This is the default behavior for new commands.

## [Managing Command Rules](/content/docs/terminal#managing-command-rules/index.html)

### [Open Terminal Settings](/content/docs/terminal#open-terminal-settings/index.html)

Navigate to **Settings → Terminal rules**.

### [Choose Allow or Block Tab](/content/docs/terminal#choose-allow-or-block-tab/index.html)

Switch between the **Allow** and **Block** tabs to manage each list.

### [Add Commands](/content/docs/terminal#add-commands/index.html)

Type a command or pattern in the input field and press **Enter** or click **Add**.

### [Remove Commands](/content/docs/terminal#remove-commands/index.html)

Hover over any command in the list and click the **delete** button to remove it.

Use the search box to filter commands when your list grows large (appears with 4+ items).

## [Prefix Matching](/content/docs/terminal#prefix-matching/index.html)

Both lists support **prefix matching**, which means a single entry can cover multiple related commands.

| Entry | Matches |
| --- | --- |
| `git` | `git status`, `git push`, `git commit -m "message"` |
| `npm` | `npm install`, `npm run dev`, `npm test` |
| `docker` | `docker build`, `docker run`, `docker compose up` |
| `rm -rf` | `rm -rf /tmp`, `rm -rf node_modules`, `rm -rf ./dist` |

Allowlist ExamplesBlocklist Examples

```
# Development tools
git
npm
pnpm
yarn
cargo
go

# Safe read operations
ls
cat
head
tail
grep
find
pwd

# Build and test
npm test
npm run build
cargo build
cargo test
```

```
# Dangerous deletions
rm -rf /
rm -rf ~
rm -rf /*

# System modifications
sudo
su
chmod 777
chown

# Network risks
curl | bash
wget | bash
nc -l

# Environment
export PATH=
unset PATH
```

## [Approving Commands](/content/docs/terminal#approving-commands/index.html)

When the Agent requests an unlisted command, an approval dialog appears:

### [Approval Options](/content/docs/terminal#approval-options/index.html)

| Option | What It Does |
| --- | --- |
| **Skip** | Reject the command—it won't run |
| **Run** | Execute once without adding to allowlist |
| **Run & Add to Allowlist** | Execute and permanently allow this command |

Use "Run & Add to Allowlist" for commands you'll approve repeatedly. This saves time on future executions.

## [AI Command Generation](/content/docs/terminal#ai-command-generation/index.html)

Press **Cmd+K** (Mac) or **Ctrl+K** (Windows/Linux) inside any terminal to generate commands using AI.

1. Press **Cmd+K** / **Ctrl+K** in the terminal
2. Type what you want in plain English (e.g., "find large files over 100MB")
3. Press **Enter** to generate the command
4. Press **Esc** to paste the command into your terminal
5. Press **Cmd+Enter** / **Ctrl+Enter** to paste and run immediately

You can also copy the generated command or click the play button to execute it.

The AI uses your recent terminal history as context, so it knows your current directory and shell environment.

## [Detached Terminals](/content/docs/terminal#detached-terminals/index.html)

You can pop out any terminal tab into its own floating window by dragging it out of the terminal panel. This is useful when you want to monitor a running process while working in the editor.

- **Drag a terminal tab** out of the panel to detach it into a floating window
- The floating terminal stays on top of other panels so you can keep an eye on output
- **Drag it back** into the terminal panel to re-dock it

You can also open a floating terminal directly with **Cmd+Shift+J** (Mac) or **Ctrl+Shift+J** (Windows/Linux).

## [Keyboard Shortcuts](/content/docs/terminal#keyboard-shortcuts/index.html)

| Action | Mac | Windows/Linux |
| --- | --- | --- |
| New terminal | **Cmd+Shift+T** | **Ctrl+Shift+T** |
| Close terminal | **Cmd+Shift+X** | **Ctrl+Shift+X** |
| Next tab | **Ctrl+Tab** | **Ctrl+Tab** |
| Previous tab | **Ctrl+Shift+Tab** | **Ctrl+Shift+Tab** |
| AI command generation | **Cmd+K** | **Ctrl+K** |
| Search output | **Cmd+F** | **Ctrl+F** |
| Floating terminal | **Cmd+Shift+J** | **Ctrl+Shift+J** |
| Toggle bottom panel | **Cmd+Alt+2** | **Ctrl+Alt+2** |

## [Background Execution](/content/docs/terminal#background-execution/index.html)

Long-running commands (servers, builds, watchers) run in **background mode**:

1. Command starts and returns after 3 seconds
2. Agent continues without waiting for completion
3. Output streams in real-time to the terminal
4. **Stop** button appears to kill the process

Background mode prevents the Agent from getting stuck waiting for commands that run indefinitely.

### [Managing Background Processes](/content/docs/terminal#managing-background-processes/index.html)

- Click the **Stop** button next to any running background command
- The process is killed and marked as stopped
- You can clear completed commands with the **Clear** button

## [Recommended Setup](/content/docs/terminal#recommended-setup/index.html)

### [For New Users](/content/docs/terminal#for-new-users/index.html)

Start with a minimal allowlist and add commands as you use them:

```
# Allowlist - Safe defaults
git
ls
pwd
cat

# Blocklist - Dangerous patterns
rm -rf /
rm -rf ~
sudo rm
chmod 777
```

### [For Development](/content/docs/terminal#for-development/index.html)

Common development workflow allowlist:

```
# Version control
git

# Package managers
npm
pnpm
yarn

# Build tools
cargo
go
make

# Testing
npm test
npm run test
cargo test
pytest
jest
```

### [For Production Caution](/content/docs/terminal#for-production-caution/index.html)

If working with sensitive systems, keep the allowlist minimal:

```
# Allowlist - Read-only
git status
git diff
git log
ls
cat
grep

# Blocklist - Prevent modifications
git push
git commit
rm
mv
cp
touch
mkdir
```

## [Best Practices](/content/docs/terminal#best-practices/index.html)

### [Allowlist Strategy](/content/docs/terminal#allowlist-strategy/index.html)

- **Start restrictive** — Add commands as you need them
- **Use prefixes wisely** — `git` is convenient but allows all git operations
- **Be specific when needed** — `npm test` is safer than just `npm`

### [Blocklist Strategy](/content/docs/terminal#blocklist-strategy/index.html)

- **Block patterns, not just commands** — `rm -rf` catches variations
- **Include dangerous flags** — `chmod 777`, `rm -f`
- **Consider piped commands** — `curl | bash` can execute arbitrary code

### [Approval Workflow](/content/docs/terminal#approval-workflow/index.html)

- **Review before approving** — Read the full command in the tooltip
- **Use "Run & Add" for trusted tools** — Saves time on repeat commands
- **Skip suspicious commands** — When in doubt, don't run it

The Agent doesn't have malicious intent, but it might suggest commands that have unintended side effects. Always review unfamiliar commands before approving.
