agents/skills/experimental-read-code-coverage-metrics/SKILL.md
This skill fetches and processes code coverage data for a given Gerrit CL and patchset. It uses the live Findit API to retrieve coverage percentages and line-by-line details, records coverage metrics for all modified source files, and extracts the code blocks corresponding to uncovered lines.
Activate this skill when:
When invoked as a subagent, the parent agent MUST explicitly pass:
cl_url: The full Gerrit CL URL to fetch coverage for (e.g., https://chromium-review.googlesource.com/c/chromium/src/+/7916168).artifact_path: The destination file path to store the JSON metrics artifact (e.g., scratch/original_metrics.json).target_files: Optional list of specific target file paths to filter coverage for (e.g., ["chrome/browser/.../CommerceBottomSheetContentMediator.java"]). If omitted, records metrics across all modified source files.Extract CL Details & Run Coverage Metrics Script: Use
tools/code_coverage/parse_gerrit_url.py to extract host, project,
change, and patchset from cl_url:
vpython3 tools/code_coverage/parse_gerrit_url.py <cl_url>
Execute fetch_coverage_metrics.py passing the extracted parameters and optional --files filter:
vpython3 tools/code_coverage/fetch_coverage_metrics.py --host <host> \
--project <project> --change <change> --patchset <patchset> \
--output <artifact_path> --files <target_files>
Verify Coverage Artifact: Confirm the script generated the artifact at
<artifact_path>. The artifact maps modified source files to their coverage
metrics and uncovered lines:
{
"chrome/browser/.../CommerceBottomSheetContentMediator.java": {
"metrics": {
"absolute_coverage": 80.0,
"incremental_coverage": 65.0,
"absolute_unit_tests_coverage": 80.0,
"incremental_unit_tests_coverage": 65.0
},
"low_coverage_type": [
"incremental_coverage",
"incremental_unit_tests_coverage"
],
"uncovered_lines": {
"77": " mBottomSheetContent.setConfirmBoxVisible(false);",
"78": " mBottomSheetContent.setConfirmButtonEnabled(false);"
}
}
}
The skill stores the detailed coverage JSON artifact directly at
<artifact_path> (scratch/original_metrics.json,
scratch/control_metrics.json, or scratch/fix_metrics.json). It should return
a summary message indicating the coverage metrics and unexecuted line counts
across modified source files.
--auth-token or set
LUCI_AUTH_TOKEN in the environment.