@code-q/code-q
v0.0.32
Published
India-first SaaS AI coding agent CLI for developers.
Downloads
19
Readme
code-q CLI
India-first SaaS AI coding agent for the terminal. OpenAI-compatible with intelligent file editing, shell automation, and MCP integrations. Built for developers in India (and beyond) with fast onboarding, local-friendly pricing, and secure authentication.
Features
- 🇮🇳 India‑first SaaS: Local-friendly onboarding, pricing, and support
- 🤖 Conversational AI: Natural language interface
- 📝 Smart File Operations: AI automatically uses tools to view, create, and edit files
- ⚡ Bash Integration: Execute shell commands through natural conversation
- 🔧 Automatic Tool Selection: AI intelligently chooses the right tools for your requests
- 🚀 Morph Fast Apply: Optional high-speed code editing at 4,500+ tokens/sec with 98% accuracy
- 🔌 MCP Tools: Extend capabilities with Model Context Protocol servers (Linear, GitHub, etc.)
- 💬 Interactive UI: Beautiful terminal interface built with Ink
- 🌍 Global Installation: Install and use anywhere with
npm i -g code-q
Installation
Prerequisites
- Node.js 16+
- API key for your chosen OpenAI-compatible provider (e.g., X.AI Grok)
- (Optional, Recommended) Morph API key for Fast Apply editing
Primary install options
- npx (no install):
npx @code-q/code-q@latest --no-tools --prompt "hello"- npm global:
npm install -g @code-q/code-q- Docker:
docker run --rm -it -v "$PWD:/work" -w /work ghcr.io/<org>/code-q code-q --no-tools -p "hello"Local Development
git clone <repository>
cd code-q-cli
npm install
npm run build
npm linkSetup
Get an API key from your provider (e.g., X.AI)
Set up your API key (choose one method):
Method 1: Environment Variable
export MUZZIK_API_KEY=your_api_key_here # GROK_API_KEY also supportedMethod 2: .env File
cp .env.example .env
# Edit .env and add your API keyMethod 3: Command Line Flag
code-q --api-key your_api_key_hereMethod 4: User Settings File
Create ~/.muzzik/user-settings.json (legacy ~/.grok/user-settings.json also supported):
{
"apiKey": "your_api_key_here"
}(Optional, Recommended) Get your Morph API key from Morph Dashboard
Set up your Morph API key for Fast Apply editing (choose one method):
Method 1: Environment Variable
export MORPH_API_KEY=your_morph_api_key_hereMethod 2: .env File
# Add to your .env file
MORPH_API_KEY=your_morph_api_key_hereCustom Base URL (Optional)
By default, the CLI uses https://api.x.ai/v1. You can configure a custom endpoint if needed (choose one method):
Method 1: Environment Variable
export MUZZIK_BASE_URL=https://your-custom-endpoint.com/v1 # GROK_BASE_URL also supportedMethod 2: Command Line Flag
code-q --api-key your_api_key_here --base-url https://your-custom-endpoint.com/v1Method 3: User Settings File
Add to ~/.muzzik/user-settings.json:
{
"apiKey": "your_api_key_here",
"baseURL": "https://your-custom-endpoint.com/v1"
}Configuration Files
code-q uses two types of configuration files to manage settings:
User-Level Settings (~/.muzzik/user-settings.json)
This file stores global settings that apply across all projects. These settings rarely change and include:
- API Key: Your API key
- Base URL: Custom API endpoint (if needed)
- Default Model: Your preferred model (e.g.,
grok-4-latest) - Available Models: List of models you can use
Example:
{
"apiKey": "your_api_key_here",
"baseURL": "https://api.x.ai/v1",
"defaultModel": "grok-4-latest",
"models": [
"grok-4-latest",
"grok-3-latest",
"grok-3-fast",
"grok-3-mini-fast"
]
}Project-Level Settings (.muzzik/settings.json)
This file stores project-specific settings in your current working directory. It includes:
- Current Model: The model currently in use for this project
- MCP Servers: Model Context Protocol server configurations
Example:
{
"model": "grok-3-fast",
"mcpServers": {
"linear": {
"name": "linear",
"transport": "stdio",
"command": "npx",
"args": ["@linear/mcp-server"]
}
}
}How It Works
- Global Defaults: User-level settings provide your default preferences
- Project Override: Project-level settings override defaults for specific projects
- Directory-Specific: When you change directories, project settings are loaded automatically
- Fallback Logic: Project model → User default model → System default (
grok-4-latest)
This means you can have different models for different projects while maintaining consistent global settings like your API key.
Using Other API Providers
Important: code-q uses OpenAI-compatible APIs. You can use any provider that implements the OpenAI chat completions standard. The CLI will try to infer the correct base URL from your API key if none is provided (e.g., sk- → OpenAI, or-v1- → OpenRouter). You can always override with --base-url.
Popular Providers:
- X.AI (Grok):
https://api.x.ai/v1(default) - OpenAI:
https://api.openai.com/v1 - OpenRouter:
https://openrouter.ai/api/v1 - Groq:
https://api.groq.com/openai/v1
Example with OpenRouter:
{
"apiKey": "your_openrouter_key",
"baseURL": "https://openrouter.ai/api/v1",
"defaultModel": "anthropic/claude-3.5-sonnet",
"models": [
"anthropic/claude-3.5-sonnet",
"openai/gpt-4o",
"meta-llama/llama-3.1-70b-instruct"
]
}Usage
Interactive Mode
Start the conversational AI assistant:
code-qOr specify a working directory:
code-q -d /path/to/projectHeadless Mode
Process a single prompt and exit (useful for scripting and automation):
code-q --prompt "show me the package.json file"
code-q -p "create a new file called example.js with a hello world function"
code-q --prompt "run npm test and show me the results" --directory /path/to/project
code-q --prompt "complex task" --max-tool-rounds 50 # Limit tool usage for faster executionThis mode is particularly useful for:
- CI/CD pipelines: Automate code analysis and file operations
- Scripting: Integrate AI assistance into shell scripts
- Terminal benchmarks: Perfect for tools like Terminal Bench that need non-interactive execution
- Batch processing: Process multiple prompts programmatically
Tool Execution Control
By default, code-q allows up to 400 tool execution rounds to handle complex multi-step tasks. You can control this behavior:
# Limit tool rounds for faster execution on simple tasks
code-q --max-tool-rounds 10 --prompt "show me the current directory"
# Increase limit for very complex tasks (use with caution)
code-q --max-tool-rounds 1000 --prompt "comprehensive code refactoring"
# Works with all modes
code-q --max-tool-rounds 20 # Interactive mode
code-q git commit-and-push --max-tool-rounds 30 # Git commandsUse Cases:
- Fast responses: Lower limits (10-50) for simple queries
- Complex automation: Higher limits (500+) for comprehensive tasks
- Resource control: Prevent runaway executions in automated environments
Model Selection
You can specify which AI model to use with the --model parameter (supports GROK_MODEL environment variable):
Method 1: Command Line Flag
# Use Grok models
code-q --model grok-4-latest
code-q --model grok-3-latest
code-q --model grok-3-fast
# Use other models (with appropriate API endpoint)
code-q --model gemini-2.5-pro --base-url https://api-endpoint.com/v1
code-q --model claude-sonnet-4-20250514 --base-url https://api-endpoint.com/v1Method 2: Environment Variable
export GROK_MODEL=grok-4-latest
code-qMethod 3: User Settings File
Add to ~/.muzzik/user-settings.json:
{
"apiKey": "your_api_key_here",
"defaultModel": "grok-4-latest"
}Model Priority: --model flag > GROK_MODEL environment variable > user default model > system default (grok-4-latest)
Command Line Options
code-q [options]
Options:
-V, --version output the version number
-d, --directory <dir> set working directory
-k, --api-key <key> code-q API key (set MUZZIK_API_KEY; GROK_API_KEY supported)
-u, --base-url <url> API base URL (set MUZZIK_BASE_URL; GROK_BASE_URL supported)
-m, --model <model> AI model to use (supports GROK_MODEL env var)
-p, --prompt <prompt> process a single prompt and exit (headless mode)
--max-tool-rounds <rounds> maximum number of tool execution rounds (default: 400)
-h, --help display help for commandCustom Instructions
You can provide custom instructions by creating .muzzik/MUZZIK.md (preferred) or legacy .grok/GROK.md in your project directory:
mkdir .muzzikCreate .muzzik/MUZZIK.md with your custom instructions:
# Custom Instructions for code-q CLI
Always use TypeScript for any new code files.
When creating React components, use functional components with hooks.
Prefer const assertions and explicit typing over inference where it improves clarity.
Always add JSDoc comments for public functions and interfaces.
Follow the existing code style and patterns in this project.code-q will automatically load and follow these instructions when working in your project directory. The custom instructions are added to the system prompt and take priority over default behavior.
Morph Fast Apply (Optional)
code-q supports Morph's Fast Apply model for high-speed code editing at 4,500+ tokens/sec with 98% accuracy. This is an optional feature that provides lightning-fast file editing capabilities.
Setup: Configure your Morph API key following the setup instructions above.
How It Works
When MORPH_API_KEY is configured:
edit_filetool becomes available alongside the standardstr_replace_editor- Optimized for complex edits: Use for multi-line changes, refactoring, and large modifications
- Intelligent editing: Uses abbreviated edit format with
// ... existing code ...comments - Fallback support: Standard tools remain available if Morph is unavailable
When to use each tool:
edit_file(Morph): Complex edits, refactoring, multi-line changesstr_replace_editor: Simple text replacements, single-line edits
Example Usage
With Morph Fast Apply configured, you can request complex code changes:
code-q --prompt "refactor this function to use async/await and add error handling"
code-q -p "convert this class to TypeScript and add proper type annotations"The AI will automatically choose between edit_file (Morph) for complex changes or str_replace_editor for simple replacements.
MCP Tools
code-q supports MCP (Model Context Protocol) servers, allowing you to extend the AI assistant with additional tools and capabilities.
Adding MCP Tools
Add a custom MCP server:
# Add an stdio-based MCP server
code-q mcp add my-server --transport stdio --command "node" --args server.js
# Add an HTTP-based MCP server
code-q mcp add my-server --transport http --url "http://localhost:3000"
# Add with environment variables
code-q mcp add my-server --transport stdio --command "python" --args "-m" "my_mcp_server" --env "API_KEY=your_key"Add from JSON configuration:
code-q mcp add-json my-server '{"command": "node", "args": ["server.js"], "env": {"API_KEY": "your_key"}}'Linear Integration Example
To add Linear MCP tools for project management:
# Add Linear MCP server
code-q mcp add linear --transport sse --url "https://mcp.linear.app/sse"This enables Linear tools like:
- Create and manage Linear issues
- Search and filter issues
- Update issue status and assignees
- Access team and project information
Managing MCP Servers
# List all configured servers
code-q mcp list
# Test server connection
code-q mcp test server-name
# Remove a server
code-q mcp remove server-nameAvailable Transport Types
- stdio: Run MCP server as a subprocess (most common)
- http: Connect to HTTP-based MCP server
- sse: Connect via Server-Sent Events
Development
# Install dependencies
npm install
# Development mode
npm run dev
# Build project
npm run build
# Run linter
npm run lint
# Type check
npm run typecheckArchitecture
- Agent: Core command processing and execution logic
- Tools: Text editor and bash tool implementations
- UI: Ink-based terminal interface components
- Types: TypeScript definitions for the entire system
License
MIT
Authentication (Supabase)
This CLI requires a Supabase-authenticated user. Configure environment variables (see env.example). If you sign in on code-q.in, device login flows and email password logins are supported in-terminal.
SUPABASE_URLSUPABASE_ANON_KEY
When you run code-q, if you are not authenticated, you will be prompted to log in with your email and password directly in the terminal. The session is securely stored in ~/.muzzik/user-settings.json and refreshed automatically.
You can verify by starting the CLI; if already logged in, no prompt will appear.
