Dir2md analyzes directory structures and generates comprehensive markdown documentation optimized for Large Language Models. It intelligently samples content, removes duplicates, and provides token-budget control to create the perfect context for AI-assisted development.
1# From source (current)
2git clone https://github.com/your-org/dir2md.git
3cd dir2md
4python -m src.dir2md.cli --help
5
6# Coming soon: PyPI installation
7pip install dir2md
1# Generate project blueprint (developer-friendly raw mode)
2dir2md .
3
4# With basic security masking
5dir2md . --masking basic
6
7# Generate with manifest for CI/CD
8dir2md . --emit-manifest --no-timestamp
9
10# Token-optimized for LLM context
11dir2md . --budget-tokens 4000 --preset iceberg
1# Project Blueprint
2
3- Root: `/path/to/project`
4- Generated: `2025-09-08 12:30:15`
5- Preset: `raw`
6- LLM mode: `inline`
7- Estimated tokens (prompt): `6247`
8
9## Directory Tree
10[Complete file structure]
11
12## Statistics
1314|--------|-------|
15| Total files | 42 |
16| Estimated tokens | 6247 |
17
18## File Contents
19[Intelligently sampled content...]
1# Basic options
2dir2md [path] -o output.md --preset [iceberg|pro|raw]
3
4# Token control
5--budget-tokens 6000 # Total token budget
6--max-file-tokens 1200 # Per-file token limit
7--sample-head 120 # Lines from file start
8--sample-tail 40 # Lines from file end
9
10# Filtering
11--include-glob "*.py,*.md" # Include patterns
12--exclude-glob "test*,*.tmp" # Exclude patterns
13--only-ext "py,js,ts" # File extensions only
14
15# Security
16--masking [off|basic|advanced] # Secret masking level
17
18# Output
19--emit-manifest # Generate JSON metadata
20--no-timestamp # Reproducible output
21--dry-run # Preview without writing
1git clone https://github.com/your-org/dir2md.git
2cd dir2md
3python -m pytest -v # Run tests
4python -m src.dir2md.cli . --dry-run # Test CLI
This project is licensed under the MIT License - see the
LICENSE file for details.
Pro features are available under a separate commercial license.
Dir2md solves these problems with intelligent analysis, sampling, and optimization specifically designed for the AI era.