Skip to content
Back to skills

Ci Cd

ASecurity

Use when PR merge waits are long or CI/CD is being designed, audited, or sped up.

  • 5 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added November 24, 2026
testingpythongobashreacttestinggitapici/cdsecurity

Works with

  • api

Security analysis

A100/100

Scanned November 24, 2026

npx -y skills add ShaftHQ/chaosengine-harness --skill ci-cd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ci Cd?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ci Cd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/shafthq-ci-cd/badge)](https://www.skillsdirectory.com/skills/shafthq-ci-cd)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ci-cd
description: >-
  Use when PR merge waits are long or CI/CD is being designed, audited, or sped
  up.
license: MIT
permissions:
  - bash
  - read
  - write
  - network
---

# CI/CD tiers and PR merge time

Fix the loop first, then the slowest leg.

## Targets (evidence)

- Merge-blocking gate ≤ 10 min p90: Fowler's 10-minute build.
- Open→merge median ≤ 15 min for auto-merge PRs. DORA elite lead time is < 1 h, and the LinearB elite merge time is < 1 h.
- Small changes: elite PR size is < ~90 changed lines. Google's median review is < 4 h with one reviewer.

## Measure first

1. Gate wall-clock: `gh run list --workflow <gate> --event pull_request --status success -L 40 --json createdAt,updatedAt`. Report p50, p90 and max.
2. Open→merge: `gh pr list --state merged -L 30 --json createdAt,mergedAt`. Report the median.
3. Runs per PR and the failure share. Re-push loops usually cost more than slow legs do.
4. Per-job durations plus queue time. The critical path is the slowest leg, not the sum.

## Three tiers

| Tier | Runs | Rule |
|---|---|---|
| PR (blocking) | path-filtered affected-module build + unit tests, lint/guards, required governance | only what MUST block; light |
| Push to main | the same path filters (tests for unrelated modules never run), never cancelled, plus slow OS/E2E legs | a red leg opens or updates one tracker issue, which auto-closes on green |
| Nightly/scheduled | full cross-OS acceptance, live/external suites, security scans, EAP verifiers | tracker issue, no `Closes` keyword |
| Release | full verify, always | never weakened |

Move a leg off PR only when all three hold:
- it is > 5 min or is the critical path;
- it caught no PR-only regression in its last ~20–30 runs;
- the main tier runs it.

Keep a live-label opt-in such as `ci:<leg>`, plus `ci:full`, and re-run the gate when the label is added. Read labels from the API, because re-runs replay the old event payload.

## Quality layers are never removed

Tests, static analysis, coverage and review may be rearranged or added, but never removed.
The one exception is a layer that repeated, evidenced analysis proves an utter waste.
Moving a layer, for example from PR to main or from blocking to reporter, must keep equal or better coverage:
- a blocking in-repo equivalent;
- findings resolved before merge;
- a tracker issue on main.

A new or changed gate is done only after it ran on one real pass case and one
real fail case; a coverage gate no PR of its kind had exercised blocked every
such PR.

## Never auto-revert

Main rolls forward. A failing post-merge leg opens or updates one rolling issue (P0, assigned to the owner), and the next green run closes it. Do not open revert PRs automatically.

## First push green

- Run the cheap CI tests locally before every push: workflow README/inventory, timeout, path-filter and PR-body validators.
- Check the PR body against the repo's required sections, and name a targeted test, before creating the PR.
- A body edit does not re-run a PR-body guard that reads the event payload. Push a commit instead.
- Contract tests that CI runs with plain `unittest` must import only the standard library. A module installed on the dev box but not on the runner, such as PyYAML, passes locally and fails in CI.
- Normalize paths with `removeprefix("./")`, never `lstrip("./")`. `lstrip` also strips the dot from `.github/`, so path-triggered pre-push checks silently stop running.
- Before babysitting, `git ls-remote origin "$BRANCH"` must equal `git rev-parse HEAD`. An unpushed local commit leaves CI testing the old head.
- Run `git status` before each push and check for unexpected deletions. A box restore can drop tracked files under cache-like directory names (`build/`, `coverage/`) in every worktree; restore them with `git ls-files -d -z | xargs -0 git checkout --`.
- Never delete a worktree or branch before checking that the cherry-pick or merge landed (`git status`, `git log`). If you already did, recover the commit with `git fsck --lost-found`.
- Validate every third-party CI config (coverage, analysis) against the vendor's validator in pre-push and CI. Some vendors silently ignore a whole file over one unknown key, and fall back to defaults.
- Coverage carryforward reads the vendor's record of the git parent. An old branch whose parent chain lacks the full flag set never goes green. Move its commits to a fresh branch from main, and make every main push upload every flag.
- A gate that reads an external status, such as Codecov, must wait for a settled verdict (an unchanged title and completion time across polls). The vendor recomputes per upload, so a mid-upload red is not final.

## Release and privileged workflows

- New release safety is additive: a hard gate before publishing, and `continue-on-error` for anything after publishing, such as attestation or SBOM upload, so it can never strand a published release.
- An API-compatibility baseline must be the published artifact downloaded as a file. Comparing against the same version number resolves to the reactor jar, so the build compares the jar with itself. Give the comparator any missing optional dependencies precisely; never set a global ignore-missing-classes, which hides real breaks.
- `pull_request_target` and `workflow_run` jobs never check out or run PR code. Use two workflows instead: the unprivileged `pull_request` job computes a result and uploads an artifact. The privileged `workflow_run` job re-reads the PR from the API, validates the artifact against an allow-list, applies it as data and pushes.

## Delivery order, queue, stacks

- One PR at a time: babysit it to merged, then open the next. Null `autoMergeRequest` is not proof the pull request left the queue; read `mergeQueueEntry.headCommit.oid`. `AWAITING_CHECKS` means that entry is already queued; do not dequeue it. The Dependabot schedule does not dequeue or re-arm. Opened, reopened, and synchronize enqueue with `BOT_TOKEN`, because `GITHUB_TOKEN` events start no merge_group workflows. A `dependabot-hold` label skips that enqueue. A missing merge-group check is a visible failure, not a loop. A cancelled or abandoned installer result is not success.
- A code-scanning alert on changed lines opens a review conversation. Under a resolve-conversations rule, it blocks the enqueue even when the scanner check is not required. Fix the finding, or, if it is accepted by design, reply with the reason and resolve the thread. Resolving does not dismiss the alert.
- Before enqueue, run `python3 scripts/ci/unresolved_review_threads.py --repo OWNER/NAME --pr N` (repo-only) and exit non-zero on any open thread. Local `code_quality_preflight` also flags `assertTrue(...length()/size() > 0)` so static-analysis bots do not burn a CI cycle.
- A required check must never share a concurrency group across runs. GitHub keeps only one pending run per group, so a burst of PR events cancels the queued one, and a cancelled required check blocks the queue. Use a per-run group (`github.run_id`) and no cancellation.
- Merge queue: add `merge_group:` to every workflow that reports a required check, and run the PR tier there. External apps that do not report on `merge_group` must leave the required list first.
- Stacked PRs: run cheap checks on every layer, and expensive legs only on the lowest unmerged layer or the top of the stack (`github.event.pull_request.stack`).

## GitHub Actions

Checked 2026-11-20. Use these pages, not a remembered workflow shape:

- Workflow syntax, including `strategy.matrix.include`, `fail-fast`, `timeout-minutes`, and permissions: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax.md
- Pin an action to a full commit SHA: https://docs.github.com/en/actions/reference/security/secure-use.md
- SHA pinning example: https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/find-and-customize-actions.md
- A matrix is for job variations. A single-variant job stays one job: https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/run-job-variations.md
- Artifact upload: https://docs.github.com/en/actions/tutorials/store-and-share-data.md

`permissions: contents: read` is the floor. Setting any permission sets the others to none. A required check uses its own concurrency group (`github.run_id`) and `cancel-in-progress: false`. Include-only matrix entries run when the matrix has no base variables. `fail-fast` defaults to true; set it false when one cell must not cancel the others.

## Report

Before/after p50/p90 gate time, the open→merge median, the PRs merged, and the admin changes left for the owner (rulesets, merge queue).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.