{"id":29806264,"url":"https://github.com/DannyAziz/claude-prune","last_synced_at":"2025-07-28T14:07:58.241Z","repository":{"id":305042560,"uuid":"1021707729","full_name":"DannyAziz/claude-prune","owner":"DannyAziz","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-17T21:18:05.000Z","size":24,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-18T01:46:40.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DannyAziz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-17T20:20:34.000Z","updated_at":"2025-07-17T23:48:30.000Z","dependencies_parsed_at":"2025-07-18T03:22:08.727Z","dependency_job_id":"17509060-5307-4acb-8542-bf0cca9a8944","html_url":"https://github.com/DannyAziz/claude-prune","commit_stats":null,"previous_names":["dannyaziz/claude-prune"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/DannyAziz/claude-prune","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyAziz%2Fclaude-prune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyAziz%2Fclaude-prune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyAziz%2Fclaude-prune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyAziz%2Fclaude-prune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyAziz","download_url":"https://codeload.github.com/DannyAziz/claude-prune/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyAziz%2Fclaude-prune/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267527835,"owners_count":24102019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-28T14:05:55.451Z","updated_at":"2025-07-28T14:07:58.234Z","avatar_url":"https://github.com/DannyAziz.png","language":"JavaScript","funding_links":[],"categories":["Tools \u0026 Utilities"],"sub_categories":[],"readme":"# claude-prune\n\nA fast CLI tool for pruning Claude Code sessions.\n\n## Features\n\n- 🎯 **Smart Pruning**: Keep messages since the last N assistant responses\n- 🛡️ **Safe by Default**: Always preserves session summaries and metadata\n- 💾 **Auto Backup**: Creates timestamped backups before modifying files\n\n## Installation\n\n### Run directly (recommended)\n\n```bash\n# Using npx (Node.js)\nnpx claude-prune \u003csessionId\u003e --keep 50\n\n# Using bunx (Bun)\nbunx claude-prune \u003csessionId\u003e --keep 50\n```\n\n### Install globally\n\n```bash\n# Using npm\nnpm install -g claude-prune\n\n# Using bun\nbun install -g claude-prune\n```\n\n## Usage\n\n```bash\nclaude-prune \u003csessionId\u003e --keep \u003cnumber\u003e [--dry-run]\n```\n\n### Arguments\n\n- `sessionId`: UUID of the Claude Code session (without .jsonl extension)\n\n### Options\n\n- `-k, --keep \u003cnumber\u003e`: Number of assistant messages to keep (required)\n- `--dry-run`: Preview changes without modifying files\n- `-h, --help`: Show help information\n- `-V, --version`: Show version number\n\n### Examples\n\n```bash\n# Keep the last 10 assistant messages and everything since then\nclaude-prune abc123-def456-789 --keep 10\n\n# Preview what would be pruned (safe mode)\nclaude-prune abc123-def456-789 --keep 5 --dry-run\n\n# Minimal pruning - keep only the last assistant message\nclaude-prune abc123-def456-789 --keep 1\n```\n\n## How It Works\n\n1. **Locates Session File**: Finds `~/.claude/projects/{project-path}/{sessionId}.jsonl`\n2. **Preserves Critical Data**: Always keeps the first line (session summary/metadata)\n3. **Smart Pruning**: Finds the Nth-to-last assistant message and keeps everything from that point forward\n4. **Preserves Context**: Keeps all non-message lines (tool results, system messages)\n5. **Safe Backup**: Creates `{sessionId}.bak.{timestamp}` before modifying\n6. **Interactive Confirmation**: Asks for confirmation unless using `--dry-run`\n\n## File Structure\n\nClaude Code stores sessions in:\n\n```\n~/.claude/projects/{project-path-with-hyphens}/{sessionId}.jsonl\n```\n\nFor example, a project at `/Users/alice/my-app` becomes:\n\n```\n~/.claude/projects/-Users-alice-my-app/{sessionId}.jsonl\n```\n\n## Development\n\n```bash\n# Clone and install\ngit clone https://github.com/dannyaziz/cc-prune.git\ncd cc-prune\nbun install\n\n# Run tests\nbun test\n\n# Build\nbun run build\n\n# Test locally\n./dist/index.js --help\n```\n\n## License\n\nMIT © Danny Aziz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDannyAziz%2Fclaude-prune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDannyAziz%2Fclaude-prune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDannyAziz%2Fclaude-prune/lists"}