[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77KBJ9K65EYTXYSS879Y7XN":3,"skill-same:01M77KBJ9K65EYTXYSS879Y7XN":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M77KBJ9K65EYTXYSS879Y7XN","gh-repo-setup-protection",null,"Idempotently converge a repo's entire Security & Quality surface — GHAS toggles (incl. push-protection bypass lockdown, per-repo Code Security, malware alerts, grouped security updates), the merge-button \u002F PR-hygiene settings (merge-commit-only, auto-merge, auto-delete head branch), a hardened templated Dependabot config (always covering GitHub Actions), an Advanced CodeQL workflow, a dependency-install-gate (npm\u002Fpip\u002Fpnpm\u002Fyarn drift guard), a dependency-pinned-gate (npm\u002Fpip\u002Factions\u002Fdocker\u002Fgo exact-version guard), a no-back-merging-guard, and the protect-main ruleset — re-asserting on every run, and committing + PR-ing its own rendered files on a single approval.","TheVoskamps\u002Fclaude-plugins-marketplace","TheVoskamps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235012489?v=4","01M77K5ZCP12QCJPQ85WVJSHTS","Irene and Edwin Voskamp","01M77K5ZDS7DB0PA1W8FM7G2QD",0,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fgithub-setup\u002Fskills\u002Fgh-repo-setup-protection\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: gh-repo-setup-protection\ndescription: \"Idempotently converge a repo's entire Security & Quality surface — GHAS toggles (incl. push-protection bypass lockdown, per-repo Code Security, malware alerts, grouped security updates), the merge-button \u002F PR-hygiene settings (merge-commit-only, auto-merge, auto-delete head branch), a hardened templated Dependabot config (always covering GitHub Actions), an Advanced CodeQL workflow, a dependency-install-gate (npm\u002Fpip\u002Fpnpm\u002Fyarn drift guard), a dependency-pinned-gate (npm\u002Fpip\u002Factions\u002Fdocker\u002Fgo exact-version guard), a no-back-merging-guard, and the protect-main ruleset — re-asserting on every run, and committing + PR-ing its own rendered files on a single approval.\"\n---\n\nYou are running the `\u002Fgh-repo-setup-protection` skill. Your job is to\nbring the **current repo** (the repo the user invoked the skill from)\nto a desired security\u002Fquality protection baseline. The skill's remit is\nthe **entire Security & Quality surface** of the repo — every setting on\nthe repo's *Security & Quality* settings page — plus the repo's\nmerge-button \u002F PR-hygiene **General** settings and the matching\n`protect-main` ruleset. The GHAS features are half-measures without the\nruleset that enforces them, so both are in scope:\n\n1. **GHAS \u002F repo security settings** — Dependabot alerts, Dependabot\n   security updates (incl. *grouped* security updates), Dependabot\n   *malware* alerts, per-repo Code Security (GHAS enablement when the\n   org\u002Frepo is entitled), and secret scanning + push protection\n   (including *locking down who may bypass* push protection) where the\n   repo is entitled to them.\n2. **Merge-button \u002F PR-hygiene repo settings** — the General-settings\n   merge-button toggles (`allow_squash_merge`, `allow_rebase_merge`,\n   `allow_update_branch`, `allow_auto_merge`, `delete_branch_on_merge`)\n   converged to the hardened state: merge-commit only, suggest-update-\n   branch + auto-merge + auto-delete-head-branch on. These are remote\n   settings applied via the GitHub API, read-then-PATCH and idempotent\n   like the GHAS toggles. See Step 4e.\n3. **A templated `dependabot.yml`** — version-update config covering\n   **every supported package ecosystem** (`github-actions`, `npm`,\n   `pip`, `docker`, `gomod`, `bundler`, `cargo`, `maven`, `gradle`,\n   `composer`, `terraform`), armed at install time regardless of what\n   the scan found, with a `security-updates` group so security PRs are\n   batched per ecosystem. Dependabot **no-ops** on an ecosystem whose\n   manifest is absent, so arming the full set adds no spurious update\n   PRs — it just means an ecosystem's first manifest is covered the\n   moment it lands, with no skill re-run. See Step 2 \u002F Step 3. (The\n   Step 2b Dependabot tab is a *de-arm* override — drop an ecosystem you\n   never want — defaulting to the full set armed.)\n4. **An Advanced CodeQL workflow** — **only when CodeQL is enabled for\n   this repo** (explicit `--codeql=on` operator override, or\n   auto-detection). The workflow is armed with the **full supported\n   CodeQL language set** and picks which to analyze at **runtime**, per\n   PR: a `detect` job emits the languages actually present in the tree,\n   an `analyze` matrix runs one leg per present language, and a\n   `codeql-required` aggregator is the single required check (green when\n   the matrix is empty, so a language-less repo is mergeable, not hung).\n   A language that lands *after* setup lights its leg up automatically —\n   no skill re-run. CodeQL is never turned on *by auto-detection* on an\n   unentitled private repo; an explicit `--codeql=on` is an operator\n   override that the skill honors. The shipped workflow is **Advanced\n   setup from the first commit** (SHA-pinned, autobuild-free,\n   least-privilege). See the \"CodeQL is opt-in\" section for why.\n5. **A dependency-install-gate** — **installed whenever CodeQL-style\n   protection is wanted for dependency drift** (armed with the full\n   supported set of npm \u002F pip \u002F pnpm \u002F yarn). A `pull_request` workflow\n   with a `detect` job (emits the package managers whose manifest is\n   present), a matrixed `gate` job (one leg per present PM, replaying the\n   lockfile \u002F running a resolver pre-flight and failing on drift), and an\n   `install-gate-required` aggregator that is the single required check\n   (green when the matrix is empty). Each Node manager keys off its\n   **own** lockfile (`package-lock.json` \u002F `pnpm-lock.yaml` \u002F\n   `yarn.lock`), so a pnpm\u002Fyarn repo is gated by the right tool instead\n   of silently passing an npm-only check. A PM whose manifest lands after\n   setup lights its leg up automatically — no skill re-run. See Step 5c.\n6. **A dependency-pinned-gate** — the **sibling** of the\n   dependency-install-gate (armed with the full supported set of npm \u002F\n   pip \u002F actions \u002F docker \u002F go): where the install-gate protects the\n   lockfile↔manifest *lock* relationship, this gate protects how the\n   manifest itself **declares** versions. A `pull_request` workflow with\n   the same `detect` → matrixed `gate` → `pinned-gate-required`\n   aggregator shape, whose per-ecosystem legs fail the PR when any\n   *declared* dependency is not pinned to an exact version\n   (caret\u002Ftilde\u002Fcomparator\u002FX-range\u002FOR\u002Fcompatible-release specs, floating\n   action `@vN` tags, floating Docker `:latest` tags, bare names) —\n   catching the \"works on main, breaks on rebase\" supply-chain drift that\n   slips past a green install-gate. Categorical exemptions\n   (peerDependencies carets, `file:`\u002F`workspace:` specs, pnpm\n   `catalog:`\u002F`catalog:\u003Cname>` references, `engines`\u002F`requires-python`\n   floors, override-value classification, `tag@sha256:` digests) live\n   in the classifier, not an allowlist file. A `catalog:` reference is\n   exempt at the consumer manifest because it is not a version itself —\n   the referenced entry in `pnpm-workspace.yaml`'s `catalog:`\u002F`catalogs:`\n   sections is validated for exactness instead, once at the source.\n   `actions` is an always-present floor (the skill always installs\n   workflows). Its aggregator is a separate required check from the\n   install-gate's. See Step 5c-pinned.\n7. **A no-back-merging-guard** — installed **unconditionally** (it has\n   no ecosystem dependency; it is pure git-history hygiene). A\n   `pull_request` workflow whose single job `no-back-merging-guard`\n   rejects PRs whose head branch contains a back-merge from the default\n   branch (a merge commit whose incoming parent is reachable from\n   `origin\u002F\u003Cdefault>`), forcing feature branches to rebase rather than\n   merge the base in. See Step 5d.\n8. **The `protect-main` ruleset** — create\u002Fconverge the standard\n   branch ruleset (deletion, non-fast-forward, a `pull_request` rule\n   with last-push-approval + code-owner review + thread-resolution, and\n   `required_status_checks`). The `pull_request` rule grants the\n   built-in **Repository admin** role a **PR-only** bypass so a\n   single-maintainer repo (sole writer == sole code-owner == last\n   pusher) is not deadlocked by last-push-approval + code-owner review.\n   Required status checks are wired through a **generic gate**: each one\n   is added **only if its producing workflow is present in the repo this\n   run** — the issue #91\u002F#230 phantom-check guard, applied at\n   **workflow** granularity (never per-leg). The required checks are the\n   workflows' **aggregators**: `codeql-required` iff a CodeQL workflow is\n   present this run, `install-gate-required` iff the\n   dependency-install-gate workflow is present this run,\n   `pinned-gate-required` iff the dependency-pinned-gate workflow is\n   present this run, and `no-back-merging-guard` iff that workflow is\n   present this run (always, since it ships unconditionally) — never a\n   per-leg name like `Analyze (python)` or `Install gate (npm)`, which\n   would hang a repo lacking that language\u002FPM (the #91\u002F#230 failure\n   mode). Each aggregator passes green when its runtime matrix was empty,\n   so a repo missing the guarded languages\u002Fecosystems is mergeable.\n\n**Converge the whole surface on every run — do not set-and-forget.**\nAn org-level change can flip a per-repo setting back off (e.g. enabling\nCode Security at the org level flips `secret_scanning_push_protection`\nback to disabled). Every run must *re-assert* the hardened state for\nevery setting, reporting each as `enabled`\u002F`changed`\u002F`unchanged`.\n\nThe headline requirement is **idempotency \u002F convergence**. This skill\nis meant to be run repeatedly across many repos (at least four:\ntwo under `TheVoskamps`, two under `ExampleProject`). Re-running on an\nalready-configured repo must **detect existing state and converge** to\nthe desired config — it must never duplicate ecosystem blocks, append\nto a config that already has the right content, or hard-error because\nsomething is already in place.\n\nThe **full supported set is armed at install time on every surface** —\nCodeQL languages, both gates' ecosystems, and Dependabot's ecosystems —\nand each surface **activates automatically the first time matching\nsource appears, with no skill re-run**. For CodeQL and the two gates\nthis is a **runtime dynamic-matrix**: a check appears on a PR iff the\nlanguage\u002Fecosystem it guards is present in the tree at that moment\n(present + clean → green; present + broken → red\u002Fblocking; absent → no\ncheck). For Dependabot (which emits no PR check) it means the rendered\n`updates:` list covers every supported ecosystem, no-opping on absent\nmanifests. This **structurally removes the protect-before-code ordering\ninversion** — you no longer merge the code first so the skill can detect\nit. Before authoring anything, the skill presents an **operator\nconfirmation checklist** (Step 2b) that is a *de-arm* override:\neverything is armed by default, and the operator can drop a\nlanguage\u002Fecosystem they never want armed.\n\nAfter rendering its files, the skill **commits, pushes, and opens a\nPR** for its own rendered files on a single approval (Step 7). The\nrendered files go on a branch named after the skill\n(`gh-repo-setup-protection`) and into a PR targeting the default\nbranch — the operator approves once, and that one approval covers\ncommit + push + PR. The **remote API changes** — the GHAS toggles\n(Step 4), the merge-button settings (Step 4e), and the `protect-main`\nruleset (Step 6) — are not file edits and cannot live in a PR, so they\nare applied **directly** to the repo; every such change is reported and\nre-running is a no-op when the setting is already correct.\n\n---\n\n## Inputs\n\nAll optional; everything else is inferred from the repo.\n\n- `--codeql=on|off|auto` (default `auto`): controls the CodeQL\n  workflow. See \"CodeQL is opt-in\".\n- `--ghas=on|off` (default `on`): whether to attempt the remote\n  settings — the GHAS toggles (Step 4) and the merge-button \u002F\n  PR-hygiene settings (Step 4e). Set `off` for a repo where you only\n  want the Dependabot\u002FCodeQL files and not the remote\n  security\u002Fmerge-button settings.\n- `--ruleset=on|off` (default `on`): whether to create\u002Fconverge the\n  `protect-main` ruleset (Step 6). Set `off` to manage branch\n  protection elsewhere and have this skill touch only the\n  GHAS\u002FDependabot\u002FCodeQL surface.\n- `--dry-run`: report what *would* change (files, GHAS toggles,\n  merge-button settings, the ruleset, and the rendered-files PR) without\n  writing files, calling the mutating API, or opening a PR. Skips the\n  Step 2b operator de-arm checklist (arms the full supported set on\n  every surface) so the multi-repo verification pass is non-interactive.\n\nIf the user passed nothing, use the defaults above.\n\n---\n\n## Step 0: Payload\n\nThe template payloads this skill renders ship with the plugin at\n`${CLAUDE_PLUGIN_ROOT}\u002Fpayload\u002Fgh-repo-setup-protection\u002F`. The\nplaceholder\u002Frender convention is documented in\n`${CLAUDE_PLUGIN_ROOT}\u002Fpayload\u002FREADME.md`.\n\n## Step 1: Pre-flight — repo root, auth, and identifiers\n\nConfirm you are inside a git working tree and capture the root:\n\n```bash\ngit rev-parse --show-toplevel\n```\n\nIf it fails, abort with:\n\n> `\u002Fgh-repo-setup-protection` must be run from inside a git\n> repository. The current directory is not a git working tree.\n\nConfirm `gh` is authenticated:\n\n```bash\ngh auth status\n```\n\nIf not authenticated, abort and tell the user to run `gh auth login`\n(scopes: `repo`, plus `security_events` and `admin:repo_hook` are\nhelpful for the GHAS toggles).\n\n`jq` must be on `PATH` (it parses the CodeQL default-setup response in\nStep 5a; it is already a hard dependency of the global config's hooks).\nStep 5a hard-stops if it is missing.\n\nResolve the repo identifiers (these feed the placeholders — see\n`${CLAUDE_PLUGIN_ROOT}\u002Fpayload\u002FREADME.md` step 1 inference table):\n\n```bash\ngh repo view --json nameWithOwner -q .nameWithOwner   # __GH_ORG__\u002F__GH_REPO__\ngh repo view --json defaultBranchRef -q .defaultBranchRef.name  # __DEFAULT_BRANCH__\ngh repo view --json visibility -q .visibility\ngh repo view --json isPrivate -q .isPrivate\n```\n\n## Step 2: Scan package ecosystems present in the repo (informational)\n\n**The armed set is no longer narrowed by this scan.** All four\nprotected surfaces — CodeQL, the two gates, and Dependabot — arm the\n**full supported set** at install time (see Steps 3, 5b, 5c, 5c-pinned).\nCodeQL and the two gates then narrow to the *present* set at **runtime**\nvia each workflow's `detect` job; Dependabot no-ops on absent manifests.\nSo this scan does **not** decide *what to author* — it is retained only\nas **informational context** for the operator (to show, in the Step 2b\nde-arm checklist, which languages\u002Fecosystems already have source in the\ntree) and for the CodeQL on\u002Foff decision (Step 5, which still needs to\nknow whether the repo has any analyzable language to auto-resolve).\n\nThe Dependabot supported set the skill arms unconditionally (one\n`updates:` block each — directory `\u002F` for `github-actions`, recursive\n`**\u002F*` for the rest):\n\n`github-actions`, `npm`, `pip`, `docker`, `gomod`, `bundler`, `cargo`,\n`maven`, `gradle`, `composer`, `terraform`.\n\n(Confirm the exact set against Dependabot's current supported-ecosystems\ndocs at implementation time — arm whatever the current docs enumerate.\n`github-actions` is the floor and is always armed.)\n\nFor the **informational** scan, use this mapping (manifest glob →\necosystem). Run it from the repo root over tracked files only and ignore\nvendored trees (`node_modules`, `vendor`, `.git`):\n\n| Manifest (anywhere in tree) | Dependabot ecosystem |\n| --- | --- |\n| `package.json` | `npm` |\n| `requirements*.txt`, `pyproject.toml`, `Pipfile`, `setup.py` | `pip` |\n| `go.mod` | `gomod` |\n| `Gemfile` | `bundler` |\n| `Cargo.toml` | `cargo` |\n| `composer.json` | `composer` |\n| `pom.xml` | `maven` |\n| `build.gradle`, `build.gradle.kts` | `gradle` |\n| `*.tf` | `terraform` |\n| `Dockerfile`, `*\u002FDockerfile` | `docker` |\n\nReference detection commands (adjust as needed):\n\n```bash\nROOT=\"$(git rev-parse --show-toplevel)\"\n# Track files only — never scan ignored\u002Fvendored trees.\ngit -C \"$ROOT\" ls-files | grep -E '(^|\u002F)package\\.json$'\ngit -C \"$ROOT\" ls-files | grep -E '(^|\u002F)go\\.mod$'\ngit -C \"$ROOT\" ls-files | grep -E '(^|\u002F)(requirements.*\\.txt|pyproject\\.toml|Pipfile|setup\\.py)$'\n# ... etc per the table above\n```\n\n**The gates' own detection is defined once, at runtime, by their\nscripts** — not by this scan. `dependency-install-gate.sh --present`\nand `dependency-pinned-gate.sh --present` emit the present set from the\nsame `git ls-files` predicates the gates check with, and CodeQL's\n`codeql-language-present.sh --matrix` does the same for languages. This\nStep 2 scan never feeds those; it is purely for display and the CodeQL\non\u002Foff gate.\n\n**A `dependabot.yml` is always written** — the full supported set is\narmed unconditionally, so the `updates:` list is never empty. The old\n\"no ecosystem detected → skip the file\" \u002F \"markdown-only repo\" path is\n**gone**: the skill always arms every supported ecosystem.\n\n## Step 2b: Operator de-arm checklist (defaults to the full armed set)\n\nEvery surface is **armed with the full supported set** at install time,\nand each **narrows to the present set at runtime** (CodeQL and the two\ngates via their `detect` jobs) or no-ops on absent manifests\n(Dependabot). So there is **nothing to detect-and-narrow up front** — the\nprotect-before-code ordering inversion is gone structurally, not via an\noperator toggle. The scan (Step 2) is informational only.\n\nThe checklist that remains is a **de-arm override**: for each surface,\nthe full supported set is armed by default, and the operator may **drop**\na language\u002Fecosystem they never want armed on this repo. This is the\ninverse of the old \"confirm what to arm\" flow — the default is\neverything-on, and the only edit is subtraction.\n\nSo after the informational scan and **before authoring any file**\n(Steps 3, 5b, 5c, 5c-pinned), present a **single multi-tab\n`AskUserQuestion`** — one tab per surface (drift-gate \u002F pinned-gate \u002F\nDependabot \u002F CodeQL), each `multiSelect: true` — whose options are the\nsurface's **full supported set, all preselected (armed)**. The operator\n**unchecks** any item they want de-armed; the **armed set** (full set\nminus the operator's unchecks) is what is authored. This is the skill's\nup-front interaction; the single commit\u002Fpush\u002FPR approval (Step 7) still\ncomes after, so the approve-once model is preserved.\n\nSkip the checklist under `--dry-run` (arm the full supported set on every\nsurface and note the checklist was skipped) — every interactive run\npresents it.\n\n**Working within the `AskUserQuestion` contract.** The tool caps a call\nat 1–4 questions, each with 2–4 options. The four surfaces ⇒ four\nquestions — at the question cap. Several surfaces have more than four\nsupported values (Dependabot ≈11, CodeQL 10, pinned-gate 5), which\nexceeds the 2–4-options-per-question cap. Because the flow is now\n**de-arm only** (no free-text \"add\" path — the full set is already\narmed), an over-cap surface is presented as a **single confirm-or-edit\noption**: default \"keep the full set armed\", with a free-text `response`\nin which the operator lists **only the items to de-arm** (e.g. \"drop\nmaven, gradle\"). A de-arm entry is validated against that surface's\nsupported set (below); an unrecognized entry is reported and re-prompted,\nnever silently applied. Surfaces that fit the cap (drift-gate has exactly\nfour PMs) list each supported value as a preselected checkbox directly.\n\n### The four tabs (all default to the full armed set)\n\n- **Drift-gate tab** (armed set → Step 5c gate is armed with these PMs).\n  Options are the four supported package managers — `npm`, `pip`,\n  `pnpm`, `yarn` — each **preselected (armed)**. Unchecking a PM de-arms\n  it (its runtime `detect` never proposes it and no leg ever spawns).\n  The armed set is baked into the workflow's `detect` script coverage;\n  in practice the gate script already covers all four, so a de-arm is\n  honored by the ruleset\u002Freporting layer, not by removing a job (there\n  are no per-PM jobs any more — one matrixed `gate` job covers all).\n- **Pinned-gate tab** (armed set → Step 5c-pinned). Five supported\n  ecosystems (`npm`, `pip`, `actions`, `docker`, `go`) — one over the\n  cap, so use the confirm-or-edit pattern: default \"keep all five\n  armed\", free-text de-arm listing the ecosystems to drop. `actions` is\n  the always-present floor — de-arming it is discouraged (report it) but\n  permitted.\n- **Dependabot tab** (armed set → Step 3 `updates:` blocks). The full\n  supported ecosystem set (`github-actions`, `npm`, `pip`, `docker`,\n  `gomod`, `bundler`, `cargo`, `maven`, `gradle`, `composer`,\n  `terraform`) — more than the cap, so use the confirm-or-edit pattern:\n  default \"arm every supported ecosystem\", free-text de-arm listing the\n  ecosystems to drop. `github-actions` is the floor and is not\n  de-armable.\n- **CodeQL tab** (armed set → Step 5b). The full supported CodeQL\n  language set (`javascript-typescript`, `python`, `go`, `java-kotlin`,\n  `csharp`, `c-cpp`, `ruby`, `rust`, `swift`, `actions`) — more than the\n  cap, so use the confirm-or-edit pattern: default \"arm every supported\n  language\", free-text de-arm listing the languages to drop. `actions`\n  is the floor. The armed set does **not** override the CodeQL on\u002Foff\n  decision — `--codeql` and the entitlement guard in Step 5 still decide\n  *whether* CodeQL runs; the armed set only bounds which languages the\n  runtime `detect` may propose. (De-arming every language does not turn\n  CodeQL off — the runtime matrix simply never spawns a leg, and the\n  `codeql-required` aggregator passes green.)\n\n### Validate a de-arm entry before it is applied\n\nA free-text de-arm entry names an item to **remove** from the armed set.\nValidate each against its surface's supported set so a typo does not\nsilently fail to de-arm (or, worse, get misread):\n\n- **Pinned-gate**: `npm`, `pip`, `actions`, `docker`, `go`.\n- **Dependabot**: the documented Dependabot `package-ecosystem` enum\n  (`github-actions`, `npm`, `pip`, `docker`, `gomod`, `bundler`, `cargo`,\n  `maven`, `gradle`, `composer`, `terraform`, plus any others GitHub's\n  options reference lists — treat the docs as authoritative).\n- **CodeQL**: `javascript-typescript`, `python`, `go`, `java-kotlin`,\n  `csharp`, `c-cpp`, `ruby`, `rust`, `swift`, `actions`.\n\nFor each de-arm entry: normalize an unambiguous alias to its canonical\nvalue (`golang`\u002F`gomod` → the surface's canonical form; `typescript` →\n`javascript-typescript`; `c#` → `csharp`; etc.); if it matches a\nsupported value, remove that value from the armed set; if it resolves to\nnothing, report the unrecognized entry, show the surface's supported set,\nand re-prompt. Never apply an unvalidated de-arm.\n\n### How the armed sets flow downstream\n\n| Tab | Armed set drives | Consumed in |\n| --- | --- | --- |\n| Drift-gate | which PMs the install-gate covers (runtime-matrixed) | Step 5c, Step 6c |\n| Pinned-gate | which ecosystems the pinned-gate covers (runtime-matrixed) | Step 5c-pinned, Step 6c |\n| Dependabot | which `updates:` ecosystem blocks render | Step 3 |\n| CodeQL | which languages the runtime CodeQL matrix may propose | Step 5, Step 5b, Step 6c |\n\nFrom Step 2b onward, the downstream steps arm the **armed set** (full\nsupported set minus operator de-arms), and the **runtime `detect` jobs**\n(CodeQL and the two gates) narrow that to the present set per PR. The\nscan is informational; the authored artifact is the armed set; the\nrunning check is the present subset of the armed set.\n\n## Step 3: Render and converge `dependabot.yml`\n\nTarget path: `\u003Crepo-root>\u002F.github\u002Fdependabot.yml`.\n\n**Arm the full supported ecosystem set** (Step 2's list, minus any\nStep 2b de-arms): `github-actions`, `npm`, `pip`, `docker`, `gomod`,\n`bundler`, `cargo`, `maven`, `gradle`, `composer`, `terraform`. Render\none `updates:` block per armed ecosystem **unconditionally** — do\n**not** narrow to detected ecosystems. Dependabot no-ops on an ecosystem\nwhose manifest is absent, so arming the full set adds no spurious update\nPRs; it just covers each ecosystem's first manifest the moment it lands,\nwith no skill re-run.\n\nThe generated baseline is **hardened** (issue #51): per-ecosystem\ncooldown soak, `versioning-strategy`, recursive directory coverage,\nsemver-major ignore, and per-ecosystem schedules. Several values vary\nby **ecosystem class** — npm\u002Fpip (the rich tier), github-actions (fixed\ndirectory, weekly, default-days only), and everything else (docker,\ngomod, bundler, cargo, maven, gradle, composer, terraform — recursing\ndirectory, daily, default-days only). The `ecosystem-block.yml`\ntemplate carries those variant parts as block placeholders the skill\nresolves per ecosystem. **Getting the class variant right for every\narmed ecosystem is the one real complexity** — a wrong variant (e.g.\n`versioning-strategy` on docker\u002Fgithub-actions, which Dependabot does\nnot support) makes Dependabot **reject the whole config**. Test this\nhardest.\n\n1. Read the per-ecosystem template\n   `gh-repo-setup-protection\u002Fecosystem-block.yml`. Strip its leading\n   comment block (every line up to and including the\n   `# Indentation ...` comment) — only the YAML body is rendered.\n2. For each armed ecosystem (directory `\u002F` unless the operator's stated\n   layout says otherwise — since the armed set no longer comes from a\n   directory-bearing scan, default every ecosystem's directory to the\n   repo root), substitute the placeholders below. Render the blocks in a\n   **stable, sorted order** (sort by ecosystem then directory) so the\n   output is deterministic — this is what makes the re-run a\n   byte-for-byte no-op instead of a reorder churn.\n\n   **Per-ecosystem placeholder resolution.** Resolve each placeholder\n   from the ecosystem class. The ecosystem classes are:\n   **npm\u002Fpip** (the rich tier), **github-actions** (fixed directory,\n   weekly, default-days only), and **everything else** (docker, gomod,\n   bundler, cargo, maven, gradle, composer, terraform — recursing\n   directory, daily, default-days only). Every newly-armed ecosystem\n   (bundler, cargo, maven, gradle, composer, terraform) falls in the\n   **\"everything else\"** class: `directories: **\u002F*`, daily, `cooldown:\n   default-days: 7` only, and **no** `versioning-strategy` (dropped).\n\n   The two scalar placeholders resolve as:\n\n   | Placeholder | npm \u002F pip | github-actions | other (docker, gomod, …) |\n   | --- | --- | --- | --- |\n   | `__ECOSYSTEM__` | the ecosystem value | `github-actions` | the ecosystem value |\n   | `__DEFAULT_BRANCH__` | default branch | default branch | default branch |\n   | `__SCHEDULE_INTERVAL__` | `daily` | `weekly` | `daily` |\n\n   The three multi-line block placeholders resolve per class as follows\n   (each block's first line carries no leading indent — the template's\n   4-space indent supplies it — and continuation lines carry their own\n   absolute 6-space indent):\n\n   - **`__DIRECTORY_BLOCK__`** — npm\u002Fpip and every other ecosystem\n     **except** `github-actions` use the plural `directories:` key with\n     a root-anchored globstar:\n\n     ```yaml\n     directories:\n       - \"\u003Cdir-glob>\"\n     ```\n\n     `\u003Cdir-glob>` is `**\u002F*` when the detected directory is the repo root\n     `\u002F`; for a non-root manifest directory `\u002Fsub`, anchor the globstar\n     there as `sub\u002F**\u002F*`. `github-actions` keeps the singular\n     `directory: \"\u002F\"` — it has a fixed workflow search and is not a\n     recursing path. Bare `**` under `directories` does **not** recurse\n     arbitrarily; `**\u002F*` is the verified pattern.\n   - **`__VERSIONING_STRATEGY_BLOCK__`** — on **npm\u002Fpip only**, the\n     single line `versioning-strategy: increase` (the only two\n     ecosystems that honour the key — preserves exact-pin policy;\n     emitting it elsewhere is a no-op at best and a parse risk at\n     worst). For every other ecosystem this block is **empty** — drop\n     the placeholder line (see empty-block collapse below).\n   - **`__COOLDOWN_BLOCK__`** — cooldown soak applies to **version\n     updates only** (security PRs bypass it). npm\u002Fpip get per-semver\n     tiers:\n\n     ```yaml\n     cooldown:\n       semver-major-days: 14\n       semver-minor-days: 7\n       semver-patch-days: 7\n       default-days: 7\n     ```\n\n     docker, github-actions, and every other ecosystem do **not**\n     support semver tiers (Dependabot rejects `semver-*-days` for them),\n     so they get `default-days` only:\n\n     ```yaml\n     cooldown:\n       default-days: 7\n     ```\n\n   Two more hardening patterns live in the **static body** of the\n   template (not placeholders) and therefore apply to every ecosystem\n   unconditionally: the **ignore semver-major** version-update entry and\n   the **`*-security` group**.\n\n   **Empty-block collapse.** `__DIRECTORY_BLOCK__`,\n   `__VERSIONING_STRATEGY_BLOCK__`, and `__COOLDOWN_BLOCK__` each sit\n   alone on a 4-space-indented line in the template. When a block\n   resolves to **empty** (`__VERSIONING_STRATEGY_BLOCK__` on every\n   non-npm\u002Fpip ecosystem), **drop the entire placeholder line** — do not\n   leave a whitespace-only line, which would be spurious diff noise on\n   re-run.\n\n3. Concatenate the rendered blocks.\n4. Read the outer template `gh-repo-setup-protection\u002Fdependabot.yml`,\n   strip its leading comment block, and substitute\n   `__DEPENDABOT_ECOSYSTEMS__` with the concatenated blocks (and\n   `__DEFAULT_BRANCH__` if it appears).\n\nThis produces the **desired file content**.\n\n**Explicitly out of this generated baseline (deferred to skill V3,\nissue #51).** Domain dependency groups (e.g. `fastapi-stack`,\n`aws-cdk`, `vite-toolchain`), `exclude-paths`, and `assignees` are\n**not** part of this template — they are repo-specific and cannot be\ninferred for an arbitrary repo. A future V3 of the skill will collect\nthem interactively and converge them. Do not add them to the generated\nblock here.\n\n### Converge (idempotency)\n\n- If `\u003Crepo-root>\u002F.github\u002Fdependabot.yml` does **not** exist: write it.\n- If it **exists**:\n  - Parse both the existing file and the desired content as YAML and\n    compare the normalized structures. If they are **semantically\n    equal**, do nothing and report \"dependabot.yml already converged\".\n  - If they **differ**, the convergence rule is **whole-file replace\n    with the rendered desired content**, NOT append. Appending is what\n    produces duplicate ecosystem blocks on re-run; this skill owns the\n    file's shape, so it overwrites. Before overwriting, show the user a\n    diff (existing vs. desired) and note any `updates:` entries in the\n    existing file that the skill would drop (e.g. a hand-added\n    ecosystem the detection missed, or custom `ignore:`\u002F`reviewers:`\n    blocks). **Halt and ask** before overwriting a file that contains\n    entries the render would lose — the user may want those preserved.\n    If the existing file's only differences are ones the render\n    subsumes, overwrite and report.\n\nNever write the file with unresolved `__...__` placeholders. If any\nremain after substitution, abort per the README's unresolved-\nplaceholder rule.\n\n## Step 4: GHAS \u002F repo security settings (convergent toggles)\n\nSkip this entire step if `--ghas=off`.\n\nThese are **remote settings**, applied via the GitHub API. Each one is\nread first and only written when it differs from the desired state, so\nre-running is a no-op. None of these toggles costs money for **public**\nrepos; for **private** repos, secret scanning \u002F push protection and\nCodeQL require a GitHub Advanced Security entitlement — detect the lack\nof entitlement and skip gracefully rather than erroring.\n\n### 4a. Dependabot alerts + security updates\n\n```bash\n# Read current state.\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fvulnerability-alerts \\\n  --silent && echo \"alerts: enabled\" || echo \"alerts: disabled\"\n```\n\nEnable (idempotent — PUT is safe to repeat):\n\n```bash\ngh api --method PUT repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fvulnerability-alerts\ngh api --method PUT repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fautomated-security-fixes\n```\n\n`vulnerability-alerts` returns 204 whether or not it was already on;\ntreat any 2xx as success and report \"Dependabot alerts: enabled\".\n\nDependabot **malware alerts** are a separate, *settings-level* toggle —\nthey are NOT a `dependabot.yml` key (that file controls version updates\nand alert *rules*, not malware-alert *enablement*). Malware alerts\nrequire Dependabot alerts to be on (enabled just above) and are\n**npm-only today**. There is no documented public per-repo REST\nendpoint for this toggle as of this writing (it is managed from the\nrepo's *Code security* settings UI). There is therefore **no enable\nPATCH to make** — the `security_and_analysis[dependabot_security_updates]`\nfield is the Dependabot *security-updates* feature (already enabled by\nthe `automated-security-fixes` PUT above), **not** malware alerts, so\npoking it would be a misdirected no-op against an already-on, unrelated\nsetting. The skill instead reads-to-report and surfaces the one manual\nstep:\n\nRead the repo's `security_and_analysis` block to *report* the malware-\nalert state if it is exposed; otherwise report\n\"Dependabot malware alerts: enable in the repo's Code security settings\n(npm-only; no public REST toggle)\" so the operator finishes the one\nmanual step. Never hard-fail on the absence of the endpoint. See\n\u003Chttps:\u002F\u002Fdocs.github.com\u002Fen\u002Fcode-security\u002Fhow-tos\u002Fsecure-your-supply-chain\u002Fsecure-your-dependencies\u002Fconfigure-malware-alerts>.\n\n**Grouped security updates** (batching security PRs per ecosystem into\none PR) are driven two ways, and the skill owns the deterministic one:\n\n- The per-repo\u002Forg *Code security* settings toggle (UI; no stable\n  public REST toggle) controls grouping for ecosystems **not**\n  configured in `dependabot.yml`.\n- The `dependabot.yml` `groups:` key with `applies-to: security-updates`\n  controls grouping for the configured ecosystems — this is the\n  in-file, deterministic mechanism the skill renders (Step 3). Because\n  the rendered `dependabot.yml` already carries a per-ecosystem\n  `security-updates` group, security PRs for every configured ecosystem\n  are grouped regardless of the settings toggle. Report\n  \"Grouped security updates: configured via dependabot.yml\n  (applies-to: security-updates)\".\n\n### 4b. Per-repo Code Security (GHAS) enablement (entitlement-gated)\n\nWhen the org\u002Frepo is **GHAS-entitled**, enable per-repo Code Security\n(Advanced Security). This is the lever that makes secret scanning,\npush protection, and CodeQL available on a *private* repo. The skill\nmust *enable* it when entitlement is present — not merely detect its\n*absence* to skip CodeQL.\n\nRead the current state, then enable iff entitled and not already on.\nRead the **granular `code_security`** field, not the deprecated\n`advanced_security` toggle: GitHub split the single Advanced Security\ntoggle into granular fields (`code_security`, `secret_scanning`, …),\nand on a fully-entitled repo the legacy `advanced_security` field reads\n`absent` while `code_security.status` reads `enabled`. Reading the\nlegacy field therefore mis-detects an entitled repo as unentitled.\nTreat the repo as **entitled** when `code_security.status == \"enabled\"`:\n\n```bash\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  --jq '.security_and_analysis.code_security.status \u002F\u002F \"absent\"'\n```\n\n```bash\n# Only attempt on a private repo (public repos get these features free\n# and have no code_security toggle). A 422 \"Advanced Security is\n# not enabled for this account\u002Forg\" means the org is not entitled —\n# report and skip, do not hard-fail.\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -f 'security_and_analysis[code_security][status]=enabled' \\\n  2>\u002Fdev\u002Fnull \\\n  && echo \"Code Security: enabled\" \\\n  || echo \"Code Security: skipped (org not GHAS-entitled)\"\n```\n\nReport `enabled (was already on)`, `enabled (changed)`, or\n`skipped (org not GHAS-entitled)`. Enabling this is what makes the\nsecret-scanning\u002Fpush-protection PATCH below succeed on a private repo.\n\n### 4c. Secret scanning + push protection (entitlement-gated)\n\nRead the current security-and-analysis block:\n\n```bash\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  --jq '.security_and_analysis'\n```\n\nBuild the desired patch and only PATCH the fields that differ. **Always\nre-assert these on every run** — an org-level Code Security change can\nflip `secret_scanning_push_protection` back to disabled, so a converge\nrun must set it back on even if a prior run already enabled it:\n\n```bash\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -f 'security_and_analysis[secret_scanning][status]=enabled' \\\n  -f 'security_and_analysis[secret_scanning_push_protection][status]=enabled'\n```\n\nIf this PATCH returns 422 \u002F \"Advanced Security is not enabled for this\nrepository\" (the common case on an unentitled private repo), do\n**not** treat it as a hard failure: report\n\"secret scanning unavailable (no GHAS entitlement on this private\nrepo); skipping\" and continue. Public repos get secret scanning for\nfree, so the PATCH succeeds there.\n\nAlways report, for each toggle, one of: `enabled (was already on)`,\n`enabled (changed)`, or `skipped (\u003Creason>)`. That report is the\nevidence the run converged.\n\n### 4d. Lock down push-protection bypass\n\nPush protection's default bypass list is **\"Anyone with write access\"**.\nThe hardened state is **nobody** — restrict bypass to a specific\nrole\u002Fteam set whose membership is empty, so a blocked secret push must\ngo through a bypass *request* rather than a self-serve override.\n\nThis is GitHub's *delegated bypass* for push protection. As of this\nwriting it is configured through an **org-level security configuration**\n(`secret_scanning_delegated_bypass_options` on the security-configuration\nAPI, then attached to the repo) and a repo-level\n`secret_scanning_delegated_bypass` enablement — there is **no clean,\nstable per-repo public REST toggle** that sets the bypass list to\n\"nobody\" directly. The skill therefore:\n\n```bash\n# Best-effort: enable delegated bypass at the repo level so bypass\n# becomes request-gated rather than self-serve. The reviewer\u002Frole list\n# (the \"who may bypass\" set) is configured in the org security\n# configuration; the skill cannot set an empty reviewer list through a\n# stable public per-repo endpoint, so it enables delegated bypass and\n# reports the residual manual step.\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -f 'security_and_analysis[secret_scanning_delegated_bypass][status]=enabled' \\\n  2>\u002Fdev\u002Fnull || true\n```\n\nReport the outcome honestly: if the enablement succeeded, report\n\"Push-protection bypass: delegated bypass enabled (set the bypass\nreviewer list to an empty role\u002Fteam in the org security configuration\nto reach 'nobody')\". If the endpoint is unavailable (422\u002F404), report\n\"Push-protection bypass: configure 'who can bypass' = nobody in the\nrepo's Code security settings (no stable public REST toggle)\". Never\nhard-fail — surface the residual manual step instead of inventing an\nendpoint that may not exist.\n\n### 4e. Merge-button \u002F PR-hygiene repo settings (convergent toggles)\n\nThe repo's General-settings merge button stays at GitHub defaults\nunless something converges it. The `protect-main` ruleset's\n`allowed_merge_methods: [\"merge\"]` (Step 6) constrains only the\n*ruleset's* merge enforcement — it does **not** flip the repo-level\n`allow_squash_merge` \u002F `allow_rebase_merge` toggles, so the merge\nbutton still offers squash and rebase. This step converges the five\nmerge-button \u002F PR-hygiene fields directly, the same read-then-PATCH,\nre-asserted-every-run, idempotent way the GHAS toggles do. These are\n**remote settings**, not file edits, so they apply directly (not via\nthe Step 7 PR). This step runs under `--ghas` (skip it when\n`--ghas=off`, like the other remote toggles).\n\nDesired hardened state:\n\n| UI setting | REST field | Desired |\n| --- | --- | --- |\n| Allow squash merging | `allow_squash_merge` | `false` |\n| Allow rebase merging | `allow_rebase_merge` | `false` |\n| Suggest updating PR branches | `allow_update_branch` | `true` |\n| Allow auto-merge | `allow_auto_merge` | `true` |\n| Auto-delete head branches | `delete_branch_on_merge` | `true` |\n\n`allow_merge_commit` is left `true` (consistent with the ruleset's\n`allowed_merge_methods: [\"merge\"]`) — do not flip it off, or the repo\nwould have no enabled merge method.\n\nRead the current values first, then PATCH only when they differ so a\nconverged re-run is a no-op:\n\n```bash\n# Read current state.\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  --jq '{allow_squash_merge, allow_rebase_merge, allow_update_branch,\n         allow_auto_merge, delete_branch_on_merge}'\n```\n\n```bash\n# Re-assert the desired state (idempotent — PATCH with the same values\n# is a no-op server-side; only PATCH the fields that differ, or PATCH\n# all five — both converge).\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -F allow_squash_merge=false \\\n  -F allow_rebase_merge=false \\\n  -F allow_update_branch=true \\\n  -F allow_auto_merge=true \\\n  -F delete_branch_on_merge=true\n```\n\nAll five are documented public REST fields on the repository object.\nReport each as `unchanged` (already at desired) or `changed` (was at a\ndifferent value). This step is convergent and never hard-fails; a\nprivate repo with no special entitlement still accepts these\nGeneral-settings PATCHes (they are not GHAS-gated).\n\n## Step 5: CodeQL — opt-in, never auto-forced\n\n### CodeQL is opt-in\n\nCodeQL must not be assumed for every repo. The hazard is concrete and\nhas happened twice on `global-claude-config`:\n\n- **Issue #91**: a CodeQL workflow on a repo with no analyzable language\n  produced a phantom required check that hung PRs on \"Waiting for Code\n  scanning results\" forever.\n- **Issue #230 (PR #226 → #227)**: CodeQL **default setup** was enabled\n  server-side with a pinned language list `[actions, python]`. The repo\n  has zero Python, so `CodeQL \u002F Analyze (python)` failed on every PR and\n  blocked merges. Default and advanced setup cannot coexist; the fix\n  (PR #227) was an Actions-only advanced `codeql.yml` plus disabling\n  default setup out-of-band.\n\nThe rationale, inlined here so it does not depend on any other rule\nfile: a CodeQL check becomes a **phantom failing\u002Fhung required check**\nwhenever the workflow's analysis cannot succeed — either because no\nanalyzable language is present, or because a server-side default-setup\nlanguage list does not match the repo. Such a check blocks every PR.\nTherefore CodeQL is opt-in, the skill reads the existing server-side\nsetup mode before writing (Step 5a below), and it never enables CodeQL\nfor a language the repo cannot analyze.\n\n\"Opt-in\" means: **auto-detection never turns CodeQL on for an\nunentitled-private repo.** It does *not* mean the skill refuses an\nexplicit operator request. `--codeql=on` is an operator override — the\noperator has decided CodeQL belongs on this repo, and the skill honors\nthat by installing the workflow. The distinction matters: the danger\nthe policy guards against is CodeQL silently *auto*-resolving on\n(recreating issue #91), not an operator deliberately enabling it.\n(Before Step 2 made `actions` the always-present floor, a markdown-only\nrepo was also an auto-skip case; it no longer is, because every repo\nthe skill touches gets workflows and therefore the `actions` analyzable\nlanguage. The one auto-skip left is the unentitled-private repo.) So:\n\nResolve whether CodeQL is wanted, in this order:\n\n1. `--codeql=on` → CodeQL on. `--codeql=off` → CodeQL off (skip Step 5\n   entirely; if a `codeql.yml` workflow already exists, report it and\n   do **not** delete it — removing a security workflow is a decision\n   for the user).\n2. `--codeql=auto` (default) → **auto-detect**:\n   - **Off** if the repo is **private AND not GHAS-entitled**. CodeQL\n     on an unentitled private repo recreates the issue #91\n     phantom-check problem. **Determine entitlement independently of\n     Step 4 — do not rely on Step 4 having run.** Step 4 is skipped\n     entirely under `--ghas=off`, so the auto-detect must read the\n     entitlement signal itself with a read-only call that is safe to\n     make regardless of `--ghas`:\n\n     ```bash\n     # isPrivate captured in Step 1. Read the granular code_security\n     # field, not the deprecated advanced_security toggle — the legacy\n     # field reads \"absent\" on a fully-entitled repo and would mis-detect\n     # entitlement (see Step 4b).\n     gh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n       --jq '.security_and_analysis.code_security.status \u002F\u002F \"absent\"'\n     ```\n\n     Treat the repo as **not entitled** when `isPrivate` is `true` AND\n     that status is `disabled` or `absent`. Equivalently, the repo is\n     **entitled** when `code_security.status == \"enabled\"`. When\n     `--ghas=on` and Step 4b already ran, its no-entitlement 422 is an\n     equivalent signal and may be reused; but the read above is the\n     source of truth so the determination is identical whether or not\n     Step 4 ran. This closes the `--ghas=off` bypass: on a private,\n     unentitled repo with workflow files (this repo's shape — `actions`\n     is an analyzable language), `--ghas=off` must still resolve CodeQL\n     **off**, never let it auto-resolve **on**.\n   - The old \"no analyzable language → off\" auto-skip is **gone.** The\n     CodeQL workflow is armed with the **full supported language set**\n     and narrows to the present languages at **runtime** via its\n     `detect` job (Step 5b). `actions` is an always-present floor (the\n     skill installs workflows), so at least one leg always runs on an\n     entitled-or-public repo, and the `codeql-required` aggregator\n     passes green even when the runtime matrix is empty. There is\n     therefore no install-time language check to fail — the only\n     off-branch left in `auto` is the **private + unentitled** case\n     above. A repo mid-transition (e.g. Python today, TypeScript\n     tomorrow) gets its new-language leg the moment the first `.ts` file\n     lands, with **no skill re-run** — the exact ordering inversion this\n     issue fixes.\n   - **On** otherwise (public repo, or entitled private repo).\n3. Do not ask — a public (or entitled private) repo resolves CodeQL\n   **on**. The runtime matrix (armed full set, narrowed to present) is\n   never a deadlock: an absent language produces no leg, and the\n   aggregator is green on an empty matrix. (The only off-resolutions\n   left are the private-unentitled and the explicit `--codeql=off`\n   cases.)\n\n**No install-time empty-matrix hazard (why the old hard stop is gone).**\nThe old \"no-supported-language hard stop\" existed because the former\nstatic CodeQL language-list matrix could be authored **empty**, producing\na check that can never pass and deadlocks branch protection (issue #230's\nfailure mode). That hazard **no longer exists**: the workflow is armed\nwith the full supported set and the analyze matrix is built at runtime\nfrom `codeql-language-present.sh --matrix`. An empty runtime matrix (no\nanalyzable language present) spawns **zero** analyze legs and the\n`codeql-required` aggregator concludes **success** (`if: always()` +\nempty-matrix pass), so the PR is mergeable, never hung. `--codeql=on`\noverrides the *entitlement* auto-skip and installs the armed workflow;\nthere is no separate language check for it to override, because the\nruntime matrix cannot deadlock.\n\n**Always report the CodeQL decision and the reason**, e.g.\n\"CodeQL: off (auto — private repo without GHAS entitlement)\" or\n\"CodeQL: on (armed with the full supported language set; runtime matrix\nnarrows to present languages per PR)\".\n\n### 5a. Read the server-side CodeQL setup mode before writing\n\nThis is the fix for the issue #230 wedge. **Before installing advanced\nsetup, read GitHub's server-side CodeQL setup mode** — the skill must\nnot write a `codeql.yml` blind to a default setup already running with a\ndifferent (possibly wrong) language list. Default setup and advanced\nsetup (a `codeql.yml` workflow) **cannot coexist**; default setup runs\nits own language list independently of any workflow file, which is\nexactly how `Analyze (python)` failed on a repo with zero Python.\n\nRead the current mode (read-only, safe regardless of `--ghas`). Only a\nclean `403` (unentitled) or `404` (code-scanning disabled \u002F no default\nsetup) means \"not configured\" — **every other non-zero exit\n(`5xx`, rate limit, auth expiry, network\u002Ftransport failure) is a hard\nstop**, because silently treating a transient failure as\n\"not-configured\" would skip the disable-default-setup step and\nre-trigger the exact wedge issue #230 fixes. Capture the HTTP status\nand branch on it:\n\n```bash\n# jq parses the response body below. If it is missing, the body parse\n# would silently yield an empty $setup and fall through to the decision\n# table with a state that is neither configured nor not-configured —\n# the exact issue #230 wedge, triggered by a missing binary. Hard-stop\n# up front instead, in the same style as the default (*) branch below.\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || {\n  echo \"ERROR: jq is required to read the CodeQL default-setup mode\" \\\n       \"for __GH_ORG__\u002F__GH_REPO__ but is not installed \u002F not on PATH.\" \\\n       \"jq is a hard dependency of the global config (its hooks need\" \\\n       \"it too). Install jq and re-run this skill rather than letting\" \\\n       \"the skill proceed blind to an empty CodeQL state (issue #230).\" >&2\n  exit 1\n}\n\n# Make a SINGLE request: -i emits the response headers AND the JSON\n# body in one response, so we parse both the HTTP status line and the\n# body from the same fetch — no second call, no transient-failure\n# window between two reads. Without letting a non-zero exit abort the\n# script; 2>\u002Fdev\u002Fnull suppresses gh's stderr so a transport failure\n# leaves the response empty (status parses to empty → default case).\nresponse=$(\n  gh api -i repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fcode-scanning\u002Fdefault-setup \\\n    2>\u002Fdev\u002Fnull\n)\nhttp_status=$(\n  printf '%s\\n' \"$response\" \\\n    | sed -n '1s\u002F^HTTP\\\u002F[0-9.]* \\([0-9]*\\).*\u002F\\1\u002Fp'\n)\n\ncase \"$http_status\" in\n  200)\n    # Extract the body (everything after the first blank line that\n    # separates headers from body) and pull state\u002Flanguages from it.\n    # No second network call — the body came back with the status above.\n    setup=$(\n      printf '%s\\n' \"$response\" \\\n        | sed -n '1,\u002F^[[:space:]]*$\u002Fd;p' \\\n        | jq '{state: .state, languages: .languages}'\n    )\n    ;;\n  403|404)\n    # Unentitled, or code-scanning disabled \u002F no default setup.\n    setup='{\"state\":\"not-configured\",\"languages\":null}'\n    ;;\n  *)\n    # Empty status = curl\u002Ftransport failure; any other status (5xx,\n    # 429 rate limit, 401 auth expiry, etc.) = a non-clean failure.\n    # Do NOT assume \"not-configured\" — halt and tell the operator.\n    echo \"ERROR: could not read CodeQL default-setup mode for\" \\\n         \"__GH_ORG__\u002F__GH_REPO__ (HTTP status: ${http_status:-none —\" \\\n         \"transport\u002Fnetwork failure}). This is not a clean 403\u002F404,\" \\\n         \"so the skill will NOT assume CodeQL is unconfigured —\" \\\n         \"doing so could skip disabling a live default setup and\" \\\n         \"re-wedge branch protection (issue #230). Re-run this skill\" \\\n         \"once the GitHub API is reachable.\" >&2\n    exit 1\n    ;;\nesac\n\necho \"$setup\"\n```\n\n(`state` is `configured` or `not-configured`. Only a clean `403`\n(unentitled) or `404` (code-scanning disabled \u002F no default setup) is\nmapped to `not-configured`; **any other non-zero exit — `5xx`, `429`\nrate limit, `401` auth expiry, or a curl\u002Ftransport failure — is a hard\nstop, not a silent \"not-configured\".** A transient failure misread as\n\"not-configured\" would skip the disable step below and re-create the\nissue #230 wedge, so the skill aborts and asks the operator to re-run\nonce the API is reachable rather than proceeding blind.)\n\n**The core invariant: default setup and an advanced `codeql.yml`\ncannot coexist.** A repo with a working advanced workflow MUST have\ndefault setup `not-configured` — that is the correct, intended end\nstate, not an incidental \"nothing to disable.\" The advanced workflow\nbeing committed is precisely what forces default setup to stay off\n(the leading comment in `gh-repo-setup-protection\u002Fcodeql.yml` says\nthis); the report wording below matches that framing. `configured`\ndefault setup alongside an advanced workflow is the issue #230 wedge,\nto be disabled with operator confirmation.\n\nDecision table once CodeQL has resolved **on** (Step 5) and you are\nabout to install advanced setup:\n\n- **default setup `not-configured`** → this is the **correct\n  mutually-exclusive state**: advanced setup active, default setup\n  correctly off, because the two cannot coexist. Nothing to disable;\n  proceed to render the workflow (5b). Report \"default setup: correctly\n  not configured (advanced setup active — the two cannot coexist)\".\n- **default setup `configured`** → it conflicts with the advanced\n  workflow (the issue #230 wedge). **Show the operator the detected\n  `state` and `languages`, and ask for confirmation** before disabling\n  it. On confirmation, disable it out-of-band, then proceed to render:\n\n  ```bash\n  gh api --method PATCH \\\n    repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fcode-scanning\u002Fdefault-setup \\\n    -f state=not-configured\n  ```\n\n  If the operator declines, do **not** install the advanced workflow\n  (the two cannot coexist); report \"CodeQL: left as server-side default\n  setup at operator's request; advanced workflow not installed\" and\n  skip the render. Never install advanced setup alongside a live default\n  setup.\n\nReport what was found and what changed, e.g. \"default setup: was\nconfigured (languages: actions, python) → disabled (operator confirmed);\ninstalling advanced setup\".\n\nWhen CodeQL has resolved **off**, do not PATCH default setup off on the\nskill's own initiative — disabling an existing server-side scan is a\nsecurity-posture change the operator owns. Report the detected default\nsetup state so the operator can act if they want to.\n\n### 5a-bis. Preserve a newer SHA-pinned action pin (never downgrade)\n\nThe workflow converges (Steps 5b, 5c, 5c-pinned, 5d) take the\n**payload** content\nas the base, but they must **never downgrade an action pin the repo\nalready has pinned to a newer release**. Doing so would silently roll\nback a deliberate operator upgrade — a regression. This sub-step\ndefines the pin-reconciliation pass each of those converges applies to\nthe desired content **before** the semantic-compare, generically to\n**every** `uses:` line (checkout, codeql-action, setup-node,\nsetup-python, and any future action).\n\n**Convergence never even offers to bump a pin down.** There is no\nprompt. For each `uses: \u003Cowner>\u002F\u003Crepo>[\u002F\u003Cpath>]@\u003Cref>` line in the\nrendered desired content, find the corresponding line in the existing\nrepo file (matched by `\u003Cowner>\u002F\u003Crepo>[\u002F\u003Cpath>]`, the action coordinate\nwithout the `@\u003Cref>`). If the repo's pin is **strictly newer and\nSHA-pinned**, keep the repo's pin (its SHA **and** its trailing\n`# vX.Y.Z` comment) in the desired content; otherwise take the\npayload's pin. Concretely, for each matched action coordinate:\n\n- Repo's resolved tag **strictly newer AND the repo's ref is a 40-hex\n  SHA** → keep the repo's `uses:` line verbatim in the desired content.\n- Repo's pin **older, equal, or floating** (the ref is a tag like `@v6`\n  or a branch, not a 40-hex SHA) → take the payload's pin.\n- An action coordinate that appears only in the payload (no matching\n  `uses:` in the repo file) → take the payload's pin (nothing to\n  preserve).\n\n**\"Newer\" is derived from the SHA, not the trailing comment.** The\ntrailing `# vX.Y.Z` comment is operator-written and may lie, so it is\n**display-only** and never used for the comparison. To compare two\nSHA-pinned refs, resolve **both** the repo's SHA and the payload's SHA\nagainst the action's upstream repo and compare the resolved release\ntags by semver:\n\n```bash\n# Resolve a commit SHA to the release tag that points at it.\n# --paginate: the tags list spans multiple pages on actions with many\n# releases; without it a matching tag on page 2+ is missed and the SHA\n# is wrongly treated as unresolvable (downgrading a genuinely-newer pin).\ngh api --paginate repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Ftags --jq \\\n  \".[] | select(.commit.sha == \\\"\u003Csha>\\\") | .name\"\n```\n\nWhen a tag does not point directly at the commit (e.g. the SHA is a\ntagged commit reached via `git rev-parse \u003Ctag>^{commit}`), fall back to\nmatching the SHA against each candidate tag's dereferenced commit via\n`gh api --paginate repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fgit\u002Frefs\u002Ftags` (again\n`--paginate`, so a tag ref on a later page isn't missed). Compare the\ntwo resolved tags with semver (`vMAJOR.MINOR.PATCH`).\n\n**Unresolvable → take the payload's pin.** If **either** SHA cannot be\nresolved to an upstream tag — a deleted tag, a fork, a private action,\nor an API \u002F network failure — do **not** guess and do **not** keep the\nrepo's pin. Take the **payload's** pin (the skill's owned, known-good\nvalue). Resolution failure is never treated as \"repo is newer\".\n\nAfter this pass, the desired content differs from the raw payload only\nwhere a repo pin was kept for being strictly-newer-and-SHA-pinned. The\nsubsequent semantic-compare (Steps 5b\u002F5c\u002F5c-pinned\u002F5d) then runs against this\n**pin-reconciled** desired content: if the only remaining difference\nbetween the existing file and the payload was those kept newer pins,\nthe file compares **equal** and is reported \"unchanged\" — no\ndowngrade, no halt. \"Match the payload\" thus explicitly **excludes**\ndowngrading a deliberately-newer SHA-pinned repo pin.\n\n### 5b. Render and converge the CodeQL workflow (only when CodeQL is on)\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fcodeql.yml`\n- `\u003Crepo-root>\u002F.github\u002Fcodeql\u002Fcodeql-config.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fcodeql-language-present.sh`\n\n**There is no install-time CodeQL language-list placeholder any more.**\nThe workflow is armed with the **full supported CodeQL language set** and\nnarrows to the present languages at **runtime**: its `detect` job runs\n`codeql-language-present.sh --matrix`, which emits a JSON array of\n`{ language, runner }` matrix entries for exactly the languages present\nin the tracked tree, and the `analyze` job builds its matrix from that\narray via `fromJSON`. So the language set is decided per PR at runtime,\nnever frozen at install time.\n\n1. Render `gh-repo-setup-protection\u002Fcodeql.yml` (strip its leading\n   comment block) substituting **only** `__DEFAULT_BRANCH__`. The\n   template has no language placeholder.\n2. `codeql-config.yml` has no placeholders — keep its `name:`\u002F`queries:`\n   body; it has no leading placeholder-doc comment block to strip, so it\n   ships as-is.\n3. `codeql-language-present.sh` has no placeholders — ship it\n   **verbatim** (including its leading comment block; it is a shell\n   script whose header documents its own behavior), with the executable\n   bit set (`chmod +x`). It is the SAME `git ls-files` predicate the\n   analyze matrix is built from, so \"what detect thinks is present\"\n   cannot drift from what the analyze legs run. The `swift` entry it\n   emits carries `runner: macos-latest`; every other language carries\n   `runner: ubuntu-latest`, so a Swift-less repo never provisions macOS.\n\nFirst apply the **pin-reconciliation pass (Step 5a-bis)** to the\nrendered `codeql.yml` — keep any `uses:` pin the repo already has\npinned to a strictly-newer SHA, never downgrade. Then converge each\ntarget as in Step 3 against that pin-reconciled content: if the target\nfile is absent, write it; if present and **semantically equal**, do\nnothing; if present and different, show the diff and halt before\noverwriting. Whole-file replace, never append. The `.sh` uses a\nnormalized-text\u002Fbyte compare (it is a shell script, not YAML), like the\ngate scripts.\n\n## Step 5c: Render and converge the dependency-install-gate (drift guard)\n\nA drifted `package.json`\u002Flockfile (or an unresolvable requirements pin)\ncan desync from its manifest via a Dependabot PR or a hand edit; without\na PR-time gate the desync auto-merges into the default branch and breaks\nlocal dev and downstream pipelines. This step installs a\n**dependency-install-gate** — a `pull_request` workflow armed with the\n**full supported set** of package managers (`npm`, `pip`, `pnpm`,\n`yarn`) that replays the lockfile \u002F runs a resolver pre-flight over\nevery discovered manifest and fails the PR on drift. The artifact is\nported from the proven `ExampleProject\u002Fexample-app-repo` gate.\n\n**Runtime dynamic-matrix, not install-time-narrowed jobs.** The workflow\nhas three jobs: a `detect` job that runs\n`dependency-install-gate.sh --present` (the SAME `git ls-files`\ndiscovery the gate checks with) and emits a JSON array of the PMs whose\nmanifest is present right now; a matrixed `gate` job over\n`fromJSON(needs.detect.outputs.pms)`, so a leg exists for a PM **iff**\nits lockfile\u002Fmanifest is in the tree at that moment; and an\n`install-gate-required` aggregator. A PM whose manifest lands **after**\nsetup lights its leg up on the next PR, with **no skill re-run** — the\nordering-inversion fix.\n\n**Why per-PM legs, not one Node job.** Each Node package manager keys\noff its **own** lockfile (npm → `package-lock.json`, pnpm →\n`pnpm-lock.yaml`, yarn → `yarn.lock`). A single npm-only job discovers\nnothing on a pnpm\u002Fyarn repo, hits its no-manifests-green branch, and\nexits 0 — a **dead check that gives false assurance** while the very\n`package.json`↔lockfile desync it exists to catch merges anyway\n(issue #111). One matrix leg per manager, each keyed off its own\nlockfile, closes that gap.\n\n### The aggregator is the required check (not the per-PM legs)\n\nGitHub `required_status_checks` is a static list of names and cannot\nexpress \"require the `npm` leg only if it runs\". So the per-PM legs\n(`Install gate (\u003Cpm>)`) are **visible** but **not** individually\nrequired; the always-running `install-gate-required` aggregator (stable\nname) is the single required check. It `needs:` the matrixed `gate` job,\nruns `if: always()`, and concludes:\n\n- **success** when the matrix was empty (no PM present) — so a\n  manifest-less repo is **mergeable, not hung**;\n- **success** when every spawned leg succeeded;\n- **failure** when any leg failed or was cancelled.\n\nThe `if: always()` is **mandatory**: without it the aggregator is\n*skipped* on an empty matrix, and a required check treats \"skipped\" as\nnot-passed → the #91\u002F#230 phantom-check hang returns. Step 6c registers\n`install-gate-required`, never a per-leg name.\n\n### Render the gate files\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fdependency-install-gate.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fdependency-install-gate.sh`\n\n1. Render `gh-repo-setup-protection\u002Fdependency-install-gate.yml` (strip\n   its leading comment block) substituting **only** `__DEFAULT_BRANCH__`.\n   The actions are SHA-pinned in the template (with the human-readable\n   tag in a trailing comment), matching the `codeql.yml` convention — do\n   not de-pin them. There is **no** per-job delimiter-comment rendering\n   any more: the workflow ships with the full detect → matrix →\n   aggregator shape, armed with all four PMs, and narrows at runtime.\n2. `dependency-install-gate.sh` has no placeholders — ship it\n   **verbatim** (including its leading comment block; it is a shell\n   script whose header documents its own behavior). The script accepts\n   all four modes (`npm`, `pip`, `pnpm`, `yarn`), the `--present` mode\n   the detect job calls, and no-ops gracefully (exit 0) for any mode\n   whose lockfile the repo lacks. The `--present` mode reuses the same\n   discovery predicate, so the runtime matrix cannot drift from what the\n   gate checks. Ship it with the executable bit set (`chmod +x`).\n\nThe gate ships **unconditionally** whenever the skill installs\nworkflows — there is no \"empty resolved set → skip the file\" case any\nmore, because the workflow is armed with the full set and gates at\nruntime (an absent PM produces no leg and a green aggregator, so it is\nnever dead weight or noise). Both files are always written together\n(the workflow calls the script).\n\nNever write the `.yml` with an unresolved `__DEFAULT_BRANCH__`. If it\nremains after rendering, abort per the README's unresolved-placeholder\nrule.\n\n### Converge the gate files (idempotency)\n\nApply the same **whole-file-replace + semantic-compare** rule the skill\nuses for `dependabot.yml`\u002F`codeql.yml`, with one difference in the\ncompare method per file type. For the `.yml`, first apply the\n**pin-reconciliation pass (Step 5a-bis)** to the rendered desired\ncontent so a repo's strictly-newer SHA-pinned action (e.g. a\n`actions\u002Fcheckout` the operator already bumped past the payload's) is\n**kept, never downgraded**, before the semantic-compare:\n\n- **`dependency-install-gate.yml`** — YAML semantic-compare (parse both\n  the existing file and the pin-reconciled desired content as YAML,\n  compare normalized structures). Equal → \"unchanged\"; absent → write;\n  different → show the diff and halt before overwriting (whole-file\n  replace, never append). Because the workflow is now a fixed\n  full-set-armed shape (no per-job rendering), the compare is against\n  the same content every run — a converged repo re-runs as a no-op.\n- **`dependency-install-gate.sh`** — this is a shell script, **not**\n  YAML, so the semantic-compare is a **normalized-text\u002Fbyte compare**\n  (trailing-whitespace-normalized), not a YAML parse. Equal →\n  \"unchanged\"; absent → write (with the executable bit set, `chmod +x`);\n  different → show the diff and halt before overwriting.\n\nBoth files are written together: install both. Never install one without\nthe other (the workflow calls the script).\n\n## Step 5c-pinned: Render and converge the dependency-pinned-gate\n\n(The exact-version guard — sibling of the install-gate.)\n\nThe dependency-install-gate (Step 5c) protects the **lock** relationship\n— it fails a PR when a manifest and its lockfile have drifted. It does\n**not** check how the *manifest itself* declares versions. A\n`package.json` with `\"aws-cdk-lib\": \"^2.172.0\"`, a `requirements.txt`\nwith `boto3>=1.40`, a workflow `uses: actions\u002Fcheckout@v4`, or a\n`FROM node:22` resolves to a **different** concrete version over time\neven when the lockfile is perfectly in sync — the \"works on main, breaks\non rebase\" supply-chain drift that slips past a green install-gate. This\nstep installs the **dependency-pinned-gate** — the sibling of the\ninstall-gate — a `pull_request` workflow armed with the **full supported\nset** of ecosystems (`npm`, `pip`, `actions`, `docker`, `go`) whose\nper-ecosystem legs fail the PR when any *declared* dependency is not\npinned to an exact version (rejecting caret `^`, tilde `~`, comparators\n`>= \u003C= > \u003C`, hyphen\u002FX-ranges, OR-ranges, compatible-release `~=`,\nfloating action `@vN`\u002F`@main` tags, floating Docker `:latest`\u002Ftag-only\nrefs, and bare\u002Funpinned names).\n\n**Runtime dynamic-matrix, same shape as the install-gate.** A `detect`\njob runs `dependency-pinned-gate.sh --present` (the SAME `git ls-files`\ndiscovery the gate checks with) and emits a JSON array of the ecosystems\nwhose manifest is present; a matrixed `gate` job over\n`fromJSON(needs.detect.outputs.ecosystems)` runs one leg per present\necosystem; and a `pinned-gate-required` aggregator is the single\nrequired check. `actions` is an always-present floor (the skill always\ninstalls workflow files). An ecosystem whose manifest lands **after**\nsetup (e.g. the repo's first `go.mod`) lights its leg up on the next PR,\nwith **no skill re-run**.\n\n**It is a separate gate from the install-gate** — its own workflow +\nscript, and its own aggregator (`pinned-gate-required`) is a separate\nrequired check from the install-gate's. Do not fold it into Step 5c; the\ntwo protect different properties (lock-drift vs. declared-version-\nfloating) and a repo may want one without the other.\n\n**Categorical exemptions live in the classifier, not an allowlist\nfile.** A small, fixed set of specs is *legitimately* not exact-pinnable\nand is exempt by category in the script (`dependency-pinned-gate.sh`),\nnever by a maintained per-package allowlist: npm `peerDependencies`\ncarets (ranges by design); `file:`\u002F`workspace:`\u002F`link:`\u002F`git+`\u002F`http(s):`\nprotocol specs (no registry version to pin); pnpm `catalog:`\u002F\n`catalog:\u003Cname>` specs (a REFERENCE into `pnpm-workspace.yaml`'s\n`catalog:`\u002F`catalogs:` sections, never a version itself — see \"Catalog\ndefinitions are validated at the source\" below); npm `engines` and pip\n`requires-python`\u002F`python_requires` (runtime\u002Ftoolchain floors, not\ndependency versions); npm `overrides`\u002F`resolutions` classified on the\noverride **value** (exact), never the selector **key** (whose caret is a\nmatch pattern); and Docker `tag@sha256:` digests (the tag floats but the\nimmutable digest is read, so the resolved image is exact). These were\nsettled empirically against the strict-pinned\n`Fablegate\u002Ffablegate_quasar_fastapi` monorepo (issue #90) — every\nnon-exact spec found there fell into this fixed set, so no escape-hatch\nfile is needed.\n\n**Catalog definitions are validated at the source.** A member\nmanifest's `catalog:`\u002F`catalog:\u003Cname>` spec is exempt above because it\ncarries no version — but the referenced catalog **entry** in\n`pnpm-workspace.yaml` must still be exact. The script checks this once,\nonly when the manifest under inspection sits beside the\n`pnpm-workspace.yaml` that defines the catalogs (i.e. it IS the\nworkspace root), so a non-exact catalog entry (e.g. `aws-cdk-lib:\n^2.172.0` under `catalog:`, or under a named `catalogs.\u003Cname>:` map) is\nreported once at the definition instead of once per consumer manifest\nthat references it via `catalog:`.\n\nFor **npm**, the depth is **direct deps + lockfile-present**: the\nhuman-authored specs in `package.json` must be exact, AND a lockfile must\nexist beside a deps-declaring manifest (an exact-pinned manifest with no\nlockfile still floats transitively). The lockfile-present check is\n**workspace-aware** (issue #170): a manifest with no sibling lockfile is\nstill accepted when an ancestor directory up to the repo root has both a\nlockfile and a workspace declaration (`pnpm-workspace.yaml` `packages:`\nglobs, or package.json `workspaces`) whose globs cover the manifest's\ndirectory — pnpm\u002Fnpm\u002Fyarn workspaces keep a single lockfile at the\nworkspace root by design. A manifest the workspace does not cover still\nfloats and stays a violation. Transitive pinning itself stays the\ninstall-gate's job.\n\n### The aggregator is the required check (not the per-ecosystem legs)\n\nExactly as the install-gate: the per-ecosystem legs\n(`Pinned gate (\u003Cecosystem>)`) are **visible** but **not** individually\nrequired; the always-running `pinned-gate-required` aggregator (stable\nname) is the single required check. It `needs:` the matrixed `gate` job,\nruns `if: always()`, and concludes **success** on an empty matrix (no\necosystem present → mergeable, not hung) or when every leg succeeded,\nand **failure** when any leg failed or was cancelled. The `if: always()`\nis **mandatory** for the empty-matrix-success property (a skipped\naggregator would hang the PR — #91\u002F#230). Step 6c registers\n`pinned-gate-required`, never a per-leg name.\n\n### Render the gate files (pinned-gate)\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fdependency-pinned-gate.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fdependency-pinned-gate.sh`\n\n1. Render `gh-repo-setup-protection\u002Fdependency-pinned-gate.yml` (strip\n   its leading comment block) substituting **only** `__DEFAULT_BRANCH__`.\n   The actions are SHA-pinned in the template — do not de-pin them (the\n   pinned-gate would flag its own workflow otherwise). There is **no**\n   per-job delimiter-comment rendering any more: the workflow ships with\n   the full detect → matrix → aggregator shape, armed with all five\n   ecosystems, and narrows at runtime.\n2. `dependency-pinned-gate.sh` has no placeholders — ship it\n   **verbatim** (including its leading comment block; it is a shell\n   script whose header documents its own classifier behavior). The\n   script accepts all five modes, the `--present` mode the detect job\n   calls, and no-ops gracefully (exit 0) for any mode whose manifest the\n   repo lacks. The `--present` mode reuses the same discovery predicate,\n   so the runtime matrix cannot drift from what the gate checks. Ship it\n   with the executable bit set (`chmod +x`).\n\nThe gate ships **unconditionally** whenever the skill installs\nworkflows — there is no \"empty resolved set → skip the file\" case any\nmore (an absent ecosystem produces no leg and a green aggregator). Both\nfiles are always written together (the workflow calls the script).\n\nNever write the `.yml` with an unresolved `__DEFAULT_BRANCH__`. If it\nremains after rendering, abort per the README's unresolved-placeholder\nrule.\n\n### Converge the gate files (idempotency, pinned-gate)\n\nApply the same **whole-file-replace + semantic-compare** rule the skill\nuses for the dependency-install-gate. For the `.yml`, first apply the\n**pin-reconciliation pass (Step 5a-bis)** to the rendered desired\ncontent so a repo's strictly-newer SHA-pinned action is **kept, never\ndowngraded**, before the semantic-compare:\n\n- **`dependency-pinned-gate.yml`** — YAML semantic-compare (parse both\n  the existing file and the pin-reconciled desired content as YAML,\n  compare normalized structures). Equal → \"unchanged\"; absent → write;\n  different → show the diff and halt before overwriting (whole-file\n  replace, never append). The workflow is a fixed full-set-armed shape,\n  so a converged repo re-runs as a no-op.\n- **`dependency-pinned-gate.sh`** — this is a shell script, **not** YAML,\n  so the semantic-compare is a **normalized-text\u002Fbyte compare**\n  (trailing-whitespace-normalized), not a YAML parse. Equal →\n  \"unchanged\"; absent → write (with the executable bit set, `chmod +x`);\n  different → show the diff and halt before overwriting.\n\nBoth files are written together: install both. Never install one without\nthe other (the workflow calls the script).\n\n## Step 5d: Render and converge the no-back-merging-guard\n\nA feature branch that brings in upstream changes by **merging the\ndefault branch** (a \"back-merge\") instead of rebasing produces a tangled\nhistory: the PR diff carries unrelated base commits, and the merge\ncommit's incoming parent is reachable from `origin\u002F\u003Cdefault>`. This step\ninstalls a **no-back-merging-guard** — a `pull_request` workflow whose\nsingle job `no-back-merging-guard` walks the merge commits unique to the\nPR head branch and **rejects** any whose incoming (second) parent is\nreachable from the base branch tip, forcing rebase-not-merge. The\nartifact is ported verbatim (script + self-test) from the proven\n`Fablegate\u002Ffablegate_quasar_fastapi` guard (issue #51).\n\n### Ships unconditionally — no ecosystem gate\n\nUnlike the dependency-install-gate (npm\u002Fpip\u002Fpnpm\u002Fyarn-gated) and CodeQL\n(language\u002Fentitlement-gated), the no-back-merging-guard has **no\necosystem dependency**. It is pure git-history hygiene and is desirable\non **every** repo. So it ships **unconditionally** on every run (subject\nonly to the converge\u002Fsemantic-compare rules below). There is no flag to\ndisable it; managing branch-merge policy elsewhere is not a supported\nmode for this guard.\n\n### Render the guard files\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fno-back-merging-guard.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fno-back-merging-guard.sh`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Ftest-no-back-merging-guard.sh`\n\n1. Render `gh-repo-setup-protection\u002Fno-back-merging-guard.yml` (strip its\n   leading comment block) substituting `__DEFAULT_BRANCH__`. This is the\n   only placeholder — it appears in the `on.pull_request.branches` filter\n   and in the explanatory comments. The per-PR base comparison is read\n   from `github.base_ref` at run time, so the guard still follows a\n   base-branch rename for the actual back-merge check; the\n   `__DEFAULT_BRANCH__` substitution only scopes which PRs the workflow\n   triggers on.\n2. `no-back-merging-guard.sh` and `test-no-back-merging-guard.sh` have\n   **no placeholders** — ship them **verbatim** (including their leading\n   comment blocks; they are shell scripts whose headers document their\n   own behavior, not placeholder blocks to strip). Set the executable\n   bit (`chmod +x`) on both when writing, matching the\n   `dependency-install-gate.sh` convention.\n\nNever write the `.yml` with an unresolved `__DEFAULT_BRANCH__`. If it\nremains after substitution, abort per the README's unresolved-\nplaceholder rule.\n\n### Converge the guard files (idempotency)\n\nApply the same **whole-file-replace + semantic-compare** rule the skill\nuses for the dependency-install-gate, with the per-file-type compare.\nFor the `.yml`, first apply the **pin-reconciliation pass (Step\n5a-bis)** to the rendered desired content so a repo's strictly-newer\nSHA-pinned `actions\u002Fcheckout` is **kept, never downgraded**, before the\nsemantic-compare:\n\n- **`no-back-merging-guard.yml`** — YAML semantic-compare (parse both the\n  existing file and the pin-reconciled desired content as YAML, compare\n  normalized structures). Equal → \"unchanged\"; absent → write; different\n  → show the diff and halt before overwriting (whole-file replace, never\n  append).\n- **`no-back-merging-guard.sh`** and **`test-no-back-merging-guard.sh`**\n  — these are shell scripts, **not** YAML, so the semantic-compare is a\n  **normalized-text\u002Fbyte compare** (trailing-whitespace-normalized), the\n  same rule used for `dependency-install-gate.sh`. Equal → \"unchanged\";\n  absent → write (with the executable bit set, `chmod +x`); different →\n  show the diff and halt before overwriting.\n\nAll three files are written together (the workflow invokes the script;\nthe self-test documents and verifies the script). Never install the\nworkflow without its script.\n\n## Step 6: Create \u002F converge the `protect-main` ruleset\n\nSkip this entire step if `--ruleset=off`.\n\nThe GHAS features above are half-measures without a ruleset that\nenforces review and required checks on the default branch. This skill\n**owns** the `protect-main` ruleset and converges it on every run, the\nsame read-then-reconcile way it converges the GHAS toggles. The proven\nreference shape is `ExampleProject\u002Fexample-app-repo`'s `protect-main`.\n\n### 6a. Read the existing ruleset\n\nA repository ruleset is identified by name, not a stable ID, so list\nand match on `name == \"protect-main\"`:\n\n```bash\n# Find an existing protect-main ruleset (empty output = none yet).\n# --paginate: the rulesets list can span multiple pages; without it a\n# protect-main ruleset on page 2+ is missed, wrongly concluding \"none\n# yet\" and creating a duplicate.\ngh api --paginate repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets \\\n  --jq '.[] | select(.name==\"protect-main\") | .id'\n```\n\nIf found, read its full body so you can compare against the desired\nshape and PUT only when it differs:\n\n```bash\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets\u002F\u003CID>\n```\n\n### 6b. Build the desired ruleset body\n\nThe desired body (targets the default branch; `enforcement: active`):\n\n```json\n{\n  \"name\": \"protect-main\",\n  \"target\": \"branch\",\n  \"enforcement\": \"active\",\n  \"conditions\": {\n    \"ref_name\": { \"include\": [\"~DEFAULT_BRANCH\"], \"exclude\": [] }\n  },\n  \"bypass_actors\": [\n    { \"actor_id\": 5, \"actor_type\": \"RepositoryRole\", \"bypass_mode\": \"pull_request\" }\n  ],\n  \"rules\": [\n    { \"type\": \"deletion\" },\n    { \"type\": \"non_fast_forward\" },\n    {\n      \"type\": \"pull_request\",\n      \"parameters\": {\n        \"required_approving_review_count\": 1,\n        \"dismiss_stale_reviews_on_push\": true,\n        \"require_code_owner_review\": true,\n        \"require_last_push_approval\": true,\n        \"required_review_thread_resolution\": true,\n        \"required_reviewers\": [],\n        \"allowed_merge_methods\": [\"merge\"]\n      }\n    },\n    {\n      \"type\": \"required_status_checks\",\n      \"parameters\": {\n        \"strict_required_status_checks_policy\": true,\n        \"do_not_enforce_on_create\": false,\n        \"required_status_checks\": []\n      }\n    }\n  ]\n}\n```\n\nNotes on the shape:\n\n- `~DEFAULT_BRANCH` is GitHub's symbolic ref for the repo's default\n  branch — use it so the ruleset follows a default-branch rename.\n- `require_last_push_approval: true` is **issue #222 item 6** — \"Require\n  approval of the most recent reviewable push\".\n- `require_code_owner_review: true` requires a `CODEOWNERS` file to be\n  meaningful. If the repo has no `.github\u002FCODEOWNERS` (or root\u002F`docs\u002F`\n  variant), still set it true (it is a no-op until CODEOWNERS exists)\n  but **report** \"code-owner review required, but no CODEOWNERS file\n  present — add one for it to take effect\".\n- `required_review_thread_resolution: true` (\"Require conversation\n  resolution before merging\"). The reference repo currently has this\n  `false`; the hardened baseline this skill converges to is `true`.\n- `bypass_actors` grants the built-in **Repository admin** role\n  (`actor_id: 5`, `actor_type: \"RepositoryRole\"`) a **PR-only** bypass\n  (`bypass_mode: \"pull_request\"`). This is **issue #61**: on a\n  single-maintainer repo whose sole writer is also the sole code-owner\n  and the last pusher (CODEOWNERS `* @owner`), the combination of\n  `require_last_push_approval` + `require_code_owner_review` is\n  unsatisfiable — the only eligible approver is the last pusher, which\n  last-push-approval forbids, so no PR can ever merge. A PR-only admin\n  bypass lets the maintainer merge their own PRs while leaving the\n  `deletion` and `non_fast_forward` protections fully enforced (the\n  bypass mode is `pull_request`, not the broader unrestricted bypass).\n  `actor_id: 5` is the documented built-in Admin repository role;\n  confirm it on the first PUT. This entry must be **ensured** on every\n  converge run (added if missing) while preserving any other\n  `bypass_actors` the repo already has — see 6d.\n- The `required_status_checks` list starts **empty** in this template\n  and is filled by the generic gate in 6c. **GitHub rejects a\n  `required_status_checks` rule whose `required_status_checks` array is\n  empty with a 422** (the whole rule is dropped), so the gate must\n  contribute at least one real check for the rule to be includable.\n  Because the no-back-merging-guard ships **unconditionally** (Step\n  5d), its check is present on every successful run, so the array is\n  never empty in practice — the empty starting state is only the\n  pre-gate template, never what is PUT. Never hard-code a check whose\n  workflow may not exist.\n\n### 6c. Gate each required status check on its producing workflow (#91\u002F#230 guard)\n\nThis is the **generic mechanism** issue #222 delivers, generalized by\nissue #61: a required status check is added to the ruleset **iff the\nworkflow that produces it is present in the repo this run**.\n\"Present in the repo this run\" is the gate condition — broader than the\nold \"installed *by this skill* this run\". A producing workflow counts\nas present when the skill wrote\u002Fconverged it this run **or** when it\nalready existed in `.github\u002Fworkflows\u002F` and the skill left it unchanged\n(converged-as-unchanged, or simply present and skill-owned). What still\ndisqualifies a check is the workflow being **absent** from the repo\nafter this run — registering a check whose producing workflow never\nuploads results recreates the issue #91 phantom-check hang, where every\nPR waits forever for a result that never comes.\n\n**The required checks are the workflows' AGGREGATORS, never per-leg\nnames.** Each of CodeQL and the two gates now runs a dynamic matrix and\nexposes a single always-running aggregator (`codeql-required`,\n`install-gate-required`, `pinned-gate-required`) whose stable name is\nwhat the ruleset lists. GitHub `required_status_checks` is a static list\nof names and **cannot** express \"require `Analyze (python)` only if it\nruns\" — listing a per-leg name on a repo lacking that language\u002FPM hangs\nthe PR forever (the #91\u002F#230 failure mode). So the gate is applied at\n**workflow** granularity: present workflow → add its aggregator context;\nabsent workflow → omit it. The per-leg legs stay **visible** (red\u002Fgreen,\nonly when their language\u002Fecosystem is present) but are **never**\nindividually required.\n\n- For each candidate aggregator, the skill knows (from this run) whether\n  the producing workflow is **present in the repo**. If present → add\n  the aggregator's context to `required_status_checks`. If absent →\n  **omit it** and report the skip with the #91 rationale.\n- **CodeQL** — add the aggregator context **iff CodeQL resolved on and\n  its workflow is present in the repo this run** (Step 5b wrote or\n  converged it, or it already existed):\n\n  ```json\n  { \"context\": \"codeql-required\" }\n  ```\n\n  The `codeql-required` aggregator passes green when the runtime matrix\n  is empty (no analyzable language present), so a language-less repo is\n  mergeable, not hung. When CodeQL is off (no workflow present), omit it\n  and report \"codeql-required required check: skipped (no CodeQL\n  workflow present — would be a phantom required check, issue #91)\".\n\n  When CodeQL **is** on, also express **code scanning** and **code\n  quality** as ruleset rules (issue #222 items 7\u002F8; matching the\n  reference shape) — these are result-consuming rule types, orthogonal\n  to the status-check aggregator:\n\n  ```json\n  {\n    \"type\": \"code_scanning\",\n    \"parameters\": {\n      \"code_scanning_tools\": [\n        {\n          \"tool\": \"CodeQL\",\n          \"security_alerts_threshold\": \"high_or_higher\",\n          \"alerts_threshold\": \"errors\"\n        }\n      ]\n    }\n  },\n  { \"type\": \"code_quality\", \"parameters\": { \"severity\": \"errors\" } }\n  ```\n\n  Append these to the `rules` array only when CodeQL is on this run.\n- **Dependency-install-gate** (issue #238, extended by issue #111) is\n  produced by the `dependency-install-gate.yml` workflow installed in\n  Step 5c. Add its **aggregator** context to `required_status_checks`\n  **iff that workflow is present in the repo this run** (Step 5c\n  wrote\u002Fconverged it, or it already existed):\n\n  ```json\n  { \"context\": \"install-gate-required\" }\n  ```\n\n  Do **not** register the per-PM leg names (`Install gate (npm)`, etc.)\n  — those are dynamic and would hang a PR on a repo lacking that PM. The\n  aggregator passes green when the runtime matrix is empty (no PM\n  present). When the gate workflow is **absent** from the repo after\n  this run, omit `install-gate-required` and report \"install-gate\n  required check: skipped (no dependency-install-gate workflow present —\n  would be a phantom required check, issue #91\u002F#230)\".\n- **Dependency-pinned-gate** (issue #90) is produced by the\n  `dependency-pinned-gate.yml` workflow installed in Step 5c-pinned. Add\n  its **aggregator** context to `required_status_checks` **iff that\n  workflow is present in the repo this run**:\n\n  ```json\n  { \"context\": \"pinned-gate-required\" }\n  ```\n\n  Do **not** register the per-ecosystem leg names — same phantom-check\n  hazard. The aggregator passes green on an empty runtime matrix. When\n  the pinned-gate workflow is **absent** from the repo after this run,\n  omit `pinned-gate-required` and report \"pinned-gate required check:\n  skipped (no dependency-pinned-gate workflow present — would be a\n  phantom required check, issue #91\u002F#230)\". The two gates' aggregators\n  are **distinct** contexts (`install-gate-required` vs.\n  `pinned-gate-required`), so a repo running both requires both to pass,\n  with no context collision.\n- **No-back-merging-guard check** (issue #51) is produced by the\n  `no-back-merging-guard.yml` workflow installed in Step 5d. Add its\n  context to `required_status_checks` **iff that workflow is present in\n  the repo this run**. The check context is the job name from the\n  workflow:\n\n  ```json\n  { \"context\": \"no-back-merging-guard\" }\n  ```\n\n  Because Step 5d installs the guard **unconditionally**, this workflow\n  is present on every successful run, so the check is registered on\n  every run — but it still goes through the same generic gate (it is\n  added because its producing workflow is present in the repo this run,\n  never standalone), preserving the issue #91\u002F#230 phantom-check\n  invariant. Under the generalized \"present in the repo\" gate, a Step 5d\n  diff-halt that leaves the **existing** workflow file in place still\n  counts the workflow as present (the file is on disk, just awaiting a\n  converge), so the check stays registered. The check is omitted only\n  when the guard workflow is genuinely **absent** from the repo after\n  this run — report \"no-back-merging-guard required check: skipped\n  (workflow not present in the repo this run — would be a phantom\n  required check, issue #91\u002F#230)\". Because the guard ships\n  unconditionally and is owned by this skill, the registered check is\n  also what keeps `required_status_checks` non-empty, so the rule is\n  always includable (avoiding the empty-array 422 described in 6b).\n- **Future producing workflows** plug into this same gate: when a\n  workflow is present in the repo, its check contexts are added to\n  `required_status_checks`; until then they are omitted.\n\nThe `integration_id` on a `required_status_checks` entry (the reference\nuses `15368`, GitHub Actions) is optional — omit it and GitHub matches\nthe check by `context` alone, which is what the gate wants.\n\n### 6d. Converge (create or update)\n\n- **No existing ruleset** → create it:\n\n  ```bash\n  gh api --method POST repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets \\\n    --input \u003Cdesired-body.json>\n  ```\n\n- **Existing ruleset that differs** → update it (PUT replaces the\n  ruleset body so the skill owns its shape; semantic-compare first and\n  skip when already equal so a converged re-run is a no-op):\n\n  ```bash\n  gh api --method PUT repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets\u002F\u003CID> \\\n    --input \u003Cdesired-body.json>\n  ```\n\n**Semantic-compare, not byte-compare — normalize before deciding to\nPUT.** The server returns a ruleset body that is *equivalent to but not\nbyte-identical with* the desired body. A naive compare would re-PUT\nevery run and break the headline idempotency guarantee. Normalize these\nfields before comparing, and treat them as equal when:\n\n- **`conditions.ref_name.include`** — the server may store\n  `[\"refs\u002Fheads\u002Fmain\", \"~DEFAULT_BRANCH\"]` (the reference repo's shape)\n  while the desired body carries only `[\"~DEFAULT_BRANCH\"]`. Treat an\n  existing `include` as **already converged** when it is equivalent to —\n  or a superset that contains — the desired symbolic ref\n  (`~DEFAULT_BRANCH`, or the concrete `refs\u002Fheads\u002F\u003Cdefault-branch>` it\n  resolves to). Do **not** re-PUT merely to strip the redundant concrete\n  entry; that churn is a spurious write, not a convergence.\n- **`required_status_checks`** — the server stores an `integration_id`\n  on each check (the reference uses `15368`, GitHub Actions) that the\n  desired body omits. **Compare on `context` only** (the set of check\n  contexts), ignoring `integration_id` presence\u002Fabsence. Equal context\n  sets → no re-PUT, even though the stored entries carry an extra\n  `integration_id`.\n- **`bypass_actors`** — the desired body asserts the admin PR-only\n  entry (`actor_id: 5`, `actor_type: \"RepositoryRole\"`,\n  `bypass_mode: \"pull_request\"`); the existing ruleset may carry that\n  same entry plus other actors the repo added (e.g. a team\n  `pull_request` bypass). Treat the existing `bypass_actors` as\n  **already converged** when it **contains** the admin PR-only entry\n  (regardless of any additional actors). Compare on the\n  `(actor_id, actor_type, bypass_mode)` tuple; the server may add no\n  extra fields here, so a plain set-containment check on those three\n  keys suffices. Only the **absence** of the admin entry is a semantic\n  difference that warrants a PUT — and the PUT carries the existing\n  actors plus the admin entry (see the preserve-and-ensure rule below),\n  never a replacement that drops the others.\n\nOnly PUT when a semantic difference remains after this normalization.\n\n**Graceful-skip a `code_quality` 422.** The `code_quality` rule type is\nlimited-availability and may not be enabled for the org\u002Frepo. If the\ncreate\u002Fupdate returns a `422` attributable to the `code_quality` rule\n(message naming `code_quality` \u002F \"Code quality\" \u002F an unsupported rule\ntype), do **not** hard-fail the whole ruleset convergence — retry the\nsame call with the `code_quality` rule dropped from the `rules` array,\nand report \"code quality required check: skipped (rule type not\navailable for this repo)\". The rest of the ruleset (deletion,\nnon-fast-forward, `pull_request`, `required_status_checks`, and the\n`code_scanning` rule) still converges. This mirrors the graceful\nentitlement degradation the GHAS toggle steps already apply to a 422.\n\n**Preserve-and-ensure `bypass_actors`.** Two rules apply together:\n\n- **Preserve** any `bypass_actors` the repo already has (the reference\n  repo grants a team `pull_request` bypass) — read them from 6a and\n  carry them through unchanged rather than clearing them; clearing a\n  bypass list is a posture change the operator owns.\n- **Ensure** the admin PR-only entry (`actor_id: 5`,\n  `actor_type: \"RepositoryRole\"`, `bypass_mode: \"pull_request\"`) is\n  present (issue #61). On every converge run, compute the union of the\n  existing actors and this admin entry: if the admin entry is already\n  in the existing list (matched on the\n  `(actor_id, actor_type, bypass_mode)` tuple), it is a no-op; if it is\n  missing, add it while keeping every other actor. Never replace the\n  list with the admin entry alone — that would drop the operator's\n  other bypasses, violating the preserve rule.\n\nSo the converged `bypass_actors` is always\n`existing ∪ {admin PR-only entry}`. On a freshly created ruleset (no\nexisting actors) that is just the admin entry; on a repo with a\npre-existing team bypass it is that team plus the admin entry. Report\nthe ruleset as `created`, `updated (changed: \u003Cfields>)`, or\n`unchanged`.\n\nWrite nothing to disk in this step — a ruleset is server-side state,\nlike the GHAS toggles. The skill applies it directly and reports it.\n\n## Step 7: Commit, push, and open a PR for the rendered files\n\nAfter rendering and converging its files (Steps 3, 5b, 5c, 5c-pinned,\n5d), the\nskill **commits, pushes, and opens a PR** for those files — **always**,\non a **single approval**. There is no flag to disable this and no\n\"am I being orchestrated?\" knob: the skill always produces a PR for its\nown rendered files. Only the **rendered files** go through this branch →\ncommit → push → PR flow. The **remote API changes** — the GHAS toggles\n(Step 4), the merge-button settings (Step 4e), and the `protect-main`\nruleset (Step 6) — are not file edits and cannot live in a PR, so they\nwere already applied directly to the repo and are **not** part of this\nPR.\n\n### 7a. Skip cleanly when there is nothing to commit\n\nIf every rendered file converged as `unchanged` (a no-op run against an\nalready-configured repo — the headline idempotency case), there is\n**nothing to commit**: skip this step entirely, report \"no file changes\nto commit; no PR opened\", and proceed to the report (Step 8). A\nconverged re-run must not produce an empty PR.\n\n### 7b. Present the changes and get one approval\n\nShow the operator the rendered file changes (the diff) and ask for a\nsingle approval that covers commit + push + PR together — **not** three\nseparate prompts:\n\n```bash\ngit status --short -- .github\u002F\ngit diff -- .github\u002F        # plus any staged\u002Fnew files under .github\u002F\n```\n\n```text\ngh-repo-setup-protection rendered these files:\n  \u003Clist of written\u002Fchanged files under .github\u002F>\n\nOn approval I will, in one go:\n  1. Commit them on a branch named after this skill\n     (gh-repo-setup-protection).\n  2. Push that branch.\n  3. Open a PR targeting the default branch (\u003Cdefault-branch>).\n\nThe remote settings (GHAS toggles, merge-button settings, protect-main\nruleset) were already applied directly and are NOT part of this PR.\n\nProceed with commit + push + PR? (y to do all three, or no to leave the\nfiles uncommitted for you to handle)\n```\n\nIf the operator declines, leave the rendered files uncommitted in the\nworking tree and report \"files left uncommitted at operator's request;\nno PR opened\". Do not partially commit.\n\n### 7c. Commit, push, and open the PR\n\nOn approval, do all three with no further prompts:\n\n```bash\n# Branch named after the skill. Create it from the current default-branch\n# tip if it does not exist; reuse it if a prior run left it.\ngit switch -c gh-repo-setup-protection \\\n  || git switch gh-repo-setup-protection\n\ngit add -- .github\u002F\ngit commit -m \"Converge repo protection config (gh-repo-setup-protection)\"\n\ngit push -u origin gh-repo-setup-protection\n\ngh pr create --base \"__DEFAULT_BRANCH__\" \\\n  --head gh-repo-setup-protection \\\n  --title \"Converge repo protection config\" \\\n  --body \"Rendered by \u002Fgh-repo-setup-protection: Dependabot config, CodeQL\nworkflow (when on), dependency-install-gate (when npm\u002Fpip\u002Fpnpm\u002Fyarn present), and\nthe no-back-merging-guard. Remote settings (GHAS toggles, merge-button\nsettings, protect-main ruleset) were applied directly to the repo and\nare not part of this PR.\"\n```\n\nCapture and report the PR URL. If a PR already exists for the branch\n(`gh pr create` reports it), report that URL instead of failing.\n\n**Nice-to-have — do the file work in a git worktree.** The skill does\nnot currently require running from inside a worktree (it is meant to be\nrun directly on a repo being transitioned), but rendering and committing\nthe files in a dedicated worktree would isolate the operator's working\ntree from the skill's edits. Adding worktree support is a welcome\nimprovement, not a requirement for this step.\n\n## Step 8: Report and next steps\n\nPrint a converged-state summary:\n\n```text\ngh-repo-setup-protection — \u003Cowner>\u002F\u003Crepo> (default branch: \u003Cbranch>)\n\nFiles (written \u002F unchanged \u002F skipped):\n  .github\u002Fdependabot.yml                          \u003Cwritten|unchanged>  (always written — github-actions floor)\n  .github\u002Fworkflows\u002Fcodeql.yml                    \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fcodeql\u002Fcodeql-config.yml                \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fworkflows\u002Fdependency-install-gate.yml   \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fscripts\u002Fdependency-install-gate.sh      \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fworkflows\u002Fdependency-pinned-gate.yml    \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fscripts\u002Fdependency-pinned-gate.sh       \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fworkflows\u002Fno-back-merging-guard.yml     \u003Cwritten|unchanged>\n  .github\u002Fscripts\u002Fno-back-merging-guard.sh        \u003Cwritten|unchanged>\n  .github\u002Fscripts\u002Ftest-no-back-merging-guard.sh   \u003Cwritten|unchanged>\n\nGHAS settings (each idempotent, re-asserted every run):\n  Code Security (Advanced Security)  \u003Cenabled changed|was on|skipped: why>\n  Dependabot alerts                  \u003Cenabled changed|was on|skipped: why>\n  Dependabot security updates        \u003C...>\n  Dependabot grouped security updates \u003Cvia dependabot.yml | settings UI>\n  Dependabot malware alerts          \u003Cenabled|UI-only (npm); manual step>\n  Secret scanning                    \u003C...>\n  Secret scanning push protection    \u003C...>\n  Push-protection bypass lockdown    \u003Cdelegated bypass on | manual: nobody>\n\nMerge-button \u002F PR-hygiene settings (each idempotent, re-asserted every run):\n  Allow squash merging   (off)       \u003Cunchanged|changed>\n  Allow rebase merging   (off)       \u003Cunchanged|changed>\n  Allow merge commit     (on, kept)  \u003Cunchanged>\n  Suggest update branch  (on)        \u003Cunchanged|changed>\n  Allow auto-merge       (on)        \u003Cunchanged|changed>\n  Auto-delete head branch (on)       \u003Cunchanged|changed>\n\nCodeQL decision: \u003Con|off> (\u003Creason>)\n  Default setup: \u003Ccorrectly not configured (advanced setup active — the two cannot coexist) | was configured → disabled | left as-is>\n\nprotect-main ruleset: \u003Ccreated|updated|unchanged|skipped (--ruleset=off)>\n  require_last_push_approval         \u003Ctrue>\n  Admin PR-only bypass               \u003Censured | already present>\n  Required status checks (aggregators, not per-leg names):\n    codeql-required                    \u003Cadded (CodeQL present) | skipped (#91)>\n    install-gate-required              \u003Cadded (gate present) | skipped (#91)>\n    pinned-gate-required               \u003Cadded (gate present) | skipped (#91)>\n    no-back-merging-guard              \u003Cadded (guard present) | skipped (#91)>\n  code scanning \u002F code quality rules   \u003Cadded (CodeQL on) | skipped>\n\nArmed Dependabot ecosystems: \u003Cfull supported set minus de-arms>  (present in tree: \u003Craw scan>)\nArmed drift-gate PMs: \u003Cnpm\u002Fpip\u002Fpnpm\u002Fyarn minus de-arms>  (runtime matrix narrows to present)\nArmed pinned-gate ecosystems: \u003Cnpm\u002Fpip\u002Factions\u002Fdocker\u002Fgo minus de-arms>  (runtime matrix narrows to present)\nArmed CodeQL languages: \u003Cfull supported set minus de-arms; runtime matrix narrows to present>  (present in tree: \u003Craw scan>)\n\nRendered-files PR: \u003CURL | no file changes to commit | left uncommitted at operator's request>\n\nNext steps:\n  1. Review and merge the rendered-files PR above (if one was opened).\n  2. Re-run \u002Fgh-repo-setup-protection any time — it converges and is a\n     no-op when everything is already in the desired state (no empty PR).\n```\n\nOn a run with file changes, the rendered files land in a PR on the\n`gh-repo-setup-protection` branch (Step 7) on a single approval; the\nremote settings (GHAS toggles, merge-button settings, ruleset) were\napplied directly. A converged re-run with no file changes opens no PR.\n\n---\n\n## Convergence strategy (summary — the headline requirement)\n\nThis skill is designed to be run repeatedly across many repos and on\nthe same repo many times. The convergence guarantees:\n\n- **Deterministic render.** Dependabot ecosystem blocks are emitted in\n  sorted order, and CodeQL \u002F the two gates ship a fixed full-set-armed\n  workflow shape (the language\u002Fecosystem narrowing is a runtime concern,\n  not part of the rendered bytes), so the same repo always renders the\n  same bytes. A second run with no repo change produces an identical\n  file → no diff → nothing to commit.\n- **Whole-file replace, never append.** The skill owns the shape of\n  `dependabot.yml`, `codeql.yml`, and `codeql-config.yml`. It computes\n  the desired content from scratch each run and replaces the file's\n  contents, rather than appending entries. Appending is the classic\n  source of duplicate ecosystem blocks on re-run; replacing eliminates\n  it.\n- **Semantic compare before write.** Before overwriting, the skill\n  compares the existing file to the desired content (YAML-normalized\n  for the dependabot\u002Fcodeql configs). Equal → no write, reported as\n  \"unchanged\". This keeps `git status` clean on no-op runs.\n- **Halt before destroying user edits.** If the existing file contains\n  `updates:`\u002Fconfig entries the render would drop (hand-added\n  ecosystems, custom `ignore:`\u002F`reviewers:` blocks, tuned\n  `paths-ignore`), the skill shows the diff and asks before\n  overwriting. Convergence never silently discards human customization.\n- **Idempotent GHAS toggles.** Each security setting is read first and\n  PUT\u002FPATCH-ed only when it differs from desired; the GitHub API\n  endpoints used are themselves idempotent (PUT returns 2xx whether or\n  not the feature was already on). Re-running reports \"was already on\".\n- **Idempotent merge-button settings.** The five General-settings\n  merge-button fields (Step 4e) are read first and PATCH-ed convergently\n  to the hardened state; re-running reports each as `unchanged` once\n  converged. Like the GHAS toggles, these are remote settings applied\n  directly, not file edits in the PR.\n- **PR for rendered files on a single approval.** The rendered files\n  (Dependabot config, CodeQL workflow when on, the gates\u002Fguard) are\n  committed, pushed, and PR-ed on the `gh-repo-setup-protection` branch\n  on one approval (Step 7). A no-op run with no file changes opens no PR.\n  The remote settings never go through the PR.\n- **Graceful entitlement degradation.** On an unentitled private repo,\n  GHAS-only features (secret scanning, CodeQL) are skipped with a clear\n  reason instead of erroring — so the same skill invocation works\n  unchanged across a public repo, an entitled private repo, and an\n  unentitled private repo.\n\n### Read-then-converge surface audit\n\nEvery surface the skill writes must **read the existing state first**\nand converge against it — never write blind. The issue #230 wedge was a\nsurface (server-side CodeQL setup mode) the skill wrote without reading.\nThis table is the audit; each row must hold on every run, including a\nno-op run against an already-configured repo:\n\n| Surface | Read before write | Step |\n| --- | --- | --- |\n| `dependabot.yml` | Parse YAML, semantic-compare | 3 |\n| `codeql.yml` \u002F `codeql-config.yml` | Parse YAML, semantic-compare | 5b |\n| `dependency-install-gate.yml` | Parse YAML, semantic-compare | 5c |\n| `dependency-install-gate.sh` | Normalized-text\u002Fbyte compare | 5c |\n| `dependency-pinned-gate.yml` | Parse YAML, semantic-compare | 5c-pinned |\n| `dependency-pinned-gate.sh` | Normalized-text\u002Fbyte compare | 5c-pinned |\n| `no-back-merging-guard.yml` | Parse YAML, semantic-compare | 5d |\n| `no-back-merging-guard.sh` | Normalized-text\u002Fbyte compare | 5d |\n| `test-no-back-merging-guard.sh` | Normalized-text\u002Fbyte compare | 5d |\n| CodeQL server-side setup mode | `code-scanning\u002Fdefault-setup` read | 5a |\n| Code Security (Advanced Security) | Read status, PATCH if off | 4b |\n| Dependabot alerts \u002F security updates | PUT idempotent; read for report | 4a |\n| Dependabot malware alerts \u002F grouping | Read state; best-effort + report | 4a |\n| Secret scanning \u002F push protection | Read state, PATCH only diffs | 4c |\n| Push-protection bypass lockdown | Read state; best-effort + report | 4d |\n| Merge-button \u002F PR-hygiene settings | Read state, PATCH only diffs | 4e |\n| `protect-main` ruleset | List by name, read body, PUT only diffs | 6 |\n| `protect-main` `bypass_actors` | Read existing, ensure admin PR-only entry, preserve others | 6d |\n| Required status checks | Gated on producing workflow present in the repo this run | 6c |\n\nEvery row converges on re-run: file surfaces semantic-compare and skip\nwhen equal; GHAS toggles are idempotent and report \"was already on\"; the\nCodeQL setup mode disables a conflicting default setup (operator\nconfirmed) before installing advanced, or installs nothing if the\noperator declines; the ruleset is read by name, semantic-compared, and\nPUT only when it differs.\n\nThe required-status-checks row is the load-bearing one: this skill now\n**owns** the `protect-main` ruleset, but it registers a required check\n**only when that check's producing workflow is present in the repo this\nrun** (Step 6c). It installs the CodeQL *workflow* and the code\nscanning \u002F code quality required checks **together**, never the checks\nalone — registering a check against a workflow that cannot produce\nresults is exactly how the repo wedged (issues #91, #230). Because the\nno-back-merging-guard ships unconditionally, its check is always\npresent, which also keeps `required_status_checks` non-empty (GitHub\n422s on an empty array — issue #61). The `bypass_actors` row is the\ncompanion: the admin PR-only entry is ensured on every run and the\noperator's other actors preserved, so a single-maintainer repo is not\ndeadlocked. A no-op run against a fully-configured repo writes nothing,\nmutates no server-side state, and leaves `git status` clean.\n\n---\n\n## Hard constraints\n\n- **Commit + push + PR the rendered files on a single approval, always.**\n  After rendering its files (Steps 3, 5b, 5c, 5c-pinned, 5d), the skill commits,\n  pushes, and opens a PR for them on a branch named after the skill\n  (`gh-repo-setup-protection`), targeting the default branch — on **one**\n  approval covering all three (Step 7). There is no `--commit` flag, no\n  opt-out, no \"am I being orchestrated?\" knob: the skill always produces\n  a PR for its own rendered files. The single approval still satisfies\n  global rule §0 (the operator explicitly approves before any commit \u002F\n  push). A no-op run with no file changes opens no PR. The **remote API\n  changes** (GHAS toggles, merge-button settings, ruleset) are applied\n  directly and are never part of the PR.\n- **Arm the full supported set; the Step 2b checklist only de-arms.**\n  Every surface (CodeQL languages, both gates' ecosystems, Dependabot\n  ecosystems) is armed with its full supported set at install time and\n  narrows to the present set at runtime (CodeQL and the gates via their\n  `detect` jobs; Dependabot no-ops on absent manifests). The Step 2b\n  multi-tab checklist (drift-gate \u002F pinned-gate \u002F Dependabot \u002F CodeQL)\n  defaults to **everything armed**; the operator may only **de-arm** a\n  language\u002Fecosystem they never want. This structurally removes the\n  protect-before-code ordering inversion — a new language\u002Fecosystem's\n  check\u002Fcoverage appears the first time its source lands, with no skill\n  re-run. Only `--dry-run` skips the checklist (arm the full set). The\n  CodeQL tab bounds the *armed language set* only — it never overrides\n  the on\u002Foff decision or the entitlement guard in Step 5, and de-arming\n  every language does not turn CodeQL off (the runtime matrix simply\n  never spawns a leg and the aggregator is green).\n- **Never auto-force CodeQL.** CodeQL is opt-in: it is enabled by an\n  explicit `--codeql=on` operator override or by auto-detection, and\n  **auto-detection** always skips the unentitled-private repo. The skill\n  never lets auto-detection turn CodeQL on for such a repo — that is what\n  recreates the issue #91 phantom-check hang (see \"CodeQL is opt-in\" for\n  the inlined rationale). An explicit `--codeql=on` is the operator's\n  deliberate choice and is honored; what is forbidden is CodeQL silently\n  *auto*-resolving on. (Markdown-only repos are no longer a separate\n  auto-skip case: `actions` is the always-present floor, so every repo\n  the skill touches has an analyzable language — the remaining auto-skip\n  is the entitlement one.)\n- **The CodeQL workflow can never deadlock on an absent language, and\n  never leaves a conflicting default setup in place.** The workflow is\n  armed with the full supported language set and narrows to the present\n  languages at runtime; an empty runtime matrix spawns zero analyze legs\n  and the `codeql-required` aggregator passes green, so a\n  language-less repo is mergeable, not hung (this replaces the old\n  install-time no-supported-language hard stop). When installing\n  advanced setup, the skill first reads the server-side default-setup\n  mode and disables it (with operator confirmation) so the two cannot\n  coexist (issue #230).\n- **Never append to a config file.** Always whole-file replace from a\n  deterministic render so re-runs converge instead of duplicating.\n- **Never overwrite user customization silently.** Halt and show the\n  diff when the existing file has entries the render would drop.\n- **Never downgrade a newer SHA-pinned action pin on converge.** When a\n  repo's workflow already pins an action (`actions\u002Fcheckout`,\n  `github\u002Fcodeql-action`, any `uses:` line) to a SHA whose upstream\n  release tag is **strictly newer** than the payload's, the converge\n  **keeps the repo's pin** — automatically, with no prompt, and never\n  offers a downgrade (Step 5a-bis, applied by Steps 5b\u002F5c\u002F5c-pinned\u002F5d). \"Newer\"\n  is decided by resolving **both** SHAs to their upstream release tags\n  and comparing by semver; the trailing `# vX.Y.Z` comment is\n  display-only and is never trusted. A pin that is older, equal,\n  floating (a `@vN` tag, not a 40-hex SHA), or **unresolvable** (deleted\n  tag, fork, private action, API failure) converges to the payload's\n  pin. \"Match the payload\" thus excludes downgrading a deliberately-\n  newer SHA-pinned repo pin.\n- **Never write a file with unresolved `__...__` placeholders.** Abort\n  per the README's unresolved-placeholder rule.\n- **Always write `dependabot.yml`, armed with the full supported\n  ecosystem set.** Render one `updates:` block per supported ecosystem\n  (`github-actions`, `npm`, `pip`, `docker`, `gomod`, `bundler`,\n  `cargo`, `maven`, `gradle`, `composer`, `terraform`) minus any Step 2b\n  de-arms — never narrowed to detected ecosystems. Dependabot no-ops on\n  an ecosystem whose manifest is absent, so the full set adds no spurious\n  update PRs; the `updates:` list is never empty and the old \"no\n  ecosystem detected → skip the file\" path is gone. Resolve the correct\n  **class variant** per ecosystem (no `versioning-strategy` on\n  docker\u002Fgithub-actions — Dependabot rejects it; `github-actions` uses\n  singular `directory: \"\u002F\"` + weekly; others use recursive\n  `directories: **\u002F*` + daily) — a wrong variant makes Dependabot reject\n  the whole config (Step 3).\n- **CodeQL, both gates arm the full set and gate at runtime — never\n  install-time-narrow.** Ship `codeql.yml`,\n  `dependency-install-gate.yml`, and `dependency-pinned-gate.yml` with\n  their full detect → matrix → aggregator shape (armed with the full\n  supported language\u002Fecosystem set), plus their sibling scripts\n  (`codeql-language-present.sh`, `dependency-install-gate.sh`,\n  `dependency-pinned-gate.sh`, all with the executable bit set). Each\n  narrows to the present set at runtime via its `detect` job (the SAME\n  `git ls-files` predicate the analysis\u002Fgate uses — detection defined\n  once per surface). The two gates are **separate** (own workflow,\n  script, and aggregator); do not fold them together. The pinned-gate's\n  categorical exemptions (peerDependencies carets, `file:`\u002F`workspace:`\n  specs, pnpm `catalog:`\u002F`catalog:\u003Cname>` references, `engines`\u002F\n  `requires-python` floors, override-value classification,\n  `tag@sha256:` digests) live in the classifier script, never in a\n  maintained allowlist file. A `catalog:` reference is exempt at the\n  consumer; the referenced entry in `pnpm-workspace.yaml` is checked\n  for exactness once, at the source.\n- **The required check per surface is its AGGREGATOR, never a per-leg\n  name.** Add `codeql-required`, `install-gate-required`, and\n  `pinned-gate-required` to `protect-main` **iff** each surface's\n  workflow is present in the repo this run (Step 6c) — never a per-leg\n  name like `Analyze (python)` or `Install gate (npm)`, which would hang\n  a PR on a repo lacking that language\u002FPM (issue #91\u002F#230). Each\n  aggregator passes green on an empty runtime matrix, so a repo missing\n  the guarded languages\u002Fecosystems is mergeable.\n- **Swift never provisions macOS when absent.** The CodeQL detect job\n  adds a `swift` matrix entry (carrying `runner: macos-latest`) only\n  when `*.swift` is present; a Swift-less repo shows no swift leg and\n  never bills for a macOS runner.\n- **Always install the no-back-merging-guard, and its three files\n  together.** The guard ships **unconditionally** (Step 5d) — no\n  ecosystem gate, no disable flag; it is pure git-history hygiene.\n  Install `no-back-merging-guard.yml`,\n  `no-back-merging-guard.sh`, and `test-no-back-merging-guard.sh`\n  together (the workflow invokes the script; the self-test verifies it);\n  ship the two scripts verbatim with the executable bit set. Add the\n  `no-back-merging-guard` required check to `protect-main` only when the\n  workflow is present in the repo this run (Step 6c) — which, because\n  the guard is unconditional, is every successful run — never\n  standalone (issue #91\u002F#230).\n- **Never edit anything outside the current repo.** All file writes go\n  under `\u003Crepo-root>\u002F.github\u002F`. Scratch work, if any, goes under\n  `\u003Crepo-root>\u002F.claude\u002Ftmp\u002Fgh-repo-setup-protection\u002F`, never `\u002Ftmp\u002F`.\n- **Treat a missing GHAS entitlement as a skip, not a failure.** A 422\n  \"Advanced Security is not enabled\" on a private repo is expected and\n  must be reported as a graceful skip.\n- **Never register a required status check whose producing workflow is\n  not present in the repo this run.** Required checks in `protect-main`\n  go through the Step 6c gate: a check is added iff its producing\n  workflow is present in the repo this run (written\u002Fconverged this run\n  or already on disk). Code scanning \u002F code quality are added iff\n  CodeQL is on and its workflow is present this run. Adding a check\n  against a workflow that cannot produce results is the issue #91\u002F#230\n  wedge.\n- **Always ensure the admin PR-only `bypass_actors` entry, and never\n  clear an existing ruleset's `bypass_actors`.** On every converge run,\n  ensure the built-in Repository admin role (`actor_id: 5`,\n  `actor_type: \"RepositoryRole\"`, `bypass_mode: \"pull_request\"`) is in\n  `bypass_actors` (issue #61 — otherwise a single-maintainer repo\n  deadlocks on last-push-approval + code-owner review), adding it if\n  missing. Read the existing actors from 6a and carry them through\n  unchanged — the converged list is `existing ∪ {admin PR-only}`, never\n  a replacement that drops the operator's other actors. Changing the\n  rest of the bypass list is a posture decision the operator owns.\n- **Best-effort, never hard-fail, on under-specified GHAS toggles.**\n  Malware alerts, grouped-security-updates settings enablement, and the\n  push-protection bypass list have no stable public per-repo REST\n  toggle. Attempt the documented shape, treat a 422\u002F404 as \"do this one\n  step in the UI\", and report the residual manual step — do not invent\n  an endpoint or abort.\n\n---\n\n## Out of scope\n\n- **Purchasing \u002F enabling a GHAS entitlement** on a private repo. The\n  skill detects the lack of entitlement and skips; buying GHAS is an\n  org-billing decision for the user.\n- **Tuning CodeQL queries \u002F `paths-ignore` per repo.** The shipped\n  `codeql-config.yml` is a sane default; the user refines it after the\n  first scan.\n- **Deleting an existing CodeQL workflow** when `--codeql=off`. Removing\n  a security workflow is the user's call; the skill reports its presence\n  and leaves it in place.\n- **The live multi-repo verification** required by the issue's third\n  acceptance criterion. The skill is built to run idempotently across\n  repos (including one where CodeQL is off), but exercising it against\n  the four live repos is an operational step the user performs.\n","You are running the `\u002Fgh-repo-setup-protection` skill. Your job is to\nbring the **current repo** (the repo the user invoked the skill from)\nto a desired security\u002Fquality protection baseline. The skill's remit is\nthe **entire Security & Quality surface** of the repo — every setting on\nthe repo's *Security & Quality* settings page — plus the repo's\nmerge-button \u002F PR-hygiene **General** settings and the matching\n`protect-main` ruleset. The GHAS features are half-measures without the\nruleset that enforces them, so both are in scope:\n\n1. **GHAS \u002F repo security settings** — Dependabot alerts, Dependabot\n   security updates (incl. *grouped* security updates), Dependabot\n   *malware* alerts, per-repo Code Security (GHAS enablement when the\n   org\u002Frepo is entitled), and secret scanning + push protection\n   (including *locking down who may bypass* push protection) where the\n   repo is entitled to them.\n2. **Merge-button \u002F PR-hygiene repo settings** — the General-settings\n   merge-button toggles (`allow_squash_merge`, `allow_rebase_merge`,\n   `allow_update_branch`, `allow_auto_merge`, `delete_branch_on_merge`)\n   converged to the hardened state: merge-commit only, suggest-update-\n   branch + auto-merge + auto-delete-head-branch on. These are remote\n   settings applied via the GitHub API, read-then-PATCH and idempotent\n   like the GHAS toggles. See Step 4e.\n3. **A templated `dependabot.yml`** — version-update config covering\n   **every supported package ecosystem** (`github-actions`, `npm`,\n   `pip`, `docker`, `gomod`, `bundler`, `cargo`, `maven`, `gradle`,\n   `composer`, `terraform`), armed at install time regardless of what\n   the scan found, with a `security-updates` group so security PRs are\n   batched per ecosystem. Dependabot **no-ops** on an ecosystem whose\n   manifest is absent, so arming the full set adds no spurious update\n   PRs — it just means an ecosystem's first manifest is covered the\n   moment it lands, with no skill re-run. See Step 2 \u002F Step 3. (The\n   Step 2b Dependabot tab is a *de-arm* override — drop an ecosystem you\n   never want — defaulting to the full set armed.)\n4. **An Advanced CodeQL workflow** — **only when CodeQL is enabled for\n   this repo** (explicit `--codeql=on` operator override, or\n   auto-detection). The workflow is armed with the **full supported\n   CodeQL language set** and picks which to analyze at **runtime**, per\n   PR: a `detect` job emits the languages actually present in the tree,\n   an `analyze` matrix runs one leg per present language, and a\n   `codeql-required` aggregator is the single required check (green when\n   the matrix is empty, so a language-less repo is mergeable, not hung).\n   A language that lands *after* setup lights its leg up automatically —\n   no skill re-run. CodeQL is never turned on *by auto-detection* on an\n   unentitled private repo; an explicit `--codeql=on` is an operator\n   override that the skill honors. The shipped workflow is **Advanced\n   setup from the first commit** (SHA-pinned, autobuild-free,\n   least-privilege). See the \"CodeQL is opt-in\" section for why.\n5. **A dependency-install-gate** — **installed whenever CodeQL-style\n   protection is wanted for dependency drift** (armed with the full\n   supported set of npm \u002F pip \u002F pnpm \u002F yarn). A `pull_request` workflow\n   with a `detect` job (emits the package managers whose manifest is\n   present), a matrixed `gate` job (one leg per present PM, replaying the\n   lockfile \u002F running a resolver pre-flight and failing on drift), and an\n   `install-gate-required` aggregator that is the single required check\n   (green when the matrix is empty). Each Node manager keys off its\n   **own** lockfile (`package-lock.json` \u002F `pnpm-lock.yaml` \u002F\n   `yarn.lock`), so a pnpm\u002Fyarn repo is gated by the right tool instead\n   of silently passing an npm-only check. A PM whose manifest lands after\n   setup lights its leg up automatically — no skill re-run. See Step 5c.\n6. **A dependency-pinned-gate** — the **sibling** of the\n   dependency-install-gate (armed with the full supported set of npm \u002F\n   pip \u002F actions \u002F docker \u002F go): where the install-gate protects the\n   lockfile↔manifest *lock* relationship, this gate protects how the\n   manifest itself **declares** versions. A `pull_request` workflow with\n   the same `detect` → matrixed `gate` → `pinned-gate-required`\n   aggregator shape, whose per-ecosystem legs fail the PR when any\n   *declared* dependency is not pinned to an exact version\n   (caret\u002Ftilde\u002Fcomparator\u002FX-range\u002FOR\u002Fcompatible-release specs, floating\n   action `@vN` tags, floating Docker `:latest` tags, bare names) —\n   catching the \"works on main, breaks on rebase\" supply-chain drift that\n   slips past a green install-gate. Categorical exemptions\n   (peerDependencies carets, `file:`\u002F`workspace:` specs, pnpm\n   `catalog:`\u002F`catalog:\u003Cname>` references, `engines`\u002F`requires-python`\n   floors, override-value classification, `tag@sha256:` digests) live\n   in the classifier, not an allowlist file. A `catalog:` reference is\n   exempt at the consumer manifest because it is not a version itself —\n   the referenced entry in `pnpm-workspace.yaml`'s `catalog:`\u002F`catalogs:`\n   sections is validated for exactness instead, once at the source.\n   `actions` is an always-present floor (the skill always installs\n   workflows). Its aggregator is a separate required check from the\n   install-gate's. See Step 5c-pinned.\n7. **A no-back-merging-guard** — installed **unconditionally** (it has\n   no ecosystem dependency; it is pure git-history hygiene). A\n   `pull_request` workflow whose single job `no-back-merging-guard`\n   rejects PRs whose head branch contains a back-merge from the default\n   branch (a merge commit whose incoming parent is reachable from\n   `origin\u002F\u003Cdefault>`), forcing feature branches to rebase rather than\n   merge the base in. See Step 5d.\n8. **The `protect-main` ruleset** — create\u002Fconverge the standard\n   branch ruleset (deletion, non-fast-forward, a `pull_request` rule\n   with last-push-approval + code-owner review + thread-resolution, and\n   `required_status_checks`). The `pull_request` rule grants the\n   built-in **Repository admin** role a **PR-only** bypass so a\n   single-maintainer repo (sole writer == sole code-owner == last\n   pusher) is not deadlocked by last-push-approval + code-owner review.\n   Required status checks are wired through a **generic gate**: each one\n   is added **only if its producing workflow is present in the repo this\n   run** — the issue #91\u002F#230 phantom-check guard, applied at\n   **workflow** granularity (never per-leg). The required checks are the\n   workflows' **aggregators**: `codeql-required` iff a CodeQL workflow is\n   present this run, `install-gate-required` iff the\n   dependency-install-gate workflow is present this run,\n   `pinned-gate-required` iff the dependency-pinned-gate workflow is\n   present this run, and `no-back-merging-guard` iff that workflow is\n   present this run (always, since it ships unconditionally) — never a\n   per-leg name like `Analyze (python)` or `Install gate (npm)`, which\n   would hang a repo lacking that language\u002FPM (the #91\u002F#230 failure\n   mode). Each aggregator passes green when its runtime matrix was empty,\n   so a repo missing the guarded languages\u002Fecosystems is mergeable.\n\n**Converge the whole surface on every run — do not set-and-forget.**\nAn org-level change can flip a per-repo setting back off (e.g. enabling\nCode Security at the org level flips `secret_scanning_push_protection`\nback to disabled). Every run must *re-assert* the hardened state for\nevery setting, reporting each as `enabled`\u002F`changed`\u002F`unchanged`.\n\nThe headline requirement is **idempotency \u002F convergence**. This skill\nis meant to be run repeatedly across many repos (at least four:\ntwo under `TheVoskamps`, two under `ExampleProject`). Re-running on an\nalready-configured repo must **detect existing state and converge** to\nthe desired config — it must never duplicate ecosystem blocks, append\nto a config that already has the right content, or hard-error because\nsomething is already in place.\n\nThe **full supported set is armed at install time on every surface** —\nCodeQL languages, both gates' ecosystems, and Dependabot's ecosystems —\nand each surface **activates automatically the first time matching\nsource appears, with no skill re-run**. For CodeQL and the two gates\nthis is a **runtime dynamic-matrix**: a check appears on a PR iff the\nlanguage\u002Fecosystem it guards is present in the tree at that moment\n(present + clean → green; present + broken → red\u002Fblocking; absent → no\ncheck). For Dependabot (which emits no PR check) it means the rendered\n`updates:` list covers every supported ecosystem, no-opping on absent\nmanifests. This **structurally removes the protect-before-code ordering\ninversion** — you no longer merge the code first so the skill can detect\nit. Before authoring anything, the skill presents an **operator\nconfirmation checklist** (Step 2b) that is a *de-arm* override:\neverything is armed by default, and the operator can drop a\nlanguage\u002Fecosystem they never want armed.\n\nAfter rendering its files, the skill **commits, pushes, and opens a\nPR** for its own rendered files on a single approval (Step 7). The\nrendered files go on a branch named after the skill\n(`gh-repo-setup-protection`) and into a PR targeting the default\nbranch — the operator approves once, and that one approval covers\ncommit + push + PR. The **remote API changes** — the GHAS toggles\n(Step 4), the merge-button settings (Step 4e), and the `protect-main`\nruleset (Step 6) — are not file edits and cannot live in a PR, so they\nare applied **directly** to the repo; every such change is reported and\nre-running is a no-op when the setting is already correct.\n\n---\n\n## Inputs\n\nAll optional; everything else is inferred from the repo.\n\n- `--codeql=on|off|auto` (default `auto`): controls the CodeQL\n  workflow. See \"CodeQL is opt-in\".\n- `--ghas=on|off` (default `on`): whether to attempt the remote\n  settings — the GHAS toggles (Step 4) and the merge-button \u002F\n  PR-hygiene settings (Step 4e). Set `off` for a repo where you only\n  want the Dependabot\u002FCodeQL files and not the remote\n  security\u002Fmerge-button settings.\n- `--ruleset=on|off` (default `on`): whether to create\u002Fconverge the\n  `protect-main` ruleset (Step 6). Set `off` to manage branch\n  protection elsewhere and have this skill touch only the\n  GHAS\u002FDependabot\u002FCodeQL surface.\n- `--dry-run`: report what *would* change (files, GHAS toggles,\n  merge-button settings, the ruleset, and the rendered-files PR) without\n  writing files, calling the mutating API, or opening a PR. Skips the\n  Step 2b operator de-arm checklist (arms the full supported set on\n  every surface) so the multi-repo verification pass is non-interactive.\n\nIf the user passed nothing, use the defaults above.\n\n---\n\n## Step 0: Payload\n\nThe template payloads this skill renders ship with the plugin at\n`${CLAUDE_PLUGIN_ROOT}\u002Fpayload\u002Fgh-repo-setup-protection\u002F`. The\nplaceholder\u002Frender convention is documented in\n`${CLAUDE_PLUGIN_ROOT}\u002Fpayload\u002FREADME.md`.\n\n## Step 1: Pre-flight — repo root, auth, and identifiers\n\nConfirm you are inside a git working tree and capture the root:\n\n```bash\ngit rev-parse --show-toplevel\n```\n\nIf it fails, abort with:\n\n> `\u002Fgh-repo-setup-protection` must be run from inside a git\n> repository. The current directory is not a git working tree.\n\nConfirm `gh` is authenticated:\n\n```bash\ngh auth status\n```\n\nIf not authenticated, abort and tell the user to run `gh auth login`\n(scopes: `repo`, plus `security_events` and `admin:repo_hook` are\nhelpful for the GHAS toggles).\n\n`jq` must be on `PATH` (it parses the CodeQL default-setup response in\nStep 5a; it is already a hard dependency of the global config's hooks).\nStep 5a hard-stops if it is missing.\n\nResolve the repo identifiers (these feed the placeholders — see\n`${CLAUDE_PLUGIN_ROOT}\u002Fpayload\u002FREADME.md` step 1 inference table):\n\n```bash\ngh repo view --json nameWithOwner -q .nameWithOwner   # __GH_ORG__\u002F__GH_REPO__\ngh repo view --json defaultBranchRef -q .defaultBranchRef.name  # __DEFAULT_BRANCH__\ngh repo view --json visibility -q .visibility\ngh repo view --json isPrivate -q .isPrivate\n```\n\n## Step 2: Scan package ecosystems present in the repo (informational)\n\n**The armed set is no longer narrowed by this scan.** All four\nprotected surfaces — CodeQL, the two gates, and Dependabot — arm the\n**full supported set** at install time (see Steps 3, 5b, 5c, 5c-pinned).\nCodeQL and the two gates then narrow to the *present* set at **runtime**\nvia each workflow's `detect` job; Dependabot no-ops on absent manifests.\nSo this scan does **not** decide *what to author* — it is retained only\nas **informational context** for the operator (to show, in the Step 2b\nde-arm checklist, which languages\u002Fecosystems already have source in the\ntree) and for the CodeQL on\u002Foff decision (Step 5, which still needs to\nknow whether the repo has any analyzable language to auto-resolve).\n\nThe Dependabot supported set the skill arms unconditionally (one\n`updates:` block each — directory `\u002F` for `github-actions`, recursive\n`**\u002F*` for the rest):\n\n`github-actions`, `npm`, `pip`, `docker`, `gomod`, `bundler`, `cargo`,\n`maven`, `gradle`, `composer`, `terraform`.\n\n(Confirm the exact set against Dependabot's current supported-ecosystems\ndocs at implementation time — arm whatever the current docs enumerate.\n`github-actions` is the floor and is always armed.)\n\nFor the **informational** scan, use this mapping (manifest glob →\necosystem). Run it from the repo root over tracked files only and ignore\nvendored trees (`node_modules`, `vendor`, `.git`):\n\n| Manifest (anywhere in tree) | Dependabot ecosystem |\n| --- | --- |\n| `package.json` | `npm` |\n| `requirements*.txt`, `pyproject.toml`, `Pipfile`, `setup.py` | `pip` |\n| `go.mod` | `gomod` |\n| `Gemfile` | `bundler` |\n| `Cargo.toml` | `cargo` |\n| `composer.json` | `composer` |\n| `pom.xml` | `maven` |\n| `build.gradle`, `build.gradle.kts` | `gradle` |\n| `*.tf` | `terraform` |\n| `Dockerfile`, `*\u002FDockerfile` | `docker` |\n\nReference detection commands (adjust as needed):\n\n```bash\nROOT=\"$(git rev-parse --show-toplevel)\"\n# Track files only — never scan ignored\u002Fvendored trees.\ngit -C \"$ROOT\" ls-files | grep -E '(^|\u002F)package\\.json$'\ngit -C \"$ROOT\" ls-files | grep -E '(^|\u002F)go\\.mod$'\ngit -C \"$ROOT\" ls-files | grep -E '(^|\u002F)(requirements.*\\.txt|pyproject\\.toml|Pipfile|setup\\.py)$'\n# ... etc per the table above\n```\n\n**The gates' own detection is defined once, at runtime, by their\nscripts** — not by this scan. `dependency-install-gate.sh --present`\nand `dependency-pinned-gate.sh --present` emit the present set from the\nsame `git ls-files` predicates the gates check with, and CodeQL's\n`codeql-language-present.sh --matrix` does the same for languages. This\nStep 2 scan never feeds those; it is purely for display and the CodeQL\non\u002Foff gate.\n\n**A `dependabot.yml` is always written** — the full supported set is\narmed unconditionally, so the `updates:` list is never empty. The old\n\"no ecosystem detected → skip the file\" \u002F \"markdown-only repo\" path is\n**gone**: the skill always arms every supported ecosystem.\n\n## Step 2b: Operator de-arm checklist (defaults to the full armed set)\n\nEvery surface is **armed with the full supported set** at install time,\nand each **narrows to the present set at runtime** (CodeQL and the two\ngates via their `detect` jobs) or no-ops on absent manifests\n(Dependabot). So there is **nothing to detect-and-narrow up front** — the\nprotect-before-code ordering inversion is gone structurally, not via an\noperator toggle. The scan (Step 2) is informational only.\n\nThe checklist that remains is a **de-arm override**: for each surface,\nthe full supported set is armed by default, and the operator may **drop**\na language\u002Fecosystem they never want armed on this repo. This is the\ninverse of the old \"confirm what to arm\" flow — the default is\neverything-on, and the only edit is subtraction.\n\nSo after the informational scan and **before authoring any file**\n(Steps 3, 5b, 5c, 5c-pinned), present a **single multi-tab\n`AskUserQuestion`** — one tab per surface (drift-gate \u002F pinned-gate \u002F\nDependabot \u002F CodeQL), each `multiSelect: true` — whose options are the\nsurface's **full supported set, all preselected (armed)**. The operator\n**unchecks** any item they want de-armed; the **armed set** (full set\nminus the operator's unchecks) is what is authored. This is the skill's\nup-front interaction; the single commit\u002Fpush\u002FPR approval (Step 7) still\ncomes after, so the approve-once model is preserved.\n\nSkip the checklist under `--dry-run` (arm the full supported set on every\nsurface and note the checklist was skipped) — every interactive run\npresents it.\n\n**Working within the `AskUserQuestion` contract.** The tool caps a call\nat 1–4 questions, each with 2–4 options. The four surfaces ⇒ four\nquestions — at the question cap. Several surfaces have more than four\nsupported values (Dependabot ≈11, CodeQL 10, pinned-gate 5), which\nexceeds the 2–4-options-per-question cap. Because the flow is now\n**de-arm only** (no free-text \"add\" path — the full set is already\narmed), an over-cap surface is presented as a **single confirm-or-edit\noption**: default \"keep the full set armed\", with a free-text `response`\nin which the operator lists **only the items to de-arm** (e.g. \"drop\nmaven, gradle\"). A de-arm entry is validated against that surface's\nsupported set (below); an unrecognized entry is reported and re-prompted,\nnever silently applied. Surfaces that fit the cap (drift-gate has exactly\nfour PMs) list each supported value as a preselected checkbox directly.\n\n### The four tabs (all default to the full armed set)\n\n- **Drift-gate tab** (armed set → Step 5c gate is armed with these PMs).\n  Options are the four supported package managers — `npm`, `pip`,\n  `pnpm`, `yarn` — each **preselected (armed)**. Unchecking a PM de-arms\n  it (its runtime `detect` never proposes it and no leg ever spawns).\n  The armed set is baked into the workflow's `detect` script coverage;\n  in practice the gate script already covers all four, so a de-arm is\n  honored by the ruleset\u002Freporting layer, not by removing a job (there\n  are no per-PM jobs any more — one matrixed `gate` job covers all).\n- **Pinned-gate tab** (armed set → Step 5c-pinned). Five supported\n  ecosystems (`npm`, `pip`, `actions`, `docker`, `go`) — one over the\n  cap, so use the confirm-or-edit pattern: default \"keep all five\n  armed\", free-text de-arm listing the ecosystems to drop. `actions` is\n  the always-present floor — de-arming it is discouraged (report it) but\n  permitted.\n- **Dependabot tab** (armed set → Step 3 `updates:` blocks). The full\n  supported ecosystem set (`github-actions`, `npm`, `pip`, `docker`,\n  `gomod`, `bundler`, `cargo`, `maven`, `gradle`, `composer`,\n  `terraform`) — more than the cap, so use the confirm-or-edit pattern:\n  default \"arm every supported ecosystem\", free-text de-arm listing the\n  ecosystems to drop. `github-actions` is the floor and is not\n  de-armable.\n- **CodeQL tab** (armed set → Step 5b). The full supported CodeQL\n  language set (`javascript-typescript`, `python`, `go`, `java-kotlin`,\n  `csharp`, `c-cpp`, `ruby`, `rust`, `swift`, `actions`) — more than the\n  cap, so use the confirm-or-edit pattern: default \"arm every supported\n  language\", free-text de-arm listing the languages to drop. `actions`\n  is the floor. The armed set does **not** override the CodeQL on\u002Foff\n  decision — `--codeql` and the entitlement guard in Step 5 still decide\n  *whether* CodeQL runs; the armed set only bounds which languages the\n  runtime `detect` may propose. (De-arming every language does not turn\n  CodeQL off — the runtime matrix simply never spawns a leg, and the\n  `codeql-required` aggregator passes green.)\n\n### Validate a de-arm entry before it is applied\n\nA free-text de-arm entry names an item to **remove** from the armed set.\nValidate each against its surface's supported set so a typo does not\nsilently fail to de-arm (or, worse, get misread):\n\n- **Pinned-gate**: `npm`, `pip`, `actions`, `docker`, `go`.\n- **Dependabot**: the documented Dependabot `package-ecosystem` enum\n  (`github-actions`, `npm`, `pip`, `docker`, `gomod`, `bundler`, `cargo`,\n  `maven`, `gradle`, `composer`, `terraform`, plus any others GitHub's\n  options reference lists — treat the docs as authoritative).\n- **CodeQL**: `javascript-typescript`, `python`, `go`, `java-kotlin`,\n  `csharp`, `c-cpp`, `ruby`, `rust`, `swift`, `actions`.\n\nFor each de-arm entry: normalize an unambiguous alias to its canonical\nvalue (`golang`\u002F`gomod` → the surface's canonical form; `typescript` →\n`javascript-typescript`; `c#` → `csharp`; etc.); if it matches a\nsupported value, remove that value from the armed set; if it resolves to\nnothing, report the unrecognized entry, show the surface's supported set,\nand re-prompt. Never apply an unvalidated de-arm.\n\n### How the armed sets flow downstream\n\n| Tab | Armed set drives | Consumed in |\n| --- | --- | --- |\n| Drift-gate | which PMs the install-gate covers (runtime-matrixed) | Step 5c, Step 6c |\n| Pinned-gate | which ecosystems the pinned-gate covers (runtime-matrixed) | Step 5c-pinned, Step 6c |\n| Dependabot | which `updates:` ecosystem blocks render | Step 3 |\n| CodeQL | which languages the runtime CodeQL matrix may propose | Step 5, Step 5b, Step 6c |\n\nFrom Step 2b onward, the downstream steps arm the **armed set** (full\nsupported set minus operator de-arms), and the **runtime `detect` jobs**\n(CodeQL and the two gates) narrow that to the present set per PR. The\nscan is informational; the authored artifact is the armed set; the\nrunning check is the present subset of the armed set.\n\n## Step 3: Render and converge `dependabot.yml`\n\nTarget path: `\u003Crepo-root>\u002F.github\u002Fdependabot.yml`.\n\n**Arm the full supported ecosystem set** (Step 2's list, minus any\nStep 2b de-arms): `github-actions`, `npm`, `pip`, `docker`, `gomod`,\n`bundler`, `cargo`, `maven`, `gradle`, `composer`, `terraform`. Render\none `updates:` block per armed ecosystem **unconditionally** — do\n**not** narrow to detected ecosystems. Dependabot no-ops on an ecosystem\nwhose manifest is absent, so arming the full set adds no spurious update\nPRs; it just covers each ecosystem's first manifest the moment it lands,\nwith no skill re-run.\n\nThe generated baseline is **hardened** (issue #51): per-ecosystem\ncooldown soak, `versioning-strategy`, recursive directory coverage,\nsemver-major ignore, and per-ecosystem schedules. Several values vary\nby **ecosystem class** — npm\u002Fpip (the rich tier), github-actions (fixed\ndirectory, weekly, default-days only), and everything else (docker,\ngomod, bundler, cargo, maven, gradle, composer, terraform — recursing\ndirectory, daily, default-days only). The `ecosystem-block.yml`\ntemplate carries those variant parts as block placeholders the skill\nresolves per ecosystem. **Getting the class variant right for every\narmed ecosystem is the one real complexity** — a wrong variant (e.g.\n`versioning-strategy` on docker\u002Fgithub-actions, which Dependabot does\nnot support) makes Dependabot **reject the whole config**. Test this\nhardest.\n\n1. Read the per-ecosystem template\n   `gh-repo-setup-protection\u002Fecosystem-block.yml`. Strip its leading\n   comment block (every line up to and including the\n   `# Indentation ...` comment) — only the YAML body is rendered.\n2. For each armed ecosystem (directory `\u002F` unless the operator's stated\n   layout says otherwise — since the armed set no longer comes from a\n   directory-bearing scan, default every ecosystem's directory to the\n   repo root), substitute the placeholders below. Render the blocks in a\n   **stable, sorted order** (sort by ecosystem then directory) so the\n   output is deterministic — this is what makes the re-run a\n   byte-for-byte no-op instead of a reorder churn.\n\n   **Per-ecosystem placeholder resolution.** Resolve each placeholder\n   from the ecosystem class. The ecosystem classes are:\n   **npm\u002Fpip** (the rich tier), **github-actions** (fixed directory,\n   weekly, default-days only), and **everything else** (docker, gomod,\n   bundler, cargo, maven, gradle, composer, terraform — recursing\n   directory, daily, default-days only). Every newly-armed ecosystem\n   (bundler, cargo, maven, gradle, composer, terraform) falls in the\n   **\"everything else\"** class: `directories: **\u002F*`, daily, `cooldown:\n   default-days: 7` only, and **no** `versioning-strategy` (dropped).\n\n   The two scalar placeholders resolve as:\n\n   | Placeholder | npm \u002F pip | github-actions | other (docker, gomod, …) |\n   | --- | --- | --- | --- |\n   | `__ECOSYSTEM__` | the ecosystem value | `github-actions` | the ecosystem value |\n   | `__DEFAULT_BRANCH__` | default branch | default branch | default branch |\n   | `__SCHEDULE_INTERVAL__` | `daily` | `weekly` | `daily` |\n\n   The three multi-line block placeholders resolve per class as follows\n   (each block's first line carries no leading indent — the template's\n   4-space indent supplies it — and continuation lines carry their own\n   absolute 6-space indent):\n\n   - **`__DIRECTORY_BLOCK__`** — npm\u002Fpip and every other ecosystem\n     **except** `github-actions` use the plural `directories:` key with\n     a root-anchored globstar:\n\n     ```yaml\n     directories:\n       - \"\u003Cdir-glob>\"\n     ```\n\n     `\u003Cdir-glob>` is `**\u002F*` when the detected directory is the repo root\n     `\u002F`; for a non-root manifest directory `\u002Fsub`, anchor the globstar\n     there as `sub\u002F**\u002F*`. `github-actions` keeps the singular\n     `directory: \"\u002F\"` — it has a fixed workflow search and is not a\n     recursing path. Bare `**` under `directories` does **not** recurse\n     arbitrarily; `**\u002F*` is the verified pattern.\n   - **`__VERSIONING_STRATEGY_BLOCK__`** — on **npm\u002Fpip only**, the\n     single line `versioning-strategy: increase` (the only two\n     ecosystems that honour the key — preserves exact-pin policy;\n     emitting it elsewhere is a no-op at best and a parse risk at\n     worst). For every other ecosystem this block is **empty** — drop\n     the placeholder line (see empty-block collapse below).\n   - **`__COOLDOWN_BLOCK__`** — cooldown soak applies to **version\n     updates only** (security PRs bypass it). npm\u002Fpip get per-semver\n     tiers:\n\n     ```yaml\n     cooldown:\n       semver-major-days: 14\n       semver-minor-days: 7\n       semver-patch-days: 7\n       default-days: 7\n     ```\n\n     docker, github-actions, and every other ecosystem do **not**\n     support semver tiers (Dependabot rejects `semver-*-days` for them),\n     so they get `default-days` only:\n\n     ```yaml\n     cooldown:\n       default-days: 7\n     ```\n\n   Two more hardening patterns live in the **static body** of the\n   template (not placeholders) and therefore apply to every ecosystem\n   unconditionally: the **ignore semver-major** version-update entry and\n   the **`*-security` group**.\n\n   **Empty-block collapse.** `__DIRECTORY_BLOCK__`,\n   `__VERSIONING_STRATEGY_BLOCK__`, and `__COOLDOWN_BLOCK__` each sit\n   alone on a 4-space-indented line in the template. When a block\n   resolves to **empty** (`__VERSIONING_STRATEGY_BLOCK__` on every\n   non-npm\u002Fpip ecosystem), **drop the entire placeholder line** — do not\n   leave a whitespace-only line, which would be spurious diff noise on\n   re-run.\n\n3. Concatenate the rendered blocks.\n4. Read the outer template `gh-repo-setup-protection\u002Fdependabot.yml`,\n   strip its leading comment block, and substitute\n   `__DEPENDABOT_ECOSYSTEMS__` with the concatenated blocks (and\n   `__DEFAULT_BRANCH__` if it appears).\n\nThis produces the **desired file content**.\n\n**Explicitly out of this generated baseline (deferred to skill V3,\nissue #51).** Domain dependency groups (e.g. `fastapi-stack`,\n`aws-cdk`, `vite-toolchain`), `exclude-paths`, and `assignees` are\n**not** part of this template — they are repo-specific and cannot be\ninferred for an arbitrary repo. A future V3 of the skill will collect\nthem interactively and converge them. Do not add them to the generated\nblock here.\n\n### Converge (idempotency)\n\n- If `\u003Crepo-root>\u002F.github\u002Fdependabot.yml` does **not** exist: write it.\n- If it **exists**:\n  - Parse both the existing file and the desired content as YAML and\n    compare the normalized structures. If they are **semantically\n    equal**, do nothing and report \"dependabot.yml already converged\".\n  - If they **differ**, the convergence rule is **whole-file replace\n    with the rendered desired content**, NOT append. Appending is what\n    produces duplicate ecosystem blocks on re-run; this skill owns the\n    file's shape, so it overwrites. Before overwriting, show the user a\n    diff (existing vs. desired) and note any `updates:` entries in the\n    existing file that the skill would drop (e.g. a hand-added\n    ecosystem the detection missed, or custom `ignore:`\u002F`reviewers:`\n    blocks). **Halt and ask** before overwriting a file that contains\n    entries the render would lose — the user may want those preserved.\n    If the existing file's only differences are ones the render\n    subsumes, overwrite and report.\n\nNever write the file with unresolved `__...__` placeholders. If any\nremain after substitution, abort per the README's unresolved-\nplaceholder rule.\n\n## Step 4: GHAS \u002F repo security settings (convergent toggles)\n\nSkip this entire step if `--ghas=off`.\n\nThese are **remote settings**, applied via the GitHub API. Each one is\nread first and only written when it differs from the desired state, so\nre-running is a no-op. None of these toggles costs money for **public**\nrepos; for **private** repos, secret scanning \u002F push protection and\nCodeQL require a GitHub Advanced Security entitlement — detect the lack\nof entitlement and skip gracefully rather than erroring.\n\n### 4a. Dependabot alerts + security updates\n\n```bash\n# Read current state.\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fvulnerability-alerts \\\n  --silent && echo \"alerts: enabled\" || echo \"alerts: disabled\"\n```\n\nEnable (idempotent — PUT is safe to repeat):\n\n```bash\ngh api --method PUT repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fvulnerability-alerts\ngh api --method PUT repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fautomated-security-fixes\n```\n\n`vulnerability-alerts` returns 204 whether or not it was already on;\ntreat any 2xx as success and report \"Dependabot alerts: enabled\".\n\nDependabot **malware alerts** are a separate, *settings-level* toggle —\nthey are NOT a `dependabot.yml` key (that file controls version updates\nand alert *rules*, not malware-alert *enablement*). Malware alerts\nrequire Dependabot alerts to be on (enabled just above) and are\n**npm-only today**. There is no documented public per-repo REST\nendpoint for this toggle as of this writing (it is managed from the\nrepo's *Code security* settings UI). There is therefore **no enable\nPATCH to make** — the `security_and_analysis[dependabot_security_updates]`\nfield is the Dependabot *security-updates* feature (already enabled by\nthe `automated-security-fixes` PUT above), **not** malware alerts, so\npoking it would be a misdirected no-op against an already-on, unrelated\nsetting. The skill instead reads-to-report and surfaces the one manual\nstep:\n\nRead the repo's `security_and_analysis` block to *report* the malware-\nalert state if it is exposed; otherwise report\n\"Dependabot malware alerts: enable in the repo's Code security settings\n(npm-only; no public REST toggle)\" so the operator finishes the one\nmanual step. Never hard-fail on the absence of the endpoint. See\n\u003Chttps:\u002F\u002Fdocs.github.com\u002Fen\u002Fcode-security\u002Fhow-tos\u002Fsecure-your-supply-chain\u002Fsecure-your-dependencies\u002Fconfigure-malware-alerts>.\n\n**Grouped security updates** (batching security PRs per ecosystem into\none PR) are driven two ways, and the skill owns the deterministic one:\n\n- The per-repo\u002Forg *Code security* settings toggle (UI; no stable\n  public REST toggle) controls grouping for ecosystems **not**\n  configured in `dependabot.yml`.\n- The `dependabot.yml` `groups:` key with `applies-to: security-updates`\n  controls grouping for the configured ecosystems — this is the\n  in-file, deterministic mechanism the skill renders (Step 3). Because\n  the rendered `dependabot.yml` already carries a per-ecosystem\n  `security-updates` group, security PRs for every configured ecosystem\n  are grouped regardless of the settings toggle. Report\n  \"Grouped security updates: configured via dependabot.yml\n  (applies-to: security-updates)\".\n\n### 4b. Per-repo Code Security (GHAS) enablement (entitlement-gated)\n\nWhen the org\u002Frepo is **GHAS-entitled**, enable per-repo Code Security\n(Advanced Security). This is the lever that makes secret scanning,\npush protection, and CodeQL available on a *private* repo. The skill\nmust *enable* it when entitlement is present — not merely detect its\n*absence* to skip CodeQL.\n\nRead the current state, then enable iff entitled and not already on.\nRead the **granular `code_security`** field, not the deprecated\n`advanced_security` toggle: GitHub split the single Advanced Security\ntoggle into granular fields (`code_security`, `secret_scanning`, …),\nand on a fully-entitled repo the legacy `advanced_security` field reads\n`absent` while `code_security.status` reads `enabled`. Reading the\nlegacy field therefore mis-detects an entitled repo as unentitled.\nTreat the repo as **entitled** when `code_security.status == \"enabled\"`:\n\n```bash\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  --jq '.security_and_analysis.code_security.status \u002F\u002F \"absent\"'\n```\n\n```bash\n# Only attempt on a private repo (public repos get these features free\n# and have no code_security toggle). A 422 \"Advanced Security is\n# not enabled for this account\u002Forg\" means the org is not entitled —\n# report and skip, do not hard-fail.\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -f 'security_and_analysis[code_security][status]=enabled' \\\n  2>\u002Fdev\u002Fnull \\\n  && echo \"Code Security: enabled\" \\\n  || echo \"Code Security: skipped (org not GHAS-entitled)\"\n```\n\nReport `enabled (was already on)`, `enabled (changed)`, or\n`skipped (org not GHAS-entitled)`. Enabling this is what makes the\nsecret-scanning\u002Fpush-protection PATCH below succeed on a private repo.\n\n### 4c. Secret scanning + push protection (entitlement-gated)\n\nRead the current security-and-analysis block:\n\n```bash\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  --jq '.security_and_analysis'\n```\n\nBuild the desired patch and only PATCH the fields that differ. **Always\nre-assert these on every run** — an org-level Code Security change can\nflip `secret_scanning_push_protection` back to disabled, so a converge\nrun must set it back on even if a prior run already enabled it:\n\n```bash\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -f 'security_and_analysis[secret_scanning][status]=enabled' \\\n  -f 'security_and_analysis[secret_scanning_push_protection][status]=enabled'\n```\n\nIf this PATCH returns 422 \u002F \"Advanced Security is not enabled for this\nrepository\" (the common case on an unentitled private repo), do\n**not** treat it as a hard failure: report\n\"secret scanning unavailable (no GHAS entitlement on this private\nrepo); skipping\" and continue. Public repos get secret scanning for\nfree, so the PATCH succeeds there.\n\nAlways report, for each toggle, one of: `enabled (was already on)`,\n`enabled (changed)`, or `skipped (\u003Creason>)`. That report is the\nevidence the run converged.\n\n### 4d. Lock down push-protection bypass\n\nPush protection's default bypass list is **\"Anyone with write access\"**.\nThe hardened state is **nobody** — restrict bypass to a specific\nrole\u002Fteam set whose membership is empty, so a blocked secret push must\ngo through a bypass *request* rather than a self-serve override.\n\nThis is GitHub's *delegated bypass* for push protection. As of this\nwriting it is configured through an **org-level security configuration**\n(`secret_scanning_delegated_bypass_options` on the security-configuration\nAPI, then attached to the repo) and a repo-level\n`secret_scanning_delegated_bypass` enablement — there is **no clean,\nstable per-repo public REST toggle** that sets the bypass list to\n\"nobody\" directly. The skill therefore:\n\n```bash\n# Best-effort: enable delegated bypass at the repo level so bypass\n# becomes request-gated rather than self-serve. The reviewer\u002Frole list\n# (the \"who may bypass\" set) is configured in the org security\n# configuration; the skill cannot set an empty reviewer list through a\n# stable public per-repo endpoint, so it enables delegated bypass and\n# reports the residual manual step.\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -f 'security_and_analysis[secret_scanning_delegated_bypass][status]=enabled' \\\n  2>\u002Fdev\u002Fnull || true\n```\n\nReport the outcome honestly: if the enablement succeeded, report\n\"Push-protection bypass: delegated bypass enabled (set the bypass\nreviewer list to an empty role\u002Fteam in the org security configuration\nto reach 'nobody')\". If the endpoint is unavailable (422\u002F404), report\n\"Push-protection bypass: configure 'who can bypass' = nobody in the\nrepo's Code security settings (no stable public REST toggle)\". Never\nhard-fail — surface the residual manual step instead of inventing an\nendpoint that may not exist.\n\n### 4e. Merge-button \u002F PR-hygiene repo settings (convergent toggles)\n\nThe repo's General-settings merge button stays at GitHub defaults\nunless something converges it. The `protect-main` ruleset's\n`allowed_merge_methods: [\"merge\"]` (Step 6) constrains only the\n*ruleset's* merge enforcement — it does **not** flip the repo-level\n`allow_squash_merge` \u002F `allow_rebase_merge` toggles, so the merge\nbutton still offers squash and rebase. This step converges the five\nmerge-button \u002F PR-hygiene fields directly, the same read-then-PATCH,\nre-asserted-every-run, idempotent way the GHAS toggles do. These are\n**remote settings**, not file edits, so they apply directly (not via\nthe Step 7 PR). This step runs under `--ghas` (skip it when\n`--ghas=off`, like the other remote toggles).\n\nDesired hardened state:\n\n| UI setting | REST field | Desired |\n| --- | --- | --- |\n| Allow squash merging | `allow_squash_merge` | `false` |\n| Allow rebase merging | `allow_rebase_merge` | `false` |\n| Suggest updating PR branches | `allow_update_branch` | `true` |\n| Allow auto-merge | `allow_auto_merge` | `true` |\n| Auto-delete head branches | `delete_branch_on_merge` | `true` |\n\n`allow_merge_commit` is left `true` (consistent with the ruleset's\n`allowed_merge_methods: [\"merge\"]`) — do not flip it off, or the repo\nwould have no enabled merge method.\n\nRead the current values first, then PATCH only when they differ so a\nconverged re-run is a no-op:\n\n```bash\n# Read current state.\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  --jq '{allow_squash_merge, allow_rebase_merge, allow_update_branch,\n         allow_auto_merge, delete_branch_on_merge}'\n```\n\n```bash\n# Re-assert the desired state (idempotent — PATCH with the same values\n# is a no-op server-side; only PATCH the fields that differ, or PATCH\n# all five — both converge).\ngh api --method PATCH repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n  -F allow_squash_merge=false \\\n  -F allow_rebase_merge=false \\\n  -F allow_update_branch=true \\\n  -F allow_auto_merge=true \\\n  -F delete_branch_on_merge=true\n```\n\nAll five are documented public REST fields on the repository object.\nReport each as `unchanged` (already at desired) or `changed` (was at a\ndifferent value). This step is convergent and never hard-fails; a\nprivate repo with no special entitlement still accepts these\nGeneral-settings PATCHes (they are not GHAS-gated).\n\n## Step 5: CodeQL — opt-in, never auto-forced\n\n### CodeQL is opt-in\n\nCodeQL must not be assumed for every repo. The hazard is concrete and\nhas happened twice on `global-claude-config`:\n\n- **Issue #91**: a CodeQL workflow on a repo with no analyzable language\n  produced a phantom required check that hung PRs on \"Waiting for Code\n  scanning results\" forever.\n- **Issue #230 (PR #226 → #227)**: CodeQL **default setup** was enabled\n  server-side with a pinned language list `[actions, python]`. The repo\n  has zero Python, so `CodeQL \u002F Analyze (python)` failed on every PR and\n  blocked merges. Default and advanced setup cannot coexist; the fix\n  (PR #227) was an Actions-only advanced `codeql.yml` plus disabling\n  default setup out-of-band.\n\nThe rationale, inlined here so it does not depend on any other rule\nfile: a CodeQL check becomes a **phantom failing\u002Fhung required check**\nwhenever the workflow's analysis cannot succeed — either because no\nanalyzable language is present, or because a server-side default-setup\nlanguage list does not match the repo. Such a check blocks every PR.\nTherefore CodeQL is opt-in, the skill reads the existing server-side\nsetup mode before writing (Step 5a below), and it never enables CodeQL\nfor a language the repo cannot analyze.\n\n\"Opt-in\" means: **auto-detection never turns CodeQL on for an\nunentitled-private repo.** It does *not* mean the skill refuses an\nexplicit operator request. `--codeql=on` is an operator override — the\noperator has decided CodeQL belongs on this repo, and the skill honors\nthat by installing the workflow. The distinction matters: the danger\nthe policy guards against is CodeQL silently *auto*-resolving on\n(recreating issue #91), not an operator deliberately enabling it.\n(Before Step 2 made `actions` the always-present floor, a markdown-only\nrepo was also an auto-skip case; it no longer is, because every repo\nthe skill touches gets workflows and therefore the `actions` analyzable\nlanguage. The one auto-skip left is the unentitled-private repo.) So:\n\nResolve whether CodeQL is wanted, in this order:\n\n1. `--codeql=on` → CodeQL on. `--codeql=off` → CodeQL off (skip Step 5\n   entirely; if a `codeql.yml` workflow already exists, report it and\n   do **not** delete it — removing a security workflow is a decision\n   for the user).\n2. `--codeql=auto` (default) → **auto-detect**:\n   - **Off** if the repo is **private AND not GHAS-entitled**. CodeQL\n     on an unentitled private repo recreates the issue #91\n     phantom-check problem. **Determine entitlement independently of\n     Step 4 — do not rely on Step 4 having run.** Step 4 is skipped\n     entirely under `--ghas=off`, so the auto-detect must read the\n     entitlement signal itself with a read-only call that is safe to\n     make regardless of `--ghas`:\n\n     ```bash\n     # isPrivate captured in Step 1. Read the granular code_security\n     # field, not the deprecated advanced_security toggle — the legacy\n     # field reads \"absent\" on a fully-entitled repo and would mis-detect\n     # entitlement (see Step 4b).\n     gh api repos\u002F__GH_ORG__\u002F__GH_REPO__ \\\n       --jq '.security_and_analysis.code_security.status \u002F\u002F \"absent\"'\n     ```\n\n     Treat the repo as **not entitled** when `isPrivate` is `true` AND\n     that status is `disabled` or `absent`. Equivalently, the repo is\n     **entitled** when `code_security.status == \"enabled\"`. When\n     `--ghas=on` and Step 4b already ran, its no-entitlement 422 is an\n     equivalent signal and may be reused; but the read above is the\n     source of truth so the determination is identical whether or not\n     Step 4 ran. This closes the `--ghas=off` bypass: on a private,\n     unentitled repo with workflow files (this repo's shape — `actions`\n     is an analyzable language), `--ghas=off` must still resolve CodeQL\n     **off**, never let it auto-resolve **on**.\n   - The old \"no analyzable language → off\" auto-skip is **gone.** The\n     CodeQL workflow is armed with the **full supported language set**\n     and narrows to the present languages at **runtime** via its\n     `detect` job (Step 5b). `actions` is an always-present floor (the\n     skill installs workflows), so at least one leg always runs on an\n     entitled-or-public repo, and the `codeql-required` aggregator\n     passes green even when the runtime matrix is empty. There is\n     therefore no install-time language check to fail — the only\n     off-branch left in `auto` is the **private + unentitled** case\n     above. A repo mid-transition (e.g. Python today, TypeScript\n     tomorrow) gets its new-language leg the moment the first `.ts` file\n     lands, with **no skill re-run** — the exact ordering inversion this\n     issue fixes.\n   - **On** otherwise (public repo, or entitled private repo).\n3. Do not ask — a public (or entitled private) repo resolves CodeQL\n   **on**. The runtime matrix (armed full set, narrowed to present) is\n   never a deadlock: an absent language produces no leg, and the\n   aggregator is green on an empty matrix. (The only off-resolutions\n   left are the private-unentitled and the explicit `--codeql=off`\n   cases.)\n\n**No install-time empty-matrix hazard (why the old hard stop is gone).**\nThe old \"no-supported-language hard stop\" existed because the former\nstatic CodeQL language-list matrix could be authored **empty**, producing\na check that can never pass and deadlocks branch protection (issue #230's\nfailure mode). That hazard **no longer exists**: the workflow is armed\nwith the full supported set and the analyze matrix is built at runtime\nfrom `codeql-language-present.sh --matrix`. An empty runtime matrix (no\nanalyzable language present) spawns **zero** analyze legs and the\n`codeql-required` aggregator concludes **success** (`if: always()` +\nempty-matrix pass), so the PR is mergeable, never hung. `--codeql=on`\noverrides the *entitlement* auto-skip and installs the armed workflow;\nthere is no separate language check for it to override, because the\nruntime matrix cannot deadlock.\n\n**Always report the CodeQL decision and the reason**, e.g.\n\"CodeQL: off (auto — private repo without GHAS entitlement)\" or\n\"CodeQL: on (armed with the full supported language set; runtime matrix\nnarrows to present languages per PR)\".\n\n### 5a. Read the server-side CodeQL setup mode before writing\n\nThis is the fix for the issue #230 wedge. **Before installing advanced\nsetup, read GitHub's server-side CodeQL setup mode** — the skill must\nnot write a `codeql.yml` blind to a default setup already running with a\ndifferent (possibly wrong) language list. Default setup and advanced\nsetup (a `codeql.yml` workflow) **cannot coexist**; default setup runs\nits own language list independently of any workflow file, which is\nexactly how `Analyze (python)` failed on a repo with zero Python.\n\nRead the current mode (read-only, safe regardless of `--ghas`). Only a\nclean `403` (unentitled) or `404` (code-scanning disabled \u002F no default\nsetup) means \"not configured\" — **every other non-zero exit\n(`5xx`, rate limit, auth expiry, network\u002Ftransport failure) is a hard\nstop**, because silently treating a transient failure as\n\"not-configured\" would skip the disable-default-setup step and\nre-trigger the exact wedge issue #230 fixes. Capture the HTTP status\nand branch on it:\n\n```bash\n# jq parses the response body below. If it is missing, the body parse\n# would silently yield an empty $setup and fall through to the decision\n# table with a state that is neither configured nor not-configured —\n# the exact issue #230 wedge, triggered by a missing binary. Hard-stop\n# up front instead, in the same style as the default (*) branch below.\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || {\n  echo \"ERROR: jq is required to read the CodeQL default-setup mode\" \\\n       \"for __GH_ORG__\u002F__GH_REPO__ but is not installed \u002F not on PATH.\" \\\n       \"jq is a hard dependency of the global config (its hooks need\" \\\n       \"it too). Install jq and re-run this skill rather than letting\" \\\n       \"the skill proceed blind to an empty CodeQL state (issue #230).\" >&2\n  exit 1\n}\n\n# Make a SINGLE request: -i emits the response headers AND the JSON\n# body in one response, so we parse both the HTTP status line and the\n# body from the same fetch — no second call, no transient-failure\n# window between two reads. Without letting a non-zero exit abort the\n# script; 2>\u002Fdev\u002Fnull suppresses gh's stderr so a transport failure\n# leaves the response empty (status parses to empty → default case).\nresponse=$(\n  gh api -i repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fcode-scanning\u002Fdefault-setup \\\n    2>\u002Fdev\u002Fnull\n)\nhttp_status=$(\n  printf '%s\\n' \"$response\" \\\n    | sed -n '1s\u002F^HTTP\\\u002F[0-9.]* \\([0-9]*\\).*\u002F\\1\u002Fp'\n)\n\ncase \"$http_status\" in\n  200)\n    # Extract the body (everything after the first blank line that\n    # separates headers from body) and pull state\u002Flanguages from it.\n    # No second network call — the body came back with the status above.\n    setup=$(\n      printf '%s\\n' \"$response\" \\\n        | sed -n '1,\u002F^[[:space:]]*$\u002Fd;p' \\\n        | jq '{state: .state, languages: .languages}'\n    )\n    ;;\n  403|404)\n    # Unentitled, or code-scanning disabled \u002F no default setup.\n    setup='{\"state\":\"not-configured\",\"languages\":null}'\n    ;;\n  *)\n    # Empty status = curl\u002Ftransport failure; any other status (5xx,\n    # 429 rate limit, 401 auth expiry, etc.) = a non-clean failure.\n    # Do NOT assume \"not-configured\" — halt and tell the operator.\n    echo \"ERROR: could not read CodeQL default-setup mode for\" \\\n         \"__GH_ORG__\u002F__GH_REPO__ (HTTP status: ${http_status:-none —\" \\\n         \"transport\u002Fnetwork failure}). This is not a clean 403\u002F404,\" \\\n         \"so the skill will NOT assume CodeQL is unconfigured —\" \\\n         \"doing so could skip disabling a live default setup and\" \\\n         \"re-wedge branch protection (issue #230). Re-run this skill\" \\\n         \"once the GitHub API is reachable.\" >&2\n    exit 1\n    ;;\nesac\n\necho \"$setup\"\n```\n\n(`state` is `configured` or `not-configured`. Only a clean `403`\n(unentitled) or `404` (code-scanning disabled \u002F no default setup) is\nmapped to `not-configured`; **any other non-zero exit — `5xx`, `429`\nrate limit, `401` auth expiry, or a curl\u002Ftransport failure — is a hard\nstop, not a silent \"not-configured\".** A transient failure misread as\n\"not-configured\" would skip the disable step below and re-create the\nissue #230 wedge, so the skill aborts and asks the operator to re-run\nonce the API is reachable rather than proceeding blind.)\n\n**The core invariant: default setup and an advanced `codeql.yml`\ncannot coexist.** A repo with a working advanced workflow MUST have\ndefault setup `not-configured` — that is the correct, intended end\nstate, not an incidental \"nothing to disable.\" The advanced workflow\nbeing committed is precisely what forces default setup to stay off\n(the leading comment in `gh-repo-setup-protection\u002Fcodeql.yml` says\nthis); the report wording below matches that framing. `configured`\ndefault setup alongside an advanced workflow is the issue #230 wedge,\nto be disabled with operator confirmation.\n\nDecision table once CodeQL has resolved **on** (Step 5) and you are\nabout to install advanced setup:\n\n- **default setup `not-configured`** → this is the **correct\n  mutually-exclusive state**: advanced setup active, default setup\n  correctly off, because the two cannot coexist. Nothing to disable;\n  proceed to render the workflow (5b). Report \"default setup: correctly\n  not configured (advanced setup active — the two cannot coexist)\".\n- **default setup `configured`** → it conflicts with the advanced\n  workflow (the issue #230 wedge). **Show the operator the detected\n  `state` and `languages`, and ask for confirmation** before disabling\n  it. On confirmation, disable it out-of-band, then proceed to render:\n\n  ```bash\n  gh api --method PATCH \\\n    repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Fcode-scanning\u002Fdefault-setup \\\n    -f state=not-configured\n  ```\n\n  If the operator declines, do **not** install the advanced workflow\n  (the two cannot coexist); report \"CodeQL: left as server-side default\n  setup at operator's request; advanced workflow not installed\" and\n  skip the render. Never install advanced setup alongside a live default\n  setup.\n\nReport what was found and what changed, e.g. \"default setup: was\nconfigured (languages: actions, python) → disabled (operator confirmed);\ninstalling advanced setup\".\n\nWhen CodeQL has resolved **off**, do not PATCH default setup off on the\nskill's own initiative — disabling an existing server-side scan is a\nsecurity-posture change the operator owns. Report the detected default\nsetup state so the operator can act if they want to.\n\n### 5a-bis. Preserve a newer SHA-pinned action pin (never downgrade)\n\nThe workflow converges (Steps 5b, 5c, 5c-pinned, 5d) take the\n**payload** content\nas the base, but they must **never downgrade an action pin the repo\nalready has pinned to a newer release**. Doing so would silently roll\nback a deliberate operator upgrade — a regression. This sub-step\ndefines the pin-reconciliation pass each of those converges applies to\nthe desired content **before** the semantic-compare, generically to\n**every** `uses:` line (checkout, codeql-action, setup-node,\nsetup-python, and any future action).\n\n**Convergence never even offers to bump a pin down.** There is no\nprompt. For each `uses: \u003Cowner>\u002F\u003Crepo>[\u002F\u003Cpath>]@\u003Cref>` line in the\nrendered desired content, find the corresponding line in the existing\nrepo file (matched by `\u003Cowner>\u002F\u003Crepo>[\u002F\u003Cpath>]`, the action coordinate\nwithout the `@\u003Cref>`). If the repo's pin is **strictly newer and\nSHA-pinned**, keep the repo's pin (its SHA **and** its trailing\n`# vX.Y.Z` comment) in the desired content; otherwise take the\npayload's pin. Concretely, for each matched action coordinate:\n\n- Repo's resolved tag **strictly newer AND the repo's ref is a 40-hex\n  SHA** → keep the repo's `uses:` line verbatim in the desired content.\n- Repo's pin **older, equal, or floating** (the ref is a tag like `@v6`\n  or a branch, not a 40-hex SHA) → take the payload's pin.\n- An action coordinate that appears only in the payload (no matching\n  `uses:` in the repo file) → take the payload's pin (nothing to\n  preserve).\n\n**\"Newer\" is derived from the SHA, not the trailing comment.** The\ntrailing `# vX.Y.Z` comment is operator-written and may lie, so it is\n**display-only** and never used for the comparison. To compare two\nSHA-pinned refs, resolve **both** the repo's SHA and the payload's SHA\nagainst the action's upstream repo and compare the resolved release\ntags by semver:\n\n```bash\n# Resolve a commit SHA to the release tag that points at it.\n# --paginate: the tags list spans multiple pages on actions with many\n# releases; without it a matching tag on page 2+ is missed and the SHA\n# is wrongly treated as unresolvable (downgrading a genuinely-newer pin).\ngh api --paginate repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Ftags --jq \\\n  \".[] | select(.commit.sha == \\\"\u003Csha>\\\") | .name\"\n```\n\nWhen a tag does not point directly at the commit (e.g. the SHA is a\ntagged commit reached via `git rev-parse \u003Ctag>^{commit}`), fall back to\nmatching the SHA against each candidate tag's dereferenced commit via\n`gh api --paginate repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fgit\u002Frefs\u002Ftags` (again\n`--paginate`, so a tag ref on a later page isn't missed). Compare the\ntwo resolved tags with semver (`vMAJOR.MINOR.PATCH`).\n\n**Unresolvable → take the payload's pin.** If **either** SHA cannot be\nresolved to an upstream tag — a deleted tag, a fork, a private action,\nor an API \u002F network failure — do **not** guess and do **not** keep the\nrepo's pin. Take the **payload's** pin (the skill's owned, known-good\nvalue). Resolution failure is never treated as \"repo is newer\".\n\nAfter this pass, the desired content differs from the raw payload only\nwhere a repo pin was kept for being strictly-newer-and-SHA-pinned. The\nsubsequent semantic-compare (Steps 5b\u002F5c\u002F5c-pinned\u002F5d) then runs against this\n**pin-reconciled** desired content: if the only remaining difference\nbetween the existing file and the payload was those kept newer pins,\nthe file compares **equal** and is reported \"unchanged\" — no\ndowngrade, no halt. \"Match the payload\" thus explicitly **excludes**\ndowngrading a deliberately-newer SHA-pinned repo pin.\n\n### 5b. Render and converge the CodeQL workflow (only when CodeQL is on)\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fcodeql.yml`\n- `\u003Crepo-root>\u002F.github\u002Fcodeql\u002Fcodeql-config.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fcodeql-language-present.sh`\n\n**There is no install-time CodeQL language-list placeholder any more.**\nThe workflow is armed with the **full supported CodeQL language set** and\nnarrows to the present languages at **runtime**: its `detect` job runs\n`codeql-language-present.sh --matrix`, which emits a JSON array of\n`{ language, runner }` matrix entries for exactly the languages present\nin the tracked tree, and the `analyze` job builds its matrix from that\narray via `fromJSON`. So the language set is decided per PR at runtime,\nnever frozen at install time.\n\n1. Render `gh-repo-setup-protection\u002Fcodeql.yml` (strip its leading\n   comment block) substituting **only** `__DEFAULT_BRANCH__`. The\n   template has no language placeholder.\n2. `codeql-config.yml` has no placeholders — keep its `name:`\u002F`queries:`\n   body; it has no leading placeholder-doc comment block to strip, so it\n   ships as-is.\n3. `codeql-language-present.sh` has no placeholders — ship it\n   **verbatim** (including its leading comment block; it is a shell\n   script whose header documents its own behavior), with the executable\n   bit set (`chmod +x`). It is the SAME `git ls-files` predicate the\n   analyze matrix is built from, so \"what detect thinks is present\"\n   cannot drift from what the analyze legs run. The `swift` entry it\n   emits carries `runner: macos-latest`; every other language carries\n   `runner: ubuntu-latest`, so a Swift-less repo never provisions macOS.\n\nFirst apply the **pin-reconciliation pass (Step 5a-bis)** to the\nrendered `codeql.yml` — keep any `uses:` pin the repo already has\npinned to a strictly-newer SHA, never downgrade. Then converge each\ntarget as in Step 3 against that pin-reconciled content: if the target\nfile is absent, write it; if present and **semantically equal**, do\nnothing; if present and different, show the diff and halt before\noverwriting. Whole-file replace, never append. The `.sh` uses a\nnormalized-text\u002Fbyte compare (it is a shell script, not YAML), like the\ngate scripts.\n\n## Step 5c: Render and converge the dependency-install-gate (drift guard)\n\nA drifted `package.json`\u002Flockfile (or an unresolvable requirements pin)\ncan desync from its manifest via a Dependabot PR or a hand edit; without\na PR-time gate the desync auto-merges into the default branch and breaks\nlocal dev and downstream pipelines. This step installs a\n**dependency-install-gate** — a `pull_request` workflow armed with the\n**full supported set** of package managers (`npm`, `pip`, `pnpm`,\n`yarn`) that replays the lockfile \u002F runs a resolver pre-flight over\nevery discovered manifest and fails the PR on drift. The artifact is\nported from the proven `ExampleProject\u002Fexample-app-repo` gate.\n\n**Runtime dynamic-matrix, not install-time-narrowed jobs.** The workflow\nhas three jobs: a `detect` job that runs\n`dependency-install-gate.sh --present` (the SAME `git ls-files`\ndiscovery the gate checks with) and emits a JSON array of the PMs whose\nmanifest is present right now; a matrixed `gate` job over\n`fromJSON(needs.detect.outputs.pms)`, so a leg exists for a PM **iff**\nits lockfile\u002Fmanifest is in the tree at that moment; and an\n`install-gate-required` aggregator. A PM whose manifest lands **after**\nsetup lights its leg up on the next PR, with **no skill re-run** — the\nordering-inversion fix.\n\n**Why per-PM legs, not one Node job.** Each Node package manager keys\noff its **own** lockfile (npm → `package-lock.json`, pnpm →\n`pnpm-lock.yaml`, yarn → `yarn.lock`). A single npm-only job discovers\nnothing on a pnpm\u002Fyarn repo, hits its no-manifests-green branch, and\nexits 0 — a **dead check that gives false assurance** while the very\n`package.json`↔lockfile desync it exists to catch merges anyway\n(issue #111). One matrix leg per manager, each keyed off its own\nlockfile, closes that gap.\n\n### The aggregator is the required check (not the per-PM legs)\n\nGitHub `required_status_checks` is a static list of names and cannot\nexpress \"require the `npm` leg only if it runs\". So the per-PM legs\n(`Install gate (\u003Cpm>)`) are **visible** but **not** individually\nrequired; the always-running `install-gate-required` aggregator (stable\nname) is the single required check. It `needs:` the matrixed `gate` job,\nruns `if: always()`, and concludes:\n\n- **success** when the matrix was empty (no PM present) — so a\n  manifest-less repo is **mergeable, not hung**;\n- **success** when every spawned leg succeeded;\n- **failure** when any leg failed or was cancelled.\n\nThe `if: always()` is **mandatory**: without it the aggregator is\n*skipped* on an empty matrix, and a required check treats \"skipped\" as\nnot-passed → the #91\u002F#230 phantom-check hang returns. Step 6c registers\n`install-gate-required`, never a per-leg name.\n\n### Render the gate files\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fdependency-install-gate.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fdependency-install-gate.sh`\n\n1. Render `gh-repo-setup-protection\u002Fdependency-install-gate.yml` (strip\n   its leading comment block) substituting **only** `__DEFAULT_BRANCH__`.\n   The actions are SHA-pinned in the template (with the human-readable\n   tag in a trailing comment), matching the `codeql.yml` convention — do\n   not de-pin them. There is **no** per-job delimiter-comment rendering\n   any more: the workflow ships with the full detect → matrix →\n   aggregator shape, armed with all four PMs, and narrows at runtime.\n2. `dependency-install-gate.sh` has no placeholders — ship it\n   **verbatim** (including its leading comment block; it is a shell\n   script whose header documents its own behavior). The script accepts\n   all four modes (`npm`, `pip`, `pnpm`, `yarn`), the `--present` mode\n   the detect job calls, and no-ops gracefully (exit 0) for any mode\n   whose lockfile the repo lacks. The `--present` mode reuses the same\n   discovery predicate, so the runtime matrix cannot drift from what the\n   gate checks. Ship it with the executable bit set (`chmod +x`).\n\nThe gate ships **unconditionally** whenever the skill installs\nworkflows — there is no \"empty resolved set → skip the file\" case any\nmore, because the workflow is armed with the full set and gates at\nruntime (an absent PM produces no leg and a green aggregator, so it is\nnever dead weight or noise). Both files are always written together\n(the workflow calls the script).\n\nNever write the `.yml` with an unresolved `__DEFAULT_BRANCH__`. If it\nremains after rendering, abort per the README's unresolved-placeholder\nrule.\n\n### Converge the gate files (idempotency)\n\nApply the same **whole-file-replace + semantic-compare** rule the skill\nuses for `dependabot.yml`\u002F`codeql.yml`, with one difference in the\ncompare method per file type. For the `.yml`, first apply the\n**pin-reconciliation pass (Step 5a-bis)** to the rendered desired\ncontent so a repo's strictly-newer SHA-pinned action (e.g. a\n`actions\u002Fcheckout` the operator already bumped past the payload's) is\n**kept, never downgraded**, before the semantic-compare:\n\n- **`dependency-install-gate.yml`** — YAML semantic-compare (parse both\n  the existing file and the pin-reconciled desired content as YAML,\n  compare normalized structures). Equal → \"unchanged\"; absent → write;\n  different → show the diff and halt before overwriting (whole-file\n  replace, never append). Because the workflow is now a fixed\n  full-set-armed shape (no per-job rendering), the compare is against\n  the same content every run — a converged repo re-runs as a no-op.\n- **`dependency-install-gate.sh`** — this is a shell script, **not**\n  YAML, so the semantic-compare is a **normalized-text\u002Fbyte compare**\n  (trailing-whitespace-normalized), not a YAML parse. Equal →\n  \"unchanged\"; absent → write (with the executable bit set, `chmod +x`);\n  different → show the diff and halt before overwriting.\n\nBoth files are written together: install both. Never install one without\nthe other (the workflow calls the script).\n\n## Step 5c-pinned: Render and converge the dependency-pinned-gate\n\n(The exact-version guard — sibling of the install-gate.)\n\nThe dependency-install-gate (Step 5c) protects the **lock** relationship\n— it fails a PR when a manifest and its lockfile have drifted. It does\n**not** check how the *manifest itself* declares versions. A\n`package.json` with `\"aws-cdk-lib\": \"^2.172.0\"`, a `requirements.txt`\nwith `boto3>=1.40`, a workflow `uses: actions\u002Fcheckout@v4`, or a\n`FROM node:22` resolves to a **different** concrete version over time\neven when the lockfile is perfectly in sync — the \"works on main, breaks\non rebase\" supply-chain drift that slips past a green install-gate. This\nstep installs the **dependency-pinned-gate** — the sibling of the\ninstall-gate — a `pull_request` workflow armed with the **full supported\nset** of ecosystems (`npm`, `pip`, `actions`, `docker`, `go`) whose\nper-ecosystem legs fail the PR when any *declared* dependency is not\npinned to an exact version (rejecting caret `^`, tilde `~`, comparators\n`>= \u003C= > \u003C`, hyphen\u002FX-ranges, OR-ranges, compatible-release `~=`,\nfloating action `@vN`\u002F`@main` tags, floating Docker `:latest`\u002Ftag-only\nrefs, and bare\u002Funpinned names).\n\n**Runtime dynamic-matrix, same shape as the install-gate.** A `detect`\njob runs `dependency-pinned-gate.sh --present` (the SAME `git ls-files`\ndiscovery the gate checks with) and emits a JSON array of the ecosystems\nwhose manifest is present; a matrixed `gate` job over\n`fromJSON(needs.detect.outputs.ecosystems)` runs one leg per present\necosystem; and a `pinned-gate-required` aggregator is the single\nrequired check. `actions` is an always-present floor (the skill always\ninstalls workflow files). An ecosystem whose manifest lands **after**\nsetup (e.g. the repo's first `go.mod`) lights its leg up on the next PR,\nwith **no skill re-run**.\n\n**It is a separate gate from the install-gate** — its own workflow +\nscript, and its own aggregator (`pinned-gate-required`) is a separate\nrequired check from the install-gate's. Do not fold it into Step 5c; the\ntwo protect different properties (lock-drift vs. declared-version-\nfloating) and a repo may want one without the other.\n\n**Categorical exemptions live in the classifier, not an allowlist\nfile.** A small, fixed set of specs is *legitimately* not exact-pinnable\nand is exempt by category in the script (`dependency-pinned-gate.sh`),\nnever by a maintained per-package allowlist: npm `peerDependencies`\ncarets (ranges by design); `file:`\u002F`workspace:`\u002F`link:`\u002F`git+`\u002F`http(s):`\nprotocol specs (no registry version to pin); pnpm `catalog:`\u002F\n`catalog:\u003Cname>` specs (a REFERENCE into `pnpm-workspace.yaml`'s\n`catalog:`\u002F`catalogs:` sections, never a version itself — see \"Catalog\ndefinitions are validated at the source\" below); npm `engines` and pip\n`requires-python`\u002F`python_requires` (runtime\u002Ftoolchain floors, not\ndependency versions); npm `overrides`\u002F`resolutions` classified on the\noverride **value** (exact), never the selector **key** (whose caret is a\nmatch pattern); and Docker `tag@sha256:` digests (the tag floats but the\nimmutable digest is read, so the resolved image is exact). These were\nsettled empirically against the strict-pinned\n`Fablegate\u002Ffablegate_quasar_fastapi` monorepo (issue #90) — every\nnon-exact spec found there fell into this fixed set, so no escape-hatch\nfile is needed.\n\n**Catalog definitions are validated at the source.** A member\nmanifest's `catalog:`\u002F`catalog:\u003Cname>` spec is exempt above because it\ncarries no version — but the referenced catalog **entry** in\n`pnpm-workspace.yaml` must still be exact. The script checks this once,\nonly when the manifest under inspection sits beside the\n`pnpm-workspace.yaml` that defines the catalogs (i.e. it IS the\nworkspace root), so a non-exact catalog entry (e.g. `aws-cdk-lib:\n^2.172.0` under `catalog:`, or under a named `catalogs.\u003Cname>:` map) is\nreported once at the definition instead of once per consumer manifest\nthat references it via `catalog:`.\n\nFor **npm**, the depth is **direct deps + lockfile-present**: the\nhuman-authored specs in `package.json` must be exact, AND a lockfile must\nexist beside a deps-declaring manifest (an exact-pinned manifest with no\nlockfile still floats transitively). The lockfile-present check is\n**workspace-aware** (issue #170): a manifest with no sibling lockfile is\nstill accepted when an ancestor directory up to the repo root has both a\nlockfile and a workspace declaration (`pnpm-workspace.yaml` `packages:`\nglobs, or package.json `workspaces`) whose globs cover the manifest's\ndirectory — pnpm\u002Fnpm\u002Fyarn workspaces keep a single lockfile at the\nworkspace root by design. A manifest the workspace does not cover still\nfloats and stays a violation. Transitive pinning itself stays the\ninstall-gate's job.\n\n### The aggregator is the required check (not the per-ecosystem legs)\n\nExactly as the install-gate: the per-ecosystem legs\n(`Pinned gate (\u003Cecosystem>)`) are **visible** but **not** individually\nrequired; the always-running `pinned-gate-required` aggregator (stable\nname) is the single required check. It `needs:` the matrixed `gate` job,\nruns `if: always()`, and concludes **success** on an empty matrix (no\necosystem present → mergeable, not hung) or when every leg succeeded,\nand **failure** when any leg failed or was cancelled. The `if: always()`\nis **mandatory** for the empty-matrix-success property (a skipped\naggregator would hang the PR — #91\u002F#230). Step 6c registers\n`pinned-gate-required`, never a per-leg name.\n\n### Render the gate files (pinned-gate)\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fdependency-pinned-gate.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fdependency-pinned-gate.sh`\n\n1. Render `gh-repo-setup-protection\u002Fdependency-pinned-gate.yml` (strip\n   its leading comment block) substituting **only** `__DEFAULT_BRANCH__`.\n   The actions are SHA-pinned in the template — do not de-pin them (the\n   pinned-gate would flag its own workflow otherwise). There is **no**\n   per-job delimiter-comment rendering any more: the workflow ships with\n   the full detect → matrix → aggregator shape, armed with all five\n   ecosystems, and narrows at runtime.\n2. `dependency-pinned-gate.sh` has no placeholders — ship it\n   **verbatim** (including its leading comment block; it is a shell\n   script whose header documents its own classifier behavior). The\n   script accepts all five modes, the `--present` mode the detect job\n   calls, and no-ops gracefully (exit 0) for any mode whose manifest the\n   repo lacks. The `--present` mode reuses the same discovery predicate,\n   so the runtime matrix cannot drift from what the gate checks. Ship it\n   with the executable bit set (`chmod +x`).\n\nThe gate ships **unconditionally** whenever the skill installs\nworkflows — there is no \"empty resolved set → skip the file\" case any\nmore (an absent ecosystem produces no leg and a green aggregator). Both\nfiles are always written together (the workflow calls the script).\n\nNever write the `.yml` with an unresolved `__DEFAULT_BRANCH__`. If it\nremains after rendering, abort per the README's unresolved-placeholder\nrule.\n\n### Converge the gate files (idempotency, pinned-gate)\n\nApply the same **whole-file-replace + semantic-compare** rule the skill\nuses for the dependency-install-gate. For the `.yml`, first apply the\n**pin-reconciliation pass (Step 5a-bis)** to the rendered desired\ncontent so a repo's strictly-newer SHA-pinned action is **kept, never\ndowngraded**, before the semantic-compare:\n\n- **`dependency-pinned-gate.yml`** — YAML semantic-compare (parse both\n  the existing file and the pin-reconciled desired content as YAML,\n  compare normalized structures). Equal → \"unchanged\"; absent → write;\n  different → show the diff and halt before overwriting (whole-file\n  replace, never append). The workflow is a fixed full-set-armed shape,\n  so a converged repo re-runs as a no-op.\n- **`dependency-pinned-gate.sh`** — this is a shell script, **not** YAML,\n  so the semantic-compare is a **normalized-text\u002Fbyte compare**\n  (trailing-whitespace-normalized), not a YAML parse. Equal →\n  \"unchanged\"; absent → write (with the executable bit set, `chmod +x`);\n  different → show the diff and halt before overwriting.\n\nBoth files are written together: install both. Never install one without\nthe other (the workflow calls the script).\n\n## Step 5d: Render and converge the no-back-merging-guard\n\nA feature branch that brings in upstream changes by **merging the\ndefault branch** (a \"back-merge\") instead of rebasing produces a tangled\nhistory: the PR diff carries unrelated base commits, and the merge\ncommit's incoming parent is reachable from `origin\u002F\u003Cdefault>`. This step\ninstalls a **no-back-merging-guard** — a `pull_request` workflow whose\nsingle job `no-back-merging-guard` walks the merge commits unique to the\nPR head branch and **rejects** any whose incoming (second) parent is\nreachable from the base branch tip, forcing rebase-not-merge. The\nartifact is ported verbatim (script + self-test) from the proven\n`Fablegate\u002Ffablegate_quasar_fastapi` guard (issue #51).\n\n### Ships unconditionally — no ecosystem gate\n\nUnlike the dependency-install-gate (npm\u002Fpip\u002Fpnpm\u002Fyarn-gated) and CodeQL\n(language\u002Fentitlement-gated), the no-back-merging-guard has **no\necosystem dependency**. It is pure git-history hygiene and is desirable\non **every** repo. So it ships **unconditionally** on every run (subject\nonly to the converge\u002Fsemantic-compare rules below). There is no flag to\ndisable it; managing branch-merge policy elsewhere is not a supported\nmode for this guard.\n\n### Render the guard files\n\nTarget paths:\n\n- `\u003Crepo-root>\u002F.github\u002Fworkflows\u002Fno-back-merging-guard.yml`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Fno-back-merging-guard.sh`\n- `\u003Crepo-root>\u002F.github\u002Fscripts\u002Ftest-no-back-merging-guard.sh`\n\n1. Render `gh-repo-setup-protection\u002Fno-back-merging-guard.yml` (strip its\n   leading comment block) substituting `__DEFAULT_BRANCH__`. This is the\n   only placeholder — it appears in the `on.pull_request.branches` filter\n   and in the explanatory comments. The per-PR base comparison is read\n   from `github.base_ref` at run time, so the guard still follows a\n   base-branch rename for the actual back-merge check; the\n   `__DEFAULT_BRANCH__` substitution only scopes which PRs the workflow\n   triggers on.\n2. `no-back-merging-guard.sh` and `test-no-back-merging-guard.sh` have\n   **no placeholders** — ship them **verbatim** (including their leading\n   comment blocks; they are shell scripts whose headers document their\n   own behavior, not placeholder blocks to strip). Set the executable\n   bit (`chmod +x`) on both when writing, matching the\n   `dependency-install-gate.sh` convention.\n\nNever write the `.yml` with an unresolved `__DEFAULT_BRANCH__`. If it\nremains after substitution, abort per the README's unresolved-\nplaceholder rule.\n\n### Converge the guard files (idempotency)\n\nApply the same **whole-file-replace + semantic-compare** rule the skill\nuses for the dependency-install-gate, with the per-file-type compare.\nFor the `.yml`, first apply the **pin-reconciliation pass (Step\n5a-bis)** to the rendered desired content so a repo's strictly-newer\nSHA-pinned `actions\u002Fcheckout` is **kept, never downgraded**, before the\nsemantic-compare:\n\n- **`no-back-merging-guard.yml`** — YAML semantic-compare (parse both the\n  existing file and the pin-reconciled desired content as YAML, compare\n  normalized structures). Equal → \"unchanged\"; absent → write; different\n  → show the diff and halt before overwriting (whole-file replace, never\n  append).\n- **`no-back-merging-guard.sh`** and **`test-no-back-merging-guard.sh`**\n  — these are shell scripts, **not** YAML, so the semantic-compare is a\n  **normalized-text\u002Fbyte compare** (trailing-whitespace-normalized), the\n  same rule used for `dependency-install-gate.sh`. Equal → \"unchanged\";\n  absent → write (with the executable bit set, `chmod +x`); different →\n  show the diff and halt before overwriting.\n\nAll three files are written together (the workflow invokes the script;\nthe self-test documents and verifies the script). Never install the\nworkflow without its script.\n\n## Step 6: Create \u002F converge the `protect-main` ruleset\n\nSkip this entire step if `--ruleset=off`.\n\nThe GHAS features above are half-measures without a ruleset that\nenforces review and required checks on the default branch. This skill\n**owns** the `protect-main` ruleset and converges it on every run, the\nsame read-then-reconcile way it converges the GHAS toggles. The proven\nreference shape is `ExampleProject\u002Fexample-app-repo`'s `protect-main`.\n\n### 6a. Read the existing ruleset\n\nA repository ruleset is identified by name, not a stable ID, so list\nand match on `name == \"protect-main\"`:\n\n```bash\n# Find an existing protect-main ruleset (empty output = none yet).\n# --paginate: the rulesets list can span multiple pages; without it a\n# protect-main ruleset on page 2+ is missed, wrongly concluding \"none\n# yet\" and creating a duplicate.\ngh api --paginate repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets \\\n  --jq '.[] | select(.name==\"protect-main\") | .id'\n```\n\nIf found, read its full body so you can compare against the desired\nshape and PUT only when it differs:\n\n```bash\ngh api repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets\u002F\u003CID>\n```\n\n### 6b. Build the desired ruleset body\n\nThe desired body (targets the default branch; `enforcement: active`):\n\n```json\n{\n  \"name\": \"protect-main\",\n  \"target\": \"branch\",\n  \"enforcement\": \"active\",\n  \"conditions\": {\n    \"ref_name\": { \"include\": [\"~DEFAULT_BRANCH\"], \"exclude\": [] }\n  },\n  \"bypass_actors\": [\n    { \"actor_id\": 5, \"actor_type\": \"RepositoryRole\", \"bypass_mode\": \"pull_request\" }\n  ],\n  \"rules\": [\n    { \"type\": \"deletion\" },\n    { \"type\": \"non_fast_forward\" },\n    {\n      \"type\": \"pull_request\",\n      \"parameters\": {\n        \"required_approving_review_count\": 1,\n        \"dismiss_stale_reviews_on_push\": true,\n        \"require_code_owner_review\": true,\n        \"require_last_push_approval\": true,\n        \"required_review_thread_resolution\": true,\n        \"required_reviewers\": [],\n        \"allowed_merge_methods\": [\"merge\"]\n      }\n    },\n    {\n      \"type\": \"required_status_checks\",\n      \"parameters\": {\n        \"strict_required_status_checks_policy\": true,\n        \"do_not_enforce_on_create\": false,\n        \"required_status_checks\": []\n      }\n    }\n  ]\n}\n```\n\nNotes on the shape:\n\n- `~DEFAULT_BRANCH` is GitHub's symbolic ref for the repo's default\n  branch — use it so the ruleset follows a default-branch rename.\n- `require_last_push_approval: true` is **issue #222 item 6** — \"Require\n  approval of the most recent reviewable push\".\n- `require_code_owner_review: true` requires a `CODEOWNERS` file to be\n  meaningful. If the repo has no `.github\u002FCODEOWNERS` (or root\u002F`docs\u002F`\n  variant), still set it true (it is a no-op until CODEOWNERS exists)\n  but **report** \"code-owner review required, but no CODEOWNERS file\n  present — add one for it to take effect\".\n- `required_review_thread_resolution: true` (\"Require conversation\n  resolution before merging\"). The reference repo currently has this\n  `false`; the hardened baseline this skill converges to is `true`.\n- `bypass_actors` grants the built-in **Repository admin** role\n  (`actor_id: 5`, `actor_type: \"RepositoryRole\"`) a **PR-only** bypass\n  (`bypass_mode: \"pull_request\"`). This is **issue #61**: on a\n  single-maintainer repo whose sole writer is also the sole code-owner\n  and the last pusher (CODEOWNERS `* @owner`), the combination of\n  `require_last_push_approval` + `require_code_owner_review` is\n  unsatisfiable — the only eligible approver is the last pusher, which\n  last-push-approval forbids, so no PR can ever merge. A PR-only admin\n  bypass lets the maintainer merge their own PRs while leaving the\n  `deletion` and `non_fast_forward` protections fully enforced (the\n  bypass mode is `pull_request`, not the broader unrestricted bypass).\n  `actor_id: 5` is the documented built-in Admin repository role;\n  confirm it on the first PUT. This entry must be **ensured** on every\n  converge run (added if missing) while preserving any other\n  `bypass_actors` the repo already has — see 6d.\n- The `required_status_checks` list starts **empty** in this template\n  and is filled by the generic gate in 6c. **GitHub rejects a\n  `required_status_checks` rule whose `required_status_checks` array is\n  empty with a 422** (the whole rule is dropped), so the gate must\n  contribute at least one real check for the rule to be includable.\n  Because the no-back-merging-guard ships **unconditionally** (Step\n  5d), its check is present on every successful run, so the array is\n  never empty in practice — the empty starting state is only the\n  pre-gate template, never what is PUT. Never hard-code a check whose\n  workflow may not exist.\n\n### 6c. Gate each required status check on its producing workflow (#91\u002F#230 guard)\n\nThis is the **generic mechanism** issue #222 delivers, generalized by\nissue #61: a required status check is added to the ruleset **iff the\nworkflow that produces it is present in the repo this run**.\n\"Present in the repo this run\" is the gate condition — broader than the\nold \"installed *by this skill* this run\". A producing workflow counts\nas present when the skill wrote\u002Fconverged it this run **or** when it\nalready existed in `.github\u002Fworkflows\u002F` and the skill left it unchanged\n(converged-as-unchanged, or simply present and skill-owned). What still\ndisqualifies a check is the workflow being **absent** from the repo\nafter this run — registering a check whose producing workflow never\nuploads results recreates the issue #91 phantom-check hang, where every\nPR waits forever for a result that never comes.\n\n**The required checks are the workflows' AGGREGATORS, never per-leg\nnames.** Each of CodeQL and the two gates now runs a dynamic matrix and\nexposes a single always-running aggregator (`codeql-required`,\n`install-gate-required`, `pinned-gate-required`) whose stable name is\nwhat the ruleset lists. GitHub `required_status_checks` is a static list\nof names and **cannot** express \"require `Analyze (python)` only if it\nruns\" — listing a per-leg name on a repo lacking that language\u002FPM hangs\nthe PR forever (the #91\u002F#230 failure mode). So the gate is applied at\n**workflow** granularity: present workflow → add its aggregator context;\nabsent workflow → omit it. The per-leg legs stay **visible** (red\u002Fgreen,\nonly when their language\u002Fecosystem is present) but are **never**\nindividually required.\n\n- For each candidate aggregator, the skill knows (from this run) whether\n  the producing workflow is **present in the repo**. If present → add\n  the aggregator's context to `required_status_checks`. If absent →\n  **omit it** and report the skip with the #91 rationale.\n- **CodeQL** — add the aggregator context **iff CodeQL resolved on and\n  its workflow is present in the repo this run** (Step 5b wrote or\n  converged it, or it already existed):\n\n  ```json\n  { \"context\": \"codeql-required\" }\n  ```\n\n  The `codeql-required` aggregator passes green when the runtime matrix\n  is empty (no analyzable language present), so a language-less repo is\n  mergeable, not hung. When CodeQL is off (no workflow present), omit it\n  and report \"codeql-required required check: skipped (no CodeQL\n  workflow present — would be a phantom required check, issue #91)\".\n\n  When CodeQL **is** on, also express **code scanning** and **code\n  quality** as ruleset rules (issue #222 items 7\u002F8; matching the\n  reference shape) — these are result-consuming rule types, orthogonal\n  to the status-check aggregator:\n\n  ```json\n  {\n    \"type\": \"code_scanning\",\n    \"parameters\": {\n      \"code_scanning_tools\": [\n        {\n          \"tool\": \"CodeQL\",\n          \"security_alerts_threshold\": \"high_or_higher\",\n          \"alerts_threshold\": \"errors\"\n        }\n      ]\n    }\n  },\n  { \"type\": \"code_quality\", \"parameters\": { \"severity\": \"errors\" } }\n  ```\n\n  Append these to the `rules` array only when CodeQL is on this run.\n- **Dependency-install-gate** (issue #238, extended by issue #111) is\n  produced by the `dependency-install-gate.yml` workflow installed in\n  Step 5c. Add its **aggregator** context to `required_status_checks`\n  **iff that workflow is present in the repo this run** (Step 5c\n  wrote\u002Fconverged it, or it already existed):\n\n  ```json\n  { \"context\": \"install-gate-required\" }\n  ```\n\n  Do **not** register the per-PM leg names (`Install gate (npm)`, etc.)\n  — those are dynamic and would hang a PR on a repo lacking that PM. The\n  aggregator passes green when the runtime matrix is empty (no PM\n  present). When the gate workflow is **absent** from the repo after\n  this run, omit `install-gate-required` and report \"install-gate\n  required check: skipped (no dependency-install-gate workflow present —\n  would be a phantom required check, issue #91\u002F#230)\".\n- **Dependency-pinned-gate** (issue #90) is produced by the\n  `dependency-pinned-gate.yml` workflow installed in Step 5c-pinned. Add\n  its **aggregator** context to `required_status_checks` **iff that\n  workflow is present in the repo this run**:\n\n  ```json\n  { \"context\": \"pinned-gate-required\" }\n  ```\n\n  Do **not** register the per-ecosystem leg names — same phantom-check\n  hazard. The aggregator passes green on an empty runtime matrix. When\n  the pinned-gate workflow is **absent** from the repo after this run,\n  omit `pinned-gate-required` and report \"pinned-gate required check:\n  skipped (no dependency-pinned-gate workflow present — would be a\n  phantom required check, issue #91\u002F#230)\". The two gates' aggregators\n  are **distinct** contexts (`install-gate-required` vs.\n  `pinned-gate-required`), so a repo running both requires both to pass,\n  with no context collision.\n- **No-back-merging-guard check** (issue #51) is produced by the\n  `no-back-merging-guard.yml` workflow installed in Step 5d. Add its\n  context to `required_status_checks` **iff that workflow is present in\n  the repo this run**. The check context is the job name from the\n  workflow:\n\n  ```json\n  { \"context\": \"no-back-merging-guard\" }\n  ```\n\n  Because Step 5d installs the guard **unconditionally**, this workflow\n  is present on every successful run, so the check is registered on\n  every run — but it still goes through the same generic gate (it is\n  added because its producing workflow is present in the repo this run,\n  never standalone), preserving the issue #91\u002F#230 phantom-check\n  invariant. Under the generalized \"present in the repo\" gate, a Step 5d\n  diff-halt that leaves the **existing** workflow file in place still\n  counts the workflow as present (the file is on disk, just awaiting a\n  converge), so the check stays registered. The check is omitted only\n  when the guard workflow is genuinely **absent** from the repo after\n  this run — report \"no-back-merging-guard required check: skipped\n  (workflow not present in the repo this run — would be a phantom\n  required check, issue #91\u002F#230)\". Because the guard ships\n  unconditionally and is owned by this skill, the registered check is\n  also what keeps `required_status_checks` non-empty, so the rule is\n  always includable (avoiding the empty-array 422 described in 6b).\n- **Future producing workflows** plug into this same gate: when a\n  workflow is present in the repo, its check contexts are added to\n  `required_status_checks`; until then they are omitted.\n\nThe `integration_id` on a `required_status_checks` entry (the reference\nuses `15368`, GitHub Actions) is optional — omit it and GitHub matches\nthe check by `context` alone, which is what the gate wants.\n\n### 6d. Converge (create or update)\n\n- **No existing ruleset** → create it:\n\n  ```bash\n  gh api --method POST repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets \\\n    --input \u003Cdesired-body.json>\n  ```\n\n- **Existing ruleset that differs** → update it (PUT replaces the\n  ruleset body so the skill owns its shape; semantic-compare first and\n  skip when already equal so a converged re-run is a no-op):\n\n  ```bash\n  gh api --method PUT repos\u002F__GH_ORG__\u002F__GH_REPO__\u002Frulesets\u002F\u003CID> \\\n    --input \u003Cdesired-body.json>\n  ```\n\n**Semantic-compare, not byte-compare — normalize before deciding to\nPUT.** The server returns a ruleset body that is *equivalent to but not\nbyte-identical with* the desired body. A naive compare would re-PUT\nevery run and break the headline idempotency guarantee. Normalize these\nfields before comparing, and treat them as equal when:\n\n- **`conditions.ref_name.include`** — the server may store\n  `[\"refs\u002Fheads\u002Fmain\", \"~DEFAULT_BRANCH\"]` (the reference repo's shape)\n  while the desired body carries only `[\"~DEFAULT_BRANCH\"]`. Treat an\n  existing `include` as **already converged** when it is equivalent to —\n  or a superset that contains — the desired symbolic ref\n  (`~DEFAULT_BRANCH`, or the concrete `refs\u002Fheads\u002F\u003Cdefault-branch>` it\n  resolves to). Do **not** re-PUT merely to strip the redundant concrete\n  entry; that churn is a spurious write, not a convergence.\n- **`required_status_checks`** — the server stores an `integration_id`\n  on each check (the reference uses `15368`, GitHub Actions) that the\n  desired body omits. **Compare on `context` only** (the set of check\n  contexts), ignoring `integration_id` presence\u002Fabsence. Equal context\n  sets → no re-PUT, even though the stored entries carry an extra\n  `integration_id`.\n- **`bypass_actors`** — the desired body asserts the admin PR-only\n  entry (`actor_id: 5`, `actor_type: \"RepositoryRole\"`,\n  `bypass_mode: \"pull_request\"`); the existing ruleset may carry that\n  same entry plus other actors the repo added (e.g. a team\n  `pull_request` bypass). Treat the existing `bypass_actors` as\n  **already converged** when it **contains** the admin PR-only entry\n  (regardless of any additional actors). Compare on the\n  `(actor_id, actor_type, bypass_mode)` tuple; the server may add no\n  extra fields here, so a plain set-containment check on those three\n  keys suffices. Only the **absence** of the admin entry is a semantic\n  difference that warrants a PUT — and the PUT carries the existing\n  actors plus the admin entry (see the preserve-and-ensure rule below),\n  never a replacement that drops the others.\n\nOnly PUT when a semantic difference remains after this normalization.\n\n**Graceful-skip a `code_quality` 422.** The `code_quality` rule type is\nlimited-availability and may not be enabled for the org\u002Frepo. If the\ncreate\u002Fupdate returns a `422` attributable to the `code_quality` rule\n(message naming `code_quality` \u002F \"Code quality\" \u002F an unsupported rule\ntype), do **not** hard-fail the whole ruleset convergence — retry the\nsame call with the `code_quality` rule dropped from the `rules` array,\nand report \"code quality required check: skipped (rule type not\navailable for this repo)\". The rest of the ruleset (deletion,\nnon-fast-forward, `pull_request`, `required_status_checks`, and the\n`code_scanning` rule) still converges. This mirrors the graceful\nentitlement degradation the GHAS toggle steps already apply to a 422.\n\n**Preserve-and-ensure `bypass_actors`.** Two rules apply together:\n\n- **Preserve** any `bypass_actors` the repo already has (the reference\n  repo grants a team `pull_request` bypass) — read them from 6a and\n  carry them through unchanged rather than clearing them; clearing a\n  bypass list is a posture change the operator owns.\n- **Ensure** the admin PR-only entry (`actor_id: 5`,\n  `actor_type: \"RepositoryRole\"`, `bypass_mode: \"pull_request\"`) is\n  present (issue #61). On every converge run, compute the union of the\n  existing actors and this admin entry: if the admin entry is already\n  in the existing list (matched on the\n  `(actor_id, actor_type, bypass_mode)` tuple), it is a no-op; if it is\n  missing, add it while keeping every other actor. Never replace the\n  list with the admin entry alone — that would drop the operator's\n  other bypasses, violating the preserve rule.\n\nSo the converged `bypass_actors` is always\n`existing ∪ {admin PR-only entry}`. On a freshly created ruleset (no\nexisting actors) that is just the admin entry; on a repo with a\npre-existing team bypass it is that team plus the admin entry. Report\nthe ruleset as `created`, `updated (changed: \u003Cfields>)`, or\n`unchanged`.\n\nWrite nothing to disk in this step — a ruleset is server-side state,\nlike the GHAS toggles. The skill applies it directly and reports it.\n\n## Step 7: Commit, push, and open a PR for the rendered files\n\nAfter rendering and converging its files (Steps 3, 5b, 5c, 5c-pinned,\n5d), the\nskill **commits, pushes, and opens a PR** for those files — **always**,\non a **single approval**. There is no flag to disable this and no\n\"am I being orchestrated?\" knob: the skill always produces a PR for its\nown rendered files. Only the **rendered files** go through this branch →\ncommit → push → PR flow. The **remote API changes** — the GHAS toggles\n(Step 4), the merge-button settings (Step 4e), and the `protect-main`\nruleset (Step 6) — are not file edits and cannot live in a PR, so they\nwere already applied directly to the repo and are **not** part of this\nPR.\n\n### 7a. Skip cleanly when there is nothing to commit\n\nIf every rendered file converged as `unchanged` (a no-op run against an\nalready-configured repo — the headline idempotency case), there is\n**nothing to commit**: skip this step entirely, report \"no file changes\nto commit; no PR opened\", and proceed to the report (Step 8). A\nconverged re-run must not produce an empty PR.\n\n### 7b. Present the changes and get one approval\n\nShow the operator the rendered file changes (the diff) and ask for a\nsingle approval that covers commit + push + PR together — **not** three\nseparate prompts:\n\n```bash\ngit status --short -- .github\u002F\ngit diff -- .github\u002F        # plus any staged\u002Fnew files under .github\u002F\n```\n\n```text\ngh-repo-setup-protection rendered these files:\n  \u003Clist of written\u002Fchanged files under .github\u002F>\n\nOn approval I will, in one go:\n  1. Commit them on a branch named after this skill\n     (gh-repo-setup-protection).\n  2. Push that branch.\n  3. Open a PR targeting the default branch (\u003Cdefault-branch>).\n\nThe remote settings (GHAS toggles, merge-button settings, protect-main\nruleset) were already applied directly and are NOT part of this PR.\n\nProceed with commit + push + PR? (y to do all three, or no to leave the\nfiles uncommitted for you to handle)\n```\n\nIf the operator declines, leave the rendered files uncommitted in the\nworking tree and report \"files left uncommitted at operator's request;\nno PR opened\". Do not partially commit.\n\n### 7c. Commit, push, and open the PR\n\nOn approval, do all three with no further prompts:\n\n```bash\n# Branch named after the skill. Create it from the current default-branch\n# tip if it does not exist; reuse it if a prior run left it.\ngit switch -c gh-repo-setup-protection \\\n  || git switch gh-repo-setup-protection\n\ngit add -- .github\u002F\ngit commit -m \"Converge repo protection config (gh-repo-setup-protection)\"\n\ngit push -u origin gh-repo-setup-protection\n\ngh pr create --base \"__DEFAULT_BRANCH__\" \\\n  --head gh-repo-setup-protection \\\n  --title \"Converge repo protection config\" \\\n  --body \"Rendered by \u002Fgh-repo-setup-protection: Dependabot config, CodeQL\nworkflow (when on), dependency-install-gate (when npm\u002Fpip\u002Fpnpm\u002Fyarn present), and\nthe no-back-merging-guard. Remote settings (GHAS toggles, merge-button\nsettings, protect-main ruleset) were applied directly to the repo and\nare not part of this PR.\"\n```\n\nCapture and report the PR URL. If a PR already exists for the branch\n(`gh pr create` reports it), report that URL instead of failing.\n\n**Nice-to-have — do the file work in a git worktree.** The skill does\nnot currently require running from inside a worktree (it is meant to be\nrun directly on a repo being transitioned), but rendering and committing\nthe files in a dedicated worktree would isolate the operator's working\ntree from the skill's edits. Adding worktree support is a welcome\nimprovement, not a requirement for this step.\n\n## Step 8: Report and next steps\n\nPrint a converged-state summary:\n\n```text\ngh-repo-setup-protection — \u003Cowner>\u002F\u003Crepo> (default branch: \u003Cbranch>)\n\nFiles (written \u002F unchanged \u002F skipped):\n  .github\u002Fdependabot.yml                          \u003Cwritten|unchanged>  (always written — github-actions floor)\n  .github\u002Fworkflows\u002Fcodeql.yml                    \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fcodeql\u002Fcodeql-config.yml                \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fworkflows\u002Fdependency-install-gate.yml   \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fscripts\u002Fdependency-install-gate.sh      \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fworkflows\u002Fdependency-pinned-gate.yml    \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fscripts\u002Fdependency-pinned-gate.sh       \u003Cwritten|unchanged|skipped: reason>\n  .github\u002Fworkflows\u002Fno-back-merging-guard.yml     \u003Cwritten|unchanged>\n  .github\u002Fscripts\u002Fno-back-merging-guard.sh        \u003Cwritten|unchanged>\n  .github\u002Fscripts\u002Ftest-no-back-merging-guard.sh   \u003Cwritten|unchanged>\n\nGHAS settings (each idempotent, re-asserted every run):\n  Code Security (Advanced Security)  \u003Cenabled changed|was on|skipped: why>\n  Dependabot alerts                  \u003Cenabled changed|was on|skipped: why>\n  Dependabot security updates        \u003C...>\n  Dependabot grouped security updates \u003Cvia dependabot.yml | settings UI>\n  Dependabot malware alerts          \u003Cenabled|UI-only (npm); manual step>\n  Secret scanning                    \u003C...>\n  Secret scanning push protection    \u003C...>\n  Push-protection bypass lockdown    \u003Cdelegated bypass on | manual: nobody>\n\nMerge-button \u002F PR-hygiene settings (each idempotent, re-asserted every run):\n  Allow squash merging   (off)       \u003Cunchanged|changed>\n  Allow rebase merging   (off)       \u003Cunchanged|changed>\n  Allow merge commit     (on, kept)  \u003Cunchanged>\n  Suggest update branch  (on)        \u003Cunchanged|changed>\n  Allow auto-merge       (on)        \u003Cunchanged|changed>\n  Auto-delete head branch (on)       \u003Cunchanged|changed>\n\nCodeQL decision: \u003Con|off> (\u003Creason>)\n  Default setup: \u003Ccorrectly not configured (advanced setup active — the two cannot coexist) | was configured → disabled | left as-is>\n\nprotect-main ruleset: \u003Ccreated|updated|unchanged|skipped (--ruleset=off)>\n  require_last_push_approval         \u003Ctrue>\n  Admin PR-only bypass               \u003Censured | already present>\n  Required status checks (aggregators, not per-leg names):\n    codeql-required                    \u003Cadded (CodeQL present) | skipped (#91)>\n    install-gate-required              \u003Cadded (gate present) | skipped (#91)>\n    pinned-gate-required               \u003Cadded (gate present) | skipped (#91)>\n    no-back-merging-guard              \u003Cadded (guard present) | skipped (#91)>\n  code scanning \u002F code quality rules   \u003Cadded (CodeQL on) | skipped>\n\nArmed Dependabot ecosystems: \u003Cfull supported set minus de-arms>  (present in tree: \u003Craw scan>)\nArmed drift-gate PMs: \u003Cnpm\u002Fpip\u002Fpnpm\u002Fyarn minus de-arms>  (runtime matrix narrows to present)\nArmed pinned-gate ecosystems: \u003Cnpm\u002Fpip\u002Factions\u002Fdocker\u002Fgo minus de-arms>  (runtime matrix narrows to present)\nArmed CodeQL languages: \u003Cfull supported set minus de-arms; runtime matrix narrows to present>  (present in tree: \u003Craw scan>)\n\nRendered-files PR: \u003CURL | no file changes to commit | left uncommitted at operator's request>\n\nNext steps:\n  1. Review and merge the rendered-files PR above (if one was opened).\n  2. Re-run \u002Fgh-repo-setup-protection any time — it converges and is a\n     no-op when everything is already in the desired state (no empty PR).\n```\n\nOn a run with file changes, the rendered files land in a PR on the\n`gh-repo-setup-protection` branch (Step 7) on a single approval; the\nremote settings (GHAS toggles, merge-button settings, ruleset) were\napplied directly. A converged re-run with no file changes opens no PR.\n\n---\n\n## Convergence strategy (summary — the headline requirement)\n\nThis skill is designed to be run repeatedly across many repos and on\nthe same repo many times. The convergence guarantees:\n\n- **Deterministic render.** Dependabot ecosystem blocks are emitted in\n  sorted order, and CodeQL \u002F the two gates ship a fixed full-set-armed\n  workflow shape (the language\u002Fecosystem narrowing is a runtime concern,\n  not part of the rendered bytes), so the same repo always renders the\n  same bytes. A second run with no repo change produces an identical\n  file → no diff → nothing to commit.\n- **Whole-file replace, never append.** The skill owns the shape of\n  `dependabot.yml`, `codeql.yml`, and `codeql-config.yml`. It computes\n  the desired content from scratch each run and replaces the file's\n  contents, rather than appending entries. Appending is the classic\n  source of duplicate ecosystem blocks on re-run; replacing eliminates\n  it.\n- **Semantic compare before write.** Before overwriting, the skill\n  compares the existing file to the desired content (YAML-normalized\n  for the dependabot\u002Fcodeql configs). Equal → no write, reported as\n  \"unchanged\". This keeps `git status` clean on no-op runs.\n- **Halt before destroying user edits.** If the existing file contains\n  `updates:`\u002Fconfig entries the render would drop (hand-added\n  ecosystems, custom `ignore:`\u002F`reviewers:` blocks, tuned\n  `paths-ignore`), the skill shows the diff and asks before\n  overwriting. Convergence never silently discards human customization.\n- **Idempotent GHAS toggles.** Each security setting is read first and\n  PUT\u002FPATCH-ed only when it differs from desired; the GitHub API\n  endpoints used are themselves idempotent (PUT returns 2xx whether or\n  not the feature was already on). Re-running reports \"was already on\".\n- **Idempotent merge-button settings.** The five General-settings\n  merge-button fields (Step 4e) are read first and PATCH-ed convergently\n  to the hardened state; re-running reports each as `unchanged` once\n  converged. Like the GHAS toggles, these are remote settings applied\n  directly, not file edits in the PR.\n- **PR for rendered files on a single approval.** The rendered files\n  (Dependabot config, CodeQL workflow when on, the gates\u002Fguard) are\n  committed, pushed, and PR-ed on the `gh-repo-setup-protection` branch\n  on one approval (Step 7). A no-op run with no file changes opens no PR.\n  The remote settings never go through the PR.\n- **Graceful entitlement degradation.** On an unentitled private repo,\n  GHAS-only features (secret scanning, CodeQL) are skipped with a clear\n  reason instead of erroring — so the same skill invocation works\n  unchanged across a public repo, an entitled private repo, and an\n  unentitled private repo.\n\n### Read-then-converge surface audit\n\nEvery surface the skill writes must **read the existing state first**\nand converge against it — never write blind. The issue #230 wedge was a\nsurface (server-side CodeQL setup mode) the skill wrote without reading.\nThis table is the audit; each row must hold on every run, including a\nno-op run against an already-configured repo:\n\n| Surface | Read before write | Step |\n| --- | --- | --- |\n| `dependabot.yml` | Parse YAML, semantic-compare | 3 |\n| `codeql.yml` \u002F `codeql-config.yml` | Parse YAML, semantic-compare | 5b |\n| `dependency-install-gate.yml` | Parse YAML, semantic-compare | 5c |\n| `dependency-install-gate.sh` | Normalized-text\u002Fbyte compare | 5c |\n| `dependency-pinned-gate.yml` | Parse YAML, semantic-compare | 5c-pinned |\n| `dependency-pinned-gate.sh` | Normalized-text\u002Fbyte compare | 5c-pinned |\n| `no-back-merging-guard.yml` | Parse YAML, semantic-compare | 5d |\n| `no-back-merging-guard.sh` | Normalized-text\u002Fbyte compare | 5d |\n| `test-no-back-merging-guard.sh` | Normalized-text\u002Fbyte compare | 5d |\n| CodeQL server-side setup mode | `code-scanning\u002Fdefault-setup` read | 5a |\n| Code Security (Advanced Security) | Read status, PATCH if off | 4b |\n| Dependabot alerts \u002F security updates | PUT idempotent; read for report | 4a |\n| Dependabot malware alerts \u002F grouping | Read state; best-effort + report | 4a |\n| Secret scanning \u002F push protection | Read state, PATCH only diffs | 4c |\n| Push-protection bypass lockdown | Read state; best-effort + report | 4d |\n| Merge-button \u002F PR-hygiene settings | Read state, PATCH only diffs | 4e |\n| `protect-main` ruleset | List by name, read body, PUT only diffs | 6 |\n| `protect-main` `bypass_actors` | Read existing, ensure admin PR-only entry, preserve others | 6d |\n| Required status checks | Gated on producing workflow present in the repo this run | 6c |\n\nEvery row converges on re-run: file surfaces semantic-compare and skip\nwhen equal; GHAS toggles are idempotent and report \"was already on\"; the\nCodeQL setup mode disables a conflicting default setup (operator\nconfirmed) before installing advanced, or installs nothing if the\noperator declines; the ruleset is read by name, semantic-compared, and\nPUT only when it differs.\n\nThe required-status-checks row is the load-bearing one: this skill now\n**owns** the `protect-main` ruleset, but it registers a required check\n**only when that check's producing workflow is present in the repo this\nrun** (Step 6c). It installs the CodeQL *workflow* and the code\nscanning \u002F code quality required checks **together**, never the checks\nalone — registering a check against a workflow that cannot produce\nresults is exactly how the repo wedged (issues #91, #230). Because the\nno-back-merging-guard ships unconditionally, its check is always\npresent, which also keeps `required_status_checks` non-empty (GitHub\n422s on an empty array — issue #61). The `bypass_actors` row is the\ncompanion: the admin PR-only entry is ensured on every run and the\noperator's other actors preserved, so a single-maintainer repo is not\ndeadlocked. A no-op run against a fully-configured repo writes nothing,\nmutates no server-side state, and leaves `git status` clean.\n\n---\n\n## Hard constraints\n\n- **Commit + push + PR the rendered files on a single approval, always.**\n  After rendering its files (Steps 3, 5b, 5c, 5c-pinned, 5d), the skill commits,\n  pushes, and opens a PR for them on a branch named after the skill\n  (`gh-repo-setup-protection`), targeting the default branch — on **one**\n  approval covering all three (Step 7). There is no `--commit` flag, no\n  opt-out, no \"am I being orchestrated?\" knob: the skill always produces\n  a PR for its own rendered files. The single approval still satisfies\n  global rule §0 (the operator explicitly approves before any commit \u002F\n  push). A no-op run with no file changes opens no PR. The **remote API\n  changes** (GHAS toggles, merge-button settings, ruleset) are applied\n  directly and are never part of the PR.\n- **Arm the full supported set; the Step 2b checklist only de-arms.**\n  Every surface (CodeQL languages, both gates' ecosystems, Dependabot\n  ecosystems) is armed with its full supported set at install time and\n  narrows to the present set at runtime (CodeQL and the gates via their\n  `detect` jobs; Dependabot no-ops on absent manifests). The Step 2b\n  multi-tab checklist (drift-gate \u002F pinned-gate \u002F Dependabot \u002F CodeQL)\n  defaults to **everything armed**; the operator may only **de-arm** a\n  language\u002Fecosystem they never want. This structurally removes the\n  protect-before-code ordering inversion — a new language\u002Fecosystem's\n  check\u002Fcoverage appears the first time its source lands, with no skill\n  re-run. Only `--dry-run` skips the checklist (arm the full set). The\n  CodeQL tab bounds the *armed language set* only — it never overrides\n  the on\u002Foff decision or the entitlement guard in Step 5, and de-arming\n  every language does not turn CodeQL off (the runtime matrix simply\n  never spawns a leg and the aggregator is green).\n- **Never auto-force CodeQL.** CodeQL is opt-in: it is enabled by an\n  explicit `--codeql=on` operator override or by auto-detection, and\n  **auto-detection** always skips the unentitled-private repo. The skill\n  never lets auto-detection turn CodeQL on for such a repo — that is what\n  recreates the issue #91 phantom-check hang (see \"CodeQL is opt-in\" for\n  the inlined rationale). An explicit `--codeql=on` is the operator's\n  deliberate choice and is honored; what is forbidden is CodeQL silently\n  *auto*-resolving on. (Markdown-only repos are no longer a separate\n  auto-skip case: `actions` is the always-present floor, so every repo\n  the skill touches has an analyzable language — the remaining auto-skip\n  is the entitlement one.)\n- **The CodeQL workflow can never deadlock on an absent language, and\n  never leaves a conflicting default setup in place.** The workflow is\n  armed with the full supported language set and narrows to the present\n  languages at runtime; an empty runtime matrix spawns zero analyze legs\n  and the `codeql-required` aggregator passes green, so a\n  language-less repo is mergeable, not hung (this replaces the old\n  install-time no-supported-language hard stop). When installing\n  advanced setup, the skill first reads the server-side default-setup\n  mode and disables it (with operator confirmation) so the two cannot\n  coexist (issue #230).\n- **Never append to a config file.** Always whole-file replace from a\n  deterministic render so re-runs converge instead of duplicating.\n- **Never overwrite user customization silently.** Halt and show the\n  diff when the existing file has entries the render would drop.\n- **Never downgrade a newer SHA-pinned action pin on converge.** When a\n  repo's workflow already pins an action (`actions\u002Fcheckout`,\n  `github\u002Fcodeql-action`, any `uses:` line) to a SHA whose upstream\n  release tag is **strictly newer** than the payload's, the converge\n  **keeps the repo's pin** — automatically, with no prompt, and never\n  offers a downgrade (Step 5a-bis, applied by Steps 5b\u002F5c\u002F5c-pinned\u002F5d). \"Newer\"\n  is decided by resolving **both** SHAs to their upstream release tags\n  and comparing by semver; the trailing `# vX.Y.Z` comment is\n  display-only and is never trusted. A pin that is older, equal,\n  floating (a `@vN` tag, not a 40-hex SHA), or **unresolvable** (deleted\n  tag, fork, private action, API failure) converges to the payload's\n  pin. \"Match the payload\" thus excludes downgrading a deliberately-\n  newer SHA-pinned repo pin.\n- **Never write a file with unresolved `__...__` placeholders.** Abort\n  per the README's unresolved-placeholder rule.\n- **Always write `dependabot.yml`, armed with the full supported\n  ecosystem set.** Render one `updates:` block per supported ecosystem\n  (`github-actions`, `npm`, `pip`, `docker`, `gomod`, `bundler`,\n  `cargo`, `maven`, `gradle`, `composer`, `terraform`) minus any Step 2b\n  de-arms — never narrowed to detected ecosystems. Dependabot no-ops on\n  an ecosystem whose manifest is absent, so the full set adds no spurious\n  update PRs; the `updates:` list is never empty and the old \"no\n  ecosystem detected → skip the file\" path is gone. Resolve the correct\n  **class variant** per ecosystem (no `versioning-strategy` on\n  docker\u002Fgithub-actions — Dependabot rejects it; `github-actions` uses\n  singular `directory: \"\u002F\"` + weekly; others use recursive\n  `directories: **\u002F*` + daily) — a wrong variant makes Dependabot reject\n  the whole config (Step 3).\n- **CodeQL, both gates arm the full set and gate at runtime — never\n  install-time-narrow.** Ship `codeql.yml`,\n  `dependency-install-gate.yml`, and `dependency-pinned-gate.yml` with\n  their full detect → matrix → aggregator shape (armed with the full\n  supported language\u002Fecosystem set), plus their sibling scripts\n  (`codeql-language-present.sh`, `dependency-install-gate.sh`,\n  `dependency-pinned-gate.sh`, all with the executable bit set). Each\n  narrows to the present set at runtime via its `detect` job (the SAME\n  `git ls-files` predicate the analysis\u002Fgate uses — detection defined\n  once per surface). The two gates are **separate** (own workflow,\n  script, and aggregator); do not fold them together. The pinned-gate's\n  categorical exemptions (peerDependencies carets, `file:`\u002F`workspace:`\n  specs, pnpm `catalog:`\u002F`catalog:\u003Cname>` references, `engines`\u002F\n  `requires-python` floors, override-value classification,\n  `tag@sha256:` digests) live in the classifier script, never in a\n  maintained allowlist file. A `catalog:` reference is exempt at the\n  consumer; the referenced entry in `pnpm-workspace.yaml` is checked\n  for exactness once, at the source.\n- **The required check per surface is its AGGREGATOR, never a per-leg\n  name.** Add `codeql-required`, `install-gate-required`, and\n  `pinned-gate-required` to `protect-main` **iff** each surface's\n  workflow is present in the repo this run (Step 6c) — never a per-leg\n  name like `Analyze (python)` or `Install gate (npm)`, which would hang\n  a PR on a repo lacking that language\u002FPM (issue #91\u002F#230). Each\n  aggregator passes green on an empty runtime matrix, so a repo missing\n  the guarded languages\u002Fecosystems is mergeable.\n- **Swift never provisions macOS when absent.** The CodeQL detect job\n  adds a `swift` matrix entry (carrying `runner: macos-latest`) only\n  when `*.swift` is present; a Swift-less repo shows no swift leg and\n  never bills for a macOS runner.\n- **Always install the no-back-merging-guard, and its three files\n  together.** The guard ships **unconditionally** (Step 5d) — no\n  ecosystem gate, no disable flag; it is pure git-history hygiene.\n  Install `no-back-merging-guard.yml`,\n  `no-back-merging-guard.sh`, and `test-no-back-merging-guard.sh`\n  together (the workflow invokes the script; the self-test verifies it);\n  ship the two scripts verbatim with the executable bit set. Add the\n  `no-back-merging-guard` required check to `protect-main` only when the\n  workflow is present in the repo this run (Step 6c) — which, because\n  the guard is unconditional, is every successful run — never\n  standalone (issue #91\u002F#230).\n- **Never edit anything outside the current repo.** All file writes go\n  under `\u003Crepo-root>\u002F.github\u002F`. Scratch work, if any, goes under\n  `\u003Crepo-root>\u002F.claude\u002Ftmp\u002Fgh-repo-setup-protection\u002F`, never `\u002Ftmp\u002F`.\n- **Treat a missing GHAS entitlement as a skip, not a failure.** A 422\n  \"Advanced Security is not enabled\" on a private repo is expected and\n  must be reported as a graceful skip.\n- **Never register a required status check whose producing workflow is\n  not present in the repo this run.** Required checks in `protect-main`\n  go through the Step 6c gate: a check is added iff its producing\n  workflow is present in the repo this run (written\u002Fconverged this run\n  or already on disk). Code scanning \u002F code quality are added iff\n  CodeQL is on and its workflow is present this run. Adding a check\n  against a workflow that cannot produce results is the issue #91\u002F#230\n  wedge.\n- **Always ensure the admin PR-only `bypass_actors` entry, and never\n  clear an existing ruleset's `bypass_actors`.** On every converge run,\n  ensure the built-in Repository admin role (`actor_id: 5`,\n  `actor_type: \"RepositoryRole\"`, `bypass_mode: \"pull_request\"`) is in\n  `bypass_actors` (issue #61 — otherwise a single-maintainer repo\n  deadlocks on last-push-approval + code-owner review), adding it if\n  missing. Read the existing actors from 6a and carry them through\n  unchanged — the converged list is `existing ∪ {admin PR-only}`, never\n  a replacement that drops the operator's other actors. Changing the\n  rest of the bypass list is a posture decision the operator owns.\n- **Best-effort, never hard-fail, on under-specified GHAS toggles.**\n  Malware alerts, grouped-security-updates settings enablement, and the\n  push-protection bypass list have no stable public per-repo REST\n  toggle. Attempt the documented shape, treat a 422\u002F404 as \"do this one\n  step in the UI\", and report the residual manual step — do not invent\n  an endpoint or abort.\n\n---\n\n## Out of scope\n\n- **Purchasing \u002F enabling a GHAS entitlement** on a private repo. The\n  skill detects the lack of entitlement and skips; buying GHAS is an\n  org-billing decision for the user.\n- **Tuning CodeQL queries \u002F `paths-ignore` per repo.** The shipped\n  `codeql-config.yml` is a sane default; the user refines it after the\n  first scan.\n- **Deleting an existing CodeQL workflow** when `--codeql=off`. Removing\n  a security workflow is the user's call; the skill reports its presence\n  and leaves it in place.\n- **The live multi-repo verification** required by the issue's third\n  acceptance criterion. The skill is built to run idempotently across\n  repos (including one where CodeQL is off), but exercising it against\n  the four live repos is an operational step the user performs.\n",{"name":5,"description":7},"main","4b187366f06afb374243166f6a0f5fc1514fa579","plugins\u002Fgithub-setup\u002Fskills\u002Fgh-repo-setup-protection","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace","https:\u002F\u002Fgithub.com\u002FTheVoskamps","2026-11-14 13:16:57",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add TheVoskamps\u002Fclaude-plugins-marketplace --skill gh-repo-setup-protection",{"tool":36,"command":37},"bunx","bunx skills add TheVoskamps\u002Fclaude-plugins-marketplace --skill gh-repo-setup-protection",{"tool":39,"command":40},"pnpm","pnpm dlx skills add TheVoskamps\u002Fclaude-plugins-marketplace --skill gh-repo-setup-protection","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fgithub-setup\u002Fskills\u002Fgh-repo-setup-protection\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M77KH3GAXPPXNQS96KDEEZBS","mask-inappropriate-language","Replace inappropriate language (profanity, slurs, strong insults) in provided text or a file with asterisks, character-for-character, preserving everything else.","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fwriting-tools\u002Fskills\u002Fmask-inappropriate-language\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M77KGY5TZDQT8QR23Y0R8P7A","theorem-agents-interface","The interface between the sdlc reviewer and the theorem agents it spawns — what each double-dash brief parameter means, and what each consequence class means. Preloaded into every theorem agent (sdlc:theorem-generator, the disprover, and the verifier) via its skills frontmatter, and read by name by the sdlc:theorem-based-pr-reviewer agent for what its briefs' parameters mean; not invoked from the user's slash menu.","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fsdlc\u002Fskills\u002Ftheorem-agents-interface\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M77KGT5HW0XAE500WSSM0PZY","sdlc-config-user","Interactively create or merge-update the repo user sdlc config, `\u003Crepo-root>\u002F.sdlc\u002Fuser-config.yml` (tier 3 — this user, this repo, never committed), and add it to the repo's tracked `.gitignore`.","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fsdlc\u002Fskills\u002Fsdlc-config-user\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M77KGQGQVB0NYZX0WJRJPDEK","sdlc-config-repo","Interactively create or merge-update the shared repo sdlc config, `\u003Crepo-root>\u002F.sdlc\u002Frepo-config.yml` (tier 2 — tracked, every user of this repo).","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fsdlc\u002Fskills\u002Fsdlc-config-repo\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M77KGKPEN7C5RCEDSEP3Z1XB","sdlc-config-global","Interactively create or merge-update the global user sdlc config, `$XDG_CONFIG_HOME\u002Fsdlc\u002Fuser-config.yml` (tier 1 — this user, every repo on this machine).","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fsdlc\u002Fskills\u002Fsdlc-config-global\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M77KGFX95J2XEQBBD49QHTXK","pr-read-cli-interface","The contract for sdlc's PR-read CLIs — sdlc-pr-round, sdlc-pr-adjustments, sdlc-fixer-brief and sdlc-records-chain — their arguments, exit codes and output grammar. Preloaded into sdlc:theorem-based-pr-reviewer, sdlc:issue-fixer, sdlc:docs-writer and sdlc:pr-finalizer via their skills frontmatter; not invoked from the user's slash menu.","https:\u002F\u002Fgithub.com\u002FTheVoskamps\u002Fclaude-plugins-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fsdlc\u002Fskills\u002Fpr-read-cli-interface\u002FSKILL.md",[],[]]