mahabali
v1.0.33
Published
Mahabali AI multi-LLM assistant CLI
Maintainers
Readme
Mahabali CLI
Mahabali is a powerful AI-powered developer CLI that brings multi-LLM intelligence directly into your workflow. Ask questions about your codebase, generate AI-powered patches, and manage code snapshots - all from your terminal.
Features
- Multi-LLM Support - Choose between GPT, Claude, Grok, and Gemini
- Smart Code Understanding - AI analyzes your entire codebase for context-aware responses
- Safe Patch Application - Patches are tested in isolation before applying
- Version Snapshots - Automatic backups before any AI-generated changes
- Git-Aware - Respects
.gitignoreand integrates with your repository
Quick Start
1. Install
npm install -g mahabali2. Login
mahabali loginEnter your email and password when prompted. Your credentials are securely stored in ~/.mahabali/config.json.
3. Link Your Project
Navigate to your project directory and run:
cd /path/to/your/project
mahabali linkSelect an existing project or create a new one, then choose your preferred AI model.
4. Sync Your Codebase
mahabali syncThis uploads your code to Mahabali's backend where it's indexed for AI queries.
5. Start Using AI
# Ask questions about your code
mahabali ask "How does the authentication flow work?"
# Generate and apply AI-powered code changes
mahabali apply "Add input validation to the user registration form"Commands
Authentication
| Command | Description |
|---------|-------------|
| mahabali login | Authenticate with email/password |
| mahabali login --token <jwt> | Authenticate with a JWT token |
| mahabali logout | Clear stored credentials |
Project Management
| Command | Description |
|---------|-------------|
| mahabali link | Link current directory to a Mahabali project |
| mahabali status | Show project info, sync status, and pending changes |
| mahabali sync | Upload code changes to Mahabali backend |
AI Interaction
| Command | Description |
|---------|-------------|
| mahabali ask "<query>" | Ask AI about your codebase |
| mahabali ask "<query>" --model claude | Use a specific model (gpt, claude, grok, gemini) |
| mahabali apply "<instruction>" | Generate and apply AI code changes |
| mahabali apply "<instruction>" --model grok | Use a specific model for patch generation |
Model & Versions
| Command | Description |
|---------|-------------|
| mahabali model set <alias> | Set default model (gpt, claude, grok, gemini) |
| mahabali versions --list | List available snapshots |
| mahabali versions --save | Manually save a snapshot |
| mahabali versions --revert <id> | Revert to a previous snapshot |
| mahabali undo | Revert to the most recent snapshot |
Configuration
Global Config (~/.mahabali/config.json)
{
"token": "your-jwt-token",
"userId": "user-123",
"email": "[email protected]",
"baseUrl": "https://api.mahabali.ai"
}Project Config (.mahabali/project.json)
Created automatically when you run mahabali link:
{
"projectId": "proj-123",
"linkedAt": "2025-01-01T00:00:00.000Z",
"preferredModel": "gpt",
"lastSyncHash": "abc123"
}Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| MAHABALI_BASE_URL | Backend API URL | https://api.mahabali.ai |
| MAHABALI_HTTP_TIMEOUT_MS | HTTP request timeout | 30000 |
| MAHABALI_DEBUG | Enable verbose logging | 0 |
| MAHABALI_INSECURE_TLS | Skip TLS verification (dev only) | 0 |
Examples
Ask AI About Your Code
# Understand complex logic
mahabali ask "Explain what the processPayment function does"
# Find specific patterns
mahabali ask "Where are database connections handled?"
# Get suggestions
mahabali ask "How can I improve error handling in the API routes?"Apply AI-Generated Changes
# Add new features
mahabali apply "Add a rate limiter middleware to all API routes"
# Refactor code
mahabali apply "Convert all callback functions to async/await"
# Fix issues
mahabali apply "Add null checks to prevent undefined errors in utils.js"The apply command:
- Generates a patch based on your instruction
- Shows a preview of the changes
- Applies the patch in an isolated workspace
- Runs lint and tests (if available)
- Shows a diff for final approval
- Creates a snapshot backup before applying
Workflow Tips
Using Different AI Models
# Set a default model for all commands
mahabali model set claude
# Override for a single command
mahabali ask "Explain this code" --model grokManaging Snapshots
# Before major changes, save a snapshot
mahabali versions --save
# See all available snapshots
mahabali versions --list
# Revert if something goes wrong
mahabali undo
# or
mahabali versions --revert snap-abc123Ignoring Files
Create a .mahabaliignore file (same syntax as .gitignore) to exclude files from sync:
# .mahabaliignore
node_modules/
*.log
.env
dist/Troubleshooting
"getaddrinfo ENOTFOUND api.mahabali.ai"
The CLI cannot reach the backend. Check your internet connection or set a custom backend URL:
mahabali login --base-url http://localhost:5000"Project is not linked"
Run mahabali link in your project directory to connect it to Mahabali.
"Failed to apply patch"
The AI-generated patch may not apply cleanly. Try:
- Running
mahabali syncto update the backend with your latest code - Providing more specific instructions in your
applycommand - Manually reviewing the patch and making adjustments
Enable Debug Logging
export MAHABALI_DEBUG=1
mahabali sync
# Check logs at ~/.mahabali/logs/cli.logRequirements
- Node.js 18+
- npm 9+
- Git (for patch application)
License
MIT
