How to code with AI offline
On a plane, on a train or somewhere with no Wi-Fi, you can still code with AI. The trick is running the model on your own computer and preparing before you go.
Most AI coding tools stop working the moment you lose your connection, because the AI runs on another company's servers, and that company receives and handles everything you send it. It doesn't have to be that way. If the model runs on your own computer, your code stays on your machine and you can write, edit and debug code with AI anywhere: on a flight, while travelling, or simply when you'd rather keep your work off the internet.
What works offline and what doesn't
| Works offline | Needs the internet |
|---|---|
| A local model running in Ollama, LM Studio or MLX (once downloaded) | Cloud models: Claude Code and Codex by default, Ollama's cloud models, GitHub Copilot's service, Cursor's AI |
| Editors such as VS Code, Zed, Xcode, Sublime Text, BBEdit and Neovim | Downloading models and editor updates |
| Git commits, branches and history | Pushing to GitHub or another remote |
| Building and running your project | Installing new packages (npm, pip) you haven't downloaded |
Step 1: Choose a local model runner
You need a tool that runs AI models on your machine. Three common free choices on a Mac:
- Ollama: a simple open-source model server. It also offers optional cloud models, which run on Ollama's servers and need the internet; set
OLLAMA_NO_CLOUD=1to keep it local-only. - LM Studio: a graphical app. LM Studio says it doesn't need the internet to work for chat and its local server.
- MLX (mlx-lm): Apple's open-source framework, used from the terminal.
See Ollama vs LM Studio vs MLX to pick one, and how to run a coding model locally for setup.
Step 2: Download a model before you leave
Models range from a few gigabytes to over 50 GB, so download them on a good connection. Choose one that fits your computer's memory: see the best open-source coding models and what computer you need. Run it once while online to check it works.
Step 3: Connect it to your editor
- VS Code: its documentation says bring-your-own-key local models work without a GitHub account, a Copilot plan or an internet connection. Ollama provides an official VS Code extension. Copilot's own inline suggestions still need its online service, and local models can't be used for inline suggestions.
- Zed: its agent and inline assistant can use Ollama, LM Studio, llama.cpp or any OpenAI-compatible server, and its edit predictions can use Ollama.
- Xcode: predictive code completion runs on your Mac (Apple silicon; download its model while online), and you can add a locally hosted model provider such as Ollama.
- JetBrains IDEs: Full Line Code Completion runs locally, and AI Assistant can use Ollama or LM Studio, although JetBrains says AI Assistant's agents can't use local models. Its separate Junie Local runs JetBrains' agent offline on high-end Macs (M5, 64 GB of memory).
- Open-source assistants: Cline (in VS Code and JetBrains) and Aider (in the terminal) both work with Ollama.
See the best offline code editors for Mac and AI IDEs that run locally for more.
Step 4: Prepare your project
- Install dependencies first. Run
npm installor your package manager while online. npm also has an offline mode for installing from its cache. - Commit as you go. Git works offline: commit locally and push when you're back online.
- Save documentation. Download any docs you rely on.
- Turn off what phones home. Some tools send telemetry or check for updates. VS Code, Zed, Cline and others let you turn these off in settings.
The limits of offline AI
Local models are smaller than the best cloud models, so they're strongest at focused tasks: writing a function, explaining code, fixing a specific bug. Big, multi-step changes are harder for them. Speed depends on your computer's memory and chip. Running a model also works a laptop hard and drains its battery. Plan the bigger jobs for when you're connected.
Offline AI coding with Nexus
Nexus is a native Mac app for building with AI. Its built-in MLX engine runs open models on your Mac, downloaded inside the app, and it can also use your Ollama models (choose a local one, not one of Ollama's cloud models, to stay offline). Your projects are folders on your Mac, with a live preview, diffs and restore points. With a local model, the AI work happens entirely on your Mac and your code stays there. You'll need the internet to download models, and Nexus may contact its licensing service to check your trial or licence (it never sends your code, projects or conversations). Claude Code by Anthropic and the Codex app by OpenAI, which you can switch to in the same chat, need an internet connection, and the code they work on is sent to Anthropic or OpenAI. Nexus will be a one-time purchase of $199 USD, with no Nexus subscription; it needs an Apple silicon Mac with macOS 12 or later (14 or later for local models and the Codex app, 13 or later for Claude Code). Connecting third-party AI services such as Claude Code or Codex is optional and at your own expense (see Nexus pricing). It's coming soon.
Frequently asked questions
Can AI coding assistants work completely offline?
Yes, if the AI model runs on your own computer. Tools such as Ollama, LM Studio and Apple's MLX run open models locally, and editors such as VS Code and Zed can use them. Claude Code and Codex use cloud models by default, which need the internet (both can be pointed at a local Ollama model), and Cursor's AI needs the internet even with a local model.
Does Cursor work offline?
Not for AI features. A reply on Cursor's forum says Cursor cannot work when totally offline, because its AI requests go through Cursor's servers.
What do I need to download before going offline?
The AI model itself (often several gigabytes), any packages your project needs, and documentation you might want. Model downloads and package installs need the internet; running the model doesn't.