@techsavvyash/threads-pi adds threads to Pi.

Install

pi install npm:@techsavvyash/threads-pi

The package is a Pi package: its package.json has the pi-package keyword and a pi.extensions entry. The library is a normal dependency, which Pi installs alongside it.

Install it for all of Pi like this, not only in a project’s .pi/settings.json. Pi reads project settings only in projects you’ve trusted, and a headless Pi (pi -p, which launch uses) can’t ask. Without the extension, a launched Pi thread records nothing until it exits. From a checkout, pi install ./plugins/threads-pi-extension does the same.

The threads skill

The package also ships a threads skill. It tells Pi when to cut a thread and how: find the cutoff, pick the fewest events, then let you approve the exact seed.

Pi loads skills from packages, so install the package with pi install or declare it in .pi/settings.json. Loading only the extension file with -e skips the skill.

What it does

Live capture

  • On session start and after every agent turn, the current session is saved into the store, ~/.threads/log.jsonl.
  • Session to thread: a session that’s already attached to a thread, such as a child you launched, is added to that thread. Any other session becomes a new root.
  • Empty sessions are skipped until they have messages.

The footer shows the current thread, how many cuts have been made from it, and context usage:

⑂ t-1cc6636e84 · 2 cuts · ctx 63%

When usage reaches THREADS_CONTEXT_WARN (80% by default), Pi warns you once per session to cut a continue thread instead of compacting. A cut made from the wizard while usage is over the threshold is recorded with trigger context_limit.

/thread: the cut wizard

/thread [task] walks you through a cut:

  1. Kind: continue (same work, fresh context), branch (parallel work) or handoff (a scoped task).
  2. Task: taken from the command argument if you gave one.
  3. Cutoff: #n, or empty for the latest event.
  4. Events to carry: a selection spec, last:6 by default. See concepts > Selecting events.
  5. Seed preview: opened in the editor. Edits are ignored.
  6. What to do with it:
    • Start it here in a new Pi session: commits the child, opens a new session linked to the current one as its parent, records that session as the child’s run, and sends the seed as the first message.
    • Launch in the background: Pi / Claude Code: commits the child and runs it headless. The reply is posted back into this session when it finishes.
    • Create only or Cancel.

/threads

Toggles a widget above the editor showing the project’s thread tree.

Agent tools

ToolWhat the agent uses it for
threads_historyList this conversation’s events as #n role: text, optionally filtered by query, to find a cutoff
threads_cutPropose a cut (task, intent, at, select, title, launch, model); model is passed to the launch as --model
threads_treeShow the project forest

So you can just ask: “hand off writing the store tests to a new thread, with the design discussion as context”.

When the agent calls threads_cut, Pi shows an approval dialog with the summary:

  • create
  • create and launch in Pi or Claude Code in the background
  • show the seed first
  • cancel

Without an interactive UI (print mode), the tool returns the preview plus instructions instead. The agent then has to call it again with approve: true and the previewed expect id, and the commit is refused if the cut no longer matches. See concepts > Preview, approve, commit.

Configuration

VariableDefaultMeaning
THREADS_STOREStore file instead of ~/.threads/log.jsonl
THREADS_HOME~/.threadsFolder for the store and plugin state
THREADS_CONTEXT_WARN80Warning threshold, in percent of the context window
THREADS_PI_ARGSExtra args for background Pi launches
THREADS_CLAUDE_ARGSExtra args for background Claude Code launches