Inside The Machine
All goalsRecipe · about 15 min · Mac first

A coding helper

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

New to local AI? Read Start here first. It takes 5 minutes.

Your computer's memory

PC with a graphics card? Pick the card's memory (VRAM). Why?

It runs, but 32 GB or more is smoother.

Your modelOrnith 1.5 9Bby Ornith AI · needs about 8.8 GBCompare other models

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.

  1. 1

    Install Ollama

    Ollama downloads AI models and runs them on your computer. Open the Terminal app and paste this. It may ask for your Mac password.

    curl -fsSL https://ollama.com/install.sh | sh
    Or download the app from ollama.com/download

    You should see: Run ollama --version. It prints a version number. If it also says “could not connect”, open Ollama from your Applications folder, wait a few seconds, then go on.

  2. 2

    Download a coding model

    This is the AI itself. It is one big file, so it takes a few minutes.

    ollama pull ornith-1.5:9b

    You should see: The download finishes with “success”.

  3. 3

    Give the model more room

    Code needs a longer memory than chat. Quit the Ollama menu-bar app, then start Ollama like this. Leave this window open.

    OLLAMA_CONTEXT_LENGTH=8192 ollama serve
  4. 4

    Install Aider

    Aider is the coding helper. Open a second Terminal window. It installs with uv, a Python tool manager. Skip the first line if you already have uv.

    brew install uv
    Needs Homebrew (brew.sh)
    uv tool install --force --python python3.12 --with pip aider-chat@latest

    You should see: Run aider --version. It prints a version.

  5. 5

    Start it in your project

    Go to a project folder that uses git, then start Aider with your model.

    export OLLAMA_API_BASE=http://127.0.0.1:11434
    cd /path/to/your/project
    aider --model ollama_chat/ornith-1.5:9b

    You should see: Ask “explain this project”. It answers about your files.

It works. What now?

  • Try it: ask “explain this project”, then “add a comment to the main function”. Small, clear jobs work best.
  • Before a big change, commit your work in git. Then you can always go back.
  • See every model you have: ollama list.
  • Try a different model: copy any ollama run name from the Models page.
  • Update your model: run ollama pull ornith-1.5:9b again. It only downloads what changed.
  • Free disk space: ollama rm ornith-1.5:9b deletes a model you no longer use.

Something went wrong?

“could not connect to ollama app, is it running?”

Ollama is not running. Open Ollama from your Applications folder, or run ollama serve in a new Terminal window and leave it open.

“command not found: ollama”

Close the Terminal window and open a new one. If it still fails, run the install command again.

“model requires more system memory”

The model is too big for your memory. Pick a smaller memory size at the top of this page and use that model. Close other big apps too.

“file does not exist” when you download

The model name is wrong, or Ollama is too old. Copy the command again from this page. Then update Ollama: run the install command again.

It is very slow

Run ollama ps. PROCESSOR should say 100% GPU. If it shows CPU, the model does not fit in memory. Pick a smaller model.

The computer freezes, or the fan is loud

The model uses all your memory. Stop it with ollama stop ornith-1.5:9b. Then use a smaller one.

A warning about “unknown context window size”

You can ignore it. Aider still works with your model.

“aider: command not found”

Close the Terminal window and open a new one. If it still fails, run uv tool update-shell and open a new window.

Good to know

  • Check your free disk space first. You need room for the model plus about 1 GB for Aider.
  • Local models handle small, clear tasks best. Ask for one change at a time. On a 16 GB Mac an answer took about 1 minute.
  • Aider commits each change to git, so `/undo` takes it back.
  • Aider has had no new release since August 2025. It still works with Ollama.
How to remove it
uv tool uninstall aider-chat
Removes Aider
ollama rm ornith-1.5:9b
Let your agent do itPartly checked
curl -fsSL https://insidethemachine.ai/install/code.sh | bash
irm https://insidethemachine.ai/install/code.ps1 | iex
Windows PowerShell (not run by us)
Plan, check, undo

Add -s -- plan to print every step and run nothing, verify to only check, rollback --yes to undo. 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.

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. For Windows and Linux, see the box above.

Try another

More things you can do

AGENT VIEW · text/markdown · or send Accept: text/markdown
# Recipe: A coding helper

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

URL: https://insidethemachine.ai/do/code
Memory: needs 16 GB+, best with 32 GB+. Platform: macOS (Apple silicon) first.
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.

## Model by memory (replace {MODEL})

| RAM GB | model | ollama tag | needs GB |
|---|---|---|---|
| 8 | Qwen3.5 4B | qwen3.5:4b | 5.8 |
| 16 | Ornith 1.5 9B | ornith-1.5:9b | 8.8 |
| 24 | Gemma 4 12B | gemma4:12b | 11.2 |
| 32 | Qwen3.8 27B | qwen3.8:27b | 22.7 |
| 48 | Qwen3.8 27B | qwen3.8:27b | 22.7 |
| 64 | Qwen3.8 27B | qwen3.8:27b | 22.7 |
| 96 | Qwen3.8 27B | qwen3.8:27b | 22.7 |
| 128 | Qwen3.8 27B | qwen3.8:27b | 22.7 |
| 192 | Qwen3.8-Flash-Next (125B-A6B) | qwen3.8-flash-next:125b-a6b | 140 |
| 256 | Qwen3.8-Flash-Next (125B-A6B) | qwen3.8-flash-next:125b-a6b | 140 |
| 512 | Qwen3.8-Flash-Next (125B-A6B) | qwen3.8-flash-next:125b-a6b | 140 |

## Steps

1. **Install Ollama**: Ollama downloads AI models and runs them on your computer. Open the Terminal app and paste this. It may ask for your Mac password.
   ```sh
   curl -fsSL https://ollama.com/install.sh | sh
   ```
   (Or download the app from ollama.com/download)
   Expect: Run `ollama --version`. It prints a version number. If it also says “could not connect”, open Ollama from your Applications folder, wait a few seconds, then go on.
2. **Download a coding model**: This is the AI itself. It is one big file, so it takes a few minutes.
   ```sh
   ollama pull {MODEL}
   ```
   Expect: The download finishes with “success”.
3. **Give the model a long memory**: OpenCode needs at least 64k of context (how much text the model reads at once). Quit the Ollama menu-bar app, then start Ollama like this. Leave this window open.
   ```sh
   OLLAMA_CONTEXT_LENGTH=64000 ollama serve
   ```
4. **Install OpenCode**: OpenCode is the coding agent. Open a second Terminal window.
   ```sh
   curl -fsSL https://opencode.ai/install | bash
   ```
   (Or with Homebrew: brew install anomalyco/tap/opencode)
   Expect: Run `opencode --version`. It prints a version.
5. **Start it in your project**: Go to your project folder, then let Ollama start OpenCode. When it asks for a model, pick {MODEL}.
   ```sh
   cd /path/to/your/project
   ```
   ```sh
   ollama launch opencode
   ```
   Expect: Ask “explain this project”. It answers about your files.

## Alternative

Prefer a simpler helper? Use Aider. Aider edits files and commits each change to git. It works with smaller models that cannot use tools. It has had no new release since August 2025. (https://insidethemachine.ai/setups/aider)

## Rollback

- `rm -rf ~/.opencode` (Removes OpenCode from the install script. Also delete the line with .opencode/bin in ~/.zshrc. With Homebrew: brew uninstall opencode)
- `ollama rm {MODEL}`

## One-command install

```bash
curl -fsSL https://insidethemachine.ai/install/code.sh | bash             # install, then check
curl -fsSL https://insidethemachine.ai/install/code.sh | bash -s -- plan     # print only
curl -fsSL https://insidethemachine.ai/install/code.sh | bash -s -- rollback --yes
```

Run status and Windows: https://insidethemachine.ai/install/code.md. The script picks {MODEL} from the machine's memory (override: ITM_RAM, ITM_MODEL).

## Notes

- Check your free disk space first. You need room for the model plus about 1 GB for OpenCode.
- Local models handle small, clear tasks best. Ask for one change at a time.
- Type `/undo` in OpenCode to take back its last change. `/redo` brings it back.
- If it is slow, run `ollama ps`. PROCESSOR should say 100% GPU. If not, the model and its 64k memory do not fit.

## If something goes wrong

- “could not connect to ollama app, is it running?”: Ollama is not running. Open Ollama from your Applications folder, or run `ollama serve` in a new Terminal window and leave it open.
- “command not found: ollama”: Close the Terminal window and open a new one. If it still fails, run the install command again.
- “model requires more system memory”: The model is too big for your memory. Pick a smaller memory size at the top of this page and use that model. Close other big apps too.
- “file does not exist” when you download: The model name is wrong, or Ollama is too old. Copy the command again from this page. Then update Ollama: run the install command again.
- It is very slow: Run `ollama ps`. PROCESSOR should say 100% GPU. If it shows CPU, the model does not fit in memory. Pick a smaller model.
- The computer freezes, or the fan is loud: The model uses all your memory. Stop it with `ollama stop {MODEL}`. Then use a smaller one.
- It talks, but it does not change any files: The model is too small to use tools. Use a bigger model, or Aider (the box above), which does not need tools.
- It forgets the start of the job: Ollama was started without the long memory. Quit Ollama and run step 3 again.

## After it works

- Try it: ask “explain this project”, then “add a comment to the main function”. Small, clear jobs work best.
- Before a big change, commit your work in git. Then you can always go back.
- See every model you have: `ollama list`.
- Try a different model: copy any `ollama run` name from the Models page.
- Update your model: run `ollama pull {MODEL}` again. It only downloads what changed.
- Free disk space: `ollama rm {MODEL}` deletes a model you no longer use.

## Windows / Linux (not tested by us)

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.

```powershell
irm https://ollama.com/install.ps1 | iex
```
(Windows: paste in PowerShell. Or get the installer from ollama.com/download)
```powershell
$env:OLLAMA_CONTEXT_LENGTH=64000; ollama serve
```
(PowerShell version of step 3)

## If the computer has 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. Use these steps instead.

1. **Install Ollama**: Ollama downloads AI models and runs them on your computer. Open the Terminal app and paste this. It may ask for your Mac password.
   ```sh
   curl -fsSL https://ollama.com/install.sh | sh
   ```
   (Or download the app from ollama.com/download)
   Expect: Run `ollama --version`. It prints a version number. If it also says “could not connect”, open Ollama from your Applications folder, wait a few seconds, then go on.
2. **Download a coding model**: This is the AI itself. It is one big file, so it takes a few minutes.
   ```sh
   ollama pull {MODEL}
   ```
   Expect: The download finishes with “success”.
3. **Give the model more room**: Code needs a longer memory than chat. Quit the Ollama menu-bar app, then start Ollama like this. Leave this window open.
   ```sh
   OLLAMA_CONTEXT_LENGTH=8192 ollama serve
   ```
4. **Install Aider**: Aider is the coding helper. Open a second Terminal window. It installs with uv, a Python tool manager. Skip the first line if you already have uv.
   ```sh
   brew install uv
   ```
   (Needs Homebrew (brew.sh))
   ```sh
   uv tool install --force --python python3.12 --with pip aider-chat@latest
   ```
   Expect: Run `aider --version`. It prints a version.
5. **Start it in your project**: Go to a project folder that uses git, then start Aider with your model.
   ```sh
   export OLLAMA_API_BASE=http://127.0.0.1:11434
   ```
   ```sh
   cd /path/to/your/project
   ```
   ```sh
   aider --model ollama_chat/{MODEL}
   ```
   Expect: Ask “explain this project”. It answers about your files.

Rollback: `uv tool uninstall aider-chat`, `ollama rm {MODEL}`

Notes: Check your free disk space first. You need room for the model plus about 1 GB for Aider. Local models handle small, clear tasks best. Ask for one change at a time. On a 16 GB Mac an answer took about 1 minute. Aider commits each change to git, so `/undo` takes it back. Aider has had no new release since August 2025. It still works with Ollama.

Windows on this path: 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 more room like this. Aider's page has its Windows steps. `irm https://ollama.com/install.ps1 | iex`, `$env:OLLAMA_CONTEXT_LENGTH=8192; ollama serve`

If something goes wrong on this path: “could not connect to ollama app, is it running?”: Ollama is not running. Open Ollama from your Applications folder, or run `ollama serve` in a new Terminal window and leave it open. “command not found: ollama”: Close the Terminal window and open a new one. If it still fails, run the install command again. “model requires more system memory”: The model is too big for your memory. Pick a smaller memory size at the top of this page and use that model. Close other big apps too. “file does not exist” when you download: The model name is wrong, or Ollama is too old. Copy the command again from this page. Then update Ollama: run the install command again. It is very slow: Run `ollama ps`. PROCESSOR should say 100% GPU. If it shows CPU, the model does not fit in memory. Pick a smaller model. The computer freezes, or the fan is loud: The model uses all your memory. Stop it with `ollama stop {MODEL}`. Then use a smaller one. A warning about “unknown context window size”: You can ignore it. Aider still works with your model. “aider: command not found”: Close the Terminal window and open a new one. If it still fails, run `uv tool update-shell` and open a new window.