pi-import-claude-history
Pi coding agent extension: import Claude Code JSONL sessions into Pi session format
Package details
Install pi-import-claude-history from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-import-claude-history- Package
pi-import-claude-history- Version
1.0.1- Published
- May 2, 2026
- Downloads
- not available
- Author
- kshivendu
- License
- MIT
- Types
- extension
- Size
- 26.4 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-import-claude-history
Import Claude Code session logs (NDJSON / .jsonl) into Pi so you can continue the same thread inside Pi’s agent UI.
This repo publishes a single Pi extension: claude-import.ts, which registers the slash command /import-claude.
Features
/import-claude— reads a Claude session from disk and writes a new Pi session file under~/.pi/agent/sessions/....- Autocomplete — when you type the command, Pi can suggest Claude session IDs discovered under
~/.claude/projects/**/*.jsonl. - Modes —
compact(default, readable) vsstrict(includes tool_use / tool_result as text). - Turn limit — import only the last N turns to keep context bounded.
Requirements
- Pi coding agent with extension support.
- Claude Code stores sessions under
~/.claude/projects/<encoded-path>/<session-id>.jsonl.
Install
With the Pi CLI (recommended)
From npm (adds the package to Pi settings; global by default under ~/.pi/agent/settings.json):
pi install npm:pi-import-claude-history
# pin a version: pi install npm:pi-import-claude-history@1.0.1
From GitHub (clones to ~/.pi/agent/git/...):
pi install https://github.com/KShivendu/pi-import-claude-history
# or: pi install git:github.com/KShivendu/pi-import-claude-history
# pin a tag/commit: pi install https://github.com/KShivendu/pi-import-claude-history@v1.0.0
Project-local install (writes .pi/settings.json, good for teams):
pi install npm:pi-import-claude-history -l
# or: pi install https://github.com/KShivendu/pi-import-claude-history -l
Then start Pi (or run /reload in the TUI) so the package loads.
Manual copy
Copy (or symlink) the extension file:
cp src/claude-import.ts ~/.pi/agent/extensions/
# optional: project-local — mkdir -p .pi/extensions && cp src/claude-import.ts .pi/extensions/
In Pi: /reload
Usage
/import-claude <session-id|path.jsonl> [--mode compact|strict] [--turns N]
| Argument | Meaning |
|---|---|
session-id |
Looks up ~/.claude/projects/*/<session-id>.jsonl. |
path.jsonl |
Absolute or relative path to a Claude .jsonl file. |
--mode compact |
Default: user + assistant text turns; collapses noisy repeats. |
--mode strict |
Also surfaces tool_use / tool_result lines as assistant text. |
--turns N |
Keep only the last N turns (default 60, max 400). |
After import, Pi writes a new JSONL session file and notifies you. Open the session picker in Pi and load that session to continue.
Try with the bundled sample
# From repo root; in Pi, cwd should be this repo (or use absolute path):
/import-claude examples/sample-claude-session.jsonl
See examples/sample-claude-session.jsonl for the minimal Claude NDJSON shape this importer expects.
Where files go
Imported Pi sessions are written to:
~/.pi/agent/sessions/--<cwd-encoded>--/<iso-timestamp>_<pi-session-id>.jsonl
The first assistant message is a bootstrap summary (source path, mode, turn counts, tool counts, objective snippet).
Demo
A short terminal walkthrough is in demo/ (recorded with asciinema + agg + ffmpeg):
demo/demo.mp4— H.264 video (~11s), easy to upload or attach to a post.demo/demo.gif— same session as a GIF (embedded at the top of this README).
Regenerate locally (requires asciinema and agg):
./demo/record-demo.sh
Project layout
.
├── LICENSE
├── README.md
├── package.json # metadata + peerDependency on @mariozechner/pi-coding-agent
├── src/
│ └── claude-import.ts # Pi extension (default export)
├── examples/
│ └── sample-claude-session.jsonl
└── demo/
├── README.md
├── record-demo.sh
├── demo.cast # optional; generated
├── demo.gif # generated / committed for sharing
└── demo.mp4 # generated / committed for sharing
License
MIT — see LICENSE.