> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/QwenLM/qwen-code/llms.txt
> Use this file to discover all available pages before exploring further.

# Approval Modes

> Control how Qwen Code requests permission for actions

## Overview

Approval modes control when the AI must request permission before executing tools. They balance safety, control, and automation to match your workflow and trust level.

```bash theme={null}
# Set approval mode
qwen --approval-mode default

# Change during session
/approval-mode yolo

# Quick toggle with Shift+Tab
# (cycles through: default → auto-edit → yolo → plan → default)
```

## The Four Modes

<CardGroup cols={2}>
  <Card title="Plan" icon="magnifying-glass" color="#60a5fa">
    **Read-only analysis mode**

    AI can analyze and reason but cannot modify files or run commands.
  </Card>

  <Card title="Default" icon="shield" color="#34d399">
    **Balanced mode (recommended)**

    Prompts for approval before file edits and shell commands.
  </Card>

  <Card title="Auto Edit" icon="pencil" color="#fbbf24">
    **Automated editing**

    Auto-approves file edits but still prompts for shell commands.
  </Card>

  <Card title="YOLO" icon="rocket" color="#f87171">
    **Full automation**

    Auto-approves all actions. Use with caution!
  </Card>
</CardGroup>

## Plan Mode

**Best for:** Code review, architecture planning, learning about a codebase

```bash theme={null}
qwen --approval-mode plan
```

### What's Allowed

<Tabs>
  <Tab title="Allowed">
    * Read files
    * Search code (glob, grep, ripgrep)
    * List directories
    * Analyze code structure
    * Browse file tree
    * Fetch documentation
    * Reason and explain
  </Tab>

  <Tab title="Blocked">
    * Edit or write files
    * Delete files
    * Run shell commands
    * Execute scripts
    * Make network requests (write operations)
    * Modify system state
  </Tab>
</Tabs>

### Use Cases

```bash theme={null}
# Safe code review
qwen --approval-mode plan --prompt "Review this PR for security issues"

# Understand codebase structure
qwen --approval-mode plan --prompt "Explain the architecture of this project"

# Learning without risk
qwen --approval-mode plan --prompt "Show me how the authentication works"
```

<Info>
  Plan mode is perfect for read-only analysis where you want insights without any risk of changes.
</Info>

## Default Mode

**Best for:** Day-to-day development, learning while building, supervised automation

```bash theme={null}
qwen --approval-mode default
# or just:
qwen
```

### Approval Flow

<Steps>
  <Step title="Tool Call Initiated">
    AI decides to use a tool that requires approval.
  </Step>

  <Step title="Confirmation Prompt">
    You see the tool name, arguments, and preview (for edits).
  </Step>

  <Step title="Your Decision">
    * **Allow** - Execute this one time
    * **Reject** - Skip this tool call
    * **Allow All Edits** - Auto-approve all future file edits
    * **Always Allow \[command/tool]** - Remember approval for this specific tool
  </Step>

  <Step title="Execution">
    Tool runs (if approved) and AI continues with the result.
  </Step>
</Steps>

### What Requires Approval

| Tool         | Requires Approval | Reason                   |
| ------------ | ----------------- | ------------------------ |
| `edit`       | Yes               | Modifies files           |
| `write_file` | Yes               | Creates/overwrites files |
| `bash`       | Yes               | Executes commands        |
| `mcp_tool`   | Yes (first use)   | External tool            |
| `read`       | No                | Read-only                |
| `glob`       | No                | Search only              |
| `grep`       | No                | Search only              |
| `ls`         | No                | List only                |
| `web_fetch`  | No                | Read-only                |

### Example Session

```
> Fix the bug in auth.ts

I'll analyze the file first...

✓ Executed: read("src/auth.ts")

I found the issue. I need to update line 42.

? Allow file edit?
  File: src/auth.ts
  Lines: 42
  Changes: Fix null check in validateToken
  
  [Show diff] [Allow] [Reject] [Allow All Edits]

> [You press Allow]

✓ Executed: edit("src/auth.ts", ...)

Fixed! Now let me run the tests...

? Allow shell command?
  Command: npm test
  
  [Allow] [Reject] [Always Allow npm]

> [You press Allow]

✓ Executed: bash("npm test")

All tests pass! The bug is fixed.
```

<Tip>
  In default mode, you maintain full control while still getting AI assistance. Approve only what makes sense.
</Tip>

## Auto Edit Mode

**Best for:** Refactoring, code generation, automated documentation

```bash theme={null}
qwen --approval-mode auto-edit
```

### What's Auto-Approved

<Tabs>
  <Tab title="Auto-Approved">
    * File edits (`edit`)
    * File creation (`write_file`)
    * File reads (`read`)
    * Code search (`glob`, `grep`)
    * Directory listing (`ls`)
    * Documentation fetching
  </Tab>

  <Tab title="Still Prompts">
    * Shell commands (`bash`)
    * File deletion
    * MCP tools (first use per server)
    * System operations
  </Tab>
</Tabs>

### Use Cases

```bash theme={null}
# Large-scale refactoring
qwen --approval-mode auto-edit \
  --prompt "Rename Component to Widget throughout the codebase"

# Code generation
qwen --approval-mode auto-edit \
  --prompt "Generate CRUD endpoints for the User model"

# Automated documentation
qwen --approval-mode auto-edit \
  --prompt "Add JSDoc comments to all exported functions"
```

### Safety Features

Even in auto-edit mode:

* You can press `Ctrl+C` to cancel mid-stream
* Changes are applied incrementally (visible in real-time)
* Git integration shows diffs automatically
* Shell commands still require explicit approval

<Warning>
  Auto-edit mode trusts the AI to modify your files. Make sure you have version control and can revert changes if needed.
</Warning>

## YOLO Mode

**Best for:** Trusted environments, CI/CD, automation scripts, rapid prototyping

```bash theme={null}
qwen --approval-mode yolo
```

### What's Auto-Approved

**Everything.** No prompts, no confirmations.

* File operations (read, write, edit, delete)
* Shell commands
* MCP tools
* System operations
* Network requests
* All other tools

### Use Cases

<Tabs>
  <Tab title="CI/CD">
    ```yaml theme={null}
    # .github/workflows/ai-fix.yml
    - name: Auto-fix Issues
      run: |
        qwen --approval-mode yolo \
          --prompt "Fix all linting errors" \
          --output json
    ```
  </Tab>

  <Tab title="Automation">
    ```bash theme={null}
    #!/bin/bash
    # daily-maintenance.sh

    qwen --approval-mode yolo --prompt "Update dependencies"
    qwen --approval-mode yolo --prompt "Run tests and fix failures"
    qwen --approval-mode yolo --prompt "Generate changelog"
    ```
  </Tab>

  <Tab title="Rapid Prototyping">
    ```bash theme={null}
    # Quick project setup
    qwen --approval-mode yolo \
      --prompt "Create a Next.js app with Auth0 and Tailwind"
    ```
  </Tab>
</Tabs>

### Safety Considerations

<Warning>
  **YOLO mode is powerful and dangerous.**

  The AI can:

  * Execute any shell command
  * Modify or delete any file
  * Make network requests
  * Change system configuration
  * Install packages
  * Deploy code

  Only use in:

  * Isolated environments (containers, VMs)
  * Non-production systems
  * With version control
  * When you understand the prompt's implications
</Warning>

### Cancellation

Even in YOLO mode, you can:

* Press `Ctrl+C` to abort immediately
* Use `--max-turns` to limit iterations
* Set timeouts to prevent runaway processes

```bash theme={null}
# Safe YOLO with limits
timeout 300 qwen \
  --approval-mode yolo \
  --max-turns 10 \
  --prompt "Deploy to staging"
```

## Switching Modes Mid-Session

### Interactive Mode

```bash theme={null}
# Use slash command
/approval-mode auto-edit

# Or use Shift+Tab to cycle
# (default → auto-edit → yolo → plan → default)
```

When you switch modes:

* **Pending approvals** are auto-resolved based on new mode
* **In-flight operations** continue with original mode
* **Future operations** use the new mode

### Headless Mode

Mode is set at startup and cannot be changed:

```bash theme={null}
qwen --approval-mode yolo --prompt "Task"
```

## Configuration

### Settings File

```json theme={null}
// .qwen/settings.json
{
  "approvalMode": "default",
  "tools": {
    "bash": {
      "alwaysAllow": ["npm test", "git status"]
    },
    "mcp": {
      "trustedServers": ["filesystem", "github"]
    }
  }
}
```

### Environment Variable

```bash theme={null}
export QWEN_APPROVAL_MODE=auto-edit
qwen
```

### Per-Tool Configuration

You can customize approval behavior per tool:

```json theme={null}
{
  "tools": {
    "bash": {
      "approvalMode": "prompt",
      "alwaysAllow": ["git status", "npm test"],
      "neverAllow": ["rm -rf", "sudo"]
    },
    "edit": {
      "approvalMode": "auto"
    },
    "mcp_tool": {
      "approvalMode": "prompt",
      "trustedServers": ["filesystem"]
    }
  }
}
```

## Advanced Features

### Persistent Approvals

When you choose "Always Allow", approvals are saved:

```json theme={null}
// ~/.qwen/approvals.json
{
  "bash": {
    "npm test": true,
    "npm run build": true
  },
  "mcp_servers": {
    "github": true
  }
}
```

Clear persistent approvals:

```bash theme={null}
/permissions
# Opens dialog to manage saved approvals
```

### Conditional Approval

Configure approval based on context:

```json theme={null}
{
  "approvalMode": "default",
  "approvalRules": [
    {
      "when": { "tool": "bash", "args.command": "npm test" },
      "then": "allow"
    },
    {
      "when": { "tool": "edit", "args.filePath": "tests/**" },
      "then": "allow"
    },
    {
      "when": { "tool": "bash", "args.command": "rm*" },
      "then": "deny"
    }
  ]
}
```

### Approval Hooks

Run custom logic before approval:

```typescript theme={null}
// .qwen/hooks/before-approval.ts
export async function beforeApproval(tool: ToolCall) {
  if (tool.name === 'bash' && tool.args.command.includes('rm')) {
    // Extra confirmation for dangerous commands
    return {
      require: 'explicit',
      message: 'This command will delete files. Are you sure?'
    };
  }
  return { require: 'default' };
}
```

## Comparison Table

| Feature        | Plan    | Default     | Auto Edit | YOLO   |
| -------------- | ------- | ----------- | --------- | ------ |
| Read files     | ✓       | ✓           | ✓         | ✓      |
| Search code    | ✓       | ✓           | ✓         | ✓      |
| Edit files     | ✗       | Prompt      | ✓         | ✓      |
| Shell commands | ✗       | Prompt      | Prompt    | ✓      |
| MCP tools      | ✗       | Prompt      | Prompt    | ✓      |
| Delete files   | ✗       | Prompt      | Prompt    | ✓      |
| Safety level   | Highest | High        | Medium    | Lowest |
| Automation     | ✗       | Limited     | Good      | Full   |
| Best for       | Review  | Development | Refactor  | CI/CD  |

## Best Practices

<AccordionGroup>
  <Accordion title="Start with Default">
    Begin with `default` mode to understand what the AI wants to do. Graduate to higher automation as you build trust.
  </Accordion>

  <Accordion title="Use Plan for Reviews">
    When reviewing code or learning, use `plan` mode to explore safely without accidental changes.
  </Accordion>

  <Accordion title="Auto-Edit for Bulk Changes">
    Switch to `auto-edit` for large refactorings where you'd approve every edit anyway.
  </Accordion>

  <Accordion title="YOLO in Containers">
    Use `yolo` mode in Docker containers or VMs where mistakes are isolated and easily reversed.
  </Accordion>

  <Accordion title="Git is Your Safety Net">
    Always commit your work before switching to auto-edit or yolo modes. You can revert if needed.
  </Accordion>

  <Accordion title="Test in Plan First">
    For complex prompts, run in `plan` mode first to verify the AI understands correctly before allowing execution.
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Tools are denied in headless mode">
    **Problem:** In headless mode with `default`, tools requiring approval fail.

    **Solution:** Use `--approval-mode yolo` or `--approval-mode auto-edit` for headless automation.
  </Accordion>

  <Accordion title="Too many approval prompts">
    **Problem:** Constantly approving the same operations.

    **Solution:**

    * Choose "Always Allow" for trusted operations
    * Switch to `auto-edit` for file operations
    * Add commands to `alwaysAllow` in settings
  </Accordion>

  <Accordion title="AI isn't making necessary changes">
    **Problem:** In `plan` mode, AI can't complete the task.

    **Solution:** Switch to `default` or higher. Plan mode is read-only by design.
  </Accordion>

  <Accordion title="Can't revert approval mode">
    **Problem:** Stuck in YOLO mode.

    **Solution:**

    * In interactive: `/approval-mode default`
    * In headless: Restart with `--approval-mode default`
    * Check settings file for persistent configuration
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Interactive Mode" icon="window" href="/features/interactive-mode">
    Use approval modes in the interactive UI
  </Card>

  <Card title="Headless Mode" icon="robot" href="/features/headless-mode">
    Automate with YOLO mode
  </Card>

  <Card title="Session Commands" icon="terminal" href="/features/commands">
    Learn the /approval-mode command
  </Card>

  <Card title="Configuration" icon="gear" href="/configuration/settings">
    Configure approval settings
  </Card>
</CardGroup>
