agentleFS
hass-energyhass-energy/haeo/.agents/skills/coverage/SKILL.md

coverage

Skill77 starsChanged 20 days agoMITView on GitHub

Analyze test coverage for the current branch and add tests for uncovered lines, using the remove-first decision tree before writing new tests. Use when asked about coverage, when codecov reports a drop on changed lines or a failing patch target, or when deciding what tests a change still needs.

33 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use scan, profile and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • rajnavakotiSkill

    scan

    Run the AI dashboard scanner and generate the HTML report.

    Also in 4 projects that use this

  • julienamorganSkill

    profile

    Researches the user's market, competitors, and competitive positioning to build a complete ICP profile. Shows findings for user approval before proceeding. Triggers: /profile, "research my market", "who are my competitors". Reads: ./gtm/company.md, ./gtm/icp.md. Writes: updates ./gtm/icp.md with competitive positioning. Standalone: yes (asks for domain if company.md missing).

    Also in 3 projects that use this

  • asterkinSkill

    adr

    Create Architecture Decision Records (ADRs) following project standards. Guides template usage, process, and best practices for documenting architecturally significant decisions.

    Also in 4 projects that use this

  • anombyte93Skill

    discover

    Phase 1 of the prd-taskmaster pipeline: brainstorm-driven discovery. Delegates to superpowers:brainstorming in Interactive Mode (one adaptive question at a time), or self-brainstorms in Autonomous Mode when no user is present. Intercepts before the brainstorming chain hands off to writing-plans — this skill owns the exit. Extracts constraints, calibrates scale (Solo / Team / Enterprise), and advances the pipeline to GENERATE.

    Also in 3 projects that use this

  • MicrosoftSkill

    worktree

    Create, reuse or clean up a dedicated git worktree for working on a pull request or a private branch. Use from any PR-scoped workflow that needs an isolated checkout to keep current code and build output untouched.

    Also in 3 projects that use this

  • SentrySkill

    e2e

    Run E2E tests for Sentry JavaScript SDK test applications

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 29 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check coverage for the current branch and decide what each uncovered line needs: deletion, a stricter type, or a test.

    line 8
  2. Distinctive:

    Run the unit test gate with coverage, as CI does:

    line 12
  3. Very specific:

    Add --cov-report=html and open htmlcov/index.html for a line-by-line view.

    line 18
  4. Distinctive:

    Test behavior and edge cases, not percentages: a covered line that no assertion checks proves nothing.

    line 32
  5. Distinctive:

    Read an uncovered line as a signal: usually an untested edge case, an error path, or the other side of a branch, and sometimes code no …

    line 34
  6. Distinctive:

    If no input can reach a line, the line is unreachable: delete it rather than testing it.

    line 55
  7. Distinctive:

    Add a case to an existing data module before writing a new test function:

    line 59

“Common” is measured: kept by at least 6 in 10 of the 29 edited versions of this file we could read. “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

Code coverage analysis

Check coverage for the current branch and decide what each uncovered line needs: deletion, a stricter type, or a test.

Step 1: run coverage

Run the unit test gate with coverage, as CI does:

uv run check test -- --cov=custom_components/haeo --cov-branch --cov-report=term-missing

Add --cov-report=html and open htmlcov/index.html for a line-by-line view.

To run only the tests a branch changed, list them against origin/main, since a local main may be stale. Tests are colocated, so match every tests/ directory, not just the top-level one. The :(glob) magic makes ** span directories, and xargs -r runs nothing when no test changed rather than the whole suite:

git fetch origin main
git diff origin/main...HEAD --name-only -z --diff-filter=AM -- ':(glob)**/tests/**/test_*.py' | \
    xargs -0 -r uv run pytest --cov=custom_components/haeo --cov-branch --cov-report=term-missing

Coverage philosophy

  • Test behavior and edge cases, not percentages: a covered line that no assertion checks proves nothing.
  • Simplify before testing: code with fewer branches needs fewer tests, so removing a branch beats covering it.
  • Read an uncovered line as a signal: usually an untested edge case, an error path, or the other side of a branch, and sometimes code no input can reach, which should be deleted.
  • Cover what matters first:
    1. Optimization logic: constraints and costs
    2. Error handling paths
    3. Edge cases and boundaries
    4. New features on the branch

The testing skill's decision tree says what each uncovered line needs; it is not repeated here.

Step 2: what codecov enforces

codecov.yml sets the targets:

  • Patch: at least 90% of the lines a pull request changes must be covered.
  • Project: overall coverage may not drop by more than 1%.

Codecov can also report lines outside the diff whose coverage changed indirectly, such as a branch that a refactor made unreachable.

Step 3: decide what each uncovered line needs

Work through the decision tree in the testing skill, in order: remove the code, tighten the types, add a parametrized case, combine tests, and only then write a bespoke test. If no input can reach a line, the line is unreachable: delete it rather than testing it.

Step 4: where cases go

Add a case to an existing data module before writing a new test function:

  • Model elements: VALID_CASES in core/model/tests/test_data/{model_element}.py
  • Element adapters: CREATE_CASES and OUTPUTS_CASES in core/adapters/elements/tests/test_data/{element_type}.py
  • Element flows: VALID_DATA and INVALID_DATA in flows/tests/test_data/{element_type}.py
  • Everything else: the tests/ directory beside the module

The testing skill describes each of these structures.

Step 5: verify and summarize

Re-run the coverage command, then uv run check. Report the coverage of the changed files, the cases added, and any code removed as unreachable.

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.