Initializing a Baseline
nolapse init sets up nolapse in a repository for the first time. It runs your test suite, records the current coverage as the baseline, and creates a nolapse.yaml template if one does not already exist.
Prerequisites
Section titled “Prerequisites”- The repository must be a git repo with at least one commit.
- For Go projects:
go testmust be runnable from the repo root. - For Python projects:
pytestandpytest-covmust be installed.
What nolapse init does
Section titled “What nolapse init does”- Checks for an existing baseline. If
.audit/coverage/baseline.mdalready exists, init aborts unless--forceis passed. - Resolves the HEAD SHA. Records the current commit hash to tie the baseline to a specific point in history.
- Runs the coverage tool. Executes the language-specific runner (
go test -coverprofile=...orpytest --cov) to measure current coverage. - Creates
.audit/coverage/baseline.md. Writes the initial baseline file with the coverage percentage, timestamp, and commit SHA. - Creates
nolapse.yaml(if not present). Writes a template with commented defaults so you can tune thresholds right away.
Basic usage
Section titled “Basic usage”# Go project (default)nolapse init --repo .
# Python projectnolapse init --repo . --lang python
# Explicit pathnolapse init --repo /path/to/my-serviceThe --repo flag defaults to the current working directory, so nolapse init (no flags) works from the repo root.
What gets created
Section titled “What gets created”After a successful init, two files are written:
.audit/coverage/baseline.md
Section titled “.audit/coverage/baseline.md”coverage: 82.50%timestamp: 2026-01-15T09:32:11Zcommit: a3f8c21d4e6b09f1c2d3e4f5a6b7c8d9e0f1a2b3This file is the source of truth for all future nolapse run comparisons. It should be committed to your repository and treated as part of your CI configuration.
nolapse.yaml (template)
Section titled “nolapse.yaml (template)”lang: gowarn_threshold: -1.0fail_threshold: -3.0strict_mode: falseEdit the thresholds to match your team’s tolerance before committing. See Thresholds for guidance.
What to commit
Section titled “What to commit”After running nolapse init, commit both files:
git add .audit/coverage/baseline.md nolapse.yamlgit commit -m "chore: initialise nolapse coverage baseline"Do not add .nolapse_run_state to git — it is a transient file used between nolapse run and nolapse baseline update.
The --force flag
Section titled “The --force flag”If a baseline already exists, nolapse init exits with an error:
error: baseline already exists at .audit/coverage/baseline.md use --force to overwritePass --force to overwrite the existing baseline with a fresh measurement:
nolapse init --repo . --forceGo vs Python variants
Section titled “Go vs Python variants”nolapse init --repo . --lang goInternally runs something equivalent to:
go test -coverprofile=.nolapse_cover.out ./...go tool cover -func=.nolapse_cover.outPython
Section titled “Python”nolapse init --repo . --lang pythonInternally runs something equivalent to:
pytest --cov=. --cov-report=term-missingEnsure pytest-cov is installed in the active environment before running init on a Python project.
Troubleshooting
Section titled “Troubleshooting””baseline already exists”
Section titled “”baseline already exists””error: baseline already exists at .audit/coverage/baseline.mdYou have already run nolapse init in this repo. If you want to re-baseline from scratch, use --force. If you want to advance the baseline after a coverage improvement, use nolapse baseline update instead.
”not a git repository”
Section titled “”not a git repository””error: could not resolve HEAD: not a git repositorynolapse init requires a git repository with at least one commit. Run git init && git commit before running nolapse init.
Coverage tool not found (Python)
Section titled “Coverage tool not found (Python)”error: pytest not found in PATHInstall pytest and pytest-cov in the active environment:
pip install pytest pytest-covZero coverage reported
Section titled “Zero coverage reported”If nolapse reports 0.00%, the coverage tool ran but found no test files or no instrumented packages. Check that:
- For Go: your
./...pattern matches packages with_test.gofiles. - For Python: your
--covtarget points at the source directory, not the test directory.