Guides

Improve test coverage overnight with Codex or Claude Code

Write meaningful tests around risk and behavior until quitting time, using coverage as a tripwire rather than a target.

Answers: use Codex or Claude Code to increase test coverage · Updated

SHORT ANSWER

A coverage hunt follows untested behavior and risk, not a vanity percentage. Add tests that can fail for the right reason, keep exclusions explicit, and let the deadline bound the open-ended work.

01

Choose useful targets

Prioritize important behavior, error paths, recovery, contracts, and recently changed code. A covered line is valuable only when the assertion protects an outcome.

  • Start from failures and boundaries.
  • Prefer behavior over implementation detail.
  • Avoid assertions that merely repeat the code.
  • Explain every exclusion.
02

Keep the suite trustworthy

Run the focused test during development and the declared gate before commit. Do not silence flakes or weaken assertions just to move the number.

  • Use deterministic fixtures.
  • Test both success and failure paths.
  • Keep runtime proportional to the protection gained.
03

Stop at the deadline

Coverage work has no natural final percentage. Finish the current coherent test unit, record what remains, and stop when the clock expires.

TRY IT

Start with a bounded prompt

This prompt names the outcome and preserves Nightshift’s review boundary. Paste it into the supported coding host from the project you want to change.

Run a four-hour coverage hunt. Find high-value untested behavior, write behavior-protecting tests, run the item gate, and commit each coherent test improvement separately.
BOUNDARIES

What this workflow does not claim

  • Coverage is a discovery signal, not the completion target; padding tests is forbidden.
  • Open-ended coverage work requires hours and a deadline.
SOURCES

Evidence and sources

These links support the released behavior, public outcomes, or problem language described on this page.

coverage-hunt contractThe released coverage contract: behavior first, clock bounded, gate green.Open evidence ↗Versioned Hunt skillGuided and automatic selection, review-first, run-direct, and clock rules.Open evidence ↗Merged Codex hardening PRAn 11-item Nightshift run in Codex that shipped in v0.9.2.Open evidence ↗OpenAI's documented coverage use caseOpenAI describes pointing Codex at low-coverage modules overnight and returning to runnable unit-test pull requests.Open evidence ↗
RELATED QUESTIONS

Continue from the question you have

use Codex to add meaningful testsRead the answer →use Claude Code to improve test coverageRead the answer →repair flaky tests without retriesRead the answer →