A Node.js script that converts entire codebases into a single Markdown file, optimized for LLM context.
Have you ever tried to ask a question about a large project to a LLM? It can be a frustrating experience. You can't just paste the entire codebase, and explaining the architecture takes time.
This script solves that problem by creating a single, comprehensive Markdown file that you can easily share with an LLM. This provides the model with the necessary context to understand your project's structure, dependencies, and code, leading to more relevant and accurate answers.
- Recursive Traversal: Automatically walks through the directory structure.
- Content Aggregation: Reads and appends the content of each file.
- Ignore Patterns: Skips specified directories and files (configured in
ignore.json). - Customizable Output: Specify an output file or let the script create one in your Downloads folder.
- Clear Formatting: Each file's content is clearly marked with its path and enclosed in a code block.
- Clone the repository:
git clone https://github.com/sebasxs/codemap.git
- Navigate to the project directory:
cd codemap - Install the package globally:
This will make the
npm install -g .codemapcommand available in your system.
Once installed, you can run the codemap command from your terminal.
codemap <inputPath> [outputPath] [--exclude "file1,dir2,..."] [--include "file1,dir2,..."]<inputPath>: (Required) The path to the directory you want to export.[outputPath]: (Optional) The path where the final Markdown file will be saved. If not provided, it defaults to your Downloads folder.[--exclude "file1,dir2,..."]: (Optional) A comma-separated list of files and directories to ignore in the current run.[--include "file1,dir2,..."]: (Optional) A comma-separated list of files and directories to include in the current run.
# Export the 'my-project' directory to a markdown file
codemap ./my-project --exclude "tests,package-lock.json,logs" --include "schemas.sql"Now you can open the my-project.md file and paste its content into your LLM of choice.
This project is licensed under the ISC License.
