codecontext init
Initialize CodeContext in your project and generate your first documentation
Usage
codecontext init [options]
The init
command initializes CodeContext in your current project directory. It will:
- Check if you're in a git repository (or offer to create one)
- Ask for project information through interactive prompts
- Analyze your codebase structure
- Generate initial documentation based on your codebase
- Create a
.codecontext.json
configuration file - Configure git hooks for auto-updates (Pro users only)
Options
-y, --yes
Skip interactive setup and use defaults
$ codecontext init -y
Configuration
After initialization, CodeContext creates a configuration file at .codecontext.json
:
{ "projectName": "my-awesome-project", "description": "A modern web application", "features": ["readme", "changelog", "contributing", "api"], "docStyle": "comprehensive", "autoUpdate": true, "publishSettings": { "subdomain": "my-awesome-project", "theme": "default" } }
Interactive Prompts
Project Name
The name of your project. Defaults to the directory name or package.json name.
Default: package.json name or directory name
Brief Description
A short description of your project. Used in the README header.
Default: package.json description or "An awesome project"
Documentation Features
Select which documentation files to generate. CodeContext analyzes your project and suggests appropriate documentation.
readme
changelog
contributing
api
Documentation Types
Select which documentation files to generate:
No API Keys Required!
Managed AI Service
CodeContext uses a managed AI service - no API keys needed! Just install and start using.
• No API keys required
• No configuration needed
• Enterprise-grade security
• We handle all the AI complexity for you
Git Hooks (Pro Feature)
Automatic Updates for Pro Users
Pro users get automatic git hooks configured during initialization:
# .git/hooks/pre-commit #!/bin/sh codecontext context --update --quiet
This ensures your documentation context stays up-to-date with every commit!
Examples
Basic initialization
$ codecontext init
Skip prompts and use defaults
$ codecontext init --yes
Initialize in a specific directory
$ cd my-project && codecontext init
Troubleshooting
"Not a git repository" error
CodeContext requires git to analyze your commit history. Either initialize git first with git init
, or let CodeContext do it for you when prompted.
"Daily limit reached" error
Free plan includes 5 daily documentation updates. You can either wait until midnight UTC for the limit to reset, or upgrade to a paid plan with codecontext upgrade
for higher limits.
"CodeContext already initialized" message
CodeContext is already set up in this project. You can either reinitialize (which will overwrite existing config) or use codecontext update
to regenerate documentation.
See Also
- codecontext update - Update existing documentation
- codecontext config - Configure CodeContext settings
- Quick Start Guide - Get started in 60 seconds