Skip to content
Back to skills

Yad Checks

ASecurity

Build step C: wire and run the CI check gates on a code repo (spec link, contract, build/test/lint, signed commits). Use when the user says "wire the check gates", "run the gates", "require signed commits", or "set up CI checks" for a repo.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 14, 2026
developmentgoshellbashnodedockertestinggitapici/cd

Works with

  • claude code
  • cursor
  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned November 25, 2026

npx -y skills add abdelrahmannasr/yadflow --skill yad-checks --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Yad Checks?

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

Security grade badge for Yad Checks
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/abdelrahmannasr-yad-checks/badge)](https://www.skillsdirectory.com/skills/abdelrahmannasr-yad-checks)

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: yad-checks
description: 'Build step C: wire and run the CI check gates on a code repo (spec link, contract, build/test/lint, signed commits). Use when the user says "wire the check gates", "run the gates", "require signed commits", or "set up CI checks" for a repo.'
---

# SDLC — Check Gates (Build Step C)

<!-- generated: yad-cli — from cli/skill-yad-cli.mjs by scripts/skill-yad-cli.mjs; do not edit by hand -->

**This skill needs the `yad` command.** Before its first `yad …` command, run `command -v yad` (in PowerShell, `(Get-Command yad -ErrorAction SilentlyContinue).Source`). When it prints nothing, the yadflow CLI is not installed on this machine: stop there, and tell the person:

- Install it with `npm install -g yadflow@latest`, or run each command as `npx -y yadflow@4 …` in place of `yad …`.
- It is needed because the CLI is what enforces the approvals. Without it, a step could only ask you to wait; it could not check that a person approved.

Go on only when that check prints a path, or when the person chooses `npx -y yadflow@4`. A command this skill already writes as `npx -y yadflow@4 …` runs without the install.

<!-- end: yad-cli -->

**Goal:** Install and run the **check gates** that protect production for a code repo. They run
in CI on every PR/MR and must pass before merge (build plan §C). Each is a small, separate check:

1. **spec-link** — the change links a real story/spec: its commits carry a `Task: <story>-<task>`
   trailer (the convention `yad-implement` writes) whose `<story>` resolves to `specs/<story>/link.md`.
   No unlinked code reaches merge.
2. **contract-check** — if the diff changes the **contract surface** (the repo's quoted slice under
   `specs/<story>/contracts/`) without a `Contract-Change: yes` trailer **and** an updated, re-locked
   contract upstream, it **FAILS and routes back to the architecture gate**. The shared surface is
   never widened from inside a code repo (Phase 2 contract representation: delimited block + SHA-256 lock).
   **A quote is not a change (issue #344):** a slice whose every changed file is Markdown holding exactly
   one `<!-- CONTRACT-QUOTE:BEGIN -->` … `<!-- CONTRACT-QUOTE:END -->` block (plus blank lines and, first,
   the optional title `# Contract slice — <story ID>`), the block an unbroken, in-order run of the locked
   `CONTRACT-SURFACE` lines, passes with **no** trailer — when the Product is reached, `link.md` pins the current lock, and the locked `contract.md`
   (the owner's, for a change-epic's pointer lock) still hashes to it. Anything it cannot prove still
   needs the trailer. **The change is what merging the branch into the target would change** (issue
   #363; `git merge-tree`, git 2.38+), so a slice that changed on the target after the branch split off is
   not this branch's, and a rename on the target cannot carry an edit into a slice unseen. A branch that
   does not merge cleanly fails closed; an older git reads from the merge base and fails closed on
   several merge bases or a file the target removed or moved that the branch modifies. A slice the
   branch's own commits touch counts even when the merge nets it to nothing (a "Rebase and merge"
   replays every commit), and its quote proof then needs the branch rebased onto the target with no
   merge commits; `docs/branch-protection.md` lists the merge methods the gate models.
   Every story whose slice the diff touches is checked, not just the first — see `references/check-gates.md`.
   A claimed `Contract-Change` against an epic that has **no lock at all** fails too: an epic on a short
   lane (`chore`/`spike`) has no architecture step and never locks a surface, so it may consume the
   contract but not change it, and the change belongs to a new epic on `classic`. That failure needs the
   epic's ledger directory to resolve — a Product that is simply not checked out still defers, as before,
   except on a repo's **first spec** (no `link.md` on the base names a Product): there a slice change whose
   `product-repo` reaches nothing **fails** (E119), because the PR chose that value itself. Where the
   Product lives is a repo fact once `.sdlc/product-link.json` is on the code repo's default branch
   (E120; `yad check --fix --open-pr`, merged by a person, or `--push` after the person's yes): the gates read it from the base first, and `checks/product-checkout.sh` clones
   the Product there in CI when the `YAD_PRODUCT_TOKEN` secret is set (see `references/check-gates.md`).
   A missing token on a PR that is not from a fork is a `WARNING` in CI, and a token that expires within
   30 days is warned about there too (#345); `yad doctor` reports where each code repo's CI gets it.
3. **build/test/lint** — standard quality stage; tests must actually exercise new behavior, not just pass.
   A Unity project (`ProjectSettings/ProjectVersion.txt` and `Assets/`, no `package.json`) is skipped with a
   note: build and test it with Unity's own CI, such as GameCI (#496).
   CI installs and runs through the package manager declared by the repo's standard
   `package.json#packageManager` field (`npm` and `pnpm` are supported; any other manager stays on
   npm with a warning when an npm lockfile is present, and fails closed otherwise); an npm repo
   without that field retains the historical npm behavior. A declared manager requires a full, exact semantic
   version (with Corepack's optional integrity suffix supported), and CI activates that exact version.
   The code-repo `yad-checks` workflow uses Node 22 by default (the build/test/lint job on GitHub; every
   `yad-*` gate job's image in the GitLab fragment) and reads `YAD_NODE_VERSION` (a GitHub repository
   variable or GitLab CI/CD variable) for repos whose declared runtime differs (a declared `packageManager` needs Corepack, so the override must be a line that
   bundles a current one: 20.19+, 22.14+ or 24; Node 25+ dropped it). The Product-side workflows (verified-commits, product-checks, update-guard,
   gate-sync) only run the `yad` CLI and keep their own pinned Node; the variable does not reach them.
   The CI job sets `YAD_TEST_MAX_WORKERS` (default `2`); the gate caps jest/vitest test concurrency at
   that and is a no-op for other runners (see `references/check-gates.md`).
4. **verified-commits** — no unsigned commits: every commit in the range must carry a signature the
   platform marks **Verified**. There is no author allowlist (E62): write access to the repo decides who
   can author. An old `.sdlc/verified-authors` file is no longer read, and the gate prints a note when it
   finds one. Enforced on the **Product and every connected repo**; runs on PRs/MRs only, so the
   gate-sync bot's direct ledger pushes are unaffected (never replace it with a default-branch push rule — see
   `references/check-gates.md` §4).
5. **lineage-check** (Phase 6) — the change's owning epic is a valid node in a **feature thread**: a
   `change`/`defect`/`hotfix` epic must thread to a real `parent`. Builds on spec-link's story→epic
   resolution; the every-code-change-has-a-threaded-epic enforcement.
6. **epic-open** (Phase 6, the staleness preventer) — an epic is **sealed** once every story is
   `shipped`; a commit targeting a sealed epic **FAILS**, forcing new behaviour into a new threaded
   change-epic (so the Shape artifacts can never go stale).
7. **reconcile-debt** (Phase 6) — a hotfix that shipped first opens debt; the **next** change on its
   thread **FAILS** until the debt is paid (artifacts updated + a regression test added).
8. **risk-map** (E65, **advisory — never fails**) — reads the code repo's `.sdlc/risk-map` (one line per
   directory: `high` / `medium` / `low`, no names) and **warns** when this change adds a directory no line
   covers, leaves a line whose directory is gone, touches a line still `unset` or `guessed`, or edits the
   map itself. A repo with no map gets one note. It also prints the **approver count** (E66): a change
   touching a directory the **base branch's** map marks `high` asks for one more approver — reported,
   never enforced: branch protection holds the merge — and names who has **committed there in the last 30 days**
   (E67), so the team knows who can meet that ask. The map is the team's file, never wired; the
   `yad-connect-repos` skill drafts it. See `references/check-gates.md` §10.

The Phase 6 gates read the owning epic in the **Product** via `specs/<story>/link.md`'s
`product-repo` path (like contract-check), and degrade to a PASS-with-note when the Product is not reachable
from CI. `product-repo` is read from the base, a Product this repo tracks is read from the base commit, and
`epic:` must be the story ID's prefix — the PR cannot choose what is gated (E117, E118). See `references/check-gates.md` and `skills/yad-change`.

The gates are **CI-agnostic bash** in `checks/`; thin pipeline configs invoke them on GitHub Actions
and GitLab CI. This step is **by hand** in Phase 3 — run the gates with the skill (`yad run checks`) or let CI run them;
**nothing auto-advances**. The gates are blocking in CI (all but the advisory risk-map check), but the human still owns the merge (Step E).

## Conventions

- `{project-root}` resolves from the project working directory — the **product** repo (holds the
  canonical templates under this skill).
- Code repos are separate git repos under `{project-root}/demo-repos/<repo>/`
  (`config.yaml` `build.code_repos_root`).
- Canonical gate sources live in this skill's `templates/` (the source of truth that gets installed
  into each code repo):
  - `templates/checks/{spec-link,contract-check,package-manager,install-deps,build-test-lint,verified-commits,risk-map-check}.sh`
  - `templates/checks/ledger-guard.sh` → **Product-only** gate, active **only in verified mode** — `product.json`
    (`hub.json` on an older Product) carries BOTH a `platform` and `ledger: "verified"` — or, before `yad migrate`, `bridge_enabled`
    (or the legacy `bridge`) true. The same predicate
    `isVerifiedLedger` (`cli/manifest.mjs`) applies, so the gate and the CLI can never disagree about who owns the
    ledger (#186). A no-op otherwise, when humans legitimately own it. On review PRs it FAILs any
    commit that touches the
    CI-owned gate ledger (`.sdlc/{state,approvals,comments,product-prs,hub-prs}.json`, `reviews/*.md`) unless it
    is a **verified gate-bot commit** — bot-authored AND platform-Verified. (Known gap: the Verified
    badge proves only that the committer signed, not that the bot did, so the GitHub job is given no
    token and refuses every such commit; on GitLab the gap is still open. See `references/check-gates.md`.) `.sdlc/contract-lock.json` is artifact-side and exempt. So is a **new epic's seed**:
    no CI path can create a ledger (`gate ci` only *advances* an existing chain, at merge, on the
    default branch), so an epic whose `.sdlc/state.json` is absent from the base ref may be created by
    a human on its first review PR/MR — **creation, not mutation** (#162). Once the ledger is on the
    default branch the guard is absolute again. Runs in `yad-product-checks`; `verified-commits` runs beside
    it in its own `yad-verified-commits` workflow (and requires the bot's signature like any other
    commit's). See `yad-product-bridge`.
  - `templates/hooks/ledger-guard.mjs` → **Product-only** agent guardrail, active **only in verified mode**
    (the same `isVerifiedLedger` predicate). Not a CI gate: it is a **harness hook** that refuses an agent's
    edit to the CI-owned ledger at the moment it is attempted and names `yad gate open` instead — the
    local half of `checks/ledger-guard.sh` (#171). Installed to `<product>/hooks/ledger-guard.mjs` with the
    `PreToolUse` entry in `.claude/settings.json`; a `.cursor` project also gets
    `templates/hooks/ledger-guard-cursor.mjs` and a `preToolUse` entry in `.cursor/hooks.json`.
    Fails OPEN; see "Step 2b" below. Every hook is a Node script the entry runs as `node <script>`, so
    it needs no bash and no execute bit and runs on Windows too (E113).
  - `templates/hooks/agent-guard.mjs` → the Product (`hooks/agent-guard.mjs`) **and every connected code
    repo** (`checks/agent-guard.mjs`, E158b), in **both** ledger modes (E158): the harness
    hook that runs `yad hook agent-guard` before every shell command an AI agent sends. It refuses a yad
    command only the person may run (`gate approve`, `comment`, `advance`, `reopen`, `commit --manual`),
    approving or merging a PR/MR (`gh pr review --approve`, `gh pr merge`, `glab mr approve|merge|accept`, or the
    same through `gh api`/`glab api`), skipping the git hooks (`git commit --no-verify` or `-n`,
    `YAD_HOOK_DISABLE=…`, `core.hooksPath`), and a force push (`--force`, `-f`, `--force-with-lease`, `--force-if-includes`, `--mirror`, a `+` refspec), and tells the agent to hand it to the person. Wired as a `PreToolUse` entry on `Bash` in
    `.claude/settings.json` and a `beforeShellExecution` entry in `.cursor/hooks.json` of each of those
    folders, so it runs in a session opened at either. Fails OPEN, and is a speed bump, not
    proof: a command inside a script is not seen, and Codex has no hooks.
  - `templates/hooks/yad-capture.mjs` → **Product-only**, in **both** ledger modes (E43): the post-edit
    harness hook that runs `yad capture --hook`, which snapshots every changed Shape artifact onto the
    person's private `yad/wip/<name>/<epic>` branches without touching the checkout. Wired as a
    `PostToolUse` entry in `.claude/settings.json` and an `afterFileEdit` entry in `.cursor/hooks.json`;
    always exits 0. It prints nothing, except under Claude Code when a file the edit changed is also
    being edited by someone else (E46 claims): then one PostToolUse JSON note the agent reads.
    `"capture": false` in the Product config unwires it.
  - `templates/github/yad-verified-commits.yml` + `templates/gitlab/yad-verified-commits.gitlab-ci.yml`
    → the standalone Product-side verified-commits CI (installed by `yad check --fix` with the Product wiring)
  - `templates/github/yad-checks.yml` → installs to `.github/workflows/yad-checks.yml` (marked `# yad-managed: yad-checks`);
    its quality job uses `install-deps.sh`, reads the optional `YAD_NODE_VERSION` repository variable,
    exports the PR's exact `NX_BASE`/`NX_HEAD`, and checks out the full history. It never starts on
    `edited` (#425): a gate job skipped on an edit counts as passed, so an edit of the PR text could turn
    a failed gate green. Every PR gate job (both platforms) runs the base branch's copy of `checks/`
    through `"$YAD_CHECKS/…"`, never the PR's own, and keeps no token in the checkout (#426) — except
    `yad-update-guard`, which runs on a direct push to the default branch;
    advise the CODEOWNERS lines in `docs/branch-protection.md` ("Who may change the gates") — never
    write CODEOWNERS.
  - `templates/github/yad-pr-text.yml` → `.github/workflows/yad-pr-text.yml`: `pr-title` + `pr-template`,
    the only checks that re-run on an edit of the PR title or body. The Product gets
    `templates/github/yad-product-pr-text.yml` (`--profile product`) beside `yad-product-checks.yml`.
  - `templates/gitlab/yad-checks.gitlab-ci.yml` → includable fragment, installs to `.gitlab/ci/yad-checks.yml`;
    it uses the same installer, honors a project/group `YAD_NODE_VERSION` CI/CD variable, and exports
    the MR's exact `NX_BASE`/`NX_HEAD`.
  - `templates/gitlab/gitlab-ci.include-root.yml` → minimal root written only when no root `.gitlab-ci.yml` exists
- The gates depend on the conventions from earlier steps: the `Task:`/`Contract-Change:` commit
  trailers (`yad-implement`), the `specs/<story>/link.md` + `contracts/` slice (`yad-spec`), and the
  locked `contract.md` (`yad-architecture`).

## Inputs

- `repo`  — the code repo to wire/run gates for (one of an epic's repos), or `product` to wire the Product itself (`hub`, the old name, still works). A code repo that is itself named
  `product`: give its registered path instead (for example `repos/product`), so it is not taken for the Product.
- `action` — `wire` (install the gates into the repo) | `run` (run the three gates now). Default `run`.
- `base`  — for `run`: the base ref to diff against (the PR/MR target; default the repo's default branch).

## On Activation

### Step 1 — Resolve the code repo
Map `repo` → `{project-root}/demo-repos/<repo>/` (or the registry `path` in `.sdlc/repos.json`). A `repo` value with a `/` in it is a registry `path`, not a name: match it against each entry's `path`
(so a code repo named `product` is reached as, for example, `repos/product`). Confirm
it is its own git repo. Operate inside it with absolute paths. For `repo: product`, the target is
`{project-root}` itself and the platform comes from `.sdlc/product.json` (`.sdlc/hub.json` on an older Product) — see "Wiring the Product" in
`references/check-gates.md`.

### Step 2 — `wire` (install the gates, syncing with any existing CI)
Copy from this skill's `templates/`:
- `templates/checks/*.sh` → `<repo>/checks/` (and `chmod +x`).
- Detect the platform and **merge — never clobber — the matching** CI config. Inspect what is already
  there first; the principle is **additive: never edit a foreign CI file**.

  **GitHub** (detect by any `.github/workflows/*.y*ml`): our gates live in their own
  `.github/workflows/yad-checks.yml`, which GitHub runs independently of every other workflow, so
  "merge" reduces to "do not collide on the path".
  - No file at our path → copy `templates/github/yad-checks.yml` verbatim.
  - A file at our path whose **first line is `# yad-managed: yad-checks`** → it is ours; refresh it
    (no-op if unchanged). 
  - A **foreign** file occupies that path/name → write to a non-colliding filename
    (`yad-checks.gen.yml`) and ensure its `name:` does not clash. Never merge jobs into a foreign
    workflow; never edit one.
  - Also install `templates/github/yad-pr-text.yml` → `.github/workflows/yad-pr-text.yml` the same way.
  - Also install `templates/github/yad-update-guard.yml` → `.github/workflows/yad-update-guard.yml`
    (marker `# yad-managed: yad-checks`) — the push-on-default integrity gate for direct-to-default
    commits (`yad update --push`); it runs only `verified-commits` + `commit-message`. Same
    own-a-file rules as above.

  **GitLab** (detect by a root `.gitlab-ci.yml` and/or `.gitlab/ci/*.yml`): install the includable
  fragment `templates/gitlab/yad-checks.gitlab-ci.yml` → `<repo>/.gitlab/ci/yad-checks.yml` (its jobs
  carry `needs: []` and no `stage:`, so a foreign root `stages:` cannot break or reorder them).
  - No root `.gitlab-ci.yml` → write `templates/gitlab/gitlab-ci.include-root.yml` to
    `<repo>/.gitlab-ci.yml` (a minimal root that only `include:`s our fragment).
  - Root exists → read its top-level `include:`. Add the `include:` key if absent; append
    `- local: '.gitlab/ci/yad-checks.yml'` if the key exists but the entry is missing; **no-op** if it
    is already listed. Touch nothing else in the root.
  - Also install `templates/gitlab/yad-update-guard.gitlab-ci.yml` → `<repo>/.gitlab/ci/yad-update-guard.yml`
    (marker `# yad-managed-include: yad-checks`) — the push-on-default integrity gate — and append
    `- local: '.gitlab/ci/yad-update-guard.yml'` to the root `include:` the same additive, idempotent way.
  - If the existing YAML cannot be parsed safely → **STOP** and print the exact include snippet for the
    human to paste (graceful degradation — never guess-edit a pipeline you cannot parse).
  - A greenfield repo with no root `.gitlab-ci.yml` gets `gitlab-ci.include-root.yml` (above) plus the
    fragments — there is no single-file template (the old one, with 4 of the 11 gates, was removed in #434).
  - **CI/CD variables, tokens and branch protection are the person's (E158).** An AI agent gives them
    the steps below, never sets one itself, and confirms by reading once they say it is done.
    `yad doctor` reads branch protection and where `YAD_PRODUCT_TOKEN` is set; it cannot read the
    `YAD_RUNNER_TAGS` or `YAD_NODE_VERSION` values, so for those, ask the person and take the next
    green pipeline as the proof. It runs `yad update --overwrite-local` only when the person asks.
  - **Tag-locked runners** (`run_untagged: false`, common on self-hosted): the fragment's jobs run a
    docker image, so set a `YAD_RUNNER_TAGS` CI/CD variable (e.g. `dind_runner`) to route them — every
    GitLab fragment's jobs carry `tags: [$YAD_RUNNER_TAGS]`. When unset, current GitLab (≥15) drops the
    empty-expanded tag so the jobs run untagged (gitlab.com shared runners); older versions may
    strand them `pending`, in which case set the variable to a real tag. The variable lives in
    project settings, so it survives every `yad` sync. Single value only — `tags: [$VAR]` is one tag
    equal to the whole variable, not a comma-split. Leave **Protect variable** unticked on both
    variables below: a protected variable reaches only pipelines on protected branches, so the MR
    gates would run without it — untagged and on the default Node line.
  - **A trunk that is not the default branch** (#599): the update guard checks direct pushes to the
    platform's default branch, and to the branch a `YAD_TRUNK` CI variable names. When the repo's
    `default_branch` in yad's files (for example `testing`) is not the platform's default, the person
    sets `YAD_TRUNK` to it — a project or group CI/CD variable on GitLab (`rules:` read it), a
    repository variable on GitHub. Unset, only the default branch is checked. `yad ci check` shows a
    `trunk` warning with the value; it cannot read the variable, so ask the person whether it is set.
  - **The Node line** (#364): every GitLab job runs `image: node:${YAD_NODE_VERSION}`, `22` by default.
    Set a `YAD_NODE_VERSION` CI/CD variable (a current `20`, `22` or `24` line) to change it — a
    project variable wins over the fragment's value, so the fragment itself is never edited.
  - **Shell-executor runners** ignore `image:`. The jobs then run on the runner host as they are, so
    the host needs `bash`, `git`, `curl` (the signature gates read the GitLab API with it; without it
    every commit reads as unverified) and Node (any current 22 or 24 line — for example from nvm)
    on the runner user's `PATH`, plus whatever the repo's own build needs (Corepack, pnpm, …) for
    `build-test-lint`. `YAD_NODE_VERSION` has no effect there. Point `YAD_RUNNER_TAGS` at that
    runner's tag.
  - **Do not hand-edit the fragments to fit a runner.** They are managed bytes: `yad check` reports a
    hand-edited one as `modified`, and a plain `yad update` leaves it alone — so it never receives a
    fix again. Both runner settings above are CI/CD variables, so no edit is needed: move the
    customisation into them (the person's, above), then, when the person asks, run
    `yad update --overwrite-local` to restore the fragment (it keeps
    a `.yad-orig` copy of the edited one first). `yad doctor` warns when a wired
    fragment has no `tags:` (`YAD-CI-001`) or still runs a fixed `node:<n>` image (`YAD-CI-002`, an
    install from before the variable — `yad update` replaces it).
  - **Product jobs of your own** (`yad-product-checks.yml`): before #364 this fragment set its image
    and tag in a top-level `default:`, which GitLab applies to every job in the pipeline — the
    Product's own jobs too. They now sit on the yad jobs only. A job of yours that had no `image:` or
    `tags:` and relied on that block needs its own after `yad update`.

- Ensure `<repo>/package.json` defines `lint`, `build`, `test` scripts (see `references/check-gates.md`
  for the canonical scripts). **Only ADD a missing script; never overwrite an existing one.**

Re-running `wire` is **idempotent** — markers (`# yad-managed: yad-checks`,
`# yad-managed-include: yad-checks`) and the include-entry check make a second run a no-op.
The wiring belongs on the repo's default branch (it is shared infrastructure, not a task diff). Get it
there with `yad check --fix --open-pr`, which opens a PR/MR without asking; a commit or push straight
to the default branch needs the person's yes each time (E158).

**The Product is wired the same way.** `repo: product` wires the Product repo itself (platform from `.sdlc/product.json`)
with a Product-flavored gate set — see "Wiring the Product" in `references/check-gates.md`.

**The Product also gets the agent guardrail** (see below): `templates/hooks/ledger-guard.mjs` →
`<product>/hooks/ledger-guard.mjs`, plus the `PreToolUse` entry in `.claude/settings.json`. A project
whose targets include `.cursor` also gets `templates/hooks/ledger-guard-cursor.mjs` and a `preToolUse`
entry in `.cursor/hooks.json`. Every Product, in both ledger modes, also gets the agent guard
(`templates/hooks/agent-guard.mjs`, above), which stops an agent from running an approval or a force
push. `yad setup` and `yad check --fix` install them; nothing by hand.

### Step 2b — the agent guardrail (harness hooks, verified mode only)
The CI gates speak at CI time. That is too late for one failure the field kept hitting (#171): in
verified mode the gate ledger is **CI-owned**, so an agent that hand-edits
`epics/*/.sdlc/state.json` only finds out twenty minutes later, from a `ledger-guard` FAIL with
nothing connecting cause to effect — and by then the write has to be reverted before the review
PR/MR can go green.

`hooks/ledger-guard.mjs` is the local half of that same rule. It runs as a **harness hook** before a
file-editing tool call and refuses the write up front, naming the command that owns the transition
(`yad gate open`), so the agent corrects itself instead of failing a pipeline.

- **Harness-agnostic by contract.** The script only locates `yad` and hands the tool payload to
  `yad hook ledger-guard`: **stdin** is a JSON tool-call payload, **exit 0** allows, **exit 2**
  denies with the reason on stderr. Claude Code's `PreToolUse` reads exactly that, so its entry points
  straight at the script. Cursor does NOT: its `preToolUse` is a **permission hook**, which wants a
  JSON verdict on stdout and treats an empty or off-schema answer as a refusal — and this script
  prints nothing when it allows, so wiring it there directly would block every file write in the
  project. Cursor's entry runs `node hooks/ledger-guard-cursor.mjs` instead, which runs
  `yad hook ledger-guard --format cursor` and always answers `{"permission":"allow"}` or
  `{"permission":"deny","user_message":…,"agent_message":…}`. **Check which kind a harness is
  before wiring it by hand.** A hook that fires only AFTER the write, such as Cursor's
  `afterFileEdit`, is not used: it could report the edit but never refuse it, and reporting is what
  the CI gate already does.
- **Targets with no such hook are named, not skipped.** `.agents`, `.gemini`, `.zencoder` and
  `.opencode` get the script and no wiring, and `yad doctor` says which of a project's targets are
  guarded by CI alone. Silence about an unguarded target reads as a guarded one.
- **Same scope as the CI gate**, deliberately: guarded are `epics/*/.sdlc/{state,approvals,comments,product-prs,hub-prs}.json`
  and `epics/*/reviews/*.md` (at the gate's own glob depth, which spans `/`); exempt are
  `contract-lock.json`, `change.json`, and every artifact. A **new** epic's ledger is exempt too —
  creation, not mutation (#162), decided by listing the epics the **base ref** carries (an
  `origin/` ref, case-folded slugs), never by looking at the working tree.
- **A no-op with a local ledger.** There the ledger is locally owned and the hand-edit the authoring
  skills describe is *correct*, so nothing is wired and nothing is blocked.
- **It fails OPEN** — no `yad`, no Product, an unreadable config, an unparseable payload all ALLOW, with
  a note on stderr. `ledger-guard` in CI fails *closed* and remains the authority. A PERSON can skip it
  for one command with `YAD_HOOK_DISABLE=1`; never the agent (a NEVER rule, and the agent guard refuses it). A PERSON who must commit a ledger change anyway uses `yad commit --manual --reason
  "<why>"` (E49) — never the agent, even when asked: it gives the person the exact command (E158).
- **Known gaps** (both caught by the CI gate instead): a `Bash` tool call (`sed -i epics/…`) is not
  intercepted — matching it would mean parsing shell; and the hook arms sessions **rooted at the
  Product**, since a harness reads hooks from its own project root — a session opened at the workspace
  above the Product never loads the Product's `.claude/settings.json`.

`yad doctor` reports the guardrail as `agent ledger guard wired` / `not wired` on a verified Product.
See `references/check-gates.md` §"The agent guardrail".

**The same rule for a person's `git commit` (E48).** On a verified Product, `yad check --fix` also
installs `.git/hooks/pre-commit` in the clone it runs in. It runs `node hooks/ledger-guard.mjs
--staged`, which judges the files the commit is about to record by the same rules as the CI gate (a
merge commit and a `yad-gate-sync` commit pass, as they do in CI) and refuses the commit with the files,
the `git restore --staged` line and the owning command. It is per clone — git never copies hooks — so
`yad doctor` warns `git-hook` in a clone that has none. A `pre-commit` that is not yad's, or a
`core.hooksPath` folder, is never written: print the one line `yad doctor` gives and let the person add
it. Branch protection is what makes the CI gates hold a merge at all: point the team at yadflow's
`docs/branch-protection.md`.

### Step 3 — `run` (run the gates now)
From inside the repo, run `yad run checks` (add `--body <file>` holding the PR/MR description, and
`--title` unless the branch has exactly one commit). It runs every installed gate as CI does — the
Product's default branch where CI checks it out, every gate even after one fails — and prints a summary;
report PASS, FAIL or skipped per gate from it (`--json` lists each gate's FAIL lines). A skipped
pr-title or pr-template is not a pass. It runs `npm ci` (which replaces `node_modules`) and the build;
add `--no-build` when that is not wanted. One gate by hand:
```
bash checks/spec-link.sh "<base>"
bash checks/contract-check.sh "<base>"
bash checks/build-test-lint.sh
```
`<base>` is optional for the gates that take one (`build-test-lint` takes none) — omitted, the gate
resolves the trunk (configured `default_branch`, else `origin/HEAD`, else `origin/main`) and prints
the base it chose; pass it (or `SDLC_BASE`) when the PR/MR targets another branch.

A non-zero exit is a FAIL. Summarize which gates passed and, for any failure, the exact remediation
(spec-link: add the `Task:` trailer / spec; contract-check: route back to the architecture gate and
re-lock the contract; build/test/lint: fix the failing lint/test).

### Step 4 — Report; the advance decision belongs to the dial (Phase 4)
Report the gate results. Passing gates do **not** merge anything — the AI review (Step D/E) and the
human engineer review (Step E) still own the merge. This skill never edits the epic's `.sdlc/` state.

- **Run standalone** (the Phase 3 default): **stop** here. A clean pass does not advance anything; a
  human takes the next step.
- **Run by the orchestrator** (`yad-run`, Phase 4): this skill still just reports PASS/FAIL — the
  *advance decision* is the orchestrator's, read from the `checks` step's advance dial. On a clean
  pass with `checks` set to `advance: auto`, `yad-run` advances to `engineer-review` on its own;
  on any FAIL it halts and pulls in a human (build plan §B). **What the gates check is unchanged** —
  only who decides to proceed after a clean pass.

## Hard rules (build plan §C, Cross-cutting)

- **The gates are blocking in CI, advisory to no one.** A FAIL stops the merge; a PASS does not grant it.
- **Contract surface is never widened from a code repo.** contract-check routes surface changes back
  to the architecture gate; only an updated, re-locked contract + `Contract-Change: yes` may pass.
- **Tests must exercise behavior.** build/test/lint is not satisfied by empty or trivial tests.
- **The gate never advances itself.** A FAIL always halts. A clean PASS advances only when the
  orchestrator's `checks` dial is `advance: auto` (`yad dial`) — and only as far as the engineer review,
  which is always human. Standalone, the gate still stops and the human owns the merge.

## Reference
- Gate definitions, the canonical scripts, CI wiring, and the convention map: `references/check-gates.md`.
- Commit-trailer conventions the gates read: `../yad-implement/references/implement-conventions.md`.
- Contract surface + hash recipe: `../yad-architecture/references/contract-format.md`.

Files in this skill

  • SKILL.md31.6 KB
  • references/check-gates.md91.2 KB
  • templates/checks/build-test-lint.sh3.8 KB
  • templates/checks/commit-message.sh9.1 KB
  • templates/checks/contract-check.sh71.9 KB
  • templates/checks/epic-open.sh36.7 KB
  • templates/checks/install-deps.sh1.9 KB
  • templates/checks/ledger-guard.sh24 KB
  • templates/checks/lineage-check.sh37.7 KB
  • templates/checks/member-check.mjs29.9 KB
  • templates/checks/package-manager.sh12.3 KB
  • templates/checks/product-checkout.sh19.4 KB
  • templates/checks/reconcile-debt-check.sh37.5 KB
  • templates/checks/risk-map-check.sh28.6 KB
  • templates/checks/spec-link.sh11.9 KB
  • templates/checks/verified-commits.sh11.9 KB
  • templates/github/yad-checks.yml27.5 KB
  • templates/github/yad-pr-text.yml6.7 KB
  • templates/github/yad-product-checks.yml9.6 KB
  • templates/github/yad-product-pr-text.yml7.7 KB

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 development →

Comments

Loading comments…

Newsletter

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