Configuration Overview
Codemetry is designed to work out of the box with sensible defaults. Configuration is optional but allows fine-tuning for your specific workflow.
Configuration Files
Publishing the Config File
php artisan vendor:publish --tag=codemetry-configThis creates config/codemetry.php in your Laravel project.
Creating wp-cli.yml
Create a wp-cli.yml file in your project root:
codemetry: baseline_days: 56 follow_up_horizon_days: 3 keywords: fix_pattern: '/\b(fix|bug|hotfix|patch|typo|oops)\b/i' revert_pattern: '/\b(revert)\b/i' wip_pattern: '/\b(wip|tmp|debug|hack)\b/i' ai: enabled: false engine: openai api_key: ${CODEMETRY_AI_API_KEY} model: ${CODEMETRY_AI_MODEL} base_url: ${CODEMETRY_AI_BASE_URL} timeout: 30 batch_size: 10Viewing Current Configuration
wp codemetry configThis displays the active configuration including defaults and any overrides from wp-cli.yml.
Configuration Options
Analysis Window
'baseline_days' => 56, // Days of history for baseline comparison'follow_up_horizon_days' => 3, // Days to scan for follow-up fixescodemetry: baseline_days: 56 # Days of history for baseline comparison follow_up_horizon_days: 3 # Days to scan for follow-up fixesbaseline_days determines how much history is used to establish “normal” patterns:
- Default 56 days (8 weeks) provides stable baselines
- Shorter periods are more reactive to recent changes
- Longer periods are more stable but slower to adapt
follow_up_horizon_days controls how far ahead to look for fix commits:
- Default 3 days catches most immediate fixes
- Increase if your team’s fix cycle is longer
- Shorter values may miss delayed fixes
Keyword Patterns
'keywords' => [ 'fix_pattern' => '/\b(fix|bug|hotfix|patch|typo|oops)\b/i', 'revert_pattern' => '/\b(revert)\b/i', 'wip_pattern' => '/\b(wip|tmp|debug|hack)\b/i',],codemetry: keywords: fix_pattern: '/\b(fix|bug|hotfix|patch|typo|oops)\b/i' revert_pattern: '/\b(revert)\b/i' wip_pattern: '/\b(wip|tmp|debug|hack)\b/i'These regex patterns identify commit types:
- Fix pattern: Commits that fix issues
- Revert pattern: Commits that undo changes
- WIP pattern: Work-in-progress or temporary commits
See Keywords Configuration for customization details.
AI Configuration
'ai' => [ 'enabled' => false, // AI is opt-in 'engine' => env('CODEMETRY_AI_ENGINE', 'openai'), 'api_key' => env('CODEMETRY_AI_API_KEY', null), 'model' => env('CODEMETRY_AI_MODEL', null), // null = use engine default 'base_url' => env('CODEMETRY_AI_BASE_URL', null), // Custom API endpoint 'timeout' => env('CODEMETRY_AI_TIMEOUT', 30), // Request timeout in seconds 'batch_size' => env('CODEMETRY_AI_BATCH_SIZE', 10), // Days per API call],codemetry: ai: enabled: false # AI is opt-in engine: openai # openai, anthropic, deepseek, google api_key: ${CODEMETRY_AI_API_KEY} # Reference env var model: ${CODEMETRY_AI_MODEL} # null = use engine default base_url: ${CODEMETRY_AI_BASE_URL} # Custom API endpoint timeout: 30 # Request timeout in seconds batch_size: 10 # Days per API callAI summarization is disabled by default. To enable:
- Set
enabledtotrueor use--ai=1flag - Configure your preferred engine
- Provide API credentials via environment variables
Advanced options:
base_url: Custom API endpoint for self-hosted models or proxiestimeout: Request timeout in seconds (default: 30)batch_size: Number of days to process per API call (default: 10). Higher values mean fewer API calls but larger requests.
See AI Engines for setup instructions.
Environment Variables
Codemetry respects these environment variables:
| Variable | Purpose | Default |
|---|---|---|
CODEMETRY_AI_ENGINE | AI engine to use | openai |
CODEMETRY_AI_API_KEY | API key for AI engine | — |
CODEMETRY_AI_MODEL | Model override | Engine default |
CODEMETRY_AI_BASE_URL | Custom API endpoint | — |
CODEMETRY_AI_TIMEOUT | Request timeout (seconds) | 30 |
CODEMETRY_AI_BATCH_SIZE | Days per API call | 10 |
OPENAI_API_KEY | OpenAI API key (fallback) | — |
ANTHROPIC_API_KEY | Anthropic API key (fallback) | — |
DEEPSEEK_API_KEY | DeepSeek API key (fallback) | — |
GOOGLE_AI_API_KEY | Google AI API key (fallback) | — |
CLI Overrides
Most configuration options can be overridden via CLI flags:
# Override baseline periodphp artisan codemetry:analyze --days=7 --baseline-days=30
# Override follow-up horizonphp artisan codemetry:analyze --days=7 --follow-up-horizon=5
# Enable AI for single runphp artisan codemetry:analyze --days=7 --ai=1
# Specify AI enginephp artisan codemetry:analyze --days=7 --ai=1 --ai-engine=anthropic# Override baseline periodwp codemetry analyze --days=7 --baseline-days=30
# Override follow-up horizonwp codemetry analyze --days=7 --follow-up-horizon=5
# Enable AI for single runwp codemetry analyze --days=7 --ai=1
# Specify AI enginewp codemetry analyze --days=7 --ai=1 --ai-engine=anthropicRecommended Starting Configuration
For most projects, the defaults work well. Consider adjusting:
baseline_days: Increase to 90 for very stable projects, decrease to 30 for fast-moving projectsfollow_up_horizon_days: Increase to 5-7 if your team typically fixes issues later in the week- Keywords: Customize if your team uses different conventions
// Example: Fast-moving startup projectreturn [ 'baseline_days' => 30, 'follow_up_horizon_days' => 5, 'keywords' => [ 'fix_pattern' => '/\b(fix|bug|hotfix|patch|typo|oops|broken)\b/i', 'revert_pattern' => '/\b(revert|rollback)\b/i', 'wip_pattern' => '/\b(wip|tmp|debug|hack|todo)\b/i', ],];# Example: Fast-moving startup projectcodemetry: baseline_days: 30 follow_up_horizon_days: 5 keywords: fix_pattern: '/\b(fix|bug|hotfix|patch|typo|oops|broken)\b/i' revert_pattern: '/\b(revert|rollback)\b/i' wip_pattern: '/\b(wip|tmp|debug|hack|todo)\b/i'