generate-context
v1.0.1
Published
CLI tool to generate LLM-friendly code context files for AI, agents, embeddings, and prompt engineering.
Maintainers
Readme
📝 generate-context
Effortless context file generator for AI, LLMs, prompt engineering, code agents & embeddings.
Recursively grabs your codebase, filters noise, and spits out clean, LLM-friendly context files. 🚀
🚀 Features
- Recursively scans files & nested folders
- Fully configurable file filtering
- Priority files ordering (put your important files on top!)
- Auto prioritizes
README.mdby default - Works for files at any depth
- Exclude unwanted folders, extensions, or specific files
- Supports both CLI args & config file
- Friendly CLI: supports comma-separated OR space-separated inputs
- Dry-run mode to preview files
- Clean, LLM-friendly output format
- Beautiful colored CLI output 🎨
- Fast & lightweight pure Node.js CLI
📦 Installation
Clone the repo & install dependencies:
git clone <your-repo-url>
cd generate-context
npm installOptional: link globally:
npm linkOr:
npm install -g .⚡ Quick Usage
generate-contextScans current directory and creates prompt-context.txt like:
FILE: /src/file1.js
BEGIN FILE CONTENT
<file content here>
END FILE CONTENT
FILE: /public/index.html
BEGIN FILE CONTENT
<file content here>
END FILE CONTENT🔧 CLI Options
| Option | Description | Default |
| ----------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------- |
| -p, --path <path> | Path to scan | . |
| -o, --output <filename> | Output filename | prompt-context.txt |
| -F, --ignore-folders [folders...] | Folders to ignore (space/comma separated) | .git .vscode node_modules dist |
| -f, --ignore-files [files...] | Files to ignore (space/comma separated) | .env package-lock.json .generatecontextrc.json prompt-context.txt |
| -e, --ignore-extensions [extensions...] | Extensions to ignore (space/comma separated, no dot) | bat log tmp |
| -P, --priority-files [files...] | Files to always place on top (space/comma separated, any path) | README.md always default |
| -d, --dry-run | Show files that would be included without writing | false |
✅ Both comma , and space-separated values are supported.
🔧 Config File Support (.generatecontextrc.json)
You can also configure via file in project root:
{
"output": "my-context.txt",
"ignoreFolders": [".git", ".vscode", "node_modules", "dist", "coverage"],
"ignoreExtensions": ["bat", "log", "tmp", "env"],
"ignoreFiles": ["package-lock.json", ".env"],
"dryRun": false
}- CLI flags always override config values.
- Priority files take absolute priority regardless of directory depth.
🔥 Examples
Default usage
generate-contextCustom priority files
generate-context -P index.js bin/cli.js src/app.jsScan specific folder
generate-context -p ./srcChange output filename
generate-context -o context.txtIgnore folders
generate-context -F dist .cache coverage
# OR
generate-context --ignore-folders dist,.cache,coverageIgnore file extensions
generate-context -e log tmp env
# OR
generate-context --ignore-extensions log,tmp,envIgnore specific files
generate-context -f .env .DS_Store package-lock.json
# OR
generate-context --ignore-files .env,.DS_Store,package-lock.jsonCombine everything
generate-context -p ./backend -o my-context.txt -F dist .cache -e log tmp -f .env package-lock.json -P index.js schema/prisma/schema.prisma -dDry-run mode
generate-context -d📊 Output format (LLM optimized)
FILE: /relative/path/to/file.js
BEGIN FILE CONTENT
<actual file content>
END FILE CONTENT- ✅ Easy to parse
- ✅ No YAML or JSON headaches
- ✅ Perfect for LLM context injection
💡 Why this tool?
LLMs work better with clean, structured context from your codebase.
generate-context helps you package your files into simple, predictable formats for:
- AI agents
- Embeddings
- Prompt chains
- Fine-tuning data prep
- Code summarization pipelines
🤝 Contribute
Got ideas? Found bugs? Issues, PRs, and feedback always welcome!
Made with ❤️ by Mihir Patel
