Improve coverage

From redpanda-data/redpanda · View interactive version

Improve coverage is an AI agent skill from the GitHub repository redpanda-data/redpanda. Improve code coverage for a Bazel C++ test target or source file

How to use this skill

Skill file

Improve Code Coverage

Improve test coverage for a Bazel C++ test target or source file path.

Input Resolution

  1. Bazel test target (starts with //, e.g. //src/v/bytes/tests:iobuf_test):

use it directly.

  1. Source file path (e.g. src/v/bytes/iobuf.cc): find the test target:

```bash

bazel query "kind('.*_test', rdeps(//src/v/..., //$(dirname $FILE):$(basename $FILE .cc), 1))" 2>/dev/null

```

If multiple targets match, pick the one in the closest tests/ directory.

If none match, tell the user and stop.

Workflow

Step 1: Baseline Coverage

Run coverage and read the LLM report:

tools/run-cov <target> -r llm

Note the total line coverage percentage — this is the baseline to beat.

Read the report and identify:

error-path or edge-case tests.

Step 2: Understand the Code

Read the source files named in the report. Focus on:

Key codebase patterns:

redpanda_cc_btest targets use Seastar Boost test

(SEASTAR_THREAD_TEST_CASE). Match whichever the test file uses.

SEASTAR_THREAD_TEST_CASE or the Seastar GTest runner.

Step 3: Write Tests

Prioritize by impact:

  1. Uncovered functions — call each one. A 20-line function = 20 lines covered.
  2. Uncovered error paths — trigger the uncovered branches in partially

covered functions.

  1. Zero-coverage files — add smoke tests if practical.

Rules:

targets unless necessary.

Step 4: Verify Build

bazel build <target>

Fix compilation errors before proceeding.

Step 5: Verify Coverage

Re-run coverage:

tools/run-cov <target> -r llm

Compare to the baseline. Report:

Coverage: X.Y% → A.B% (+N.N%)
New lines covered: <count>

If coverage did not improve, investigate:

Step 6: Summary

Report:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.