Overview
Andi AIRun’s permission system controls what actions AI scripts can take. By default, scripts run in read-only mode. For scripts that need to write files, run commands, or take actions, you must explicitly grant permissions.Permission Modes
Default Mode (Read-Only)
No permission flags needed. The AI can:- Read files and directories
- Analyze code
- Search and grep
- Output text
- Write or modify files
- Run shell commands
- Make network requests
- Install packages
Auto Mode (--auto)
Smart auto-approve. The runtime decides which actions are safe:
- Claude Code: AI classifier reviews each action. Safe actions proceed; risky ones (force-push,
curl | bash, mass deletion) are blocked. - Codex CLI: Sandboxed execution. File writes allowed in workspace, network blocked.
Bypass Mode (--bypass)
Shortcut for --permission-mode bypassPermissions. Grants full access through the permission mode system. No safety classifier or sandbox restrictions.
When to use: Standard automation where you need full access and trust the script completely.
Example:
- Full file system access (read, write, delete)
- Shell command execution
- Network requests
- Package installation
- All Claude Code tools
Skip Permissions (--skip)
Shortcut for --dangerously-skip-permissions. Nuclear option that bypasses ALL permission checks and overrides any --permission-mode setting.
When to use: Quick, simple automation where you need absolute full access.
Example:
- Everything
--bypassenables - Overrides any other permission mode flags
- Most aggressive permission setting
Allowed Tools (--allowedTools)
Granular control — only specified tools are allowed. Best for security-conscious automation.
When to use: When you want to restrict the AI to specific, approved operations.
Example:
'Read'— Allow reading files'Write'— Allow writing files'Bash(command)'— Allow specific shell command'Bash'— Allow all shell commands (not recommended)
--skip vs --bypass Difference
Both shortcuts result in no permission prompts, but they work differently internally:
--skip (Nuclear Option)
- Expands to
--dangerously-skip-permissions - Standalone flag that completely bypasses all permission checks
- Overrides any
--permission-modesetting (even if you set both) - Use for simple, quick automation
--bypass (Composable)
- Expands to
--permission-mode bypassPermissions - Sets permission mode through the standard mode system
- Respects the mode framework
- Composable with other Claude Code settings
- Use when working with advanced permission configurations
Comparison Table
When in Doubt
For most automation scripts, either works. Use--bypass when you want future flexibility.
Permission Flag Precedence
When multiple permission flags are present,ai resolves them in order:
Explicit Flags Always Win
--permission-mode <value>is explicit — always takes precedence--dangerously-skip-permissionsis explicit — always takes precedence--skipand--bypassare shortcuts — ignored if explicit flags present
CLI Overrides Shebang
CLI flags override shebang flags — if you runai --permission-mode plan script.md and the script has --skip in its shebang, plan mode is used.
Examples
Conflict Resolution
script.md
Granular Control with --allowedTools
Tool Syntax
Read-only tools:Real-World Examples
Test runner (no file modifications):Security Best Practices
1. Principle of Least Privilege
Always use the minimum permissions needed:
- Read-only analysis? Use default mode (no flags)
- Run specific commands? Use
--allowedTools - Full automation? Use
--bypassor--skip
2. Trust and Verification
3. Sandboxing in CI/CD
Always run AI automation in sandboxed environments:Use containers:Run with limited permissions:
4. File System Restrictions
Restrict file access in containers:
5. Network Isolation
Limit network access:
6. Audit Logging
Log all AI actions:
7. Secret Management
8. Code Review Before Merge
Always review AI-generated changes:
.github/workflows/ai-fix.yml
Permission Mode Reference
Complete Mode Table
Available Tools for --allowedTools
| Tool | Purpose | Example |
|------|---------|---------||
| Read | Read files | --allowedTools 'Read' |
| Write | Write files | --allowedTools 'Write' |
| Edit | Edit files | --allowedTools 'Edit' |
| Bash | All shell commands | --allowedTools 'Bash' (not recommended) |
| Bash(cmd) | Specific command | --allowedTools 'Bash(npm test)' |
| Glob | File pattern search | --allowedTools 'Glob' |
| Grep | Content search | --allowedTools 'Grep' |
Common Patterns
Pattern 1: Secure Test Runner
Pattern 2: Sandboxed CI Job
Pattern 3: Gradual Permission Escalation
Pattern 4: Multi-Stage Pipeline
Troubleshooting
Permission Denied Errors
Problem: Script tries to write file but fails with permission error Solution: Add appropriate permission flag:Tool Not Allowed
Problem:Error: Tool 'Bash' not allowed
Solution: Add tool to allowed list:
Conflicting Permission Flags
Problem: Warning about ignored shortcuts Solution: Remove shortcut flags when using explicit modes:Next Steps
Writing Scripts
Learn script basics and common patterns
CI/CD Automation
Run scripts in CI/CD with proper security
Live Output
Stream progress in real-time
Script Variables
Make scripts reusable with CLI overrides