GitHub Actions efficiency
Inspect workflow YAML and recent run evidence, identify the highest CI-minute waste, protect required validation through guardrails, and return up to three ranked fixes with validation and impact.
When to invoke
- "Reduce GitHub Actions runtime and cost."
- "Audit our workflows for wasted CI minutes."
- "Add caching and concurrency to these workflows."
- "Narrow path filters or matrix jobs safely."
- "Create an efficient GitHub Actions baseline."
Prerequisites and context
- Use
.github/workflows/ when workflows exist.
- If no workflows exist, read
references/actions.md and define a baseline before proceeding.
- If shell or
gh CLI access is unavailable, ask for .github/workflows/ contents and gh run list --limit 10 output. If only partial files are provided, state: Static-only analysis (not confirmed with live runs).
Procedure
- Measure workflow structure and recent run evidence:
rg -n "on:|concurrency:|paths:|paths-ignore:|strategy:|matrix:|cache:" .github/workflows
gh run list --limit 10
run_id=$(gh run list --limit 1 --json databaseId --jq '.[0].databaseId')
gh run view "$run_id" --log-failed
- Look for missing dependency caches, missing
concurrency cancellation, over-broad triggers, duplicate workflow coverage, and expensive jobs that run on every change regardless of scope.
- Apply all guardrails before recommending changes.
- Rank supported fixes by estimated daily CI minutes saved: per-run savings multiplied by runs per day.
- Select all supported candidates, up to a maximum of three.
- Validate path-gating and concurrency cancellation with a live test push on a non-protected branch when
gh access and repo policy allow it.
Waste candidates
| Candidate |
Evidence |
Safe fix pattern |
| Dependency caching |
Repeated install steps and no lockfile-based cache. |
Add cache keys derived from lockfiles; avoid caching generated build output unless safe. |
concurrency cancellation |
Multiple runs queue on the same branch or PR. |
Add group by workflow and ref/PR, then cancel-in-progress: true where safe. |
| Duplicate workflow coverage |
Multiple workflows run equivalent tests on the same event. |
Remove overlap before merging jobs; keep release and required checks intact. |
| Trigger narrowing |
Docs-only or unrelated changes run full CI. |
Add paths or paths-ignore at workflow or job level with required validation preserved. |
| Matrix reduction |
Matrix legs lack documented version/platform commitment. |
Keep documented legs; reduce low-risk event types or run full matrix on scheduled/release events. |
| Critical-path parallelism |
Independent jobs run serially. |
Split jobs only when setup overhead does not erase wall-clock gains. |
Guardrails
- Do not hide required validation such as release, schema, migration, or shared-source checks.
- Do not reduce parallelism unless the user prioritizes cost over latency and the new critical path stays within 1.25× the original.
- Preserve only documented matrix legs; remove unsupported legs only with evidence.
- Formatter or bot write-back jobs should use opt-in triggers rather than automatic write-back on every run.
- Split repo-editable YAML recommendations from org-level or GitHub-account settings.
- Treat unexpected live behavior as a real bug even when YAML appears correct.
Progressive disclosure and bundled resources
references/actions.md: audits, job gating, matrix reduction, live validation, and workflow-specific fixes.
references/reporting.md: before/after efficiency report format and calculations.
references/patterns.md: full YAML examples when inline commands are not enough.
references/review-rubric.md: use when reviewing completed efficiency work.
Output template
## GitHub Actions efficiency result
**Status:** proven live | static-only | blocked
**Scope:** `.github/workflows/<workflow>.yml`
### Waste sources
| Rank | Source | Evidence | Estimated daily CI minutes wasted |
| --- | --- | --- | --- |
| 1 | <driver> | <workflow line, run log, or assumption> | <minutes> |
### Proposed fixes
| Rank | Fix | Evidence | Estimated daily CI minutes saved | Risk |
| --- | --- | --- | --- | --- |
| 1 | <top fix> | <why supported> | <minutes> | <remaining risk> |
### Validation
- Workflow syntax/static review: pass | fail
- Live test push: pass | fail | not run, <reason>
- Path gating: verified | unverified, <reason>
- Concurrency cancellation: verified | unverified, <reason>
### Impact
- PR wall-clock time: <expected or measured>
- Total runner time: <expected or measured>
Quality gate
1---2name: github-actions-efficiency3description: Audit GitHub Actions workflow efficiency and recommend fixes that reduce CI runtime, runner minutes, and wasted workflow runs. Use when the user asks about caching, concurrency, path filters, matrix reduction, job optimization, workflow cost, or CI baseline design.4---56<!-- Generated from harness/github-copilot/skills/github-actions-efficiency/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# GitHub Actions efficiency910Inspect workflow YAML and recent run evidence, identify the highest CI-minute waste, protect required validation through guardrails, and return up to three ranked fixes with validation and impact.1112## When to invoke1314- "Reduce GitHub Actions runtime and cost."15- "Audit our workflows for wasted CI minutes."16- "Add caching and concurrency to these workflows."17- "Narrow path filters or matrix jobs safely."18- "Create an efficient GitHub Actions baseline."1920## Prerequisites and context2122- Use `.github/workflows/` when workflows exist.23- If no workflows exist, read `references/actions.md` and define a baseline before proceeding.24- If shell or `gh` CLI access is unavailable, ask for `.github/workflows/` contents and `gh run list --limit 10` output. If only partial files are provided, state: `Static-only analysis (not confirmed with live runs).`2526## Procedure27281. Measure workflow structure and recent run evidence:2930```bash31rg -n "on:|concurrency:|paths:|paths-ignore:|strategy:|matrix:|cache:" .github/workflows32gh run list --limit 1033run_id=$(gh run list --limit 1 --json databaseId --jq '.[0].databaseId')34gh run view "$run_id" --log-failed35```36372. Look for missing dependency caches, missing `concurrency` cancellation, over-broad triggers, duplicate workflow coverage, and expensive jobs that run on every change regardless of scope.383. Apply all guardrails before recommending changes.394. Rank supported fixes by estimated daily CI minutes saved: per-run savings multiplied by runs per day.405. Select all supported candidates, up to a maximum of three.416. Validate path-gating and concurrency cancellation with a live test push on a non-protected branch when `gh` access and repo policy allow it.4243## Waste candidates4445| Candidate | Evidence | Safe fix pattern |46| --- | --- | --- |47| Dependency caching | Repeated install steps and no lockfile-based cache. | Add cache keys derived from lockfiles; avoid caching generated build output unless safe. |48| `concurrency` cancellation | Multiple runs queue on the same branch or PR. | Add group by workflow and ref/PR, then `cancel-in-progress: true` where safe. |49| Duplicate workflow coverage | Multiple workflows run equivalent tests on the same event. | Remove overlap before merging jobs; keep release and required checks intact. |50| Trigger narrowing | Docs-only or unrelated changes run full CI. | Add `paths` or `paths-ignore` at workflow or job level with required validation preserved. |51| Matrix reduction | Matrix legs lack documented version/platform commitment. | Keep documented legs; reduce low-risk event types or run full matrix on scheduled/release events. |52| Critical-path parallelism | Independent jobs run serially. | Split jobs only when setup overhead does not erase wall-clock gains. |5354## Guardrails5556- Do not hide required validation such as release, schema, migration, or shared-source checks.57- Do not reduce parallelism unless the user prioritizes cost over latency and the new critical path stays within 1.25× the original.58- Preserve only documented matrix legs; remove unsupported legs only with evidence.59- Formatter or bot write-back jobs should use opt-in triggers rather than automatic write-back on every run.60- Split repo-editable YAML recommendations from org-level or GitHub-account settings.61- Treat unexpected live behavior as a real bug even when YAML appears correct.6263## Progressive disclosure and bundled resources6465- `references/actions.md`: audits, job gating, matrix reduction, live validation, and workflow-specific fixes.66- `references/reporting.md`: before/after efficiency report format and calculations.67- `references/patterns.md`: full YAML examples when inline commands are not enough.68- `references/review-rubric.md`: use when reviewing completed efficiency work.6970## Output template7172```markdown73## GitHub Actions efficiency result7475**Status:** proven live | static-only | blocked76**Scope:** `.github/workflows/<workflow>.yml`7778### Waste sources79| Rank | Source | Evidence | Estimated daily CI minutes wasted |80| --- | --- | --- | --- |81| 1 | <driver> | <workflow line, run log, or assumption> | <minutes> |8283### Proposed fixes84| Rank | Fix | Evidence | Estimated daily CI minutes saved | Risk |85| --- | --- | --- | --- | --- |86| 1 | <top fix> | <why supported> | <minutes> | <remaining risk> |8788### Validation89- Workflow syntax/static review: pass | fail90- Live test push: pass | fail | not run, <reason>91- Path gating: verified | unverified, <reason>92- Concurrency cancellation: verified | unverified, <reason>9394### Impact95- PR wall-clock time: <expected or measured>96- Total runner time: <expected or measured>97```9899## Quality gate100101- [ ] `.github/workflows/` was inspected or its absence was handled with `references/actions.md`.102- [ ] `rg`, `gh run list --limit 10`, and `gh run view "$run_id" --log-failed` were run or the static-only limitation is stated.103- [ ] Every proposed fix has evidence, passes all guardrails, and preserves required validation.104- [ ] No more than three fixes are recommended, ranked by estimated daily CI minutes saved.105- [ ] Validation separates live proof from local/static review and remaining risk.106- [ ] Impact separates PR wall-clock time from total runner time.