Context extraction and codebase analysis for AI workflows. Generate precise, token‑efficient context, combine files, distill entire repos, and visualize APIs — all from one CLI.
Local installation via Bun
git clone
·
bun link
·
dex --help
# Clone and install locally
git clone https://github.com/scottbaggett/dex.git
cd dex
bun install
bun link
# Now use dex globally
dex --help
# Extract your current changes (txt by default)
dex -s --format md --clipboardDex treats AI context generation as a trust-boundary operation. When context leaves your repository and enters a model prompt, leakage risk is real.
Dex is opinionated by design:
- Always scan content for secrets and obvious PII before output.
- Redact sensitive spans by default.
- Write an audit manifest entry for every generated output.
Unsafe behavior should be an explicit override, not a hidden default.
Extracts Git changes and formats context for LLMs.
dex # Current unstaged changes
dex -s # Staged changes only
dex -a # Staged + unstaged
dex HEAD~5..HEAD # Specific commit range
dex -p "src/**" -t ts,tsx # Filter by path and types
dex --select # Interactive file picker (TTY)Key options:
- -s, --staged: Only staged changes
- -a, --all: Staged + unstaged changes
- --full : Include full files matching pattern
- --diff-only: Force diffs (disable Smart Context)
- -p, --path : Filter by file path
- -t, --type : Filter by file types (e.g. ts,tsx,js)
- -f, --format : md | json | txt (default: txt)
- -c, --clipboard: Copy output to clipboard
- -u, --include-untracked: Include untracked files
- --untracked-pattern : Pattern for untracked files
- --optimize <flags...>: aid, symbols
- --no-metadata: Omit metadata block
- --select: Interactive file selection (TTY)
- --sort-by : name | updated | size | status
- --sort-order : asc | desc
- --filter-by : all | staged | unstaged | untracked | modified | added | deleted
- --include-sensitive: Include sensitive content without redaction safeguards
- --target : claude | gpt | local | custom (recorded in audit metadata)
- --yes: Required in non-TTY usage with
--include-sensitive
Outputs are saved to .dex/ by default unless --clipboard, --stdout (where available), or an explicit --output is used.
Extract clean API signatures from entire codebases, removing implementation details for token-efficient LLM context.
dex distill . # Distill current project
dex distill packages/api # Distill a specific directory
dex distill src/index.ts # Distill a single file
dex distill . --private 1 # Include private members
dex distill . --include "*.ts" # Only TypeScript files
dex distill . --stdout # Print to stdoutKey options:
- -f, --format : txt | md | json (default: txt)
- -o, --output : Write to a specific file
- -c, --clipboard: Copy output to clipboard
- --stdout: Print to stdout
- -s, --select: Interactive file selection
- --include <patterns...>: Include file patterns (e.g., ".ts" "src/**/.js")
- --exclude <patterns...>: Exclude file patterns
- --comments <0|1>: Include comments (default: 0)
- --docstrings <0|1>: Include docstrings (default: 1)
- --private <0|1>: Include private members (default: 0)
- --protected <0|1>: Include protected members (default: 0)
- --internal <0|1>: Include internal members (default: 0)
- --workers : Number of worker threads (default: 1)
- --dry-run: Preview what would be processed
- --staged: Only process staged files
- --include-sensitive: Include sensitive content without redaction safeguards
- --target : claude | gpt | local | custom (recorded in audit metadata)
- --yes: Required in non-TTY usage with
--include-sensitive
Create a single, LLM‑friendly document from many files.
dex combine src/auth/ src/api/ # Combine directories
dex combine file1.ts file2.ts # Combine specific files
dex combine -s # Pick files interactively (TTY)
dex combine --staged -c # Use staged files; copy to clipboardKey options:
- -f, --format : txt | md | json (default: txt)
- --staged: Use all staged files (full contents)
- -c, --clipboard: Copy to clipboard
- -o, --output : Write to file instead of saving to
.dex/ - --include <patterns...>: Include patterns, e.g. ".ts" ".js"
- --exclude <patterns...>: Exclude patterns, e.g. ".test." ".spec."
- --max-files : Limit files processed (default 1000)
- --no-gitignore: Ignore .gitignore
- -s, --select: Interactive picker (TTY)
- --stdout: Print output to stdout
- --since : Only process files changed since git ref
- --dry-run: Show what files would be processed
- --include-sensitive: Include sensitive content without redaction safeguards
- --target : claude | gpt | local | custom (recorded in audit metadata)
- --yes: Required in non-TTY usage with
--include-sensitive
Run detection-only safety scans without generating context artifacts.
dex scan . # Human-readable summary
dex scan . --format json # CI-friendly machine outputKey options:
- -f, --format : txt | json (default: txt)
Generate a beautiful API tree or outline for quick understanding.
dex tree src/ # Tree view
dex tree . --outline # Outline view
dex tree . --group-by type --show-types --show-paramsKey options:
- -o, --output : Write to file
- --stdout: Print to stdout
- -c, --clipboard: Copy to clipboard
- --exclude <pattern...>: Exclude patterns
- --include-private: Include private/internal APIs
- --show-types: Show param and return types
- --show-params: Show function parameters
- --group-by : file | type | none (default: file)
# Clone the repository
git clone https://github.com/scottbaggett/dex.git
cd dex
# Install dependencies and link globally
bun install
bun link
# Verify installation
dex --help# With Bun (no build needed, runs TypeScript directly)
cd /path/to/dex
bun run src/cli.ts [command] [options]DEX saves outputs to .dex/ with descriptive, timestamped filenames. Use --clipboard, --stdout (where available), or --output <file> to override.
DEX supports worker threads for CPU parallelism during distill:
# Default: sequential worker mode
dex distill .
# Sequential processing for small projects
dex distill . --workers 1
# Parallel processing for larger codebases
dex distill . --workers 4Performance Notes:
- Default safety: Sequential mode avoids worker startup overhead in small runs
- Small projects (<100 files): Keep
--workers 1 - Large projects (1000+ files): Try
--workers 2to--workers 8 - Memory-intensive: Each worker has independent parser state
- Bun 1.0+
- Git (for change tracking)
- Use
--selectto interactively choose files when you don’t want to depend on Git state. - Prefer
--format txtfor agents that parse structure,--format mdfor human review, and--format jsonfor programmatic pipelines. distillsupports--dry-runto preview scope and--excluderepeatedly for fine control.
- ⭐ Star the repo: https://github.com/scottbaggett/dex
- 🐛 Issues: https://github.com/scottbaggett/dex/issues
- 🔧 PRs: https://github.com/scottbaggett/dex/pulls
MIT — see LICENSE