A terminal UI tool for building context files for LLMs, built with Python and Textual. Visually select files from your projects and generate formatted context documents suitable for prompting large language models. Largely inspired by Simon Willison's files-to-prompt project
- Terminal-native UI — runs anywhere Python runs
- File explorer with checkbox selection (lazy-loaded for large projects)
- Support for different output formats (XML, Markdown, Plain Text)
- Live preview with accurate token counting (tiktoken)
- Smart file filtering (respects .gitignore, hidden files toggle)
- Custom instructions field included in output
- Optional project structure tree in generated context
- Line numbering option
- Copy to clipboard and save to file
- Keyboard shortcuts for fast workflow
- Clone the repository:
git clone https://github.com/pachev/context-builder
cd context-builder- Install dependencies:
uv sync- Install globally:
uv tool install -e .Open the TUI for the current directory:
ctx-builder .Or specify a different directory:
ctx-builder /path/to/project| Key | Action |
|---|---|
a |
Select all files |
d |
Deselect all files |
c |
Copy output to clipboard |
ctrl+s |
Save output to file |
q |
Quit |
- XML: Structured format with
<context>,<projectTree>, and<file>tags - Markdown: GitHub-flavored markdown with fenced code blocks
- Plain Text: Simple format with file paths and separators
- Python 3.10+
- Textual
- tiktoken
Apache License 2.0
