Skip to content

ToolmeshAI/docs-to-context

English | 中文

docs-to-context

docs-to-context social preview

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.

Quick Proof

  • 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 .git and node_modules, while keeping the runtime dependency-free.

Start Here

npx docs-to-context samples/docs -o dist/context.md

If 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.

docs-to-context demo

Features

  • 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 .git and node_modules
  • ships with zero runtime dependencies

Install

Use it directly from the repo:

node src/cli.mjs samples/docs

Or run the published package once without installing it globally:

npx docs-to-context samples/docs

Or install it globally to keep docs-to-context on your PATH:

npm install -g docs-to-context

Usage

The 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/docs

Bundle multiple inputs to a file:

docs-to-context samples/docs README.md README.zh-CN.md -o dist/context.md

Force headings to stay relative to a chosen workspace root:

docs-to-context samples/docs --root samples

Show help:

docs-to-context --help

CLI Options

Usage: 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

Supported File Types

.md, .txt, .json, .html, .yml, .yaml, .js, .mjs, .cjs, .ts, .tsx, .jsx, .css, .sh

Limitations

  • 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

Samples

The repo includes a nested sample set under samples/docs so you can inspect bundle behavior on a realistic tree.

Project Docs

Development

Run the sample bundle:

npm run bundle:sample

Run the tests:

npm test

Roadmap

  • 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

About

Zero-dependency CLI that turns scattered docs into one clean Markdown context bundle for LLMs and coding agents.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors