Init Command Reference
Overview
The init command creates the AI provider configuration file at .r2r/eac/ai-provider.yml. This configuration enables AI-powered features throughout EAC including commit message generation, specification creation, architecture design, and pull request descriptions.
AI Provider Comparison
| Provider | API Key Required | Cost | Best For | Model |
|---|---|---|---|---|
| claude-api | ANTHROPIC_API_KEY |
Pay-per-use | Production use, high volume | Claude Sonnet 4.5 |
| claude-cli | None (Claude Pro subscription) | Included with subscription | Development, lower volume | Claude Sonnet 4.5 |
| openai | OPENAI_API_KEY |
Pay-per-use | OpenAI ecosystem integration | GPT-4 |
| gemini | GOOGLE_API_KEY |
Pay-per-use | Google Cloud integration | Gemini Pro |
Provider Selection Guide
Choose claude-api when:
- You need production-grade reliability
- You have high-volume AI operations
- You want the latest Claude models
- You're willing to pay per API call
Choose claude-cli when:
- You have a Claude Pro subscription
- You're doing development work
- You have moderate AI usage needs
- You want to avoid API costs
Choose openai when:
- You're already using OpenAI services
- You prefer GPT-4 models
- You have existing OpenAI infrastructure
Choose gemini when:
- You're using Google Cloud Platform
- You prefer Google's AI models
- You have Google Cloud credits
Cost Optimization
For claude-cli:
- Free usage included with Claude Pro subscription
- Rate limits apply
- Best for development work
For claude-api, openai, gemini:
- Monitor usage through provider dashboard
- Set spending limits in provider console
- Use caching when available
- Start with smaller models for testing
Configuration File Format
The init command creates .r2r/eac/ai-provider.yml with provider-specific configuration.
Claude API Configuration
provider: claude-api
api_key_env: ANTHROPIC_API_KEY
model: claude-sonnet-4-5
max_tokens: 4096
temperature: 0.7
Configuration Options:
provider: Must beclaude-apiapi_key_env: Environment variable name containing the API keymodel: Claude model to use (default:claude-sonnet-4-5)max_tokens: Maximum tokens in response (default: 4096)temperature: Randomness in responses, 0.0-1.0 (default: 0.7)
Claude CLI Configuration
Configuration Options:
provider: Must beclaude-climodel: Claude model to use (default:claude-sonnet-4-5)
Note: No API key required. Uses Claude Pro subscription authentication.
OpenAI Configuration
Configuration Options:
provider: Must beopenaiapi_key_env: Environment variable name containing the API keymodel: OpenAI model to use (default:gpt-4)max_tokens: Maximum tokens in response (default: 4096)temperature: Randomness in responses, 0.0-1.0 (default: 0.7)
Gemini Configuration
Configuration Options:
provider: Must begeminiapi_key_env: Environment variable name containing the API keymodel: Gemini model to use (default:gemini-pro)max_tokens: Maximum tokens in response (default: 4096)temperature: Randomness in responses, 0.0-1.0 (default: 0.7)
Environment Variable Setup
Windows (PowerShell)
# Temporary (current session only)
$env:ANTHROPIC_API_KEY = "sk-ant-api03-..."
$env:OPENAI_API_KEY = "sk-proj-..."
$env:GOOGLE_API_KEY = "AIza..."
# Permanent (user environment variable)
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'sk-ant-api03-...', 'User')
[System.Environment]::SetEnvironmentVariable('OPENAI_API_KEY', 'sk-proj-...', 'User')
[System.Environment]::SetEnvironmentVariable('GOOGLE_API_KEY', 'AIza...', 'User')
Windows (Command Prompt)
# Temporary (current session only)
set ANTHROPIC_API_KEY=sk-ant-api03-...
set OPENAI_API_KEY=sk-proj-...
set GOOGLE_API_KEY=AIza...
# Permanent (requires admin)
setx ANTHROPIC_API_KEY "sk-ant-api03-..."
setx OPENAI_API_KEY "sk-proj-..."
setx GOOGLE_API_KEY "AIza..."
Linux/macOS (Bash/Zsh)
# Temporary (current session only)
export ANTHROPIC_API_KEY="sk-ant-api03-..."
export OPENAI_API_KEY="sk-proj-..."
export GOOGLE_API_KEY="AIza..."
# Permanent (add to ~/.bashrc or ~/.zshrc)
echo 'export ANTHROPIC_API_KEY="sk-ant-api03-..."' >> ~/.bashrc
echo 'export OPENAI_API_KEY="sk-proj-..."' >> ~/.bashrc
echo 'export GOOGLE_API_KEY="AIza..."' >> ~/.bashrc
# Reload configuration
source ~/.bashrc
Verify Environment Variables
# Check if variable is set
echo $ANTHROPIC_API_KEY
echo $OPENAI_API_KEY
echo $GOOGLE_API_KEY
# Should display your API key
# If empty, the variable is not set
CI/CD Setup
# Store API key in CI/CD secrets
# GitHub Actions example:
# Add ANTHROPIC_API_KEY to repository secrets
# In your workflow:
- name: Initialize AI provider
env:
ANTHROPIC_API_KEY: ⟪ secrets.ANTHROPIC_API_KEY ⟫
run: r2r eac init --ai claude-api
Configuration File Location
The configuration file is stored at:
Important: This file should NOT be committed to version control as it may contain sensitive information or preferences specific to your environment.
Recommended .gitignore Entry
Troubleshooting
Problem: API Key Not Found
Error:
Solution:
# Verify variable is set
echo $ANTHROPIC_API_KEY
# If empty, set it
export ANTHROPIC_API_KEY="sk-ant-api03-..."
# Try again
r2r eac init --ai claude-api
Problem: Invalid API Key
Error:
Solution:
- Verify you copied the complete key (no spaces)
- Check key hasn't expired
- Confirm key is for the correct provider
- Generate a new key from provider dashboard
Problem: Configuration File Already Exists
Error:
Solution:
# The command will overwrite the existing file
# Your choice:
# 1. Proceed (overwrites old config)
r2r eac init --ai claude-api
# 2. Back up old config first
cp .r2r/eac/ai-provider.yml .r2r/eac/ai-provider.yml.backup
r2r eac init --ai claude-api
Problem: Permission Denied
Error:
Solution:
# Check directory permissions
ls -la .r2r/eac/
# Fix permissions
chmod 755 .r2r/eac
chmod 644 .r2r/eac/ai-provider.yml
# Try again
r2r eac init --ai claude-api
Problem: Provider Not Recognized
Error:
Solution:
# Use exact provider name
# Valid options: claude-api, claude-cli, openai, gemini
r2r eac init --ai claude-api # ✓ Correct
r2r eac init --ai claude # ✗ Invalid
Problem: AI Features Not Working After Init
Symptoms:
r2r eac work commitdoesn't generate messagesr2r eac create specfails- No AI responses
Solution:
# 1. Verify configuration exists
cat .r2r/eac/ai-provider.yml
# 2. Check environment variable
echo $ANTHROPIC_API_KEY # or appropriate variable
# 3. Test with debug mode
r2r eac work commit --all --debug
# 4. Re-initialize if needed
r2r eac init --ai claude-api --debug
Technical Notes
- The init command can be run multiple times to change providers
- Each run overwrites the previous configuration
- Environment variables are checked during initialization
- API keys are never stored in the configuration file (only the environment variable name)
- The command validates the provider name but does not validate API keys
- Configuration is local to each repository
- Team members can use different providers if desired
- The
.r2r/eac/directory is created automatically if it doesn't exist
Related Commands
work commit- Generate AI-powered commit messagescreate spec- Generate Gherkin specifications with AIcreate design- Generate architecture diagrams with AIwork pr- Create pull requests with AI-generated descriptionsshow config- Display current configuration
See Also
- Init Command Guide - Quick start and basic usage
Tutorials | How-to Guides | Explanation | Reference
You are here: Reference — information-oriented technical descriptions of the system.