Skip to content

Latest commit

 

History

History
274 lines (202 loc) · 6.15 KB

File metadata and controls

274 lines (202 loc) · 6.15 KB

🛠️ Commands Reference

Complete reference for all Codestral CLI commands and tools.

📝 Basic Commands

Interactive Mode Commands

These work when you're in interactive mode (codestral-cli with no arguments):

Command Description Example
help Show help information help
clear Clear conversation history clear
config Show current configuration config
exit Exit the application exit
quit Exit the application quit
bye Exit the application bye

Command Line Arguments

These work when starting the CLI:

Argument Description Example
prompt Send a single prompt codestral-cli "Write Python code"
--max-tokens INT Limit response length codestral-cli "Long prompt" --max-tokens 500
--version Show version information codestral-cli --version
--help Show help message codestral-cli --help

🔧 Developer Tools

All tool commands start with / and can be used in interactive mode:

Code Analysis Tools

/explain <command>

Explains shell commands, code snippets, or technical concepts.

/explain ls -la
/explain "grep -r pattern ."
/explain "docker run -it ubuntu"

/review <file>

Performs code review on the specified file.

/review app.py
/review src/main.js
/review ../config.yaml

/analyze <file>

Analyzes code structure and provides insights.

/analyze myproject.py
/analyze package.json

Git & Version Control Tools

/commit

Generates git commit messages based on current changes.

/commit
# Analyzes git diff and suggests commit messages

/git <command>

General git help and command suggestions.

/git "merge conflicts"
/git "rebase vs merge"

Debugging Tools

/debug <error>

Helps debug errors and provides solutions.

/debug "ModuleNotFoundError: No module named 'requests'"
/debug "TypeError: unsupported operand type(s)"
/debug "CORS error in browser"

Documentation Tools

/docs <code>

Generates documentation for code snippets.

/docs "def calculate_average(numbers): return sum(numbers) / len(numbers)"

/test <file>

Generates unit tests for code files.

/test utils.py
/test components/Button.js

Task Automation Tools

/suggest <task>

Suggests commands or approaches for development tasks.

/suggest "deploy Flask app to production"
/suggest "optimize database queries"
/suggest "set up CI/CD pipeline"

💬 Conversation Flow Examples

Basic Conversation

👤 You: How do I create a REST API in Python?

🤖 Codestral: Here's how you can create a REST API in Python using Flask:

```python
from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route('/api/data', methods=['GET'])
def get_data():
    return jsonify({'message': 'Hello, World!'})

if __name__ == '__main__':
    app.run(debug=True)

👤 You: /review api.py

🤖 Codestral: [Reviews your API file and provides feedback...]


### Developer Workflow
```bash
👤 You: /explain "docker-compose up -d"

🤖 Codestral: This command starts Docker containers defined in docker-compose.yml:
- `docker-compose`: Docker Compose command-line tool
- `up`: Start services
- `-d`: Detached mode (run in background)

👤 You: /debug "Port 5000 is already in use"

🤖 Codestral: This error occurs when another process is using port 5000. Solutions:
1. Stop the process: `lsof -ti:5000 | xargs kill`
2. Use a different port in your app
3. Find what's using the port: `lsof -i :5000`

👤 You: /commit

🤖 Codestral: [Analyzes git changes and suggests commit message...]

⌨️ Keyboard Shortcuts

Shortcut Action
Ctrl+C Exit gracefully
Ctrl+D Exit (EOF)
↑/↓ Command history (in terminal)
Tab Auto-completion (in terminal)

🎯 Best Practices

Effective Prompting

# ✅ Good - Specific and clear
"Write a Python function that validates email addresses using regex"

# ❌ Less effective - Too vague  
"help with email"

# ✅ Good - Context provided
"How do I fix this React error: 'Cannot read property of undefined'"

# ❌ Less effective - No context
"React error"

Using Developer Tools

# ✅ Review before committing
/review changed_files.py
/commit

# ✅ Debug with full error message
/debug "ValueError: invalid literal for int() with base 10: 'abc'"

# ✅ Explain unfamiliar commands
/explain "awk '{print $2}' file.txt | sort | uniq -c"

Conversation Management

# Start fresh for different topics
clear

# Check current settings
config

# Get help when needed
help
/help

🔍 Advanced Usage

Custom Prompts for Code Generation

"Create a Python class for a simple cache with TTL (time-to-live) functionality"

"Write a bash script that backs up a directory to S3 with error handling"

"Generate a React component with TypeScript for a searchable dropdown"

Code Analysis Workflows

/analyze main.py          # Get overview
/review main.py           # Detailed review  
/test main.py             # Generate tests
/docs main.py             # Create documentation

Debugging Workflows

/debug "specific error message"
/explain "complex command or concept"
/suggest "alternative approach"

📊 Output Examples

Streaming Response

Responses appear token-by-token in real-time:

👤 You: Explain async programming

🤖 Codestral: Async programming allows...
[continues streaming live]

Rich Formatting

Responses include:

  • Syntax highlighting for code blocks
  • Markdown formatting for headers, lists, links
  • Progress indicators showing tokens and timing
  • Error messages with helpful suggestions

Tool Responses

Developer tools provide structured output:

/explain ls -la

📋 Command Breakdown:
• ls: List directory contents
• -l: Long format (permissions, size, date)
• -a: Include hidden files (starting with .)

🔍 Example Output:
drwxr-xr-x  5 user staff  160 Oct 13 10:30 .
-rw-r--r--  1 user staff 1024 Oct 13 09:15 file.txt