AI Magicx CLI
AI-powered coding agent for the terminal with multi-provider support, semantic search, and extensible tools
AI Magicx CLI is an AI-powered coding agent that brings intelligent code assistance directly to your terminal. It supports multiple LLM providers, persistent sessions, semantic code search, and extensible tools.
Current version: 0.1.9 | Requires Node.js 18+
Features
- Multi-Provider Support - OpenAI, Anthropic, GitHub Copilot, OpenRouter, Groq, and more
- Interactive TUI - Rich terminal interface with markdown rendering
- Agent Mode - AI with access to file operations, shell commands, and web search
- Approval Modes - Control autonomy: read-only, auto, or full
- Background Tasks - Spawn parallel agents for concurrent work
- Session Management - Resume conversations, auto-compact, export transcripts
- Semantic Code Search - Vector-indexed codebase for intelligent context retrieval
- LSP Integration - Go-to-definition, find references, hover info, diagnostics
- Memory System - Persistent memories across sessions
- MCP Integration - Extend capabilities with Model Context Protocol servers
- Custom Commands & Agents - Define your own slash commands and specialized agents
Installation
npm install -g @aimagicx/clipnpm add -g @aimagicx/cliQuick Start
# Start the TUI (opens provider connect if not authenticated)
aimagicx
# With a specific model
aimagicx chat -m gpt-4o
# Resume a previous session
aimagicx -r <session-id>
# One-shot prompt
aimagicx chat -p "Explain this codebase"Keyboard Shortcuts
Global Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+L | Switch model |
Ctrl+N | New session |
Ctrl+O | Connect provider |
Ctrl+C | Cancel current operation (2x to quit) |
Ctrl+W | Quit immediately |
Ctrl+Z | Undo last file change |
Ctrl+Y | Redo last undone change |
Ctrl+X | Toggle expand/collapse messages |
Esc Esc | Rewind to last checkpoint |
Tab | Cycle approval mode (read-only → auto → full) |
Shift+Tab | Cycle modes (Agent → Review → Plan) |
Alt+T | Toggle task panel |
/ | Open command palette |
@ | Attach file |
# | Save/attach memory |
$ | Save/insert snippet |
* | Toggle favorite (in model selector) |
Input Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+U | Clear input line |
Escape | Clear input (if not empty) |
Ctrl+A | Jump to beginning of line |
Ctrl+E | Jump to end of line |
Ctrl+N | Insert new line (multiline input) |
↑ / ↓ | Navigate input history |
Commands
Authentication
# Login with API key
aimagicx auth login
aimagicx auth login --provider anthropic
# Check auth status
aimagicx auth status
# Logout
aimagicx auth logout
aimagicx auth logout --provider openaiChat
# Start interactive chat
aimagicx chat
# Use specific model
aimagicx chat -m claude-sonnet-4-20250514
# Resume previous session
aimagicx chat -r <session-id>
# Set approval mode
aimagicx chat -a read-only # Read-only mode (exploration only)
aimagicx chat -a auto # Auto mode (default)
aimagicx chat -a full # Full mode (auto-approve all)
aimagicx chat --yolo # Alias for --approval-mode full
# Headless mode (for automation/scripts)
aimagicx chat -p "Fix the bug" --headlessProviders
# List configured providers
aimagicx provider list
# Show available presets
aimagicx provider presets
# Add provider from preset
aimagicx provider add anthropic --preset anthropic
# Add custom provider
aimagicx provider add my-provider \
--endpoint https://api.example.com/v1 \
--protocol openai \
--model gpt-4
# Switch active provider
aimagicx provider use anthropic
# Remove provider
aimagicx provider remove openaiSessions
# List sessions
aimagicx session list
aimagicx session list --all
# Resume session
aimagicx session resume <session-id>
# Rename session
aimagicx session rename <session-id> "Feature Implementation"
# Compact session (reduce context)
aimagicx session compact <session-id>
# Export session
aimagicx session export <session-id> --format markdown
aimagicx session export <session-id> --format json
# Delete session
aimagicx session delete <session-id>Configuration
# Show all config
aimagicx config list
# Get specific value
aimagicx config get defaultModel
# Set value
aimagicx config set maxTokens 8192
aimagicx config set autoConfirmWrites true
# Initialize project config
aimagicx config init
# Show config paths
aimagicx config path
# Reset to defaults
aimagicx config resetSemantic Search Index
# Build vector index
aimagicx index build
# Check index status
aimagicx index status
# Search codebase
aimagicx index search "authentication logic"Shell Completions
aimagicx completion bash >> ~/.bashrc
# Or
aimagicx completion bash > /etc/bash_completion.d/aimagicxmkdir -p ~/.zsh/completions
aimagicx completion zsh > ~/.zsh/completions/_aimagicx
# Add to ~/.zshrc:
# fpath=(~/.zsh/completions $fpath)
# autoload -Uz compinit && compinitmkdir -p ~/.config/fish/completions
aimagicx completion fish > ~/.config/fish/completions/aimagicx.fishOther Commands
# Check API quota/usage
aimagicx usage
# Run diagnostics
aimagicx doctor
# Start server for IDE extensions
aimagicx serve
# Check for updates
aimagicx updateIn-Chat Commands
Type / to open the command palette:
| Command | Description |
|---|---|
/new-session | Start new session |
/session-list | List sessions |
/compact | Summarize conversation to reduce context |
/switch-model | Switch model |
/provider-connect | Connect a provider |
/index-build | Build semantic search index |
/memories | List saved memories |
/commit | Generate AI commit message |
/diff | Show git status/diff |
/undo | Undo last file change |
/redo | Redo last undone change |
/history | Show recent file changes |
/tools | Open Tool Manager |
/checkpoint | Create manual checkpoint |
/rewind | Rewind to last checkpoint |
/spawn | Spawn a background task |
/tasks | List background tasks |
/mcp-status | Show MCP server status |
/approval-mode | Cycle approval mode |
/quota | Show API quota/balance |
/help | Show keyboard shortcuts |
/quit | Exit chat |
Configuration
Config Locations
| Type | Location |
|---|---|
| Global config | ~/.aimagicx/config.json |
| Project config | .aimagicx/config.json |
| Credentials | ~/.aimagicx/credentials.d/ |
| Sessions | ~/.aimagicx/sessions/ |
| Memories | ~/.aimagicx/memory/ |
| Vector Index | .aimagicx/index/ |
| Custom Commands | ~/.aimagicx/commands.json |
| Custom Agents | ~/.aimagicx/agents.json |
| MCP Servers | ~/.aimagicx/mcp.json |
| LSP Servers | ~/.aimagicx/lsp.json |
| Checkpoints | .aimagicx/checkpoints/ |
| Context Files | AI_MAGICX.md |
| Ignore Patterns | .aimagicxignore |
Config Options
{
"defaultModel": "claude-sonnet-4-20250514",
"maxTokens": 16384,
"maxToolIterations": 10,
"autoConfirmWrites": false,
"showTokenUsage": true,
"contextThreshold": 0.9,
"autoCompactEnabled": true,
"useVectorIndex": true,
"maxContextChunks": 10,
"maxContextTokens": 8000,
"minContextScore": 0.15,
"favoriteModels": ["gpt-4o", "claude-sonnet-4-20250514"],
"disabledTools": [],
"approvalMode": "auto"
}| Option | Type | Default | Description |
|---|---|---|---|
defaultModel | string | - | Default model to use |
maxTokens | number | 16384 | Maximum tokens per request |
maxToolIterations | number | 10 | Max tool calls per response |
autoConfirmWrites | boolean | false | Skip file operation confirmations |
contextThreshold | number | 0.9 | Auto-compact threshold (0-1) |
useVectorIndex | boolean | true | Enable semantic code search |
approvalMode | string | "auto" | Default: read-only, auto, or full |
Supported Providers
| Provider | Protocol | Default Model | Auth |
|---|---|---|---|
| Anthropic | anthropic | claude-sonnet-4-5-20250929 | API Key |
| OpenAI | openai | gpt-4o-mini | API Key |
| GitHub Copilot | openai | gpt-4o | OAuth |
| OpenRouter | openai | openai/gpt-4o-mini | API Key |
| Groq | openai | moonshotai/kimi-k2 | API Key |
| AI Magicx | aimagicx | openai/gpt-oss-120b | API Key |
Adding Custom Providers
aimagicx provider add ollama \
--endpoint http://localhost:11434/v1 \
--protocol openai \
--model llama3.2Agent Tools
| Tool | Description |
|---|---|
read | Read file contents with line numbers |
write | Create new files |
edit | Modify existing files |
apply_patch | Apply unified diff patches |
glob | Find files by pattern |
grep | Search file contents with regex |
bash | Execute shell commands |
list_directory | List directory contents |
web_search | Search the web |
web_fetch | Fetch and analyze web pages |
vector_search | Semantic code search |
vision | Analyze images |
save_memory | Save persistent memories |
lsp_goto_definition | Navigate to symbol definition |
lsp_find_references | Find all references |
lsp_hover | Get type info and docs |
lsp_diagnostics | Get file errors/warnings |
todos | Track multi-step tasks |
spawn_agent | Spawn specialized subagents |
Tool Modes
- Agent Mode (default) - Full access to all tools
- Review Mode - Collects changes for batch review
- Plan Mode - Read-only tools for exploration
Toggle with Shift+Tab.
Approval Modes
| Mode | Description | Use Case |
|---|---|---|
read-only | Only exploration tools | Safe exploration |
auto | Confirm file changes and shell commands | Normal development |
full | Auto-approve all operations | Trusted automation |
# Change via CLI
aimagicx chat -a read-only
aimagicx chat --yolo # Alias for -a full
# Or press Tab to cycle modes during chatBackground Tasks
Spawn parallel agents to work concurrently:
# In chat
/spawn Run all tests and fix any failures
/spawn Generate API documentation
# Monitor
/tasks
# Kill a task
/task-kill <id>Task Status
| Status | Icon | Description |
|---|---|---|
| pending | ⏳ | Waiting to start |
| running | 🔄 | Actively executing |
| completed | ✅ | Finished successfully |
| failed | ❌ | Encountered error |
| cancelled | ⏹️ | Manually stopped |
Context Files (AI_MAGICX.md)
Create AI_MAGICX.md files to provide persistent context:
# Project: My App
## Architecture
- React frontend with TypeScript
- Express backend with PostgreSQL
## Conventions
- Use functional components with hooks
- All API responses follow { data, error, meta } format
## Do NOT modify
- src/legacy/ (deprecated)
@docs/api-reference.mdUse @path/to/file.md to import content from other files.
Memory System
Save important information that persists across sessions:
# In chat, use # prefix
#project-context This is a React app using TypeScript...
# Or type # to open the memory pickerMemories are stored as markdown files in ~/.aimagicx/memory/ (global) or .aimagicx/memory/ (project).
Custom Commands
Create custom slash commands in ~/.aimagicx/commands.json:
{
"commands": [
{
"id": "review",
"name": "Code Review",
"description": "Review current file",
"type": "prompt",
"content": "Review this code for bugs and security issues:\n\n{{input}}"
},
{
"id": "git-log",
"name": "Git Log",
"type": "bash",
"content": "git log --oneline -10",
"showOutput": true
}
]
}Custom Agents
Define specialized agents in ~/.aimagicx/agents.json:
{
"agents": [
{
"id": "reviewer",
"name": "Code Reviewer",
"icon": "🔍",
"systemPrompt": "You are an expert code reviewer...",
"model": "claude-sonnet-4-20250514",
"includeContext": true
}
]
}MCP Integration
Configure MCP servers in ~/.aimagicx/mcp.json:
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "your-token" }
}
}
}Use /mcp-status, /mcp-connect, /mcp-disconnect to manage.
LSP Integration
Configure LSP servers in ~/.aimagicx/lsp.json:
{
"servers": [
{
"name": "typescript",
"languages": [".ts", ".tsx", ".js", ".jsx"],
"command": "typescript-language-server",
"args": ["--stdio"],
"enabled": true
}
],
"autoDetect": true,
"autoStart": true
}Default LSP Servers
| Language | Server | Extensions |
|---|---|---|
| TypeScript/JS | typescript-language-server | .ts, .tsx, .js, .jsx |
| Python | pylsp | .py |
| Go | gopls | .go |
| Rust | rust-analyzer | .rs |
Custom Ignore File
Control which files AI Magicx ignores in .aimagicxignore:
# Large data files
*.csv
data/
# Sensitive files
.env*
secrets/
# Generated files
dist/
build/IDE Extensions (Server Mode)
AI Magicx runs as a JSON-RPC server for IDE integration:
aimagicx serveProtocol
Uses JSON-RPC 2.0 over stdio:
| Method | Description |
|---|---|
initialize | Initialize with project path |
chat | Send message, receive streaming response |
tool/confirm | Confirm or deny tool execution |
session/list | List available sessions |
abort | Cancel current operation |
shutdown | Gracefully shutdown |
Security
File Access
- Use
allowedReadRootsto restrict file access - Write operations require confirmation (unless
autoConfirmWrites: true) - Dangerous bash commands are blocked
Credentials
- API keys stored with restricted permissions (0600)
- Keys never logged or displayed in full
- Environment variable fallback:
AI_MAGICX_API_KEY
Blocked Commands
rm -rf /and system path deletionsshutdown,reboot,halt- Fork bombs
- Device file writes
Environment Variables
| Variable | Description |
|---|---|
AI_MAGICX_API_KEY | Default API key (fallback) |
AI_MAGICX_CONFIG_DIR | Custom config directory |
NO_COLOR | Disable colored output |
Telemetry
AI Magicx collects anonymous usage data (optional):
Collected: CLI version, session duration, tool execution stats, feature usage
NOT collected: File paths, code content, prompts, API keys, PII
# Opt out
aimagicx config set telemetryEnabled falseTroubleshooting
Run Diagnostics
aimagicx doctorCommon Issues
"Not authenticated"
aimagicx auth login --provider <provider-name>"Model not found"
- Verify model name matches provider's naming
- Check
aimagicx provider presetsfor defaults
High context usage
/compact
# Or
aimagicx session compact <session-id>GitHub Copilot auth issues
- Tokens expire quickly (~30 min)
- Reconnect with
Ctrl+O
Best Practices
Start in Read-Only Mode
Use aimagicx chat -a read-only for safe exploration of unfamiliar code.
Use AI_MAGICX.md for Context
Create a AI_MAGICX.md in your project root with architecture and conventions.
Build the Vector Index
Run aimagicx index build for large codebases to enable semantic search.
Use Sessions for Complex Tasks
Resume conversations with aimagicx chat -r <session-id> to maintain context.
Leverage Checkpoints
Use /checkpoint before risky changes, /rewind or Esc Esc to rollback.