@8monkey/pi-session-gzip
Automatically compress/decompress Pi session files to save disk space
Install & Use
Copy this prompt and send it to your AI assistant (Claude / Cursor / TRAE / Codex / WorkBuddy etc.) to auto-install:
Help me install this AI Skill: @8monkey/pi-session-gzip. It is used for: Automatically compress/decompress Pi session files to save disk space Full Skill content: https://321skill.com/skills/8monkey-pi-session-gzip/raw/index.md Read that page and install it.
The prompt includes a link to the full Skill content. You can also view the full content.
This Skill addresses the issue of Pi agent session files consuming significant disk space. In practice, Pi generates numerous JSONL-format session files in the ~/.pi/agent/sessions/ directory, and as the number of sessions grows, disk space is quickly depleted. This Skill automatically compresses the current session's session.jsonl into session.jsonl.gz and deletes the original file each time Pi is closed, allowing idle sessions to be stored in a compressed state while active sessions remain unaffected.
Usage is straightforward: simply install it via pi install npm:@8monkey/pi-session-gzip. After installation, Pi will automatically compress the current session upon exit. To restore a session, tell the AI "resume the last compressed session" or directly run the /resume-compressed command, which will automatically decompress and reopen the corresponding session file. You can also specify a session ID or file path to restore a particular compressed session. The entire process requires no manual intervention and has zero runtime dependencies.
It is ideal for Pi users who need to retain extensive session history over the long term, especially developers or operations personnel who generate a high volume of daily conversations and have limited disk space. For teams that frequently need to review historical sessions but don't want their disks filled with JSONL files, this Skill is an ideal storage optimization solution. It is also suitable for scenarios where the Pi agent runs on resource-constrained servers.
It is recommended to test the compression/restoration process once immediately after installation to ensure it works correctly. Note that compression is triggered only when Pi exits normally; it will not occur if the process is forcibly terminated. The restore operation is idempotent, and repeated execution will not cause side effects. Additionally, empty sessions and sessions in --no-session mode are automatically skipped and will not generate compressed files.
Key Features
Unlike manually compressing session files with the gzip command, this Skill automatically triggers compression when Pi closes, eliminating the need for users to remember the operation. For restoration, the `/resume-compressed` command provides one-click decompression and reopening, whereas the manual method requires decompressing first and then manually loading the session.
Limitations
Only applicable to Pi framework session files (session.jsonl). It relies on the Pi environment and triggers compression only upon normal exit. It does not support Windows platforms (a limitation of Pi itself).
FAQ
How do I restore a compressed session?
Run the `/resume-compressed` command. Without parameters, it will restore the .gz file of the current session or automatically select the most recently compressed session by this Skill. You can also pass a session ID or file path to restore a specific session.
Does the original session.jsonl file remain after compression?
No, after successful compression, the original JSONL file is deleted, leaving only the .gz file with the same name. Restoration will automatically decompress and regenerate the JSONL file.
Installation guide for AI assistants
If your AI coding assistant (Claude Code, Cursor, TRAE etc.) can see this page, send it this message to auto-install:
Visit https://321skill.com/skills/8monkey-pi-session-gzip/raw/index.md to read the original Skill definition (Markdown format) for @8monkey/pi-session-gzip, and install it according to the instructions.
Raw Markdown URL for AI: /skills/8monkey-pi-session-gzip/raw/index.md