dirpack
Budgeted directory indexes for AI coding agents
dirpack creates compressed directory representations that fit within token/byte budgets. Unlike other tools, it uses progressive disclosure—including structure first, then signatures, then content—stopping exactly when the budget is exhausted.
dirpack was inspired by recent research from Jude Gao at Vercel, which suggests that putting a "compressed" index of the directory directly inside AGENTS.md outperforms the "progressive disclosure" strategy recommended by Agent Skills.
Features
- Budget-aware: Set token or byte limits; output stops at the boundary
- Tree-sitter signatures: Extract function/struct/trait signatures for Rust, Go, Python, TypeScript, JavaScript, C, C++
- Progressive disclosure: Spine → signatures → summaries → content
- Git-aware: Uses
git ls-fileswhen available, respects.gitignore - Configurable: Priority rules, file categories, exclude patterns via TOML
Installation
Quick Install (recommended)
|
This downloads a pre-built binary for your platform and installs it to ~/.local/bin.
Using Cargo
# or from source
Quick Start
# Pack current directory with 4K token budget
# Pack with 16KB byte budget, markdown output
# View directory tree with priorities
# Create default config
Output Formats
Pipe (default)
Compact, single-line format optimized for AGENTS.md:
[myproject]|root: ./path|dirs:{src,tests}|src:{main.rs,lib.rs}|main.rs:fn main(),fn setup()
Full
Markdown with sections for structure, signatures, and content.
JSON
Machine-readable output with budget stats.
Configuration
Create dirpack.toml in your project:
[]
= "pipe"
= 4000
[]
= true
= false
= 20
[]
= true
= 200
# High-priority files get included first
[[]]
= "README*"
= 200
[[]]
= "src/main.*"
= 140
Run dirpack init to generate a full default config.
Runtime Limits
dirpack enforces a per-process concurrency cap for pack jobs to protect CPU/IO.
DIRPACK_PACK_CONCURRENCY_LIMIT: max concurrent pack jobs (default: available CPU parallelism)DIRPACK_PACK_RETRY_AFTER_SECS: suggested retry delay for saturated servers (default: 1)
How It Works
- Scan directory (git-aware or walkdir fallback)
- Prioritize files by pattern rules and category
- Pack progressively:
- Phase 1: Directory spine (always included)
- Phase 2: Code signatures (high-priority files first)
- Phase 3: Doc summaries (README excerpts)
- Phase 4: Full content (budget permitting)
- Stop when budget exhausted
Comparison
| Tool | Budgeting | Signatures | Progressive |
|---|---|---|---|
| dirpack | ✅ tokens/bytes | ✅ tree-sitter | ✅ 4-phase |
| yek | ✅ tokens | ❌ | ❌ |
| code2prompt | ❌ | ❌ | ❌ |
| repomix | ❌ | ❌ | ❌ |
dirpack's unique value: progressive disclosure with real signatures, not just file listings.
CLI Reference
dirpack pack [PATH] [OPTIONS]
-t, --target-tokens <N> Token budget
-b, --target-bytes <N> Byte budget
-f, --format <FORMAT> Output: pipe, full, json
-o, --output <FILE> Write to file instead of stdout
-c, --config <FILE> Custom config path
--root-label <LABEL> Override root path in output (e.g., '.')
--no-git Don't use git ls-files
--no-signatures Skip tree-sitter extraction
-v, --verbose Show stats
dirpack tree [PATH]
--show-priority Display computed priorities
dirpack init
--global Create in ~/.config/dirpack/
--force Overwrite existing
License
MIT