agentleFS
plugyawnplugyawn/armada/.claude/skills/fix-backend-coverage/SKILL.md

fix-backend-coverage

Skill2 starsChanged 6 months agoApache-2.0View on GitHub

Fix backend test coverage gaps. Use when CI output or test-backend --coverage reports missing lines, like "ERROR: path/to/file.py no longer has complete backend test coverage".

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 11
  2. Very specific:

    If invoked with an argument, use it: $ARGUMENTS

    line 31
  3. Distinctive:

    If the CI output names the source file but not the test module, use git grep to find which test file imports or tests the relevant code.

    line 33
  4. Distinctive:

    Read the source at each missing line and classify it:

    line 53
  5. Very specific:

    When a file in not_yet_fully_covered reaches 100%, it should be removed from the list to promote it to enforced status

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Fix Backend Coverage

Fix backend test coverage gaps for Zulip's enforced 100% coverage files.

Use this skill when:

  • CI output contains "no longer has complete backend test coverage"
  • You need to verify coverage after modifying code in an enforced file
  • A file in not_yet_fully_covered has reached 100% and should be promoted to enforced, or coverage should be added to reach 100%

Workflow

1. Run coverage on the specific test module

IMPORTANT: Never run the full test suite with --coverage — it takes a very long time. Always target the specific test module that covers the file with missing coverage.

./tools/test-backend --skip-provision-check --coverage --no-cov-cleanup \
    --no-html-report zerver.tests.test_specific_module

If invoked with an argument, use it: $ARGUMENTS

If the CI output names the source file but not the test module, use git grep to find which test file imports or tests the relevant code.

2. Analyze missing lines

./.claude/skills/fix-backend-coverage/analyze-coverage <source_file_with_missing_coverage>

With no arguments, checks all enforced files for missing coverage (useful after a targeted test run to see what's still missing).

The script loads var/.coverage and reports:

  • Classification: ENFORCED (must be 100%) vs EXEMPT
  • Statement/excluded/missing counts and coverage percentage
  • Each missing line with 1 line of source context above and below

3. Fix each uncovered line using the right technique

Read the source at each missing line and classify it:

Line typeFix
Dead code (unreachable branch)Simplify/remove the dead branch
Error-only test path (assert, fail)Add # nocoverage comment
Missing test coverageWrite a test that exercises the line
Newly 100% covered fileRemove from not_yet_fully_covered in tools/test-backend

# nocoverage should only be used for lines that execute only when a test fails or for truly unreachable defensive code. Never use it to skip writing tests for reachable production code.

4. Verify

Re-run coverage on the same targeted test module and re-analyze:

./tools/test-backend --skip-provision-check --coverage --no-cov-cleanup \
    --no-html-report zerver.tests.test_specific_module
./.claude/skills/fix-backend-coverage/analyze-coverage <source_file>

Confirm 0 missing lines, then lint:

./tools/lint --skip-provision-check --fix --only=ruff,ruff-format <changed_files>

Coverage system reference

Config

  • Coverage config: tools/coveragerc
  • Coverage data: var/.coverage
  • Exclusion patterns in coveragerc: # nocoverage, if False:, raise NotImplementedError, raise AssertionError, if TYPE_CHECKING:, @abstractmethod, @skip, and ... (ellipsis)

Enforcement model

  • tools/test-backend defines two lists:
    • enforce_fully_covered: all .py files matching source_files globs minus those in not_yet_fully_covered
    • not_yet_fully_covered: files exempt from the 100% requirement
  • When a file in not_yet_fully_covered reaches 100%, it should be removed from the list to promote it to enforced status
  • Enforcement only runs in CI with full suite + --coverage; locally you check with targeted runs + analyze-coverage

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.