Codemap.Cli 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global Codemap.Cli --version 1.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Codemap.Cli --version 1.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Codemap.Cli&version=1.1.0
                    
nuke :add-package Codemap.Cli --version 1.1.0
                    

codemap

codemap turns your repository into clear, AI-ready context. Choose which files to include, add Git history or reusable Skills, control output size, and safely review or apply changes returned as standard Git diffs.

.NET 10 License

Documentation: https://meysamhadeli.github.io/codemap/

Contents

Installation

Install codemap as a global command-line tool. This lets you run codemap from any terminal and any project folder:

dotnet tool install --global Codemap.Cli

Then run it from any directory with codemap.

Running codemap without options scans the current directory and copies the generated context to the clipboard by default. Change into the repository directory before running it.

Quick Start

  • Include selected paths: codemap -i "src,tests" -e "**/bin/**,**/obj/**"
  • Generate patch context: set "usePatch": true in the global config, then run codemap

The usual AI-assisted workflow is:

Codemap AI-assisted workflow

  1. Pack the repository in patch mode with codemap.
  2. Send the generated context to an AI provider and ask for one bash script.
  3. Save the response as changes.sh in the repository root.
  4. Review the script, then run bash changes.sh.

Codemap produces context. It does not execute AI output, run Skill instructions, or silently modify repository files.

Features

Capability What it does
๐Ÿ“ฆ Repository packing Combines selected text files into one AI-ready artifact.
๐ŸŽฏ File selection Includes and excludes paths with glob patterns.
๐Ÿšซ Ignore rules Respects .gitignore, .ignore, and built-in generated-directory exclusions.
๐Ÿ“ Output formats Renders Markdown, XML, JSON, or plain text.
๐Ÿ“ค Output destinations Writes to a file, stdout, or the system clipboard.
๐Ÿฉน Patch workflow Generates patch instructions for a bash script.
๐Ÿง  Skill loading Adds named or explicit project and user Skills as read-only context.
๐Ÿ›ก๏ธ Security scanning Optionally uses DevSkim to redact every detected security finding as ***.
๐Ÿ”ข Token accounting Reports per-file and total cl100k_base token counts.
๐Ÿ“ Output limits Enforces file-size and token budgets and can split large output.
๐ŸŒ Remote repositories Clones and packs a Git repository or selected branch.
โš™๏ธ Configuration Loads one global configuration file, with CLI overrides.
๐Ÿ‘€ Watch mode Reports local source changes so output can be refreshed.
๐ŸŒณ Repository context Adds file summaries, top files by tokens, empty directories, and directory structure to supported formats.
๐Ÿ“„ Instructions and headers Prepends a custom instruction file and header text to the output.
๐Ÿค– MCP server Runs codemap as a Model Context Protocol server over stdio.
๐Ÿงน Content transformations Removes comments or empty lines and adds line numbers.

How to Run

codemap's main workflow is simple: choose a source directory, select an output format, and copy the generated repository context to the clipboard or choose another output destination. The examples below focus on core commands.

โ” Help

Use the built-in help whenever you need to check available commands and options:

codemap -h

๐Ÿ”€ Include and Exclude

Use --include to select files and --exclude to remove paths from that selection:

codemap \
	-i "src/**/*.cs,README.md" \
	-e "**/bin/**,**/obj/**" \
	-f markdown \
	-o source-context.md

Both options accept individual files, folders, comma-separated values, and glob patterns:

# One file and one folder, including all files below the folder
codemap -i "README.md,src"

# Every C# file, except generated files and build folders
codemap -i "**/*.cs" -e "**/*.generated.cs,**/bin/**,**/obj/**"

# Match a file name in any folder
codemap -i "*.cs" -e "test-*.cs"

# Match folders anywhere in the repository; spaces after commas are allowed
codemap -i "**/Api, **/tests" -e "/**/generated, **/bin"

# Match everything below folders anywhere in the repository
codemap -i "/**/Api/**" -e "/**/tests/**"

Pattern rules:

  • * matches any characters except /.
  • ** matches across folders.
  • ? matches one character.
  • A literal or wildcard folder such as src or **/Api includes or excludes everything below it.
  • Leading and trailing / are optional for repository-relative patterns.
  • Separate multiple files, folders, or patterns with commas.

codemap also reads .gitignore and .ignore automatically.

The same selection can use short aliases: codemap -i "src/**/*.cs" -e "**/bin/**,**/obj/**" -f markdown -o source-context.md.

๐Ÿฉน Patch

Generate repository context with patch-generation instructions. Patch mode is enabled by "usePatch": true in the global configuration; then run codemap and it prints to stdout:

codemap

Send that context to an AI provider and ask it to return one bash script. Save the AI response as a .sh file, such as changes.sh, in the repository root. The script writes each changed file in full with a quoted heredoc and removes deleted files. codemap only creates context in patch mode; it does not create the script.

Review the script, then run it from the repository root:

bash changes.sh

Bash is required (Git Bash or WSL on Windows). usePatch is false by default.

๐Ÿง  Skills

Load reusable AI instructions from a project or user Skill directory:

codemap -s review,architecture

Named Skills are searched in this order:

  1. .agents/skills/<name>/SKILL.md
  2. .agent/skills/<name>/SKILL.md
  3. .claude/skills/<name>/SKILL.md
  4. The same directories under the current user's home directory.
  5. ~/.codemap/skills/<name>/SKILL.md

Load one exact Skill file when a deterministic path is preferred:

codemap -s .agents/skills/review/SKILL.md

Repeat --skills to load multiple names or explicit files. Use -s as its short alias. Skill files are read as text and never executed. Named Skills use project files before global files; explicit paths do not perform discovery.

๐Ÿ“ Format

The default format is Markdown. Use --format to choose another output format when needed:

# Human- and AI-friendly document
codemap -f markdown -o repository.md

# Structured data for another program
codemap -f json -o repository.json

# XML or simple text output
codemap -f xml -o repository.xml
codemap -f plain -o repository.txt

๐Ÿ›ก๏ธ Security Check

Use DevSkim to exclude files with actionable security findings before they enter the generated context:

codemap \
	--security-check \
	-f markdown \
	-o reviewed-context.md

codemap reports excluded files in the terminal. Node.js and npm are not required.

๐ŸŒ Remote

codemap can clone a repository and pack a selected branch:

codemap \
	-r microsoft/generative-ai-for-beginners \
	-b main \
	-f markdown \
	-o remote-context.md

The same command accepts a complete Git URL. Git must be installed and available on PATH for remote repositories and Git metadata.

๐Ÿ”„ Workflows

๐Ÿ” Review a repository

Create a focused Markdown snapshot and send it to an AI tool with a specific request:

codemap \
	-i "src/**/*.cs,tests/**/*.cs,README.md" \
	-e "**/bin/**,**/obj/**" \
	-f markdown \
	-o review-context.md

Example request:

Review this repository for correctness, security risks, and missing tests.
Do not propose changes outside the selected files. Reference files by path.

Command Reference

General form:

codemap [options]
codemap stdout [options]
codemap clipboard [options]
codemap --stdout [options]
codemap --clipboard [options]
codemap mcp

Show the built-in command reference at any time:

codemap --help
Command or option Alias Value Description
--include -i comma-separated globs Include only matching paths.
--exclude -e comma-separated globs Add exclusion patterns for this run.
--format -f xml, markdown, md, json, plain, txt Output format. Defaults to Markdown.
--output -o path Output file path. Defaults to codemap-output.md.
--stdout - flag Write packed output to standard output.
--clipboard - flag Copy packed output to the clipboard.
--output-mode - file, stdout, clipboard Default output destination. Defaults to clipboard.
--copy-to-clipboard - flag Also copy normal file or stdout output to the clipboard.
--no-copy-to-clipboard - flag Disable configured automatic clipboard copying for this run.
--max-file-size -m bytes Skip files larger than this size before reading them.
--token-budget -t count Fail if the final rendered output exceeds this token count.
--skills -s comma-separated names or paths Load named or explicit Skills. Repeat to load multiple values.
--watch -w flag Watch a directory and report changes.
--version -v flag Show the tool version.
--help -h flag Show command usage, options, and examples.
--remote -r URL or owner/repository Clone a remote Git repository into a temporary directory before packing.
--remote-branch -b branch Branch to clone when using --remote.
--no-summary - flag Remove file count and token summary from structured output.
--summary - flag Include file count and token summary.
--no-tree - flag Remove the directory/file listing from structured output.
--tree - flag Include the directory/file listing.
--line-numbers - flag Prefix each output line with its line number.
--no-line-numbers - flag Disable line numbers.
--remove-comments - flag Remove common comments before rendering.
--no-remove-comments - flag Preserve source comments.
--remove-empty-lines - flag Remove blank lines after other transformations.
--no-remove-empty-lines - flag Preserve blank lines.
--security-check - flag Scan original files with DevSkim and exclude files with findings.
--no-security-check - flag Disable security scanning.
--include-diffs - flag Include git diff output.
--no-include-diffs - flag Disable Git diff output.
--include-logs - flag Include recent one-line Git commits.
--no-include-logs - flag Disable Git commit output.
--include-logs-count - count Number of commits to include. Defaults to 20.
--split-output - bytes Split output into numbered files when the rendered content exceeds this size.
--instruction - path Prepend a custom instruction file to the output. Saved as instructionPath.
--header-text - text Add header text at the top of the output. Saved as headerText.
--truncate-base64 - flag Replace long base64 runs with [base64 data truncated]. Saved as truncateBase64.
--no-truncate-base64 - flag Keep base64 runs unchanged for this run.

Boolean options can be enabled or disabled explicitly. For example, --security-check enables scanning and --no-security-check disables it, overriding the configuration file for that run.

Output formats

Format Best for Option
Markdown Human review and most AI prompts --format markdown
Plain text Simple pipes and terminals --format plain
JSON Programmatic processing --format json
XML Consumers that prefer tagged structure --format xml

Patch mode ("usePatch": true) preserves the selected output format while adding instructions for generating a bash patch script. stdout and clipboard are output destinations; they are not formats.

Configuration

Configuration uses JSON. codemap loads one global configuration file for every source repository:

Operating system Global configuration path
Windows %USERPROFILE%\.codemap\codemap.json
Linux ~/.codemap/codemap.json
macOS ~/.codemap/codemap.json

Create or update the global configuration. If the file does not exist, codemap config creates the .codemap directory and a configuration with default values. Only supplied options change; existing settings are preserved:

codemap config \
	--removeComments true \
	--removeEmptyLines true \
	--enableSecurityCheck true \
	--copyToClipboard true

Boolean values use explicit true or false values when saving configuration. For example:

codemap config \
	--max-file-size 500000 \
	--token-budget 12000 \
	--includeGitDiffs false

config always updates the global configuration file, which later commands load automatically:

codemap config \
	--include "src, tests" --exclude "**/bin/**, **/obj/**"

The same settings can be edited directly in the global JSON file. includePatterns is a global allow-list; excludePatterns removes matching paths from it. Literal directories match all descendants, so this excludes build output everywhere:

{
	"includePatterns": ["**/*"],
	"excludePatterns": ["/bin", "/obj"]
}

Global includes are useful when every repository should be limited to a file family, for example "**/*.cs". Built-in exclusions for .git, bin, obj, node_modules, dist, and coverage apply even when they are not listed in configuration.

For example:

codemap config \
	--copyToClipboard true \
	--includeGitLogs true \
	--include-logs-count 10

The global file uses this same path on every platform.

Choose the default output destination with outputMode. The default is clipboard:

codemap config --output-mode stdout

Valid values are file, stdout, and clipboard. Explicit --stdout, --clipboard, or stdout/clipboard commands override the configured mode for one run.

{
	"outputPath": "artifacts/repository.md",
	"format": "Markdown",
	"outputMode": "clipboard",
	"copyToClipboard": true,
	"includeFileSummary": true,
	"includeDirectoryStructure": true,
	"showLineNumbers": false,
	"removeComments": true,
	"removeEmptyLines": true,
	"enableSecurityCheck": true,
	"maxFileSizeBytes": 500000,
	"tokenBudget": 12000,
	"includeGitDiffs": false,
	"includeGitLogs": true,
	"gitLogCount": 10,
	"splitOutputBytes": 200000,
	"instructionPath": null,
	"headerText": null,
	"truncateBase64": false
}

When copyToClipboard is true, codemap writes its normal file output or stdout output and also copies the same final content to the clipboard. Use --copy-to-clipboard for a one-time override or --no-copy-to-clipboard to disable a configured setting for one run. --clipboard remains clipboard-only output.

Command-line values override configuration values. For list options such as --include and --exclude, the command-line value replaces the configured list.

Advanced Capabilities

๐Ÿšซ Ignore

Use .ignore to keep repository-specific files out of generated context, such as local notes, logs, fixtures, or generated output. Place it in the source root and add one glob per line; codemap also reads .gitignore, supports comments and ordered rules, and uses ! to re-include a matching path. Common generated directories are excluded automatically.

๐Ÿ”ข Token Counts

Token counts help estimate how much context an AI tool will receive. codemap reports per-file and final-output counts using the GPT-4-compatible cl100k_base encoding; use --token-budget to reject oversized output, --max-file-size to skip large files, or --split-output to create smaller parts.

๏ฟฝ Instructions and Headers

Use --instruction <path> to prepend a custom instruction file and --header-text <text> to add a header at the top of the output. Both values can be saved with codemap config. Instructions are added to Markdown, XML, JSON, and plain output.

Use --truncate-base64 to replace long base64 runs with [base64 data truncated] and keep the rest of the file unchanged.

๐ŸŒณ Summaries

Markdown, XML, and JSON output list the top files by token count and any empty directories that pass the include and exclude rules.

๐Ÿค– MCP Server

Run codemap as a Model Context Protocol server over stdio so MCP clients can request packed context:

codemap mcp

The server exposes one tool, pack_codebase. It accepts directory, include, exclude, format, removeComments, removeEmptyLines, truncateBase64, instructionPath, and headerText, returns the packed content as text, and does not write files.

๏ฟฝ๐Ÿ”„ Workflow

Use --remote when the repository is not available locally; codemap clones it into a temporary directory and packs the selected branch. For repository history, --include-diffs adds current changes and --include-logs adds recent commits. --watch monitors a local source tree and reports changes so you can run codemap again.

Support

If you like my work, feel free to:

  • โญ this repository. And we will be happy together ๐Ÿ˜ƒ

Thanks a bunch for supporting me!

๐Ÿค Contribution

Thanks to all contributors, you're awesome and this wouldn't be possible without you! The goal is to build a categorized, community-driven collection of very well-known resources.

Please follow this contribution guideline to submit a pull request or create the issue.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.1.1 52 12/2/2026
1.1.0 58 12/2/2026
1.0.12 140 9/24/2026
1.0.11 114 9/24/2026
1.0.10 138 9/22/2026
1.0.9 132 9/20/2026
1.0.8 119 9/20/2026
1.0.7 128 9/18/2026
1.0.6 129 9/17/2026
1.0.5 123 9/15/2026
1.0.4 120 9/14/2026
1.0.3 136 9/13/2026
1.0.2 117 9/12/2026
1.0.1 118 9/12/2026
1.0.0 135 9/12/2026
0.1.0 108 9/18/2026

Initial release of the codemap command-line tool.