Skip to main content
This page documents all environment variables used by wit for configuration.

AI Features

VariableDescriptionRequired
OPENAI_API_KEYOpenAI API key for AI featuresFor AI
ANTHROPIC_API_KEYAnthropic API key (alternative to OpenAI)For AI
WIT_AI_MODELAI model to use (default: gpt-4o)No

Usage

# Use OpenAI
export OPENAI_API_KEY="sk-..."

# Or use Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."

# Specify model
export WIT_AI_MODEL="gpt-4-turbo"

VariableDescriptionDefault
WIT_SEARCH_MODELEmbedding model for searchtext-embedding-3-small
WIT_SEARCH_IGNOREPatterns to ignore (comma-separated)node_modules,dist,.git

Usage

export WIT_SEARCH_MODEL="text-embedding-3-large"
export WIT_SEARCH_IGNORE="node_modules,dist,build,.git,vendor"

Server & Platform

VariableDescriptionDefault
PORTAPI server port3000
HOSTHostname to bind0.0.0.0
DATABASE_URLPostgreSQL connection stringRequired for server
REPOS_DIRRepository storage path./repos
JWT_SECRETSecret for JWT token signingRequired for auth
NODE_ENVEnvironment modedevelopment

Usage

# Database connection
export DATABASE_URL="postgresql://user:password@localhost:5432/wit"

# Server configuration
export PORT=3000
export HOST="0.0.0.0"
export REPOS_DIR="/var/lib/wit/repos"

# Security
export JWT_SECRET="your-secure-secret-key"
export NODE_ENV="production"

Repository Storage (REPOS_DIR)

The REPOS_DIR environment variable controls where wit stores git repositories on disk. This is a critical setting for the platform to function correctly.
If REPOS_DIR is not set correctly, you may see “Repository not found on disk” errors when trying to view files, save changes in the IDE, or perform git operations.

How It Works

When you create a repository through the web UI, wit:
  1. Creates a bare git repository at {REPOS_DIR}/{username}/{repo-name}.git
  2. Stores the path /repos/{username}/{repo-name}.git in the database
  3. Resolves this path using REPOS_DIR when accessing the repository

Configuration Examples

# Development (default) - relative to project directory
REPOS_DIR=./repos

# User home directory
REPOS_DIR=~/.wit/repos

# Absolute path for production
REPOS_DIR=/var/lib/wit/repos

# Docker volume
REPOS_DIR=/data/repos

Troubleshooting

If you’re getting “Repository not found on disk” errors:
  1. Check where repos are stored:
    # Find existing repositories
    find ~/.wit -name "*.git" -type d 2>/dev/null
    find ./repos -name "*.git" -type d 2>/dev/null
    
  2. Set REPOS_DIR to match:
    # In your .env file
    REPOS_DIR=/path/to/where/repos/actually/are
    
  3. Restart the server:
    wit down && wit up
    

Migration

If you need to move repositories to a new location:
# 1. Stop the server
wit down

# 2. Move repositories
mv ./repos /var/lib/wit/repos

# 3. Update .env
echo 'REPOS_DIR=/var/lib/wit/repos' >> .env

# 4. Restart
wit up

Git Configuration

VariableDescriptionUsed For
WIT_AUTHOR_NAMEDefault commit author nameCommits
WIT_AUTHOR_EMAILDefault commit author emailCommits
GIT_AUTHOR_NAMEFallback author nameCommits
GIT_AUTHOR_EMAILFallback author emailCommits
wit checks WIT_* variables first, then falls back to GIT_* variables.

Usage

export WIT_AUTHOR_NAME="Your Name"
export WIT_AUTHOR_EMAIL="you@example.com"

Code Review

VariableDescriptionRequired
CODERABBIT_API_KEYCodeRabbit API keyFor CodeRabbit reviews

Usage

export CODERABBIT_API_KEY="your-coderabbit-key"
wit review --coderabbit

Email Notifications

Email configuration for collaborator invitations.
VariableDescriptionDefault
RESEND_API_KEYResend API key-
EMAIL_FROM_ADDRESSSender email addressnoreply@wit.dev
EMAIL_FROM_NAMESender display namewit

Usage

export RESEND_API_KEY="re_..."
export EMAIL_FROM_ADDRESS="noreply@yourcompany.com"
export EMAIL_FROM_NAME="Your Company Git"

GitHub Integration

VariableDescriptionRequired
GITHUB_TOKENGitHub personal access tokenFor GitHub features
GITHUB_CLIENT_IDOAuth app client IDFor OAuth
GITHUB_CLIENT_SECRETOAuth app client secretFor OAuth

Usage

# Personal access token for CLI
export GITHUB_TOKEN="ghp_..."

# OAuth for web app
export GITHUB_CLIENT_ID="your-client-id"
export GITHUB_CLIENT_SECRET="your-client-secret"

SSH Configuration

VariableDescriptionDefault
SSH_PORTSSH server port22
SSH_HOST_KEYPath to host key~/.wit/ssh/host_key

Development & Debugging

VariableDescriptionDefault
DEBUGEnable debug loggingfalse
WIT_VERBOSEVerbose outputfalse
LOG_LEVELLog level (debug, info, warn, error)info

Usage

# Enable debug mode
export DEBUG=true
export LOG_LEVEL="debug"
export WIT_VERBOSE=true

Rate Limiting

VariableDescriptionDefault
RATE_LIMIT_WINDOWRate limit window (ms)60000
RATE_LIMIT_MAXMax requests per window100
RATE_LIMIT_ENABLEDEnable rate limitingtrue

Example Configuration

Development Environment

# .env.development
OPENAI_API_KEY="sk-dev-key"
DATABASE_URL="postgresql://wit:wit@localhost:5432/wit"
PORT=3000
NODE_ENV="development"
DEBUG=true
LOG_LEVEL="debug"

Production Environment

# .env.production
OPENAI_API_KEY="sk-prod-key"
DATABASE_URL="postgresql://wit:secure-password@db.example.com:5432/wit"
PORT=3000
NODE_ENV="production"
JWT_SECRET="your-very-secure-secret"
REPOS_DIR="/var/lib/wit/repos"

# Email
RESEND_API_KEY="re_..."
EMAIL_FROM_ADDRESS="git@yourcompany.com"

# Rate limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_MAX=100

CI/CD Environment

# For CI pipelines
WIT_AUTHOR_NAME="CI Bot"
WIT_AUTHOR_EMAIL="ci@yourcompany.com"
GITHUB_TOKEN="${GITHUB_TOKEN}"

Loading Environment Variables

Using .env Files

wit supports .env files in your project root:
# Create .env file
cat > .env << EOF
OPENAI_API_KEY=sk-...
DATABASE_URL=postgresql://...
EOF

# wit automatically loads .env
wit ai commit

Using direnv

For project-specific configuration:
# .envrc
export OPENAI_API_KEY="sk-..."
export WIT_AUTHOR_EMAIL="work@company.com"

Shell Configuration

Add to your shell profile (~/.bashrc, ~/.zshrc):
# wit configuration
export OPENAI_API_KEY="sk-..."
export WIT_AUTHOR_NAME="Your Name"
export WIT_AUTHOR_EMAIL="you@example.com"

Security Best Practices

  1. Never commit secrets - Use .env files and add them to .gitignore
  2. Use different keys per environment - Dev, staging, production
  3. Rotate secrets regularly - Especially for production
  4. Use secret managers - AWS Secrets Manager, HashiCorp Vault, etc.
# .gitignore
.env
.env.local
.env.*.local