ai utility
ctxstuff icon

ctxstuff.

dump your codebase into a single file for llm context.

ctxstuff traverses your directory and concatenates your source files into one large text block. it automatically ignores build artifacts and hidden directories.

what it is

ctxstuff is a cli that packs a codebase into one llm-friendly text file. it generates a directory tree and appends the contents of every relevant file. it respects your .gitignore and automatically skips common junk directories like node_modules, dist, and venv.

copy-pasting multiple files into a web ui is tedious and error-prone. existing tools often grab compiled binaries or massive lockfiles, wasting your token budget. ctxstuff filters out the noise so the llm only sees the source code that matters.

if you use Claude or GPT-4 to refactor entire modules or understand undocumented legacy code, this speeds up the workflow. it formats the output with clear file paths and markdown blocks so the model understands the project structure.

core features

~

smart ignoring

automatically skips node_modules, dist, and venv directories. respects your existing .gitignore rules.

~

directory tree

generates a visual map of your project structure at the top of the file. gives the llm spatial context.

~

markdown formatting

wraps each file's contents in properly tagged markdown code blocks. ensures the model parses the syntax correctly.

~

clipboard integration

copies the final output directly to your clipboard. ready to paste into your chat interface.

~

file filtering

include or exclude specific file extensions via command line flags. keep images and binaries out of your context.

how to use it

pack your src directory into a single file, ignoring tests.

// input

ctxstuff ./src --ignore '*.test.js' > context.txt

// output

packed 14 files.
ignored 3 files based on flags.
ignored 120 files in node_modules.
output written to context.txt.

the resulting text file contains a directory tree and the contents of your source code, ready for the llm.

why we built it

we were tired of manually copying and pasting twenty different source files into a chat window just to ask a simple architecture question. doing that manually guarantees you will forget a crucial utility file.

we initially tried using standard unix tools like cat and find, but dealing with node_modules and hidden git directories made the commands unreadable. ctxstuff just does what you actually want without requiring a massive bash alias.

frequently asked questions

does it handle binary files?

no. it detects binary files and skips them automatically. you will not end up with a wall of gibberish in your prompt.

can i customize the ignore list?

yes. you can pass a custom .ctxignore file or use command line flags to exclude specific patterns.

is there a limit to how many files it can pack?

the cli has no hard limit, but your llm's context window does. use tokcount to verify the output size before pasting.

does it minify the code?

no. we leave the formatting intact because language models rely on indentation and whitespace to understand code structure.

// feed the machine exactly what it needs to read.