Contextify is a CLI tool designed to facilitate Context-Driven Development by automatically generating and maintaining CONTEXT.md files throughout your codebase. It uses Google Gemini to analyze your code and create hierarchical documentation, making it easier for AI agents and human developers to understand the project structure.
- Bottom-Up Generation: Starts from the deepest subdirectories and bubbles up context to the root, ensuring high-level documentation reflects low-level details.
- Automatic Updates: Smartly updates existing
CONTEXT.mdfiles, preserving manual developer notes while refreshing technical details. - Respects Ignore Files: Honors
.gitignoreand supports a custom.contextignoreto exclude specific files or folders from analysis. - Large File Handling: Automatically truncates files larger than 200KB to fit within the context window, keeping the most relevant parts (head and tail).
- Gemini Powered: Uses Google's Gemini models for high-quality summarization.
npm install -g contextify
# OR run directly with npx
npx contextify runFirst, you need to set your Google Gemini API Key. You can do this via the CLI or by setting an environment variable.
contextify initFollow the prompts to enter your API Key.
Alternatively, set GEMINI_API_KEY in your environment or a .env file.
Navigate to the root of your project and run:
contextify runThis will:
- Traverse your directory tree (bottom-up).
- Read file contents (respecting ignores).
- Read existing
CONTEXT.mdfiles from subdirectories. - Generate or Update the
CONTEXT.mdfor the current directory using Gemini.
.gitignore: Files listed here are ignored..contextignore: Add this file to your project root to ignore specific files/folders only for Contextify (e.g., if you want to ignore documentation files but keep them in git).
- Node.js >= 18
- Google Gemini API Key