---
slug: code
kind: recipe
status: partly-ran
sh: https://insidethemachine.ai/install/code.sh
ps1: https://insidethemachine.ai/install/code.ps1
json: https://insidethemachine.ai/install/code.json
page: https://insidethemachine.ai/do/code
---

# Install: A coding helper

An AI coding agent in your Terminal that reads your project, edits files and runs commands, with changes you can undo.

**Run status: Partly checked: some paths were run, the rest only checked against docs.** The under-32 GB path (Aider) was run end to end on an Apple M4 Mac with 16 GB on 2026-10-15. The OpenCode path is checked against the docs only.

**This script:** The wrapper scripts are generated from the site data. Every .sh passed bash -n and shellcheck and ran in plan mode on Linux (Debian 13). Every .ps1 passed the PowerShell parser and chat.ps1 ran in plan, verify and rollback mode under PowerShell 7 on Linux with Windows calls mocked. Not run on macOS or real Windows.

## One command

```bash
curl -fsSL https://insidethemachine.ai/install/code.sh | bash
```

Windows (PowerShell):

```powershell
irm https://insidethemachine.ai/install/code.ps1 | iex
```

Actions: `| bash -s -- plan` (print only), `verify`, `rollback --yes`. Env: ITM_RAM, ITM_MODEL. Read the script first: `curl -fsSL https://insidethemachine.ai/install/code.sh | less`.

Lines marked YOU RUN are not run by the script (servers, interactive apps, your own files). The script prints them at the end, in order.

## Model by memory (picked automatically)

| memory GB (at least) | ollama tag |
|---|---|
| 8 | qwen3.5:4b |
| 16 | ornith-1.5:9b |
| 24 | gemma4:12b |
| 32 | qwen3.8:27b |
| 48 | qwen3.8:27b |
| 64 | qwen3.8:27b |
| 96 | qwen3.8:27b |
| 128 | qwen3.8:27b |
| 192 | qwen3.8-flash-next:125b-a6b |
| 256 | qwen3.8-flash-next:125b-a6b |
| 512 | qwen3.8-flash-next:125b-a6b |

## Steps

### macOS and Linux (bash; brew lines are macOS only)

Install:

1. **Install Ollama**
   - run: `curl -fsSL https://ollama.com/install.sh | sh`
2. **Download a coding model**
   - run: `ollama pull $MODEL`
3. **Give the model a long memory**
   - YOU RUN (starts a server that keeps running; run it in its own window): `OLLAMA_CONTEXT_LENGTH=64000 ollama serve`
4. **Install OpenCode**
   - run: `curl -fsSL https://opencode.ai/install | bash`
5. **Start it in your project**
   - YOU RUN (needs your own file, folder or model name): `cd /path/to/your/project`
   - YOU RUN (interactive; run it yourself): `ollama launch opencode`

Verify:

- `ollama --version` → expect: a version number
- `ollama list | grep -F "${MODEL%%:*}"` → expect: your model is in the list
- `opencode --version` → expect: a version number

Rollback:

- run: `rm -rf ~/.opencode`
- run: `ollama rm $MODEL`

### Under 32 GB (Under 32 GB, the models that fit cannot use tools well, and OpenCode needs tools. So this path uses Aider, which does not need them.)

Install:

1. **Install Ollama**
   - run: `curl -fsSL https://ollama.com/install.sh | sh`
2. **Download a coding model**
   - run: `ollama pull $MODEL`
3. **Give the model more room**
   - YOU RUN (starts a server that keeps running; run it in its own window): `OLLAMA_CONTEXT_LENGTH=8192 ollama serve`
4. **Install Aider**
   - run (macOS only): `brew install uv`
   - run: `uv tool install --force --python python3.12 --with pip aider-chat@latest`
5. **Start it in your project**
   - YOU RUN (sets a variable in your own shell): `export OLLAMA_API_BASE=http://127.0.0.1:11434`
   - YOU RUN (needs your own file, folder or model name): `cd /path/to/your/project`
   - YOU RUN (interactive; run it yourself): `aider --model ollama_chat/$MODEL`

Verify:

- `ollama --version` → expect: a version number
- `ollama list | grep -F "${MODEL%%:*}"` → expect: your model is in the list
- `aider --version` → expect: a version number

Rollback:

- run: `uv tool uninstall aider-chat`
- run: `ollama rm $MODEL`

### Windows (PowerShell, not run by us)

Install:

1. **Install Ollama**
   - run: `irm https://ollama.com/install.ps1 | iex`
   - YOU RUN (starts a server that keeps running; run it in its own window): `$env:OLLAMA_CONTEXT_LENGTH=64000; ollama serve`
2. **Download your model**
   - run: `ollama pull $MODEL`
3. **The rest of the recipe**
   - note: Install Ollama with this PowerShell command, or the installer from ollama.com/download. On Linux, the install command above works as it is. After that, every ollama command on this page is the same. In PowerShell, start Ollama with a long memory like this. OpenCode runs on Windows too; see opencode.ai/docs. Aider's page has its Windows steps. Steps: https://insidethemachine.ai/do/code

Verify:

- `ollama --version` → expect: a version number
- `ollama list` → expect: your model is in the list

Rollback:

- run: `ollama rm $MODEL`
