Pi: 20 power-user tips
Shortcuts, extensions and workflow tricks for the terminal agent harness.
I studied Pi's source for eight lessons. This page recaps them, then gets practical:
The codebase
A minimal, extensible agent harness: an interactive coding agent in your terminal, plus print, JSON and RPC modes and a TypeScript SDK. It works with many model providers and is built to be bent to your workflow with extensions, skills, prompt templates and themes. Built in the open at earendil-works, mostly by Mario Zechner (who created libGDX) and Armin Ronacher (who created Flask).
The eight lessons
- A small, replaceable core: MCP, code mode and tool search are built-in extensions a third-party extension can replace.
- Entry points are cost contracts: a commit check that budgets each package entry's import graph.
- A fake model and an empty environment: the faux provider and
env -iintest.sh. - Never mutate history: sessions as an append-only JSONL tree.
- The lockfile is code: exact pins, three allowed install scripts, a lockfile commit gate.
- A tool a model can't misuse: the edit tool's matching rules and per-file queue.
- Who owns the scrollback: two renderers, differential rendering, counted full redraws.
- Measure your docs: with-docs and without-docs evals.
Reading the repo taught me how it's built. Using it taught me the tricks below. On Windows and WSL a few Alt shortcuts move; /hotkeys shows the ones active in your terminal.
20 power-user tips
Keyboard first
- Steer while it works. Type and press Enter to guide the next response once the current one and its tool calls finish. Alt+Enter queues a follow-up for after the whole task. Alt+↑ pulls queued messages back into the editor, and Esc stops.
- Write long prompts in your editor. Ctrl+G opens the prompt in
$VISUALor$EDITOR. - Attach files fast. Type
@to search for a file, Tab to complete a path, or paste or drag an image in. - Hide the noise. Ctrl+O expands or collapses tool output; Ctrl+T shows or hides thinking blocks.
- Switch brains quickly. Shift+Tab cycles the thinking level, Ctrl+L opens the model picker, and Ctrl+P cycles through the models you picked in
/scoped-models. - Run a command yourself.
!git statusruns it and sends the output to the model.!!git statusruns it without sending anything. - Copy the answer. Ctrl+X (or
/copy) copies the last assistant message. - Rebind anything. Every shortcut is a named action. Map it in
~/.pi/agent/keybindings.json, use[]to disable one, then/reload.{ "app.session.new": "ctrl+shift+n", "tui.altScreen.pageUp": [] }
Sessions are trees
- Go back without losing anything.
/treeshows the whole session. Pick an earlier message of yours, edit it and resubmit: that starts a new branch, and the old one stays. When you leave a branch, Pi can summarize it into the one you enter. - Know which copy you want.
/forkstarts a new session from an earlier message of yours;/clonecopies the current branch into a new session. - Label and filter the tree. In
/tree, Shift+L labels a node, and Ctrl+U shows only your messages. - Pick up where you left off.
pi --continueresumes the latest session in this folder,pi --resumeopens the picker, and/namegives a session a name you'll recognize. - Compact with intent.
/compact keep the API decisions and open questionstells the summary what to preserve. The original messages stay in the session file. - Leave no trace.
pi --no-sessionruns without saving a session at all.
Automation
- Pipe into it.
git diff | pi --print "Review this change"prints the answer and exits. Piped input goes in front of your prompt. - Get events, not text.
pi --mode json "Inspect this repo" > events.jsonlwrites every agent event as JSON lines.--mode rpclets another program drive it over stdin. - Narrow the tools.
pi --tools read,grep,find,ls --print "Review this project"runs with only those tools.--tools +codemode,-writeadjusts the defaults instead of replacing them. It narrows what the model is offered, not what the machine allows, so use a sandbox for untrusted work.
Make it yours
- Turn prompts into commands. Save
~/.pi/agent/prompts/review.mdand it becomes/review. Use$1,$ARGUMENTSor${1:-correctness}for arguments. - Write skills, not giant prompts. A skill is a folder with a
SKILL.md. Only its name and description sit in the prompt; the full instructions load when a task needs them. - Try a package before installing it.
pi -e npm:@example/pi-toolsloads it for one run;pi installadds it for good. Packages run code, so read the source first.
Bonus: missing sub-agents or a plan mode? The repo has example extensions for both, or you can ask Pi to write the extension you want. That's the whole idea.
What's next
Next up: lessons from T3 Code and OpenCode. New codebases land on X first: follow @tarekkh1997, or subscribe via RSS.