enable-code-coverage
Skill134 starsChanged 32 days agoApache-2.0View on GitHub
Onboard a repository to Harness Code Coverage (HCC) in Harness CI: inspect test setups, wire the codeCoverage step immediately after unit tests, verify multi-module coverage reports, set up PR and baseline triggers, and configure exclusions via Harness MCP. Use when asked to enable code coverage, onboard a repository to code coverage, add coverage gating, or set up PR patch coverage checks in Harness CI. Trigger phrases: enable code coverage, onboard code coverage, add code coverage, patch coverage gate, baseline coverage.
In this repository77 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/harness.mdcCursor rule
- manage-rolesSkill
- manage-usersSkill
- create-agentSkill
- create-agent-templateSkill
- dbops-changesetSkill
- choose-metricSkill
- cleanup-feature-flagsSkill
- create-experimentSkill
- create-feature-flagSkill
- create-metricSkill
- discover-feature-flagsSkill
- explain-flagSkill
- feature-flag-onboardingSkill
- fme-pipelineSkill
- instrument-feature-flagSkill
- instrument-metricSkill
- manage-experimentsSkill
- manage-flag-lifecycleSkill
- manage-segmentsSkill
- review-experiment-resultsSkill
- update-flag-targetingSkill
- create-connectorSkill
- create-environmentSkill
- create-infrastructureSkill
- create-secretSkill
- create-serviceSkill
- ai-operationsSkill
- analyze-costsSkill
- audit-reportSkill
- chaos-code-risk-scanSkill
- chaos-dr-testSkill
- chaos-experimentSkill
- create-policySkill
- deployment-readinessSkill
- dora-metricsSkill
- gitops-statusSkill
- incident-responseSkill
- manage-idpSkill
- manage-slosSkill
- optimize-pipelineSkill
- pr-analysisSkill
- scorecard-reviewSkill
- security-reportSkill
- sei-analyticsSkill
- template-usageSkill
- create-pipelineSkill
- create-pipeline-v1Skill
- create-templateSkill
- create-triggerSkill
- debug-pipelineSkill
- manage-freeze-windowsSkill
- migrate-pipelineSkill
- run-pipelineSkill
- create-sbomSkill
- enforce-sbomSkill
- manage-artifactsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
Follow this structured checklist:
- Very specific: line 60
If test command already contains hcli cov upload or uses codeCoverage, skip wiring.
- Distinctive: line 61
If PR trigger and baseline trigger exist, skip trigger creation.
- Very specific: line 74
If any module lacks reports, prepare the build-file fix using recipes in references/language-recipes.md.
- Very specific: line 80
Pipeline: Update via harness_update(resource_type="pipeline", body={ "yamlPipeline": "<YAML string>" }).
- Distinctive: line 81
Repo-side fix: If approved, open a PR with the required build-file configuration.
- Very specific: line 82
Triggers: Create the missing PR trigger (PullRequest webhook, 80% patch gate) and Baseline trigger (Push webhook on default branch) via …
- Distinctive: line 85
Ensure Code Coverage is enabled on the account.
- Very specific: line 86
If ACCESS_DENIED is returned, flag the missing permission and resource scope directly to the user.
- Distinctive: line 90
Always conclude with this fixed summary:
- Very specific: line 129
Always inspect existing checks via harness_list(resource_type="pr_check") to avoid redundant runs.
- Distinctive: line 130
Keep the coverage step within the test stage to reuse the checkout and workspace without re-downloading source.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Enable Code Coverage
Onboard any repository or pipeline to Harness Code Coverage (HCC) in Harness CI end-to-end. The skill inspects the build and test setup, verifies report generation across all modules, adds the codeCoverage step immediately after tests, and configures PR and default-branch baseline triggers.
Scope & Platform Requirements
- Platform Target: Harness CI only (not GitHub Actions, GitLab CI, or Jenkins). The conceptual pattern (detect tests → verify multi-module reports → upload via
hcli cov upload→ evaluate patch gate viahcli cov wait-until→ configure PR & baseline triggers) is extensible and can be replicated on other platforms, but this skill specifically manages Harness CI pipelines and triggers. - Autonomous Execution: Explicitly requires the Harness MCP Server (
harness-mcp-v2/harness-mcp) for autonomous discovery and write operations (inspecting repositories, checking PR checks, reading/updating pipeline YAML, and provisioning triggers). - Build Infrastructure Compatibility: Compatible with all Harness CI build infrastructures:
- Harness Cloud (Hosted VMs):
hcliis pre-installed on the systemPATH. - Kubernetes Build Clusters & Docker Runners: The Harness Delegate / Lite-Engine automatically bind-mounts the versioned
hclihelper binary into step containers onPATH. No custom binary download or installation step is required in the pipeline.
- Harness Cloud (Hosted VMs):
Detail lives in references/ — read a reference only when needed:
| Reference | Read when |
| config.md | Standard thresholds, status checks, auto-discovery order |
| language-recipes.md | Multi-module detection, report formats, build file recipes |
| pipelines.md | Step classification, step placement rules, wiring YAML |
| triggers.md | Checking or creating PR and baseline push triggers |
| troubleshooting.md | Diagnosing errors or symptom-to-fix mapping |
Instructions
Follow this structured checklist:
Enable code coverage — <repo>
- [ ] 1. Discover (read-only, cached) & early-exit checks
- [ ] 2. Classify onboarding path & step placement
- [ ] 3. Validate coverage report generation (every module)
- [ ] 4. Plan & decisions (one batched approval)
- [ ] 5. Apply (pipeline, repo fix, triggers)
- [ ] 6. Verify & prerequisites
- [ ] 7. Quality-check summaryStep 1: Discover & Early-Exit Checks
- Accept a repository identifier, pipeline identifier, or Harness URL.
- Auto-extract
org_idandproject_id. Retrieve default branch (mainormaster), git connector, and existing PR checks viaharness_list(resource_type="pr_check"). - Fetch candidate pipeline YAML via
harness_listandharness_get. - Early exits:
- If test command already contains
hcli cov uploador usescodeCoverage, skip wiring. - If PR trigger and baseline trigger exist, skip trigger creation.
- If test command already contains
Step 2: Classify Onboarding Path & Step Placement
- Step Placement Rule: The
codeCoveragestep must be placed immediately after the test step within the same stage (reports must exist before upload). Never place it in parallel before tests run. - Track A (Extend Existing): Insert the
codeCoveragestep (fromtemplates/codeCoverage.yaml) immediately after the unit-test step in the existing pipeline. - Track B (No CI Pipeline Exists): Offer to scaffold a standard build/test/coverage pipeline for the detected language.
Step 3: Validate Coverage Report Generation (Critical)
HCC analyzes only lines present in uploaded coverage reports; it does not analyze raw git source. Verify that every module in multi-module setups (Maven <modules>, Gradle subprojects, npm workspaces, go test ./..., pytest) produces a supported report format:
- Java/Kotlin: JaCoCo XML (
jacoco.xml) - Python, JS/TS: LCOV (
lcov.info) or Cobertura (coverage.xml) - Go: Go coverage profile (
coverage.out)
If any module lacks reports, prepare the build-file fix using recipes in references/language-recipes.md.
Step 4: Plan & Batched Approval
Show all proposed diffs together (pipeline YAML, trigger YAMLs, repo PR diff). Ask for explicit chat approval before making any changes. In dry-run mode, stop here and produce the plan summary.
Step 5: Apply Approved Changes
- Pipeline: Update via
harness_update(resource_type="pipeline", body={ "yamlPipeline": "<YAML string>" }). - Repo-side fix: If approved, open a PR with the required build-file configuration.
- Triggers: Create the missing PR trigger (
PullRequestwebhook, 80% patch gate) and Baseline trigger (Pushwebhook on default branch) viaharness_create(resource_type="trigger").
Step 6: Verify & Prerequisites
- Ensure Code Coverage is enabled on the account.
- If
ACCESS_DENIEDis returned, flag the missing permission and resource scope directly to the user. - Success criteria:
coverage-patchcheck appears on PRs; baseline trigger runs on merges to the default branch.
Step 7: Quality-Check Summary
Always conclude with this fixed summary:
Quality check — <repo> [mode: normal | dry-run]
1. PR coverage
- Patch coverage (coverage-patch): working | failing | not yet verified | planned — <evidence>
- Project coverage (coverage-project): working | failing | not yet verified | planned — <evidence>
- PR trigger: existing | created (<id>) | planned
- Modules with reports: <n>/<total> — <missing modules, if any>
2. Branch scans / repo coverage (baseline)
- Baseline trigger on <default branch>: existing | created (<id>) | planned
- Baseline execution: <link + status> | pending until a PR is merged
- Monitoring: <user will monitor the first post-merge run | offered to check it after merge>
3. Fixes made
- Repo-side fix: PR <link> | manual instructions given | none needed
- Pipeline: PR/commit <link> (REMOTE) | inline update — <diff summary> | none
- Triggers: created <ids> (inline, no PR) | already existed
- Outstanding prerequisites: <e.g. account coverage enablement, deferred exclusions>Examples
Example 1: Onboard by Pipeline URL
/enable-code-coverage https://app.harness.io/ng/account/l7B_kbSEQD2wjrM7PShm5w/all/orgs/default/projects/demo/pipelines/build_pipelineThe agent inspects the pipeline, detects the mvn test step, confirms JaCoCo report generation, drafts the codeCoverage step immediately after test execution, prepares PR and baseline triggers, and presents diffs for approval.
Example 2: Dry Run on a Repository
/enable-code-coverage Dry run on repository analytics-service in org default, project core.The agent inspects the repository and pipelines, validates multi-module coverage outputs, and prints the plan and quality summary without performing any write calls.
Performance Notes
- Always inspect existing checks via
harness_list(resource_type="pr_check")to avoid redundant runs. - Keep the coverage step within the test stage to reuse the checkout and workspace without re-downloading source.
- Configure exclusions in the Code Coverage module settings rather than cluttering pipeline YAML.
Troubleshooting
| Symptom | Root Cause | Fix |
| Coverage shows 0% | Reports not generated or not placed in standard auto-discovery paths | Verify test tool output matches paths in references/config.md; check module test commands |
ACCESS_DENIED | Missing API permissions | Flag the missing permission (e.g. Pipeline Edit or Trigger Create) directly to the user |
| Baseline coverage missing | Default branch has no baseline trigger | Create the baseline push trigger; baseline populates after the first post-merge run |
| Pipeline update rejected | Invalid YAML payload | Verify pipeline YAML using harness_schema(resource_type="pipeline") |
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
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.

