Claude Code session
Claude Prune
(85 ⭐ A fast CLI tool for pruning Claude Code sessions.
Install
npm install -g claude-pruneFound in the project README. Check it for setup steps after installing.
git clone https://github.com/DannyAziz/claude-prune.gitFrom the README
claude-prune
A fast CLI tool for pruning Claude Code sessions.
Features
- 🎯 Smart Pruning: Keep messages since the last N assistant responses
- 🛡️ Safe by Default: Always preserves session summaries and metadata
- 💾 Auto Backup: Creates timestamped backups before modifying files
Installation
Run directly (recommended)
Install globally
Usage
Arguments
- sessionId: UUID of the Claude Code session (without .jsonl extension)
Options
- -k, --keep : Number of assistant messages to keep (required)
- --dry-run: Preview changes without modifying files
- -h, --help: Show help information
- -V, --version: Show version number
Examples
How It Works
1. Locates Session File: Finds ~/.claude/projects/{project-path}/{sessionId}.jsonl
2. Preserves Critical Data: Always keeps the first line (session summary/metadata)
3. Smart Pruning: Finds the Nth-to-last assistant message and keeps everything from that point forward
4. Preserves Context: Keeps all non-message lines (tool results, system messages)
5. Safe Backup: Creates {sessionId}.bak.{timestamp} before modifying
6. Interactive Confirmation: Asks for confirmation unless using --dry-run
File Structure
Claude Code stores sessions in:
For example, a project at /Users/alice/my-app becomes:
Environment Variables
CLAUDE_CONFIG_DIR
By default, claude-prune looks for session files in ~/.claude. If Claude Code is configured to use a different directory, you can specify it with the CLAUDE_CONFIG_DIR environment variable:
Development
License
MIT © Danny AzizDetails
- Repository
- DannyAziz/claude-prune
- Language
- TypeScript
- License
- MIT
- Last updated
- 16 September 2025
- Listed in
- jqueryscript/awesome-claude-code
FAQ
What is Claude Prune?
(85 ⭐ A fast CLI tool for pruning Claude Code sessions. It is a session for Claude Code, from DannyAziz/claude-prune on GitHub.
How do I install Claude Prune?
Run npm install -g claude-prune, then follow the setup in the README.
Is Claude Prune popular?
DannyAziz/claude-prune has 83 GitHub stars and 11 forks, and is included in 1 curated Claude Code list. It was last updated on 16 September 2025.
More sessions & history
Cross Agent Session Resumer
130Dicklesworthstone/cross_agent_session_resumer
Resume AI coding sessions across providers: converts Codex, Claude, Gemini, and other session formats through a canonical IR so you can pick up where you left off in any tool
Cclogviewer
85Brads3290/cclogviewer
Review Claude Code .jsonl files with a nice HTML UI
Claude Mega Brain
128guhcostan/claude-mega-brain
OKF-powered knowledge context for Claude Code — injects your project's knowledge base at every session
Ctx
127dchu917/ctx
Local context manager for Claude Code and Codex with workstreams, transcript binding, and branching.
Sesori Apps Monorepo
139sesori-ai/sesori_apps_monorepo
Sesori iOS/Android app and the Sesori Bridge CLI — drive Claude, Codex, OpenCode, Cursor, Pi, OMP, Hermes coding sessions from your phone
Aaa Code Release
128hwwn/aaa-code-release
Cross-platform Claude Code desktop client by hwwn. Multi-workspace, remote mobile access, session branching, BYO LLM. macOS / Windows / Linux.
Browse the most popular Claude Code mods, all sessions & history, or the skills and MCP server directories.