‹ Guides

Run the pi coding agent in Term

The agent runs on your server, where your code and your toolchain already are. Term is just the terminal you drive it from — so a phone is enough to read a file, make an edit and watch the tests go green.

Written

pi on a real phone: the prompt is typed, the agent reads the file, writes the change and runs the tests. Recorded on a device at the app’s default font — 48 columns. Sped up; nothing else is edited.
What runs where

pi is a terminal coding agent: it reads, writes and runs commands in a real working directory. It runs on the SERVER, not on the phone — so it has your repository, your compiler and your test runner, and nothing large is copied to the device.

That also means the session is just SSH. Nothing here is specific to Term beyond it being a terminal that renders what the agent draws.

Install it on the server

pi is a Node package, so the server needs Node 20 or newer. Install the CLI globally:

server
npm install -g --ignore-scripts @earendil-works/pi-coding-agent

--ignore-scripts is deliberate: a global install of a coding agent has no business running arbitrary postinstall code on your box.

Give it a key

pi is bring-your-own-key and provider-agnostic — Anthropic, OpenAI, Gemini, DeepSeek, Groq, OpenRouter and more, all through the same agent loop. Set the variable your provider expects and check it:

server
export DEEPSEEK_API_KEY=sk-...
pi auth check --provider deepseek

Put the export in a file only you can read rather than in your shell profile, and source it when you launch the agent — an exported key sits in the environment of every command in that session.

Connect and run it

Add the host in Term, open a session, and run pi in your project directory. That is the whole setup — from here it is the agent’s own interface.

server
cd ~/your-project
pi

Agents lean on Ctrl and Alt chords. Term speaks the kitty keyboard protocol, so those arrive intact rather than being flattened into something the agent cannot tell apart. tmux config →

If the colours look wrong

If tool blocks render as saturated blocks of green or blue instead of a faint tint, the agent has fallen back to 256 colours. It is not a display bug and the fix is one line.

Terminals advertise 24-bit colour with COLORTERM. Over SSH that variable is not carried across: TERM arrives as xterm-256color, which promises 256 colours and no more, and the env request the client sends is only advisory — stock sshd ships AcceptEnv LANG LC_* and drops everything else. The agent then quantises its palette to the 216-colour cube, and a colour meant to be a hint becomes a slab.

Set it on the server, in the shell rc for the account you log in as:

~/.bashrc
export COLORTERM=${COLORTERM:-truecolor}
~/.config/fish/config.fish
set -q COLORTERM; or set -gx COLORTERM truecolor

It applies to the next session. The same setting fixes washed-out colour in vim colorschemes, bat, delta, lazygit and btop — anything that draws in 24-bit.

Newer builds of Term set this for you when shell integration is on, so on an up-to-date app you should not need to do anything. The line above is harmless either way, and is the fix if you are on an older build, have shell integration off, or use fish.

Worth knowing

At the default font a phone session is about 56 columns. Agents lay out for that fine, but long paths wrap — a shorter project path keeps the transcript readable.

Over mosh the session survives a network change, so a long agent run keeps going when you move between Wi-Fi and mobile data. Mosh options →

The agent bills your own key. pi shows a running token and cost count in its status line, which is the number to watch on a metered plan.