docgen - your entire project in one text file
A fast, intelligent project documentation generator that creates a single, comprehensive text file containing your entire project structure and source code. Perfect for sharing context with LLMs - just drop one file in an AI chat and discuss your entire project.
Recommended: add docgen to your git pre-commit process.
- 🌳 Visual directory tree of your project structure
- 📄 Concatenated file contents with clear separators
- 🎯 Smart filtering respects .gitignore and custom exclusions
- 🚫 Automatic binary detection skips images, executables, PDFs, etc.
- ⚙️ Configurable via .docgen_ignore file
- 🔄 Git-aware uses git check-ignore for accurate filtering
- 📊 Size limits skips files over 2MB by default
This installs docgen to /usr/local/bin/ so you can use it from anywhere.
Run docgen from your project's root directory:
If a .docgen_ignore file is present, that takes precedence over the defaults. (Be sure to include .git/ in your exclusions.)
Create a .docgen_ignore file in your project root to customize which files are included or excluded. It follows .gitignore syntax:
Note: .gitignore rules are always respected. .docgen_ignore adds additional exclusions/inclusions on top of git's ignore rules.
If no .docgen_ignore exists, docgen uses these defaults:
Always included:
- .gitignore
Always excluded:
- .git/ directory
- .DS_Store
Regardless of configuration, docgen always automatically excludes:
- Binary files: detected via file extensions and content analysis (images, PDFs, executables, archives, etc.)
- Previous docgen output: any file starting with # DOCGEN-OUTPUT: pragma
Patterns follow gitignore conventions:
- *.ext - matches files with that extension anywhere
- dirname/ - matches directory and all its contents
- !pattern - always include (negation)
- # - comments
- Blank lines are ignored
- Directory Walk: Recursively scans all files in the project
- Extension Filter: Quickly skips known binary extensions (.pdf, .jpg, .exe, etc.)
- Content Detection: Reads first 8KB of remaining files to detect:
- Binary content (null bytes, magic bytes like %PDF, non-printable characters)
- Previously generated docgen files (via # DOCGEN-OUTPUT: pragma)
- Git Integration: Uses git check-ignore to respect .gitignore rules
- Custom Filtering: Applies .docgen_ignore patterns on top of git rules
- Always Include: Forces inclusion of specified files even if gitignored
- Output Generation: Creates a file with:
- Directory tree visualization
- Each file's complete contents with clear headers
The generated project_doc.txt contains:
- 📤 Share with LLMs: Give AI assistants complete project context
- 👀 Code Reviews: Easy-to-read project snapshot
- 📚 Documentation: Auto-generated project overview
- 🔍 Audits: Quick scan of entire codebase
- 📊 Diffs: Track project evolution via git diffs of the output
We recommend committing the generated file to git because:
- Visibility: See how your project evolves over time through diffs
- Convenience: Anyone cloning the repo has immediate access
- History: Track documentation changes alongside code changes
The pragma comment prevents recursive inclusion if you regenerate while an old version exists.
See FUTURE.md
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT License - see LICENSE file for details.
Michael Teter
.png)

