Documentation Getting Started Configuration

Configuration

Overview

All Primer settings use the PRIMER_ environment variable prefix. Settings can be provided as environment variables, in a .env file in the project root, or managed interactively with the CLI.

cp .env.example .env

To update settings interactively:

primer configure

This opens a guided wizard that walks through core settings and writes them to your .env file.

Server Settings

Core settings for the Primer API server.

VariableDefaultDescription
PRIMER_DATABASE_URLsqlite:///./primer.dbDatabase connection string (SQLite or PostgreSQL)
PRIMER_ADMIN_API_KEYprimer-admin-dev-keyShared secret for admin API access
PRIMER_SERVER_HOST0.0.0.0Server bind address
PRIMER_SERVER_PORT8000Server bind port
PRIMER_LOG_LEVELinfoLogging level (debug, info, warning, error)
PRIMER_CORS_ORIGINS["http://localhost:5173"]Allowed CORS origins (JSON array)

Change the admin key in production

The default key primer-admin-dev-key is public and should never be used outside local development. Generate a secure key before deploying:

python -c "import secrets; print(secrets.token_urlsafe(32))"

Database

Primer supports SQLite for development and PostgreSQL for production deployments.

SQLite (default)

PRIMER_DATABASE_URL=sqlite:///./primer.db

SQLite requires zero setup and is ideal for single-user development. The database file is created automatically on first run.

PostgreSQL (production)

PRIMER_DATABASE_URL=postgresql://user:pass@host:5432/primer

Use PostgreSQL for teams

SQLite does not handle concurrent writes safely. If multiple engineers are uploading sessions simultaneously, you will encounter database lock errors. Use PostgreSQL for any deployment serving more than one user.

After changing the database URL, run migrations to initialize the schema:

alembic upgrade head

JWT Authentication

JWT tokens are used for dashboard session management. Engineers authenticate via GitHub OAuth or admin API key, and receive a JWT pair (access + refresh) for subsequent requests.

VariableDefaultDescription
PRIMER_JWT_SECRET_KEYchange-me-in-productionSecret key for signing JWT tokens
PRIMER_JWT_ACCESS_TOKEN_EXPIRE_MINUTES15Access token lifetime in minutes
PRIMER_JWT_REFRESH_TOKEN_EXPIRE_DAYS7Refresh token lifetime in days

Change JWT_SECRET_KEY before deploying

The default value is insecure and well-known. Generate a strong secret:

python -c "import secrets; print(secrets.token_urlsafe(32))"

If this key is compromised, an attacker can forge authentication tokens for any user.

Rate Limiting

Primer uses slowapi to enforce per-route rate limits. Rate limit keys are derived from the API key prefix (for authenticated requests) or client IP (for unauthenticated requests).

VariableDefaultDescription
PRIMER_RATE_LIMIT_ENABLEDtrueEnable or disable rate limiting globally
PRIMER_RATE_LIMIT_DEFAULT60/minuteDefault limit for all endpoints
PRIMER_RATE_LIMIT_INGEST300/minuteLimit for session ingest endpoints
PRIMER_RATE_LIMIT_AUTH10/minuteLimit for authentication endpoints

Rate limits are expressed in the format count/period where period can be second, minute, hour, or day. For example, 120/minute allows 120 requests per minute per key.

Disable for development

Set PRIMER_RATE_LIMIT_ENABLED=false during local development to avoid hitting limits while testing.

GitHub OAuth

Required for GitHub-based dashboard login. This lets engineers sign into the dashboard with their GitHub account instead of using an API key.

VariableDefaultDescription
PRIMER_GITHUB_CLIENT_IDOAuth App client ID
PRIMER_GITHUB_CLIENT_SECRETOAuth App client secret
PRIMER_GITHUB_REDIRECT_URIhttp://localhost:5173/auth/callbackOAuth callback URL

See the GitHub Integration guide for step-by-step instructions on creating the OAuth App.

GitHub App

Required for PR sync, commit correlation, and AI-readiness scoring. The GitHub App allows Primer to access repository data and correlate Claude Code sessions with pull requests.

VariableDefaultDescription
PRIMER_GITHUB_APP_IDGitHub App ID (numeric)
PRIMER_GITHUB_APP_PRIVATE_KEYRSA private key in PEM format (use \n for newlines)
PRIMER_GITHUB_INSTALLATION_IDApp installation ID (numeric)
PRIMER_GITHUB_WEBHOOK_SECRETWebhook HMAC secret for verifying payloads

PEM key formatting

When storing the private key in a .env file, replace actual newlines with \n. The key should be a single line:

PRIMER_GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIE...\n-----END RSA PRIVATE KEY-----"

See the GitHub Integration guide for complete setup instructions.

Productivity Estimation

Controls the ROI calculations displayed in the dashboard. These settings determine how Primer estimates the business value of AI-assisted coding.

VariableDefaultDescription
PRIMER_PRODUCTIVITY_TIME_MULTIPLIER3.0Estimated time savings multiplier versus manual work
PRIMER_PRODUCTIVITY_HOURLY_RATE75.0Hourly rate for value calculations (USD)

The time multiplier represents how much longer the equivalent work would have taken without AI assistance. A value of 3.0 means Primer estimates that a 1-hour AI-assisted session produced 3 hours worth of manual output. Adjust this based on your team’s observed productivity gains.

Alert Thresholds

Default thresholds for anomaly detection. Alerts fire when metrics deviate significantly from baseline values calculated over the preceding period.

VariableDefaultDescription
PRIMER_ALERT_FRICTION_SPIKE_MULTIPLIER2.0Alert when friction is N times the baseline
PRIMER_ALERT_USAGE_DROP_RATIO0.5Alert when usage drops below this ratio of baseline
PRIMER_ALERT_COST_SPIKE_WARNING2.0Warning when cost is N times the baseline
PRIMER_ALERT_COST_SPIKE_CRITICAL3.0Critical alert when cost is N times the baseline
PRIMER_ALERT_SUCCESS_RATE_DROP_PP20.0Alert when success rate drops by N percentage points

These defaults can be overridden per-team in the admin panel. The priority chain is: team-specific threshold > global config threshold > code defaults.

See the Alert Thresholds guide for details on setting up alerts and notification channels.

Slack Notifications

Primer can deliver alert notifications to a Slack channel via an incoming webhook.

VariableDefaultDescription
PRIMER_SLACK_WEBHOOK_URLSlack incoming webhook URL
PRIMER_SLACK_ALERTS_ENABLEDfalseEnable alert delivery to Slack

To set up Slack notifications:

  1. Create an incoming webhook in your Slack workspace.
  2. Set PRIMER_SLACK_WEBHOOK_URL to the webhook URL.
  3. Set PRIMER_SLACK_ALERTS_ENABLED=true.

Alerts will be delivered to the configured channel with severity level, metric details, and a link to the relevant dashboard view.

Hook and MCP Client Settings

These variables are used by the SessionEnd hook and MCP sidecar running on developer machines, not the server. They tell the client-side components where to find the Primer server and how to authenticate.

VariableDefaultDescription
PRIMER_SERVER_URLhttp://localhost:8000URL of the Primer API server
PRIMER_API_KEYEngineer API key for authentication
PRIMER_ADMIN_API_KEYAdmin key (MCP sidecar only, for team-wide analytics)

MCP admin key

The MCP sidecar uses PRIMER_ADMIN_API_KEY to access team-level analytics endpoints. If only PRIMER_API_KEY is set, the sidecar will fall back to it but some team-wide tools (like team_overview and friction_report) will return limited data.

These are typically set in ~/.primer/config.toml by primer setup and primer init, but can also be set as environment variables or in a project-level .env file.