Ci audit
When you want to cut GitHub Actions minutes and wait time across one repo or a whole portfolio. Measures queue, setup and run time per job, billed minutes with per-job minute rounding and the macOS 10× multiplier, and cron runs per month. Finds pipelines that have been failing quietly, ranks fixes by minutes saved, then ships them as small PRs with warm-cache before/after numbers. Triggers on \"/ci-audit,\" \"audit our CI,\" \"why is CI so slow,\" \"cut Actions minutes,\" \"we're over our Actions minutes,\" \"optimize GitHub Actions,\" \"CI costs,\" \"speed up CI.\" Not for designing CI from scratch or picking a CI vendor.
By- name:
- ci-audit
- description:
- When you want to cut GitHub Actions minutes and wait time across one repo or a whole portfolio. Measures queue, setup and run time per job, billed minutes with per-job minute rounding and the macOS 10× multiplier, and cron runs per month. Finds pipelines that have been failing quietly, ranks fixes by minutes saved, then ships them as small PRs with warm-cache before/after numbers. Triggers on \"/ci-audit,\" \"audit our CI,\" \"why is CI so slow,\" \"cut Actions minutes,\" \"we're over our Actions minutes,\" \"optimize GitHub Actions,\" \"CI costs,\" \"speed up CI.\" Not for designing CI from scratch or picking a CI vendor.
/ci-audit — Find and fix wasted GitHub Actions time
Measure first, then fix the few things that matter. In real audits the biggest win was rarely a slow test suite. It was a scheduled pipeline that had failed every day for months, a 30-second hourly cron billed as 730 minutes a month, or an SDK silently retrying a dead request three times.
A stdlib script, scripts/ci_audit.py in this skill's folder, does the measuring. You read its output, decide what's worth fixing, and ship it.
python3 <skill-dir>/scripts/ci_audit.py inventory <owner> # which repos run Actions, private vs public
python3 <skill-dir>/scripts/ci_audit.py month <owner/repo> # billable minutes by workflow, 30 days
python3 <skill-dir>/scripts/ci_audit.py jobs <owner/repo> --runs 150 # queue / setup / run per job
python3 <skill-dir>/scripts/ci_audit.py steps <owner/repo> <run-id> # per-step seconds for one run
python3 <skill-dir>/scripts/ci_audit.py schedules <owner/repo> # every cron as runs per month
It needs the GitHub CLI (gh) logged in. month and jobs make one API call per run, so a busy repo takes a minute or two. Run them in the background.
Step 0 — Scope and rules
Before measuring, settle with the user:
- Which owners and repos. One repo, or everything pushed to in the last 60 days.
- Off-limits repos. Someone else (a teammate, another agent) is mid-feature there. Those get an issue with numbers, never a pushed branch.
- Where merges go. The integration branch (
development, say) by default. Releasing to the default branch is a separate yes, but crons and scheduled fixes only take effect after it (Step 6). - What's out of scope: cutting test coverage, paid runners, switching CI vendors. Recommend those with numbers; don't do them.
Read references/gotchas.md now.
Step 1 — Inventory and money
ci_audit.py inventory <owner>for each owner. Note private vs public: only private repos cost money, but every repo's wait time matters when agents block on CI.- For an org, pull real billing:
gh api "/organizations/<org>/settings/billing/usage?year=YYYY&month=M". For a personal account, useci_audit.py monthon each private repo and compare the total with the plan's included minutes. - Write down the top 5 repos by billable minutes. That's where the time goes.
Step 2 — Broken before slow
For every repo with scheduled workflows:
- Check the last 10 scheduled runs per workflow. Any workflow that fails every time is the first finding, whatever its cost. Read its logs (
gh api repos/O/R/actions/runs/<id>/logs > logs.zip). - Run
actionlinton.github/workflows/. A file GitHub can't parse never runs its schedule.
Expect layered errors. See references/fixes.md §1.
Step 3 — Schedules
ci_audit.py schedules <repo> on each repo with crons. Multiply runs/month by the billed minutes per run (from jobs). Flag:
- Short jobs on tight schedules (an hourly 30-second check is 730 billed min/month).
- Several crons at the same minute that hit the same rate-limited API.
- Monthly crons that make one huge run. Split the work across nights.
Step 4 — Per-job breakdown
For the top repos: ci_audit.py jobs <repo> --runs 150, then steps on one recent green run of each expensive job. Classify each job's time:
| Bucket | What it points to |
|---|---|
| Queue high | Runner contention or concurrency groups. Usually not fixable cheaply; note it. |
| Setup high | Dependency install and caching (references/fixes.md §3–4). |
| Run high, app tests | Real test time. Leave it unless a step is plainly redundant. |
| Run high, data pipeline | Instrument phases and fix the code, not the CI (references/fixes.md §6). |
| Failures > 5% | Flaky tests or broken pipelines (references/fixes.md §1, §7). |
Step 5 — Report and pick
Write one table, sorted by estimated minutes saved per month:
| Repo | Finding | Evidence | Fix | Est. saved/mo | Risk |
|---|
Include findings you won't fix (off-limits repos, owner decisions such as cron frequency or parallelism) with the numbers the owner needs to decide. Show it to the user and get a go on which rows to ship. Archive it as ${MAKERSKILLS_CONFIG:-$HOME/.config/makerskills}/ci-audit/archive/<YYYY-MM-DD>-<scope>.md.
Step 6 — Fix pass
One repo, one worker. On hosts that support subagents, run repos in parallel with the same brief: fresh clone, issue first, branch named for the issue, small commits, before/after numbers in the PR body.
For each fix:
- Open an issue with the measurement.
- Make the change on a branch. Lint and run tests locally, confirming by exit code.
- Prove it: push, then rerun the PR's CI so the cache is warm, and compare against a baseline of several old runs. For pipeline fixes, dispatch the workflow from the branch with a small limit.
- If the change didn't help (it happens, e.g. Playwright caches), close the PR with the numbers. That's a result, not a failure.
- Merge into the integration branch after review and green checks.
- For anything scheduled, open the release PR to the default branch once the user agrees. Until then, nothing changes in production.
Step 7 — Verify and log
- After the next scheduled run, read its timings and logs. Confirm the fix held in production, not just on the branch.
- Append results to the archive file: per-repo before/after, what was closed without merging, and new gotchas.
- Suggest rerunning the audit monthly, or whenever CI feels slow. A recurring reminder (
loopify) works well.
Composes with
loopify— schedule a monthly re-audit or a next-morning check of the first scheduled run.castmate— get a second model's review on a risky workflow change.unstuck— when a fix that should work measures slower, before giving up on it.project-manager— track owner decisions (cron frequency, paid runners) that the audit surfaced but didn't make.
Notes on quality
- Broken beats slow. Always check failing scheduled workflows before timing anything. A daily pipeline failing for six months is a bigger loss than any cache.
- Warm numbers or no claim. Never report a speedup from one cold run. Rerun, baseline from several old runs, and state both numbers in the PR.
- Billed minutes, not seconds. Rounding per job means fewer, fuller jobs beat many tiny ones on private repos. Parallelizing is a speed decision with a cost, not a free win.
- Same coverage, every time. The test count before and after goes in the PR body. A faster suite that runs less is not a fix.
- Scheduled means default branch. Don't call a cron or pipeline fix done until it's on the default branch and one scheduled run has passed.
- Close failed experiments with data. A PR that measured slower gets closed with its numbers, so nobody retries the same idea next quarter.
- Respect other people's branches. Off-limits repos get issues, never pushes.
Open this reference as its own page
Fix playbook
Ranked by how often each one paid off in real audits. Every fix needs a before/after number on a warm cache (the second run after the change), not a single run. Timings swing 2–5× run to run, so baseline from about 10 runs.
1. Broken scheduled workflows (check first)
The biggest find is usually a pipeline that's been failing quietly for months, not a slow one.
- List every workflow whose last 10 scheduled runs all failed. Read the logs (
gh api repos/O/R/actions/runs/ID/logs > logs.zip, then unzip).gh run view --logsometimes prints nothing. - Errors come in layers. Fixing the first one (an empty API credit balance) often exposes the next (a retired model ID). Before calling it fixed, grep the repo for hardcoded, dated model IDs (
claude-*-2025…,gpt-4-…) and deprecated APIs. - Test the fix from the branch before merging:
gh workflow run <file> --ref <branch> -f <inputs>with a small limit, if the workflow takes one. - Run
actionlinton every workflow file. A file GitHub can't parse never runs its schedule. The only symptom is a red "workflow file issue" run on every push, which reads as noise. - An explicit
permissions:block replaces all the defaults. If it lists onlyissues: write,actions/checkoutfails on a private repo. Addcontents: read.
2. Over-scheduled crons
- Run
ci_audit.py schedulesand multiply runs/month by billed minutes per run. A 30-second hourly job bills 730 min a month, because every run rounds up to a full minute. - Ask what the job protects against and how fast it really needs to notice. A check on an artifact that only changes on deploy can run every 6 hours, plus a manual dispatch after deploys.
- Stagger crons that share a rate-limited API (the same scraper or LLM key). Three jobs at 03:00 compete for the same 429 budget.
- Scheduled workflows run only from the default branch. A cron fix does nothing until it's released to
main. - When one
on.schedulehas several crons and the steps branch ongithub.event.schedule == '…', change the cron and its matchingif:together.
3. Dependency install
- Node: cache
node_modulesitself, keyed on OS + Node version + lockfile hash, and skipnpm cion a hit.setup-node'scache: npmonly caches~/.npm, sonpm cistill runs every time. Typical result: 16–67 s down to about 5 s. - pnpm:
cache: pnpmon setup-node is usually enough. Check thatpnpm install --frozen-lockfiletakes under 10 s. - Ruby: swap a
ruby:container forruby/setup-rubywithbundler-cache: true(gems 87 s down to 13 s). Gems then install intovendor/bundleinside the workspace. Gitignore/vendor/bundle, or Tailwind v4's automatic source scan reads every gem (CSS build 0.3 s → 5 s). - Remove leftover debug steps and
apt-get installof packages the runner image already has.
4. Build caches
.next/cachehelpsnext buildonly.next devand Turbopack dev leave it empty, so check what was actually saved withgh api repos/O/R/actions/caches.- A Turborepo remote or local cache helps monorepos with several apps.
5. Things that look like wins but aren't
- Playwright browser cache with
--with-deps: apt install-deps dominates, and a cache hit still has to run it. Measured slower (6 s restore + 28 s deps vs 19 s uncached). Measure before you keep it. - Splitting one job into parallel jobs on a private repo: each job pays its own setup (about 45 s) and its own minute rounding. Faster wall-clock, higher bill.
- Test parallelism on private repos:
ubuntu-latestthere has 2 vCPU (public repos get 4). Plan for 2 processes at most, and only if wall-clock matters more than minutes. - Folding a separate tiny job into another: check its triggers first. A scheduled run against
maincan't merge into a push or PR job.
6. Pipelines that run inside Actions
When the long job is the product's own data pipeline (scraping, enrichment, LLM calls), CI tuning won't help. Instrument it instead:
- Log wall time per phase (
msPlaces,msSite…) in the stage's summary line. Sums across concurrent workers exceed wall time, so compare shares, not totals. - Replace per-row work with bulk queries (one UPDATE … FROM instead of N round trips). One case went from 267–397 s to 1 s.
- Run independent network calls a few at a time (
p-limit(4)), respecting the provider's rate limit. - Read SDK retry defaults, not just timeouts. Stainless-generated SDKs (Anthropic, OpenAI, Tabstack and others) retry 5xx, 429 and timeouts twice by default, so one bad request can hold a worker for 3× the timeout. When a fallback provider exists, set
maxRetries: 0and a shorttimeout. - Cap the nightly batch (
--limit) so a monthly discovery spike drains over several nights instead of one long run. - A batch that fails as a whole on one bad row (for example, an emoji split mid-surrogate) wastes the entire batch. Sanitize inputs before batching.
7. Flaky tests
- Rerun the failed job once before investigating. Starved runners cause timeout flakes (a 5 s test limit hit at 21 s in a run that took 19 min overall).
- If it keeps happening, loop the suspect test 15–20× in a draft-PR CI job, and upload failure screenshots (
tmp/screenshotson Rails) as an artifact. If it won't reproduce, keep the screenshot upload, drop the loop, and leave the issue open.
Open this reference as its own page
Gotchas
What tripped up real audits. Read before the measurement step.
Billing
- Each job is billed rounded up to the whole minute. A 7-second job costs 1 minute, so a workflow with 4 tiny jobs costs 4. Minute rounding alone wasted 10–15% across one portfolio.
- macOS minutes count 10× against the included allowance on private repos (Windows 2×). A macOS job that only checks whether anything changed still bills 10 minutes. Do the check on
ubuntu-latestand gate the macOS job on its output (needs:+if:). - Public repos run free on standard GitHub-hosted runners. Only private repos cost money, but speed still matters for public repos when agents wait on CI before merging.
- Billing API:
/organizations/<org>/settings/billing/usage?year=&month=works with a normal token. The user-level equivalent needs theuserscope (gh auth refresh -h github.com -s user). Without it, estimate withci_audit.py month.
Measuring
- Look at daily durations, not 30-day averages. A monthly cron (the 1st of the month) makes a spike that looks like a slow average.
- A 30-day lookback misses newly added crons. Read every
schedule:(ci_audit.py schedules) and compute runs/month × billed minutes yourself. - The setup column in
jobsguesses from step names. It misfiles steps like "Run pnpm lint" as setup. Confirm the slow steps withci_audit.py steps <repo> <run-id>on a recent green run. - Caches only pay off on the second run. A PR's cache is scoped to its ref, so measure warm with
gh run rerun <id>. After merge, the first push to the integration branch seeds the cache for every PR. - Each repo gets 10 GB of Actions cache. Delete caches from abandoned experiments (
gh cache delete). Old setup-node caches age out on their own once nothing writes them. - Timings are noisy (the same code measured 186 s, then 142 s). Compare across several runs.
Waiting and tooling
- Runner queue waits of 10+ minutes happen. Wait in the background (
gh pr checks <n> --watchor an until-loop), not with a foregroundgh run watchthat can hit an agent's tool timeout. gh pr edit --bodycan fail with a Projects (classic) GraphQL error. Usegh api -X PATCH repos/O/R/pulls/N -F body=@fileinstead.gh issue create --body "$(cat <<EOF …)"breaks on apostrophes. Use--body-file.- "Closes #N" only fires when a PR merges into the default branch. Issues closed by PRs into
developmentstay open until the release. - Old job logs stay readable via
gh api repos/O/R/actions/jobs/<job-id>/logs. Diff step lines between an old and new run to prove a change.
Scope
- Don't cut test coverage to save minutes. Every fix keeps the same test count, and the PR body says so ("still 2478 examples, all passing").
- Don't move to paid runners or third-party CI as part of the audit. Recommend it, with numbers, and let the owner decide.
- Repos where another person or agent is actively working: file an issue with the measurement and suggested fix, don't push code.
- Security problems found along the way in public repos go into a private security advisory, not a public issue.
More in this playbook
Safe to turn on
Use this skill when an agent or person is about to create, change or enable an automation inside someone else's account or a shared environment: "create this workflow", "build it in the customer's account", "turn it on", "go live", "deploy this automation". Produces a proposal the human approves, an automation created in the off state, and a short list of what only the human can finish.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.


