---
name: yad-commit
description: 'Commit one staged atomic change by the conventions (subject, trailers, small-diff guard). Use when the user says "commit this", "commit by convention", or "make an atomic commit".'
---

# SDLC — Commit by Convention (Build helper)

<!-- 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:** Turn ONE staged atomic change into a single commit that satisfies the project conventions
(`CONTRIBUTING.md` / `config.yaml` `build`): a Conventional-Commits subject, the fixed trailer order
`Task → Contract-Change → Ledger-Override → Co-Authored-By` (the override only with `--manual`; the footer
**off by default** — added only via an explicit `--ai`), and the atomic-file guard. This is the standalone commit step — the same engine `yad-implement`
and `yad-ship` use. It **never auto-advances**; it just commits.

## Conventions

- Run **inside the repo holding the staged change** — a code repo under
  `{project-root}/demo-repos/<repo>/`, or the Product itself. Use absolute paths.
- **Stage first.** Only the staged (`git add`) atomic change is committed. The guard refuses more than
  `ATOMIC_FILE_LIMIT` (3) staged files unless `--force` — split the change instead. In a Unity repo
  (`ProjectSettings/ProjectVersion.txt` and `Assets/`), a staged `.meta` whose own file or folder is staged
  too is not counted (#321).
- **Subject** — `<type>: <lowercase imperative description, no trailing period>`; types are
  `feat|fix|docs|refactor|test|perf|build|ci|chore|revert`; proper nouns/acronyms keep their case.
- **Task trailer** — required on a code repo (anchors the `spec-link` + `commit-message` gates). Given
  with `--task` (a `<story>-T<NN>` id, the story an `EP-<slug>-S<n>` with a lowercase slug — an explicit
  value is validated against the `spec-link` contract, so a malformed id like a bare `EP-x-S01` or an
  `EP-Demo-S01-T01` fails locally instead of after a push), else
  derived from the branch (`feat/<story>-<task>-…`). Product commits are not
  task-scoped, so the trailer is optional there — a missing-Task warning is informational on the Product
  (`spec-link` is a code-repo gate) and only flags a real gate failure in a code repo.
- **Contract-Change trailer** — `--contract-change` only when the diff touches the locked contract
  surface; it routes the change back to the architecture gate.
- **AI co-author footer — OFF by default.** No `Co-Authored-By` trailer is written unless `--ai <id>`
  explicitly names a tool. `--ai none` (the default) produces a clean human-only commit. The flag is the
  **only** switch that adds the footer — never add it on the AI's own initiative just because a tool
  helped author the diff. The human is always the author.

## Inputs

- `type`    — Conventional-Commits type (required).
- `message` — the subject text (required), `-m "<subject>"`.
- `ai`      — co-author footer: `claude|copilot|cursor|coderabbit|none` (default `none` = **no footer**;
  the `Co-Authored-By` trailer appears only when this flag names a tool).
- `task`    — Task trailer (optional; derived from the branch when omitted).
- `contractChange` — flag; mark the contract surface touched.
- `manual` + `reason` — the ledger override (E49), for a PERSON only. On a verified Product a local
  pre-commit hook refuses a commit that changes a CI-owned file (the gate ledger, the Product index).
  `--manual --reason "<why>"` commits past that hook and records the reason as a `Ledger-Override:`
  trailer. It is refused when nothing staged is a file that hook refuses. The `ledger-guard` check on
  the pull request still fails the commit, and quotes the reason. A reason that starts with `-` is
  passed as `--reason=-…`.

## On Activation

### Step 1 — Confirm the atomic stage
Confirm the change is staged and stays within the file boundary (≤3 files where possible). If more is
staged, split it into separate commits rather than passing `--force`.

### Step 2 — Commit by convention
Run the CLI from the repo root:
```
yad commit --type <type> -m "<subject>" [--body "<text>"] [--ai <id>] [--task <id>] [--contract-change] [--manual --reason "<why>"] [--dry-run]
```
`--body` adds a body between the subject and the trailers, as its own paragraph — for example the
`Decisions:` paragraph `yad-implement` writes (#357). `yad ship` takes no body: commit with `yad commit`, and open the
PR/MR later, when the flow says to (`yad open-pr`). Use `--dry-run` first to preview the exact message (subject + trailer block) without committing. The
CLI validates the type, rejects a trailing period, and emits the trailers in the fixed order.

### Step 3 — Stop (no auto-advance)
Report what was committed (files + Task). If `--contract-change` was set, note that it routes back to
the architecture gate. To also open the PR/MR in the same step, use `yad-ship`.

## Hard rules

- **One staged atomic change = one commit.** Never bundle; never exceed the file boundary silently.
- **No AI footer by default.** A `Co-Authored-By` trailer is written ONLY when `--ai <id>` is explicitly
  passed; the default is a clean human-only commit. Never add it on your own initiative.
- **The human author owns the commit.** The AI is at most a `Co-Authored-By` footer, never the author.
- **Trailer order is fixed:** `Task → Contract-Change → Ledger-Override → Co-Authored-By` (the override only
  with `--manual`, the footer only when `--ai` is given).
- **Never widen the contract here.** A contract touch is flagged (`--contract-change`), not hidden.
- **Never pass `--manual` yourself, even when asked (E158).** Committing past the ledger hook is the person's
  act. Give them the exact command (in Claude Code: `! yad commit --manual --reason "<why>"`), wait, then
  confirm by reading (`git log -1`). `--manual` needs `--reason`, and the reason must be one line. The agent
  guard hook refuses it if you try.

## Reference
- Branch/commit conventions + the file-boundary rule: `../yad-implement/references/implement-conventions.md`.
- The full convention text: `CONTRIBUTING.md`; the config: `.sdlc/config.yaml` `build`.
- The gate that enforces the subject pattern: `../yad-checks/references/check-gates.md` (`commit-message`).
- Open the PR/MR after committing: `../yad-open-pr/SKILL.md`; both at once: `../yad-ship/SKILL.md`.
