---
name: yad-docs-sync
description: 'Find stale generated docs sites and say why, refresh them, or wire the CI job that rebuilds them. Use when the user says "sync the docs", "check docs staleness", "refresh stale docs sites", or "wire the docs CI".'
---

# SDLC — Sync the Docs Sites (the staleness reconciler)

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

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

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

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

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

**Goal:** Keep the generated docs sites in step with the artifacts they render — the per-epic sites
(`epics/EP-<slug>/docs-site/`) and the project overview (`docs/sdlc-site/`). It mirrors the `yad check`
/ `yad gate ci` reconcile pattern: it does **not** re-author content; it **detects drift** between each
site's `docs-build.json` baseline and the current inputs, and reports / refreshes / wires CI accordingly.

Docs are an output enrichment, so this skill is **never a gate** — it never touches `state.json`,
approvals, or the contract lock. Refreshing a stale site is always a **human or CI decision**, never
silent (the same discipline as `yad repo refresh`).

## Conventions

- `{project-root}` resolves from the project working directory (the **Product**).
- Per-epic baseline: `epics/EP-<slug>/.sdlc/docs-build.json` (written by `yad-docs`). Overview baseline:
  `docs/sdlc-site/.docs-build.json` (written by `yad-docs-overview`).
- The hashing + build + deploy is the **`yad docs sync` CLI**'s job; the regeneration of a stale site is
  delegated back to `yad-docs` / `yad-docs-overview` (the AI generation step). This skill orchestrates
  the reconcile.
- The docs target is `.sdlc/docs.json` (`yad-connect-docs`).
- Speak in the `communication_language` set in `{project-root}/.sdlc/config.yaml`; write documents in `document_output_language`.

## Inputs

- `action` — `check` (default, read-only) | `refresh` | `wire`.
- `epic` — optional. Default: **sweep all epics** under `epics/` **plus the overview**. Given an
  `EP-<slug>`, scope to that one site.

## On Activation

### Step 1 — Compute the current freshness hashes per target
For each target in scope, recompute its hash inputs (exact inputs in `references/staleness.md`):

- **Per-epic** (`epics/EP-<slug>/`): the `artifactHash` (sha256 of `epic.md` + `architecture.md` +
  `contract.md` CONTRACT-SURFACE + `ui-design.md` + each story) **and** `repoHeads` (current
  `git -C <path> rev-parse HEAD` for each repo in `epic.repos`).
- **Overview** (`docs/sdlc-site/`): sha256 of `skills/sdlc/config.yaml` + `skills/sdlc/module-help.csv`
  + `docs/diagrams/sdlc-overview.mmd` + the current `skillCount` (number of `yad-*` skills).

This is the same drift computation `yad check` runs for repos; reuse the repos.json HEAD-sha rule.

### Step 2 — Compare to each build manifest
Read each `docs-build.json` and compare. A site is **stale** when **any** of:
- its `artifactHash` differs (a rendered artifact moved), or
- any `repoHeads[<repo>]` differs from the repo's current HEAD (the code the components cite advanced —
  the same head-sha staleness as `repos.json`), or
- for the overview, `config.yaml` / `module-help.csv` / the `.mmd` / `skillCount` moved, or
- for a per-epic site, its `shellVersion` differs from the `version` in `skills/yad-docs/templates/app/package.json`
  (the shell was upgraded). The overview has no shell version: it is updated in place, not re-copied. An
  older manifest records only `templateVersion` (the yad CLI version, which changed on every release). That
  value is never compared; such a manifest counts as built on shell `0.0.0`, the only version before this.

A missing `docs-build.json` (a site never generated) counts as **stale → needs generate**.

### Step 3 — Act on `action`
- **`check`** (default, **read-only**) — print which sites are stale and **WHY**, in `yad check` drift
  style: *which artifact moved* (name it), *which repo HEAD advanced* (`<repo>: <old>→<new>`), *config /
  manifest / diagram / skill-count changed*, or *shell upgraded* (`shellVersion`, per-epic only). Writes nothing.
- **`refresh`** — for each stale site, re-run the generator (`yad-docs` for an epic site, `yad-docs-overview`
  for the overview) to regenerate `src/data/*.ts` + theme + manifest, then redeploy via `yad docs deploy`
  (degrading to build-only when no platform CLI). Report every site refreshed, and every site whose
  rebuild failed: `yad docs sync --refresh` exits 1 when a stale site's npm install or build fails, and
  its `--json` `sites` rows say which (`built: false` with an `error`). **Never silent** — refresh
  is a deliberate human/CI act, surfaced exactly like `yad repo refresh`.
- **`wire`** — commit the CI workflow (Step 4) that builds and deploys every site on push.

### Step 4 — `wire`: the CI auto-rebuild workflow
Commit the platform-matched workflow (GitHub `.github/workflows/yad-docs.yml`, or a GitLab `pages` job at
`.gitlab/ci/yad-docs.yml` that must be `include:`d from the root `.gitlab-ci.yml` —
`include: { local: .gitlab/ci/yad-docs.yml }`, the same fragment+include shape as the `yad-checks` gates):
- on a push to the default branch, **build every committed site and deploy them**; it commits nothing,
  so it cannot retrigger itself, and a **concurrency group** keeps one docs deploy at a time;
- a site that fails to build **fails the run** (every failed site is named) and nothing is deployed, so
  the last good site stays live. `yad doctor` warns (`docs-workflow`) when the wired file still deploys after a failed site build (as yadflow 4.5.0 and older wrote it) — re-run
  `yad docs sync --wire`. See `references/staleness.md`.

### Step 5 — Report
Report per target: **fresh** or **stale (why)**; for `refresh`, what was regenerated + the deploy URL or
"build-only"; for `wire`, the workflow path committed. Never advance any epic; docs are not a gate.

## Hard rules

- **Refresh is never silent.** A stale site is *reported*; regenerating + redeploying is a human or CI
  decision (the `yad repo refresh` discipline). `check` is strictly read-only.
- **Docs are never a gate.** This skill never touches `state.json`, `approvals.json`, or
  `contract-lock.json`. Staleness blocks nothing in the SDLC; it only flags out-of-date docs.
- **HEAD-sha staleness, reused.** Repo drift uses the exact `repos.json` `syncedHead`-vs-current-HEAD
  rule. The overview uses config + manifest + diagram + skill-count.
- **CI builds and deploys; it never commits.** The wired workflow builds every committed site on push
  and deploys them, under one concurrency group; it makes no commit, so it cannot retrigger itself. A
  site that fails to build fails the run, and nothing is deployed.
- **Reconcile, don't re-author.** This skill detects drift and delegates regeneration to `yad-docs` /
  `yad-docs-overview`; it does not generate `src/data/*.ts` itself.

## Reference
- The manifest schema (per-epic + overview), the exact hash inputs, the head-sha staleness rule, and the
  CI note: `references/staleness.md`.
- The generators this delegates to: `../yad-docs/SKILL.md`, `../yad-docs-overview/SKILL.md`.
- The docs target it deploys to: `../yad-connect-docs/SKILL.md`.
- The drift / refresh discipline this mirrors: `../yad-connect-repos/SKILL.md` (HEAD-sha staleness).
