Turn scattered docs into one clean Markdown bundle your agents can actually consume.
docs-to-context is a zero-dependency Node.js CLI that walks one or more text-heavy inputs and emits a single Markdown bundle with stable file headings.
- Bundle multiple files and directories in one command instead of copy-pasting docs by hand.
- Keep headings stable from the shared input root, or force the path base with
--root. - Write to stdout or an output file with
-o, --output, with parent directories created automatically. - Skip unsupported files plus
.gitandnode_modules, while keeping the runtime dependency-free.
npx docs-to-context samples/docs -o dist/context.mdIf you regularly feed repository docs into AI systems or coding agents, this is the "clean it once" CLI. Star the repo if it shortens your context-prep loop.
- accepts multiple files and directories in one command
- computes bundle headings from a shared input root by default
- lets you override the heading base with
--root - writes to stdout or a target file with
-o, --output - creates parent directories for output files
- skips unsupported files plus
.gitandnode_modules - ships with zero runtime dependencies
Use it directly from the repo:
node src/cli.mjs samples/docsOr run the published package once without installing it globally:
npx docs-to-context samples/docsOr install it globally to keep docs-to-context on your PATH:
npm install -g docs-to-contextThe commands below assume you are using docs-to-context through npx, a global install, or the repo-local node src/cli.mjs entrypoint.
Bundle one directory to stdout:
docs-to-context samples/docsBundle multiple inputs to a file:
docs-to-context samples/docs README.md README.zh-CN.md -o dist/context.mdForce headings to stay relative to a chosen workspace root:
docs-to-context samples/docs --root samplesShow help:
docs-to-context --helpUsage: docs-to-context <file-or-directory> [...more] [options]
Options:
-o, --output <file> Write the bundle to a file instead of stdout
--root <path> Override the base path used in bundle headings
-h, --help Show this help message
.md, .txt, .json, .html, .yml, .yaml, .js, .mjs, .cjs, .ts, .tsx, .jsx, .css, .sh
- binary files are ignored instead of converted or extracted
- there is no glob syntax yet; pass explicit files or directories
- very large repositories can still produce bundles that exceed model context windows
- there is no frontmatter-based filtering, chunking, or token budgeting yet
The repo includes a nested sample set under samples/docs so you can inspect bundle behavior on a realistic tree.
Run the sample bundle:
npm run bundle:sampleRun the tests:
npm test- add include/exclude patterns without pulling in heavy dependencies
- add chunked output modes for large documentation sets
- expose structured metadata for downstream tooling
- improve publish metadata and release automation

