CLI Options
Command Syntax
php artisan codemetry:analyze [options]wp codemetry analyze [options]Available Options
| Option | Default | Description |
|---|---|---|
--days | 7 | Number of days to analyze (ignored if both --since and --until are set) |
--since | - | Start date (ISO 8601 format) |
--until | - | End date (ISO 8601 format) |
--author | - | Filter by author name (substring match) |
--branch | - | Filter by branch name |
--format | table | Output format: table or json |
--ai | 0 | Enable AI explanations: 0 or 1 |
--ai-engine | openai | AI engine: openai, anthropic, deepseek, google |
--baseline-days | 56 | Days of history for baseline |
--follow-up-horizon | 3 | Days to scan for follow-up fixes |
--repo | base_path() | Path to Git repository |
Date Range Options
Using --days
Analyze the last N days from today:
php artisan codemetry:analyze --days=14wp codemetry analyze --days=14Using --since and --until
Analyze a specific date range:
php artisan codemetry:analyze --since=2024-01-01 --until=2024-01-31wp codemetry analyze --since=2024-01-01 --until=2024-01-31Dates must be in ISO 8601 format:
2024-01-152024-01-15T10:00:002024-01-15T10:00:00+00:00
Combining Options
When both --since/--until and --days are provided:
- If both
--sinceand--untilare set,--daysis ignored - If only
--sinceis set, analysis runs from that date to now - If only
--untilis set, analysis counts back--daysfrom that date
Filter Options
--author
Filter commits by author name:
php artisan codemetry:analyze --days=7 --author="Jane"wp codemetry analyze --days=7 --author="Jane"Uses substring matching, so “Jane” matches:
- “Jane Doe”
- “Jane Smith”
- “janet@example.com” (if author name contains “jane”)
--branch
Analyze commits from a specific branch:
php artisan codemetry:analyze --days=7 --branch=developphp artisan codemetry:analyze --days=7 --branch=feature/authwp codemetry analyze --days=7 --branch=developwp codemetry analyze --days=7 --branch=feature/authOutput Options
--format
Choose output format:
# Human-readable table (default)php artisan codemetry:analyze --days=7 --format=table
# Machine-readable JSONphp artisan codemetry:analyze --days=7 --format=json# Human-readable table (default)wp codemetry analyze --days=7 --format=table
# Machine-readable JSONwp codemetry analyze --days=7 --format=jsonJSON Output Structure
{ "schema_version": "1.0", "repo_id": "md5-hash-of-repo-path", "analyzed_at": "2024-01-15T10:30:00+00:00", "request_summary": { "since": null, "until": null, "days": 7, "author": null, "branch": null, "baseline_days": 56, "follow_up_horizon_days": 3, "ai_enabled": false, "ai_engine": "openai" }, "windows": [ { "window_label": "2024-01-15", "mood_label": "good", "mood_score": 78, "confidence": 0.80, "reasons": [ { "signal_key": "change.churn", "direction": "positive", "magnitude": 5.0, "summary": "Low churn relative to baseline" } ], "confounders": [], "raw_signals": { "signals": { "change.churn": { "value": 150, "type": "numeric" }, "change.commits_count": { "value": 5, "type": "numeric" } } }, "normalized": { "norm.change.churn.z": -0.5, "norm.change.churn.pctl": 30.0 } } ]}AI Options
--ai
Enable AI-powered explanations:
php artisan codemetry:analyze --days=7 --ai=1wp codemetry analyze --days=7 --ai=1Requires CODEMETRY_AI_API_KEY environment variable or config setting.
If AI is enabled but no API key is configured, analysis continues normally with an ai_unavailable confounder added to results.
--ai-engine
Select which AI engine to use:
# Use Anthropic Claudephp artisan codemetry:analyze --days=7 --ai=1 --ai-engine=anthropic
# Use Google Geminiphp artisan codemetry:analyze --days=7 --ai=1 --ai-engine=google
# Use DeepSeekphp artisan codemetry:analyze --days=7 --ai=1 --ai-engine=deepseek# Use Anthropic Claudewp codemetry analyze --days=7 --ai=1 --ai-engine=anthropic
# Use Google Geminiwp codemetry analyze --days=7 --ai=1 --ai-engine=google
# Use DeepSeekwp codemetry analyze --days=7 --ai=1 --ai-engine=deepseekAvailable engines: openai (default), anthropic, deepseek, google.
Each engine requires its corresponding API key configured via environment variable or config.
Advanced Options
--baseline-days
Override the baseline period:
# Shorter baseline (faster reaction to changes)php artisan codemetry:analyze --days=7 --baseline-days=14
# Longer baseline (more stable comparisons)php artisan codemetry:analyze --days=7 --baseline-days=90# Shorter baseline (faster reaction to changes)wp codemetry analyze --days=7 --baseline-days=14
# Longer baseline (more stable comparisons)wp codemetry analyze --days=7 --baseline-days=90--follow-up-horizon
Adjust the follow-up fix detection window:
# Extended horizon for slower release cyclesphp artisan codemetry:analyze --days=7 --follow-up-horizon=7# Extended horizon for slower release cycleswp codemetry analyze --days=7 --follow-up-horizon=7--repo
Analyze a repository at a different path:
php artisan codemetry:analyze --days=7 --repo=/var/www/other-projectwp codemetry analyze --days=7 --repo=/var/www/other-projectExit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Failure (invalid repo, Git error, etc.) |
Examples
# Basic 7-day analysisphp artisan codemetry:analyze
# Last 30 days as JSONphp artisan codemetry:analyze --days=30 --format=json
# January 2024, filtered by authorphp artisan codemetry:analyze --since=2024-01-01 --until=2024-02-01 --author="Jane"
# With AI explanations (default OpenAI)php artisan codemetry:analyze --days=7 --ai=1 --format=json
# With AI using Anthropic Claudephp artisan codemetry:analyze --days=7 --ai=1 --ai-engine=anthropic
# Analyze another repositoryphp artisan codemetry:analyze --days=7 --repo=/path/to/repo# Basic 7-day analysiswp codemetry analyze
# Last 30 days as JSONwp codemetry analyze --days=30 --format=json
# January 2024, filtered by authorwp codemetry analyze --since=2024-01-01 --until=2024-02-01 --author="Jane"
# With AI explanations (default OpenAI)wp codemetry analyze --days=7 --ai=1 --format=json
# With AI using Anthropic Claudewp codemetry analyze --days=7 --ai=1 --ai-engine=anthropic
# Analyze another repositorywp codemetry analyze --days=7 --repo=/path/to/repo
# View current configuration (WordPress only)wp codemetry config