|
| 1 | +--- |
| 2 | +name: gh-pr-metadata |
| 3 | +description: Update the current GitHub PR title and body for this repository so they match the repo's pull request template and conventional-commit title style. Use when a PR title is vague or misformatted, when the PR body is missing required sections or checklist items, when Codex needs to normalize PR metadata before review or merge, or when GitHub comments/checks indicate the PR title or body should be corrected. |
| 4 | +--- |
| 5 | + |
| 6 | +# GH PR Metadata |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +Normalize the current branch's GitHub PR metadata to this repo's expectations. Keep the title in conventional-commit style, keep the body aligned to `.github/pull_request_template.md`, and validate before handoff. |
| 11 | + |
| 12 | +Ground the PR metadata in the live branch state, not stale branch names or old commit subjects. Always inspect the current branch diff versus its base before rewriting the PR title/body. |
| 13 | + |
| 14 | +Read [references/repo-pr-format.md](./references/repo-pr-format.md) when you need the exact section order, checklist items, or a title example. |
| 15 | + |
| 16 | +## Workflow |
| 17 | + |
| 18 | +1. Resolve the current branch PR. |
| 19 | + |
| 20 | +```bash |
| 21 | +gh pr view --json number,title,body,url,headRefName,baseRefName |
| 22 | +``` |
| 23 | + |
| 24 | +2. Inspect the current branch state against the PR base branch. |
| 25 | + |
| 26 | +At minimum, check: |
| 27 | + |
| 28 | +```bash |
| 29 | +git diff --name-status origin/<base>...HEAD |
| 30 | +git diff --stat origin/<base>...HEAD |
| 31 | +git log --oneline --decorate --no-merges origin/<base>..HEAD |
| 32 | +``` |
| 33 | + |
| 34 | +Use these to answer: |
| 35 | +- what files actually differ from the base right now |
| 36 | +- which changes are functional versus cleanup/tooling/docs |
| 37 | +- whether the existing PR title/body still matches the current branch after rebases, reverts, or scope narrowing |
| 38 | + |
| 39 | +3. Validate the current title and body. |
| 40 | + |
| 41 | +```bash |
| 42 | +python3 .codex/skills/gh-pr-metadata/scripts/validate_pr_metadata.py |
| 43 | +``` |
| 44 | + |
| 45 | +4. If the PR body needs a clean template scaffold, print one: |
| 46 | + |
| 47 | +```bash |
| 48 | +python3 .codex/skills/gh-pr-metadata/scripts/validate_pr_metadata.py --print-template |
| 49 | +``` |
| 50 | + |
| 51 | +5. Rewrite the PR title in conventional-commit style. |
| 52 | + |
| 53 | +Rules: |
| 54 | +- Prefer `type(scope): summary` |
| 55 | +- Keep the title short and direct |
| 56 | +- Use repo-typical types such as `fix`, `feat`, `docs`, `refactor`, `chore`, `test`, `ci`, `build`, `perf`, `revert` |
| 57 | +- Keep the scope tight to the affected package or subsystem when useful |
| 58 | +- Do not add prefixes like `[codex]` |
| 59 | +- Make sure the title describes the current branch diff, not the original branch intent if the branch was later narrowed or partially reverted |
| 60 | + |
| 61 | +6. Rewrite the PR body to preserve the repo template structure: |
| 62 | +- `## Description` |
| 63 | +- `## Related Issue` |
| 64 | +- `## Types of changes` |
| 65 | +- `## Checklist` |
| 66 | + |
| 67 | +7. Update the PR with `gh`. |
| 68 | + |
| 69 | +Prefer writing the body to a temporary file first, then: |
| 70 | + |
| 71 | +```bash |
| 72 | +gh pr edit --title "<new-title>" --body-file /tmp/pr-body.md |
| 73 | +``` |
| 74 | + |
| 75 | +8. Re-run validation and report whether the PR metadata is now compliant. |
| 76 | + |
| 77 | +```bash |
| 78 | +python3 .codex/skills/gh-pr-metadata/scripts/validate_pr_metadata.py |
| 79 | +``` |
| 80 | + |
| 81 | +## Body Guidance |
| 82 | + |
| 83 | +- Keep `Description` prose-first and specific to the branch. |
| 84 | +- Reflect the branch as it exists now, especially after rebases, cleanups, or partial reverts. |
| 85 | +- Summarize the real file-level themes from the live diff instead of copying commit messages mechanically. |
| 86 | +- Put issue references in `Related Issue`; if there is no issue, say so plainly instead of deleting the section. |
| 87 | +- In `Types of changes`, check only the boxes that actually apply. |
| 88 | +- In `Checklist`, preserve all repo checklist items and mark only the items that are true. |
| 89 | +- Do not remove required sections just because the PR is small. |
| 90 | +- Keep the body concise; do not turn it into a changelog dump. |
| 91 | + |
| 92 | +## Title Guidance |
| 93 | + |
| 94 | +Good examples: |
| 95 | +- `fix(node): normalize remote chunk parsing` |
| 96 | +- `chore(manifest): drop extra compat cleanup` |
| 97 | +- `docs(agents): prefer normalized webpack path requires` |
| 98 | + |
| 99 | +Bad examples: |
| 100 | +- `update pr` |
| 101 | +- `fix stuff` |
| 102 | +- `[codex] cleanup` |
| 103 | + |
| 104 | +## Validation |
| 105 | + |
| 106 | +Use the helper script to detect: |
| 107 | +- non-conventional PR titles |
| 108 | +- missing or reordered template sections |
| 109 | +- missing repo checklist items |
| 110 | + |
| 111 | +The script validates either the current PR from `gh` or explicit `--title` / `--body-file` input. |
0 commit comments