Coding·4 min read

How to run Codestral locally for offline coding assistance

Codestral is Mistral AI's code-specialised model with support for 80+ programming languages. This guide covers running it locally via Ollama for fast, offline coding assistance.

Why Codestral for local coding

Codestral is trained specifically for code tasks — completion, debugging, and explanation — across 80+ programming languages including Python, JavaScript, TypeScript, Rust, Go, and C++. It outperforms general-purpose models of similar size on coding benchmarks.

Running it locally means zero latency after the first token, no internet required, and no API costs. This makes it excellent as an IDE completion backend where low latency is critical.

Install and run with Ollama

Ensure Ollama is installed (see the Ollama guide). Then run: `ollama pull codestral`. The model is around 12 GB at Q4_K_M and requires at least 16 GB RAM or 12 GB VRAM.

Start a coding session: `ollama run codestral 'Complete this Python function: def binary_search(arr, target):'`. Codestral is optimised for fill-in-the-middle (FIM) prompts — it excels at completing partial code rather than generating from scratch.

Use Codestral as a Continue backend

Continue is an open-source VS Code/JetBrains extension that uses local models for completions. Install Continue from the VS Code marketplace, then add Codestral as a completion model in `.continue/config.json`: set `provider` to `ollama` and `model` to `codestral`.

With this setup, you get Copilot-style inline completions powered entirely by your local machine. The first completion per session may take a few seconds to warm up; subsequent ones are near-instant.

Tips for best coding results

Codestral responds well to explicit language and framework hints. Start your prompt with the language: 'TypeScript: ...' or include a file extension comment: `// file: auth.ts`. This activates the model's language-specific training.

For debugging, paste the function and the error message together: 'This function throws a TypeError. Here is the code and the error stack trace: [...]'. Codestral will diagnose the issue and suggest a fix with high accuracy.