Trim

•
2
•

Minimizes codebase context for LLM prompts using AST-guided parsing, semantic ranking, and a two-pass token budget allocator.

Trim is a fast, zero-config CLI tool and MCP server designed to shrink local codebases into high-density prompt payloads for Large Language Models. Instead of dumping whole files or chopping tokens blindly, Trim leverages Tree-Sitter to parse code into abstract syntax tree (AST) units, semantically ranks them against user intent and a true AST call graph, and intelligently packs the most relevant code into the token budget. It employs a 3-tier degradation engine (Full, Compact, Skeleton) to maximize content without syntax truncation, all while ensuring zero credential leaks through built-in secret scanning and redaction.

主要功能

011 GitHub stars
02AST-based code parsing and unit extraction with Tree-Sitter across 12 languages
03Three-tier degradation engine (Full, Compact, Skeleton) for intelligent token budget management
04Honest AST call graph and dependency attribution for precise contextual inclusion
05Default-on secret scanning and redaction for credentials and private keys
06Continuous agent session memory ('Agent Hot Set') for multi-turn dialogue relevance boosting

使用案例

01Generate high-density, context-aware LLM prompts from local codebases for code analysis and generation tasks
02Debug and audit LLM context generation with detailed scoring explanations and call graph tracing
03Enhance multi-turn agent interactions by remembering previously referenced symbols and modules