> ## 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.

# --yolo Option

> Automatically approve all actions without prompting

## Overview

The `--yolo` (or `-y`) option runs Qwen Code in **YOLO mode** (You Only Live Once), automatically approving all tool executions without prompting for confirmation. This is useful for automation, trusted environments, and when you want maximum speed.

<Warning>
  YOLO mode automatically executes all file modifications, shell commands, and other operations without confirmation. Use with caution, especially in production environments.
</Warning>

## Syntax

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

## What It Does

With `--yolo` enabled:

✅ **Auto-approves** all file writes and edits\
✅ **Auto-executes** shell commands\
✅ **Skips** confirmation prompts\
✅ **Maximizes** execution speed\
✅ **Continues** without pausing

## Basic Usage

### Interactive Mode

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

All operations execute immediately:

```
> Create a REST API with authentication

✓ Creating src/api/routes.ts...
✓ Creating src/api/auth.ts...
✓ Installing dependencies...
✓ Running tests...

All done! API created successfully.
```

### Headless Mode

```bash theme={null}
qwen --yolo --prompt "Fix all linting errors in the project"
```

Executes without any confirmation:

```bash theme={null}
# Auto-runs:
# 1. npm run lint -- --fix
# 2. Edits all files with errors
# 3. Verifies fixes
```

## When to Use YOLO Mode

### Trusted Environments

```bash theme={null}
# Development environment
qwen --yolo --prompt "Update dependencies"

# CI/CD pipeline
qwen --yolo --prompt "Generate documentation"

# Personal projects
qwen --yolo --prompt "Refactor this module"
```

### Automation Scripts

```bash theme={null}
#!/bin/bash
# Automated code generation
qwen --yolo --prompt "Generate CRUD endpoints for User model"
```

### Batch Operations

```bash theme={null}
# Process multiple files
for file in src/**/*.ts; do
  qwen --yolo --prompt "Add JSDoc comments to $file"
done
```

### Time-Sensitive Tasks

```bash theme={null}
# Quick fixes
qwen --yolo --prompt "Fix the broken build ASAP"
```

## When NOT to Use YOLO Mode

### Production Environments

```bash theme={null}
# DON'T DO THIS
qwen --yolo --prompt "Update production database schema"

# Instead:
qwen --prompt "Generate migration for database schema"
# Review the migration before applying
```

### Unfamiliar Codebases

```bash theme={null}
# DON'T DO THIS
cd new-project
qwen --yolo --prompt "Refactor everything"

# Instead:
qwen --prompt "Analyze the codebase structure"
# Understand before making changes
```

### Destructive Operations

```bash theme={null}
# DON'T DO THIS
qwen --yolo --prompt "Delete all unused code"

# Instead:
qwen --approval-mode plan --prompt "Identify unused code"
# Review before deleting
```

### Shared Repositories

```bash theme={null}
# DON'T DO THIS on main branch
git checkout main
qwen --yolo --prompt "Update APIs"

# Instead: work on a branch
git checkout -b feature/api-update
qwen --yolo --prompt "Update APIs"
# Review and test before merging
```

## Combining with Other Options

### With Model Selection

```bash theme={null}
# Use powerful model + auto-approve
qwen --model qwen-coder-plus --yolo --prompt "Refactor entire codebase"
```

### With Output Format

```bash theme={null}
# Automation with JSON output
qwen --yolo --prompt "Fix bugs" --output-format json
```

### With Session Management

```bash theme={null}
# Continue previous session with auto-approve
qwen --continue --yolo --prompt "Now implement the remaining features"
```

## Safety Considerations

### Use Version Control

Always use Git when running YOLO mode:

```bash theme={null}
# Create a checkpoint
git add .
git commit -m "Before YOLO mode changes"

# Run YOLO mode
qwen --yolo --prompt "Refactor the codebase"

# Review changes
git diff

# Undo if needed
git reset --hard HEAD
```

### Backup Important Files

```bash theme={null}
# Backup before YOLO mode
cp -r src src.backup

# Run YOLO mode
qwen --yolo --prompt "Major refactoring"

# Restore if needed
rm -rf src
mv src.backup src
```

### Use Sandboxes

```bash theme={null}
# Run in isolated environment
qwen --yolo --sandbox --prompt "Test destructive operations"
```

### Review Logs

```bash theme={null}
# Enable logging
qwen --yolo --prompt "Task" 2>&1 | tee yolo-session.log

# Review what was executed
cat yolo-session.log
```

## YOLO Mode vs Other Approval Modes

| Mode          | File Edits   | Shell Commands | Use Case                |
| ------------- | ------------ | -------------- | ----------------------- |
| **yolo**      | Auto-approve | Auto-approve   | Automation, trusted env |
| **auto-edit** | Auto-approve | Prompt         | Safe file changes       |
| **default**   | Prompt       | Prompt         | Interactive development |
| **plan**      | No execution | No execution   | Review before executing |

### Choosing the Right Mode

```bash theme={null}
# Maximum automation
qwen --yolo  # or --approval-mode yolo

# Safe automation (only edits)
qwen --approval-mode auto-edit

# Review before executing
qwen --approval-mode plan

# Interactive (default)
qwen  # or --approval-mode default
```

## Examples

### Code Generation

```bash theme={null}
qwen --yolo --prompt "Create a complete authentication system"
```

Generates and writes:

* `src/auth/login.ts`
* `src/auth/register.ts`
* `src/auth/middleware.ts`
* `tests/auth.test.ts`

Without any confirmation prompts.

### Bug Fixes

```bash theme={null}
# Auto-fix all issues
qwen --yolo --prompt "Fix all TypeScript errors in the project"
```

### Code Refactoring

```bash theme={null}
# Refactor without interruption
qwen --yolo --prompt "Convert all class components to functional components"
```

### Dependency Updates

```bash theme={null}
# Update and test
qwen --yolo --prompt "Update all dependencies and run tests"
```

## Automation Scripts

### Daily Code Maintenance

```bash theme={null}
#!/bin/bash
# daily-maintenance.sh

set -e

echo "Starting daily maintenance..."

# Create backup
git stash

# Run maintenance tasks
qwen --yolo --prompt "Fix linting errors"
qwen --yolo --prompt "Update outdated dependencies"
qwen --yolo --prompt "Optimize imports"
qwen --yolo --prompt "Run tests and fix failures"

# Commit changes
git add .
git commit -m "Daily maintenance: $(date +%Y-%m-%d)"

echo "Maintenance complete!"
```

### CI/CD Integration

```yaml theme={null}
# .github/workflows/ai-fixes.yml
name: AI Auto-fixes

on:
  push:
    branches: [develop]

jobs:
  auto-fix:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Install Qwen Code
        run: npm install -g @qwen/cli
      
      - name: Run auto-fixes
        env:
          DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
        run: |
          qwen --yolo --prompt "Fix all linting errors" \
               --output-format json > fixes.json
      
      - name: Commit fixes
        if: success()
        run: |
          git config user.name "AI Bot"
          git config user.email "bot@example.com"
          git add .
          git commit -m "AI: Auto-fix linting errors"
          git push
```

### Bulk Code Updates

```bash theme={null}
#!/bin/bash
# bulk-update.sh

FILES=$(find src -name '*.ts')

for file in $FILES; do
  echo "Processing $file..."
  qwen --yolo --prompt "Modernize $file: use ES6+ features, add type annotations"
done

echo "Bulk update complete!"
```

## Monitoring YOLO Executions

### Log All Actions

```bash theme={null}
# Log everything
qwen --yolo --prompt "Task" 2>&1 | tee -a yolo-audit.log

# Review later
grep "Executing" yolo-audit.log
```

### Track Changes

```bash theme={null}
# Before
git rev-parse HEAD > before.txt

# Execute
qwen --yolo --prompt "Make changes"

# After
git diff $(cat before.txt) > yolo-changes.diff
```

### Cost Tracking

```bash theme={null}
qwen --yolo --prompt "Task" --output-format json | \
  jq '.usage.totalTokens' >> token-usage.log
```

## Troubleshooting

### Unexpected Changes

If YOLO mode made unwanted changes:

```bash theme={null}
# Undo with Git
git reset --hard HEAD~1

# Or restore specific files
git checkout -- path/to/file

# Review what changed
git diff HEAD~1
```

### Failed Executions

If a YOLO command fails midway:

```bash theme={null}
# Check what was completed
qwen --prompt "/stats tools"

# Review error logs
qwen --debug --yolo --prompt "Task"

# Clean up partial changes
git reset --hard
```

### Prompt Too Broad

If YOLO mode attempts too many changes:

```bash theme={null}
# Don't do this:
qwen --yolo --prompt "Improve the codebase"

# Be specific:
qwen --yolo --prompt "Add error handling to all API routes"
```

## Best Practices

<AccordionGroup>
  <Accordion title="Use Version Control">
    Always work in a version-controlled environment:

    ```bash theme={null}
    # Verify Git repo
    git status

    # Create checkpoint
    git add . && git commit -m "Before YOLO changes"

    # Run YOLO mode
    qwen --yolo --prompt "Task"

    # Review and commit or revert
    git diff
    ```
  </Accordion>

  <Accordion title="Start Small">
    Test YOLO mode with small tasks first:

    ```bash theme={null}
    # Start with safe operations
    qwen --yolo --prompt "Add comments to this function"

    # Build confidence
    qwen --yolo --prompt "Refactor this single file"

    # Then scale up
    qwen --yolo --prompt "Refactor the module"
    ```
  </Accordion>

  <Accordion title="Use Specific Prompts">
    Vague prompts are dangerous in YOLO mode:

    ```bash theme={null}
    # Bad (too vague)
    qwen --yolo --prompt "Fix the code"

    # Good (specific)
    qwen --yolo --prompt "Fix TypeScript errors in src/auth.ts"
    ```
  </Accordion>

  <Accordion title="Review Before Production">
    Never deploy YOLO changes directly:

    ```bash theme={null}
    # Development workflow
    git checkout -b feature/ai-changes
    qwen --yolo --prompt "Implement feature"
    git add . && git commit -m "AI: Feature implementation"

    # Review
    git diff main
    npm test

    # Then merge
    git checkout main
    git merge feature/ai-changes
    ```
  </Accordion>
</AccordionGroup>

## Advanced Usage

### Conditional YOLO

```bash theme={null}
#!/bin/bash
# Use YOLO only in dev environment

if [ "$ENV" = "development" ]; then
  APPROVAL_FLAG="--yolo"
else
  APPROVAL_FLAG=""  # Prompt in production
fi

qwen $APPROVAL_FLAG --prompt "Deploy updates"
```

### Sandboxed YOLO

```bash theme={null}
# Test changes in sandbox first
qwen --yolo --sandbox --prompt "Risky operation"

# If successful, apply to real environment
qwen --yolo --prompt "Risky operation"
```

### Rate-Limited YOLO

```bash theme={null}
#!/bin/bash
# Prevent runaway automation

for task in "${TASKS[@]}"; do
  qwen --yolo --prompt "$task"
  sleep 5  # Pause between operations
done
```

## See Also

<CardGroup cols={2}>
  <Card title="--plan Option" icon="list-check" href="/cli/options/plan">
    Plan-only mode for reviewing before execution
  </Card>

  <Card title="Approval Modes" icon="shield-check" href="/features/approval-modes">
    Understanding different approval modes
  </Card>

  <Card title="Safety Guidelines" icon="shield-halved" href="/advanced/safety">
    Best practices for safe AI usage
  </Card>

  <Card title="Automation" icon="robot" href="/features/automation">
    Complete automation guide
  </Card>
</CardGroup>
