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.
YOLO mode automatically executes all file modifications, shell commands, and other operations without confirmation. Use with caution, especially in production environments.
> 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.
# DON'T DO THISqwen --yolo --prompt "Update production database schema"# Instead:qwen --prompt "Generate migration for database schema"# Review the migration before applying
# DON'T DO THIScd new-projectqwen --yolo --prompt "Refactor everything"# Instead:qwen --prompt "Analyze the codebase structure"# Understand before making changes
# DON'T DO THISqwen --yolo --prompt "Delete all unused code"# Instead:qwen --approval-mode plan --prompt "Identify unused code"# Review before deleting
# DON'T DO THIS on main branchgit checkout mainqwen --yolo --prompt "Update APIs"# Instead: work on a branchgit checkout -b feature/api-updateqwen --yolo --prompt "Update APIs"# Review and test before merging
# Verify Git repogit status# Create checkpointgit add . && git commit -m "Before YOLO changes"# Run YOLO modeqwen --yolo --prompt "Task"# Review and commit or revertgit diff
Start Small
Test YOLO mode with small tasks first:
# Start with safe operationsqwen --yolo --prompt "Add comments to this function"# Build confidenceqwen --yolo --prompt "Refactor this single file"# Then scale upqwen --yolo --prompt "Refactor the module"
Use Specific Prompts
Vague prompts are dangerous in YOLO mode:
# Bad (too vague)qwen --yolo --prompt "Fix the code"# Good (specific)qwen --yolo --prompt "Fix TypeScript errors in src/auth.ts"
#!/bin/bash# Use YOLO only in dev environmentif [ "$ENV" = "development" ]; then APPROVAL_FLAG="--yolo"else APPROVAL_FLAG="" # Prompt in productionfiqwen $APPROVAL_FLAG --prompt "Deploy updates"
# Test changes in sandbox firstqwen --yolo --sandbox --prompt "Risky operation"# If successful, apply to real environmentqwen --yolo --prompt "Risky operation"