Create minimal context packets for AI coding agents.
Project description
RepoTrim turns a messy codebase into a focused context packet for AI coding agents.
RepoTrim
RepoTrim is a local CLI context engine for Codex, Claude Code, Cursor, and other AI coding tools. It scans a repository, filters out junk and risky files, understands the task, ranks the files most likely to matter, optionally applies semantic search, and writes an agent-ready context packet.
Why RepoTrim
Most AI coding sessions start with too much context or the wrong context.
| Before | After |
|---|---|
| Paste or attach a whole repo | Generate a focused packet |
| Generated files, caches, lock files, and duplicates add noise | Junk and generated paths are ignored |
| Secrets can slip into prompts | Secret-looking files are skipped |
| The agent guesses where to start | RepoTrim ranks task-relevant entry points |
| Context windows fill with unrelated files | Token count is usually reduced by 70-90% |
| Hard to audit what was sent | Packet, token savings, and agent reports are written to disk |
RepoTrim is a pre-step. Run it before opening Codex, Claude Code, or Cursor, then give the generated packet to the agent instead of the entire repository.
Install
pip install repotrim
Optional semantic search support:
pip install "repotrim[semantic]"
Quick Start
repotrim task "restrict admin screens" --semantic
Sample output:
RepoTrim Task Report
Task:
restrict admin screens
Task type:
Access control / RBAC
Primary files:
1. lib/rbac.ts
Score: 142
Tokens: 420
Why:
- prioritized core RBAC policy file
2. middleware.ts
Score: 118
Tokens: 310
Why:
- prioritized middleware/protected route file
Semantic search: 12 chunks from lexical-fallback (repotrim-lexical-fallback)
context_packet.md written - paste into Claude or Codex to one-shot this.
RepoTrim Token Savings
----------------------
Files counted: 184
Full repo estimate: 154,963 tokens
Context packet estimate: 15,994 tokens
Tokens saved: 138,969 tokens
Reduction: 89.7%
Compression ratio: 9.7x smaller
RepoTrim writes the main packet to:
.repotrim/context_packet.md
How It Works
Pipeline:
task -> scan -> classify -> rank -> semantic boost -> token fit -> packet -> agent report
Briefly:
- Parse the coding task and classify the intent.
- Scan the repo with shared ignore rules for caches, generated output, secrets, binaries, and oversized files.
- Extract lightweight file metadata: language, symbols, imports, comments, size, and token estimate.
- Rank files using deterministic task-aware scoring.
- Optionally chunk and semantically search source files, then blend those matches into the ranking.
- Fit selected files into a context budget.
- Write
context_packet.md, token savings data, and agent planning artifacts.
Key Features
- Local-first: no repo upload required
- No AI API required for the core workflow
- Deterministic ranking by default
- Secret and generated-file filtering
- Task-aware file ranking for common engineering work
- Optional semantic search with local fallback
- Token savings report
- Agent plan report
- JSON output for automation
- Designed as a pre-step before Codex, Claude Code, and Cursor
Who It's For
- Developers using AI agents on medium or large repositories
- Teams that want repeatable context selection instead of ad hoc file picking
- Maintainers who need to avoid sending secrets, caches, and generated output to AI tools
- Engineers building automation around AI-assisted code changes
- Anyone trying to keep agent prompts small enough to be useful
Roadmap
- Better scoring for framework-specific project layouts
- Evaluation benchmark for ranking quality and token reduction
- Dedicated Codex, Claude Code, and Cursor output formats
Contributing
Issues and pull requests are welcome. Keep changes focused, add tests for ranking or packet behavior, and include a real CLI example when changing user-facing output.
For local development:
pip install -e .
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file repotrim-0.1.0.tar.gz.
File metadata
- Download URL: repotrim-0.1.0.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9bd53c3a732ea8dadadf42ed863296547603444f9a3cd4b5f407f29cac6651b
|
|
| MD5 |
ad60d9fb0c61e832870184174107f12e
|
|
| BLAKE2b-256 |
f8667539d2edad5ebb4aad76fe45e778e5db6cfabee423080c9ca200b71678d1
|
Provenance
The following attestation bundles were made for repotrim-0.1.0.tar.gz:
Publisher:
publish.yml on Sudhakhar-Katta/repotrim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
repotrim-0.1.0.tar.gz -
Subject digest:
c9bd53c3a732ea8dadadf42ed863296547603444f9a3cd4b5f407f29cac6651b - Sigstore transparency entry: 1923670534
- Sigstore integration time:
-
Permalink:
Sudhakhar-Katta/repotrim@fa6cc0946e24e8e5af28d20031606e8642ae0ebe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sudhakhar-Katta
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fa6cc0946e24e8e5af28d20031606e8642ae0ebe -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file repotrim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: repotrim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f7ba801dd21f05630e6e19fa5cc08a86156ec447e0029a44245be2d907b7f7c
|
|
| MD5 |
7e93ce908609e798374b3aba02173486
|
|
| BLAKE2b-256 |
477400198a17c1d8ac34398d8a0db81fe5dab2b09cce491ce83ad50e6b554584
|
Provenance
The following attestation bundles were made for repotrim-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Sudhakhar-Katta/repotrim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
repotrim-0.1.0-py3-none-any.whl -
Subject digest:
1f7ba801dd21f05630e6e19fa5cc08a86156ec447e0029a44245be2d907b7f7c - Sigstore transparency entry: 1923670621
- Sigstore integration time:
-
Permalink:
Sudhakhar-Katta/repotrim@fa6cc0946e24e8e5af28d20031606e8642ae0ebe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sudhakhar-Katta
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fa6cc0946e24e8e5af28d20031606e8642ae0ebe -
Trigger Event:
workflow_dispatch
-
Statement type: