Run scripts/check_template.py to compare a body's headings with the template
it should follow. It reports each template heading that is missing, renamed,
out of order or left empty. The caller owns the rule the body must meet and
fixes the body; this skill only reports.
Running a check
Run it as python3 "$SKILL_DIR/scripts/check_template.py", where SKILL_DIR
is this skill's directory, from the checkout of the repository the body
belongs to.
- Check a draft with
--body FILE, or--body -for standard input, plus--kind issueor--kind pr. Check a posted body with--pr Nor--issue N. - The template is discovered where GitHub looks for it, in the root,
docs/and.github/:pull_request_template.mdor aPULL_REQUEST_TEMPLATE/folder for PRs, andissue_template.mdor anISSUE_TEMPLATE/folder of templates and issue forms for issues.--rootnames another checkout.--repo OWNER/REPOnames the repository for--prand--issueand, without--root, reads the templates from its default branch. - With several templates, pass the one the body follows with
--template-name, matching its front matternameor its file name. Without it the closest fit is used, and a tie is an error. Choose it from what the body is for, such as the issue's or PR's labels or title, and ask only when nothing settles it.--template PATHskips discovery. --jsonprints one JSON object with the same result.
Reading the result
- Exit 0 with
match: every template heading is present, verbatim, in order and has content. - Exit 0 with
no-template: the repository has no template with headings, so there is nothing to compare. - Exit 1 with
mismatch: fix each reported heading in the body and run the check again. - Exit 2 with
operational-error: the check could not compare, for example outside a git checkout, for an unreachable repository, for an issue form it cannot read, or for a body that fits several templates equally. Fix the cause it names, pass--repo,--template-nameor--template PATHas it says, and never treat it as a pass.
It reads Markdown headings in ATX form (## Title). Setext headings and
headings inside list items are not recognized. Reading stops at a pull
request's review note, a --- rule after a blank line followed by an Edit:
line, so the note is not content of the last template section.