Baseline CLI Guide

Baseline CLI Guide

Detailed command instructions for the Baseline CLI.

This page explains what each command does, when to use it, and how the CLI connects to reporting, auth, API operations, and release workflows already implemented in this repository.

Quick start notes

Best starting point
Run baseline check to see if a repository meets Baseline's production-readiness policies.
Best CI gate
Use baseline enforce when you want blocking output that reads clearly inside pipeline logs.
Best operator entry
Use baseline api serve when you need auth, audit history, and API-backed operations.
Keep the CLI current
Run npm i -g baselineprod-cli@latest before troubleshooting or testing a newly released flow.

Install and update

Baseline is moving quickly right now. If the docs mention a flow you do not see locally yet, update the CLI first.

npm i -g baselineprod-cli
baseline version

npm i -g baselineprod-cli@latest
baseline version

For release-by-release changes, read CHANGELOG.md.

Core Commands

Commands used most often during local development and release gating.

baseline version

Prints the current version and build information for the CLI binary.

Use it when: you need to confirm which build is running locally, in CI, or on an operator machine.

baseline version

baseline check

Runs the full policy set and exits non-zero if blocking violations are found.

Use it when: you want a normal repository check before push, before merge, or in CI.

baseline check

Typical result: a readable list of violations such as missing tests, secrets, deployment gaps, or rollback documentation.

baseline enforce

Runs policy enforcement with output formatted for strict release gating.

Use it when: the command is part of a required pipeline step and the output should focus on pass or block decisions.

baseline enforce

baseline scan

Builds a broader scan summary across files, security findings, and policy results.

Use it when: you want more context than a single pass/fail gate, especially during investigation or triage.

baseline scan

baseline init

Creates a local Baseline configuration file under .baseline/config.yaml.

Use it when: you are onboarding a new repository and want a standard Baseline config scaffold.

baseline init

baseline report

Exports results in machine-friendly or human-friendly formats.

Use it when: you need output for logs, automation, or security tooling.

baseline report --text
baseline report --json
baseline report --sarif

baseline explain <policy_id>

Explains the status of one policy and gives focused remediation guidance.

Use it when: a repository is blocked by one specific rule and you want the shortest path to understanding the failure.

baseline explain D1
baseline explain R1

AI Commands

Commands that draft remediation work without deciding policy outcomes.

baseline generate

Generates scaffolded remediation drafts for some violations using the configured AI provider.

Use it when: you want a starting point for CI, tests, Dockerfile, README, or env-template fixes.

baseline generate

Important: Baseline does not use AI to decide whether a policy passes. Review generated content before merge.

baseline pr

Generates remediation drafts, commits them, pushes a branch, and attempts to create a pull request through gh.

Use it when: you want a fast remediation branch workflow around detected violations.

baseline pr

baseline security-advice

Creates an AI-assisted security suggestions file for issues that may sit outside the deterministic policy set.

Use it when: you want extra review prompts beyond the enforced policies.

baseline security-advice --out SECURITY.AI.SUGGESTIONS.md

Important: the AI output may be wrong, incomplete, or overly broad. Treat it as advisory only.

API And Auth Commands

Commands for running the HTTP layer, human auth, and machine access.

baseline api serve

Starts the Baseline HTTP API server.

Use it when: you want the API, OIDC login flow, API key operations, audit persistence, or dashboard backend endpoints.

baseline api serve --addr :8080

Common hosted pages: /, /signin.html, /signup.html, /dashboard, and this CLI guide page.

baseline api keygen

Generates a random API key for machine-to-machine usage.

Use it when: you need a new bearer credential for automation or operator access.

baseline api keygen

baseline api verify-prod

Checks whether API-related production configuration is complete.

Use it when: you are preparing an environment for production or preflight validation.

baseline api verify-prod
baseline api verify-prod --strict

baseline api migrate-postgres

Migrates Baseline API data from SQLite into a Postgres target.

Use it when: you are moving an existing Baseline deployment from local SQLite storage to a hosted Postgres database.

baseline api migrate-postgres --sqlite-path ./baseline_api.db --database-url "postgres://USER:PASSWORD@HOST:5432/baseline?sslmode=disable" --reset-target

baseline dashboard serve

Runs the separate local dashboard proxy service for selected read-only API paths.

Use it when: you want the proxy dashboard workflow instead of the API-hosted dashboard route.

baseline dashboard serve --addr 127.0.0.1:8091 --api http://127.0.0.1:8080

baseline dashboard login

Starts the hosted browser login flow for a CLI session.

Use it when: you want to connect the CLI to a hosted Baseline API and approve the session in the dashboard.

baseline dashboard login --api https://baseline-api-95nb.onrender.com

baseline dashboard whoami and logout

Shows the current dashboard session identity or clears the saved CLI session.

Use it when: you want to verify which hosted account the CLI is using or explicitly sign the CLI out.

baseline dashboard whoami
baseline dashboard logout

baseline dashboard connect, status, disconnect

Manages the saved project-local dashboard upload connection used by baseline scan.

Use it when: you want to inspect, repair, or remove the saved dashboard connection for the current repository.

baseline dashboard connect --api http://127.0.0.1:8080
baseline dashboard status
baseline dashboard disconnect

Operational Workflows

Common sequences teams run in practice.

Build and test the project

go build -o baseline ./cmd/baseline
go test ./...

Use this when validating the repository itself before release or contribution.

CI workflow scaffolding

baseline ci setup --help
baseline ci setup --provider github --mode enforce

Use this when you want Baseline to scaffold a CI workflow that runs repository checks in GitHub, GitLab, or Azure pipelines.

Release gate workflow

baseline check
baseline report --sarif
bash ./scripts/release-gate.sh

Use this when you want Baseline checks plus the repository's release gating scripts.

API smoke workflow

baseline api serve --addr :8080
bash ./scripts/api-smoke.sh

Use this when validating a production-like API startup and smoke path.

Operator health checks

curl http://127.0.0.1:8080/healthz
curl http://127.0.0.1:8080/readyz
curl http://127.0.0.1:8080/metrics

Use this after starting the API to confirm health, readiness, and metrics exposure.

Auth-protected API probe

curl -H "Authorization: Bearer <admin_key>" \
  http://127.0.0.1:8080/v1/dashboard

Use this to confirm that machine auth and dashboard summary APIs are functioning.

Managed key rotation

.\scripts\api-key-rotate.ps1 `
  -ApiBaseUrl http://127.0.0.1:8080 `
  -AdminApiKey "<current_admin_key>" `
  -Role operator `
  -Name "ops-rotation-01"

Use this when rotating operator keys through the API instead of hand-managing key material.

Release And Platform Operations

The remaining commands and scripts from the command reference.

Auth page URLs

These are the API-hosted pages for local use when the Baseline API server is running.

http://127.0.0.1:8080/
http://127.0.0.1:8080/signin.html
http://127.0.0.1:8080/signup.html

Use them when: you want browser-based human access to the current public pages and auth flow.

Git and release basics

These are standard repository commands often used around Baseline rollout and release preparation.

git status
git add -A
git commit -m "your message"
git push origin main

git tag v1.0.1
git push origin v1.0.1

Use them when: you are committing Baseline-related changes or publishing a tagged release.

Branch protection setup

Baseline expects the primary branch to be protected. This example configures required status checks on GitHub.

gh api \
  -X PUT \
  repos/<owner>/<repo>/branches/main/protection \
  -H "Accept: application/vnd.github+json" \
  -F required_status_checks.strict=true \
  -F required_status_checks.contexts[]="Test" \
  -F required_status_checks.contexts[]="Security Scan" \
  -F required_status_checks.contexts[]="Release Gates" \
  -F required_status_checks.contexts[]="API Smoke" \
  -F enforce_admins=true \
  -F required_pull_request_reviews.required_approving_review_count=1 \
  -F required_pull_request_reviews.dismiss_stale_reviews=true \
  -F restrictions=

Use it when: policy A1 needs a real protected-branch configuration behind it.

Final release gate

These scripts run the repository's release gate workflow outside the main CLI command surface.

bash ./scripts/release-gate.sh

.\scripts\release-gate.ps1

Use them when: you want the complete scripted release gate, especially in CI or pre-release validation.

Production-like API smoke gate

These scripts test the API in a smoke-check workflow and write artifacts under .artifacts/api-smoke/<timestamp>.

bash ./scripts/api-smoke.sh

.\scripts\api-smoke.ps1

Use them when: you need a higher-confidence API smoke run than a single health check.

Dashboard capability and activity probes

These API calls help operators inspect what the backend exposes and what has happened recently.

curl -H "Authorization: Bearer <admin_key>" \
  http://127.0.0.1:8080/v1/dashboard/capabilities

curl -H "Authorization: Bearer <admin_key>" \
  "http://127.0.0.1:8080/v1/dashboard/activity?limit=10"

curl http://127.0.0.1:8080/v1/auth/me

Use them when: verifying auth identity, rollout stage, capability flags, or recent operator-visible activity.

Audit stream probe

Reads recent audit events from the API.

curl -H "Authorization: Bearer <admin_key>" \
  "http://127.0.0.1:8080/v1/audit/events?limit=20"

Use it when: you want to confirm that important changes are being recorded in the audit stream.

Incident triage quick checks

These examples are useful when a scan fails, readiness changes, or you need fast operational context.

curl http://127.0.0.1:8080/readyz

curl -H "Authorization: Bearer <admin_key>" \
  "http://127.0.0.1:8080/v1/scans?project_id=<project_id>"

curl -H "Authorization: Bearer <admin_key>" \
  "http://127.0.0.1:8080/v1/scans/<scan_id>/report?format=sarif"

Use them when: you need to inspect readiness dependencies, recent scans, or a SARIF report for a specific scan.

Managed API key rotation

PowerShell helper script for issuing a new operator key and optionally revoking an older one.

.\scripts\api-key-rotate.ps1 `
  -ApiBaseUrl http://127.0.0.1:8080 `
  -AdminApiKey "<current_admin_key>" `
  -Role operator `
  -Name "ops-rotation-01"

.\scripts\api-key-rotate.ps1 `
  -ApiBaseUrl http://127.0.0.1:8080 `
  -AdminApiKey "<current_admin_key>" `
  -Role operator `
  -Name "ops-rotation-02" `
  -RevokeKeyId "<old_key_id>"

Use it when: you want a controlled operator key lifecycle instead of manually distributing long-lived keys.

Reference

Quick facts that help when reading CLI output.

Exit codes

  • 0 success
  • 20 blocking violations found
  • 50 system or runtime error

Policy IDs currently enforced

A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, L1, R1

Use baseline explain <policy_id> to drill into one of these.

Policy meanings

  • A1 branch protection
  • B1 CI runs on pull requests
  • C1 tests exist
  • D1 no plaintext secrets
  • E1 dependency files exist
  • F1 README and license exist
  • G1 risky code patterns blocked
  • H1 deployment config exists
  • I1 infrastructure-as-code exists
  • J1 env template exists
  • K1 backup or recovery docs exist
  • L1 logging or monitoring exists
  • R1 rollback docs exist

Auth model

  • Human auth: OIDC login and callback flow
  • Machine auth: bearer API keys
  • Mutating session requests: CSRF header required

Database requirement

CLI-only use does not require a database. API persistence uses SQLite for keys, audit events, and integration jobs.

BASELINE_API_DB_PATH=.baseline/baseline.db

Use the CLI locally first, then add the API when your workflow needs it.

Baseline is easiest to adopt by starting with a repository check, then adding reporting, explain flows, AI drafts, and API-backed operations as your workflow matures.