Stop writing tests.
Let AI cover the gaps.

Lacuna finds your uncovered code, writes real tests with AI, runs them, and retries until they pass — all from one command.

$ npm install -g lacuna-cli Copied!
View on GitHub
lacuna generate
$ lacuna generate
 
lacuna generate
 
Model:     claude-sonnet-4-6
Runner:    vitest
Threshold: 80%
 
src/utils/math.ts          34% → 94%   generated 8 tests
src/hooks/useAuth.ts       12% → 89%   generated 5 tests
src/api/payments.ts        0% → 100%   generated 12 tests
src/lib/formatters.ts     generating  _
 
Results
Files processed: 4
Coverage:        61% → 93% ↑

Works with

Vitest Jest Mocha Pytest Go Test TypeScript JavaScript Python

Everything you need to close the gap

Lacuna isn't a code assistant that suggests tests. It's an autonomous agent that writes, runs, and verifies them — and recovers when something goes wrong.

AI-powered generation

Lacuna sends your source file, existing tests, type definitions, and project dependencies to the model — giving it everything needed to write real, meaningful tests.

Verify and retry

Every generated test is immediately run against your actual test suite. If it fails, lacuna records what went wrong and retries with negative constraints so it doesn't repeat the same mistake.

Fix failing tests

Run lacuna fix to repair existing failing tests without rewriting them. The model surgically fixes what's broken and leaves everything else untouched.

Parallel workers

Process multiple files simultaneously with -w 4. Each worker runs independently with a live status display showing what every worker is doing in real time.

Safe by default

If all retries fail or the model gets stuck, your original test file is automatically restored. Oscillation detection stops the loop early when the model is spinning in circles.

Any model, any provider

Works with Claude, GPT-4o, Gemini, DeepSeek, Groq, OpenRouter, Ollama, and LM Studio — or any OpenAI-compatible API. Switch models with a single flag.


From zero to covered in one command

Three steps. No configuration required to get started.

1

Analyze your coverage

Lacuna runs your test suite, reads the coverage report, and finds every file and function below your threshold — without touching any files.

2

Generate and verify

For each gap, lacuna builds a full context — source code, type definitions, existing tests, imports, and mocks — then asks the model to write tests that actually exercise the behavior.

3

Retry until it passes

Generated tests are run immediately. Failures are diagnosed, constraints are recorded, and the model retries with specific instructions not to repeat what failed.

# install once
npm install -g lacuna-cli
 
# in your project
lacuna init      # interactive setup
lacuna analyze   # see what's uncovered
lacuna generate  # fill the gaps
 
# target a single file (fast)
lacuna generate -f src/utils/math.ts
 
# fix failing tests
lacuna fix
lacuna fix -f src/api/auth.test.ts
 
# 4 files in parallel
lacuna generate -w 4
# .lacuna.json — optional config
{
"model": "claude-sonnet-4-6",
"testRunner": "vitest",
"threshold": 80,
"mocksFile": "src/test/mocks.ts"
}

Use the model you already have

Lacuna works with any AI provider. Bring your own API key, or run fully local with Ollama or LM Studio — no data leaves your machine.

Claude
Anthropic · Sonnet / Opus
Default
GPT-4o
OpenAI
Gemini
Google · 2.5 Pro / Flash
DeepSeek
Chat / Reasoner · Cheap
Groq
Llama 3.3 70B
Free tier
OpenRouter
100+ models, one key
Ollama
Any local model
Fully local
LM Studio
Any local model
Fully local

Ship with confidence.
Coverage handled.