- Commit messages - AI reads your diff and writes the message
- Code review - Catch issues before your teammates do
- Semantic search - Ask questions about your codebase in English
- Conflict resolution - Get AI suggestions for merge conflicts
Setup
API Key Configuration
AI features require an API key from OpenAI or Anthropic:Check Configuration
Using Different Models
AI Commands
Natural Language Commands
Ask questions or give commands in plain English:Generate Commit Messages
Code Review
Get AI-powered feedback on your changes:Explain Commits
Understand what a commit does:Conflict Resolution
Get AI help resolving merge conflicts:AI Tools
wit’s AI agent has access to specialized tools that give it full capabilities:Repository Understanding
| Tool | Purpose |
|---|---|
getStatus | Understand repository state (staged, modified, untracked files) |
getDiff | Analyze changes between commits or working directory |
getLog | Review commit history |
getBranches | Navigate and list branches |
search | Intelligent code and commit search |
Taking Actions
| Tool | Purpose |
|---|---|
stageFiles | Stage files for commit |
createCommit | Generate and create commits |
switchBranch | Switch to a different branch |
undo | Undo recent operations |
Conflict Resolution
| Tool | Purpose |
|---|---|
getMergeConflicts | Retrieve structured conflict information |
resolveConflict | Apply a resolution to a conflict |
Programmatic Usage
Use AI features in your TypeScript code:Using Individual Tools
Tips
- Be specific: “Show commits from last week that modified auth files” works better than “show commits”
-
Use context: The AI understands git concepts:
- “What’s the difference between my branch and main?”
- “Have I already committed the login changes?”
- Iterate: If the AI’s first response isn’t quite right, follow up with more details
-
Commit messages: The AI follows conventional commits format. For best results:
- Stage related changes together
- Don’t mix unrelated changes in one commit
-
Code review: Run
wit ai reviewbefore pushing to catch issues early
Environment Variables
| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY | OpenAI API key for GPT models | - |
ANTHROPIC_API_KEY | Anthropic API key for Claude models | - |
WIT_AI_MODEL | Model to use | openai/gpt-4o |
Supported Models
The AI integration uses@mastra/core which supports:
- OpenAI:
openai/gpt-4o,openai/gpt-4o-mini,openai/gpt-4-turbo - Anthropic:
anthropic/claude-sonnet-4,anthropic/claude-3-haiku - And more via the Mastra model router
Privacy & Security
AI features send code to external APIs. Consider:
- Don’t use on sensitive/proprietary code without approval
- Review AI suggestions before applying
- Only diff content is sent, not your full repository
What’s Sent
- Diff content (staged changes)
- Commit messages (for context)
- File paths
What’s NOT Sent
- Unstaged file contents (unless explicitly reviewing)
- Full repository history
- Configuration files with secrets
Troubleshooting
AI features not working
AI features not working
Check your API key:Make sure
OPENAI_API_KEY or ANTHROPIC_API_KEY is set correctly.Rate limiting
Rate limiting
If you hit rate limits:
- Wait a few minutes
- Consider upgrading your API plan
- Use a faster/cheaper model like
openai/gpt-4o-mini
Poor suggestions
Poor suggestions
For better results:
- Stage related changes together
- Don’t mix unrelated changes
- Be specific in natural language queries