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
Bypass Mode (--bypass)
Shortcut for --permission-mode bypassPermissions. Grants full access through the permission mode system. Composable with other Claude Code settings.
When to use: Standard automation where you need full access and may want to compose with other permission settings.
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
| Feature | --skip | --bypass |
|---|---|---|
| Full access | Yes | Yes |
| Permission prompts | None | None |
Overrides --permission-mode | Yes | No |
| Composable with modes | No | Yes |
| Recommended for | Quick scripts | Production automation |
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
| You use | What happens |
|---|---|
ai --skip | Same as --dangerously-skip-permissions (nuclear) |
ai --bypass | Same as --permission-mode bypassPermissions (mode-based) |
ai --skip --permission-mode plan | Plan mode used, --skip ignored (warning shown) |
ai --bypass --permission-mode plan | Plan mode used, --bypass ignored (warning shown) |
ai --permission-mode plan script.md | Plan mode used, even if script has --skip |
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
| Mode | Shebang | Long Form | Short Form | Behavior |
|---|---|---|---|---|
| Default | (none) | — | — | Read-only |
| Bypass | --bypass | --permission-mode bypassPermissions | --bypass | Full access (composable) |
| Skip | --skip | --dangerously-skip-permissions | --skip | Full access (nuclear) |
| Allowed Tools | --allowedTools | --allowedTools 'Tool1' 'Tool2' | — | Granular |
| Plan | — | --permission-mode plan | — | Plan-only (no execution) |
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: