AIW - AI CLI Unified Gateway
Unified Router & Proxy for AI CLI Tools
What is AIW?
AIW is a unified gateway that acts as an AI CLI proxy router with provider switching, role injection, and transparent parameter forwarding.
┌─────────────────────────────────────────────────────────────┐
│ AIW Gateway │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ │
│ │ AI CLI Router │ │
│ │ │ │
│ │ aiw claude ... ───┼───► Claude CLI │
│ │ aiw codex ... ───┼───► Codex CLI │
│ │ aiw gemini ... ───┼───► Gemini CLI │
│ │ │ │
│ │ + Provider Switch │ │
│ │ + Role Injection │ │
│ │ + Tool Search Unlock │ │
│ │ + Param Forwarding │ │
│ │ + CWD Control │ │
│ └─────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Installation
# Install from crates.io
# Verify installation
AI CLI Router
Basic Usage
# Route to specific AI CLI
# Auto mode: automatic failover across AI CLIs
# Route to multiple AI CLIs
Provider Switching (-p)
# Switch API provider without changing AI CLI
# Auto-select compatible provider
# Provider config: ~/.aiw/providers.json
Tool Search Unlock
When using third-party API providers (non-Anthropic official), Claude's Tool Search feature is disabled by default. AIW automatically unlocks this feature via runtime memory patch.
# Tool Search is automatically enabled when using third-party providers
How it works: AIW applies a runtime patch to the Claude process, changing if(O8()==="firstParty"&&!JB()) to if(O8()!=="firstParty"&&!JB()), enabling Tool Search for third-party providers.
- Works on Linux/macOS/Windows
- Non-destructive: only affects running process, no system files modified
- Automatic retry with increasing delays (up to 5 attempts)
Auto Mode (Automatic Failover)
# Auto mode tries CLI+Provider combinations in configured order, switches on failure
# Configure CLI+Provider execution order
Configuration (~/.aiw/config.json):
- Same CLI can be configured with multiple providers (e.g., claude+glm → claude+local → claude+official)
- Provider "auto" means use the CLI's default provider selection
- Order can be fully customized via TUI or direct config editing
Role Injection (-r)
# Inject role prompt before task
# Built-in roles + custom roles in ~/.aiw/role/*.md
Working Directory (-C)
# Start AI CLI in specific directory
Git Worktree (Isolated Execution)
AIW automatically creates a git worktree for isolated AI CLI execution.
# AIW automatically creates worktree for git repositories
# After completion, AIW outputs:
# === AIW WORKTREE END ===
# Worktree: /tmp/aiw-worktree-a1b2c3d4
# Branch: main
# Commit: abc123def456
The AI CLI works in a temporary worktree at /tmp/aiw-worktree-<hash>, keeping your working directory clean. Worktree remains after completion for manual review — merge changes or delete as needed.
Transparent Parameter Forwarding
# All unknown flags forwarded to AI CLI
# Order: aiw flags (-r, -p, -C) → AI CLI flags → prompt
Combined Example
# Full example with all options
# ^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
# role provider cwd forwarded prompt
Task Monitoring
# Show task status
# Wait for all AI CLI tasks to complete
# Wait for specific process
Update
# Update AIW itself and all installed AI CLI tools
The update command checks and updates:
- AIW: Updates via
cargo install aiw --forceif installed via cargo - Claude CLI: Uses native
claude update(works for both npm and cargo installations) - Codex CLI: Updates via
npm update -g openai-codex - Gemini CLI: Updates via
npm update -g gemini-cli
Output example:
Checking for updates...
✅ AIW updated successfully!
✅ Claude CLI updated (2.1.71 → 2.1.72)
✅ Codex CLI already up-to-date
⚠️ Gemini CLI not installed
Configuration Files
| File | Purpose |
|---|---|
~/.aiw/config.json |
AIW global configuration |
~/.aiw/providers.json |
AI provider configurations |
~/.aiw/role/*.md |
Custom role prompts |
Global Configuration (~/.aiw/config.json)
| Option | Type | Description |
|---|---|---|
user_roles_dir |
string | Custom directory for user roles (supports ~ expansion). If set, AIW will load user roles from this directory instead of ~/.aiw/role/ |
auto_execution_order |
array | CLI+Provider combinations for auto mode. Each entry has cli (codex/gemini/claude) and provider (provider name or "auto"). Use aiw config cli-order TUI to manage |
This allows you to manage all your roles in a single location, such as ~/.claude/roles/, and share them across different tools.
Available Roles
Run aiw roles list to see all built-in roles. Common ones:
| Role | Use case |
|---|---|
common |
General-purpose coding (recommended as base) |
frontend-standards |
Frontend development |
database-standards |
Backend / database work |
testing-standards |
Test code |
security |
Security review |
debugger |
Debugging |
devops |
DevOps / infrastructure |
Combine roles with commas: -r common,frontend-standards
License
MIT License - see LICENSE file for details.
AIW - Unified Gateway for AI CLI | v0.5.72