A modern GitHub Copilot-style terminal interface for Codestral - Mistral's code generation AI. Real-time streaming responses with beautiful terminal UI and powerful developer tools.
- 💬 Interactive Chat - GitHub Copilot-like terminal experience
- ⚡ Real-time Streaming - See responses as they generate, token by token
- 🎨 Rich Terminal UI - Beautiful formatting with live updates and markdown support
- 🤖 AI Function Calling - Native Mistral function calling with automatic tool selection
- 🛠️ Smart Developer Tools - AI-powered code review, debugging, analysis with 11+ tools
- 🚀 Async Architecture - Non-blocking, responsive interface
- 🔧 Easy Setup - One-command installation with automatic SSL handling
git clone https://github.com/momominds/codestral-cli.git
cd codestral-cli
./install.shGet your API key from Mistral Console:
export MISTRAL_API_KEY="your-api-key"# Interactive mode
codestral-cli
# Single prompt
codestral-cli "Write a Python function to sort a list"
# With options
codestral-cli "Explain async Python" --max-tokens 500$ codestral-cli
🚀 Codestral CLI (Function Calling Mode)
Model: codestral-latest • Tools: 11 available • AI Selection: ON
👤 You: Can you review my main.py file for security issues?
🤖 Codestral: I'll analyze your file for security concerns...
[🔧 AI automatically calls: review(file_path="main.py", focus="security")]
✅ Security Review Complete:
╭─ Code Review Results ─────────────────────────────────────────╮
│ • No SQL injection vulnerabilities detected │
│ • Input validation properly implemented │
│ • Authentication mechanisms secure │
│ • Recommendation: Consider adding rate limiting │
╰───────────────────────────────── Tokens: 120 • Time: 2.1s ──╯
👤 You: Debug this error: ImportError: No module named 'requests'
🤖 Codestral: Let me help debug that import error...
[🔧 AI automatically calls: debug(error_message="ImportError: No module named 'requests'")]
✅ Debug Analysis:
╭─ Error Diagnosis & Solution ──────────────────────────────────╮
│ Issue: Missing dependency - requests module not installed │
│ Solution: pip install requests │
│ Prevention: Add requests to requirements.txt │
╰───────────────────────────────── Tokens: 85 • Time: 1.5s ───╯
👤 You: What's the weather like?
🤖 Codestral: I don't have access to weather data, but I can help with coding tasks!
Try asking me to review code, debug errors, or explain commands.
👤 You: exit
👋 Goodbye!Codestral CLI uses Mistral AI's native function calling to intelligently select and execute the right tools for your requests. Just speak naturally - the AI automatically chooses what to do!
- Natural Language: "Review my code for bugs"
- AI Selection: Codestral automatically calls
review(file="code.py", focus="bugs") - Execution: Tool runs and returns formatted results
- Response: See actionable insights immediately
| Tool | Purpose | Example Trigger |
|---|---|---|
analyze |
Code structure & complexity analysis | "Analyze main.py complexity" |
review |
Detailed code review & feedback | "Review this file for security issues" |
test |
Generate comprehensive unit tests | "Generate tests for utils.py" |
docs |
Create documentation | "Document this function" |
debug |
Analyze & fix errors | "Debug: ImportError: No module named 'x'" |
explain |
Explain shell commands | "Explain 'docker run -it ubuntu'" |
suggest |
Suggest commands for tasks | "How do I deploy to AWS?" |
commit |
Generate commit messages | "Help me commit these changes" |
search |
Find code patterns | "Find all database queries" |
git |
Git workflow help | "Help with git merge conflicts" |
# Old way (still works)
/review main.py --focus security
# New AI way (preferred)
"Can you review main.py for security issues?"
# → AI automatically calls review(file_path="main.py", focus="security")export MISTRAL_API_KEY="your-key" # Required
export MISTRAL_MODEL="codestral-latest" # Optional
export MISTRAL_MAX_TOKENS=2000 # Optional{
"api_key": "your-key",
"model": "codestral-latest",
"max_tokens": 2000,
"temperature": 0.1
}codestral-cli [prompt] [options]
Arguments:
prompt Prompt to send (if not provided, enters interactive mode)
Options:
--max-tokens INT Maximum tokens in response
--version Show version information
--help Show help messageIf you get SSL certificate errors:
# Automatic fix
python3 fix_ssl.py
# Manual fix
pip3 install --upgrade certifi
# Temporary bypass (not recommended for production)
PYTHONHTTPSVERIFY=0 codestral-cli "test prompt"- API Key: Make sure
MISTRAL_API_KEYis set correctly - Dependencies: Run
pip3 install -r requirements.txt - Permissions: Run
chmod +x install.sh main.py fix_ssl.py
Complete documentation available in the docs/ directory:
- Quick Start Guide - Get up and running in 5 minutes
- Commands Reference - All available commands and tools
- Configuration Guide - Advanced configuration options
- Troubleshooting - Solutions for common issues
| Traditional CLI | Codestral CLI |
|---|---|
| Block and wait | ⚡ Stream live responses |
| Plain text output | 🎨 Rich markdown formatting |
| Single request/response | 💬 Conversational context |
| No developer tools | 🛠️ Built-in code tools |
| Basic error handling | 🔧 Comprehensive troubleshooting |
- Async Streaming: Real-time token-by-token responses using
aiohttp - Rich Terminal UI: Beautiful formatting with
richlibrary - Modular Tools: Extensible developer tool system
- Smart Error Handling: SSL troubleshooting and helpful error messages
- Clean Configuration: Multiple config methods with priority system
We welcome contributions! Please see:
- CONTRIBUTING.md - Contribution guidelines
- CODE_OF_CONDUCT.md - Community standards
- Issues - Bug reports and feature requests
This project is licensed under the MIT License - see the LICENSE file for details.
- Mistral AI for the excellent Codestral model
- Rich for beautiful terminal UI
- The Python async ecosystem (
aiohttp,asyncio) - The open-source community for inspiration and feedback
- GitHub Repository: https://github.com/momominds/codestral-cli
- Mistral AI: https://mistral.ai/
- Codestral API: https://docs.mistral.ai/capabilities/code_generation/
- Get API Key: https://console.mistral.ai/
Built with ❤️ for developers who love beautiful, responsive terminal experiences.
export OPENAI_API_BASE="http://localhost:8080/v1"
## 🛠️ Built-in Tools
The CLI includes powerful developer tools accessible via `/command`:
- `/explain <command>` - Explain shell commands
- `/suggest <task>` - Suggest commands for tasks
- `/review <file>` - Code review and feedback
- `/analyze <file>` - Analyze code structure
- `/commit` - Generate git commit messages
- `/debug <error>` - Help debug errors
- `/test <file>` - Generate unit tests
- `/docs <code>` - Generate documentation
## 📁 Project Structure
codestral-cli/ ├── main.py # CLI entry point ├── codestral_cli/ # Main package │ ├── core/ # Core functionality │ │ ├── client.py # API client │ │ ├── config.py # Configuration │ │ └── cli.py # CLI interface │ ├── tools/ # Developer tools │ ├── ui/ # User interface │ └── utils/ # Utilities ├── proxy/ # OpenAI-compatible proxy │ ├── server.py # Async server │ └── simple_server.py # Simple HTTP server ├── examples/ # Usage examples └── tests/ # Test suite
## ⚙️ Configuration
### Environment Variables
- `MISTRAL_API_KEY` - Your Codestral API key (required)
- `MISTRAL_MODEL` - Model to use (default: codestral-latest)
- `MISTRAL_BASE_URL` - API base URL (default: https://codestral.mistral.ai/v1)
### Config File
Create `~/.codestral/config.json`:
```json
{
"model": "codestral-latest",
"max_tokens": 2000,
"temperature": 0.1,
"show_loader": true
}
# Start proxy
python3 proxy/server.py &
# Configure VS Code to use local endpoint
# Settings → OpenAI: Base URL → http://localhost:8080/v1curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Write a Python hello world"}]}'We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see LICENSE for details.
- Mistral AI for the excellent Codestral model
- OpenAI for the API standard enabling easy integration
- The open-source community for inspiration and tools
Built for developers, by developers ❤️