PR Title Conventional Commit Reminder - Claude Code Hook
Read-only Claude Code Stop hook that checks the current GitHub pull request title against a Conventional Commits style pattern before the session ends, then falls back to the latest commit subject when no PR title is available.
Runs as a Claude Code Stop hook at the end of a session, not after every file edit., Reads the current git branch, repository root, latest commit subject, and, when GitHub CLI is available, the current branch's PR title and URL., Read-only by default: it does not edit PRs, rewrite commits, stage files, push branches, or create release notes., Default mode is advisory and exits 0 on mismatches so it will not block Claude Code from stopping., Set `PR_TITLE_REMINDER_STRICT=1` only after review; strict mode exits 2 when the PR title or fallback commit subject does not match the configured pattern., Set `PR_TITLE_REMINDER_OFFLINE=1` to skip GitHub CLI lookup and use the latest commit subject only.
Privacy notes
The GitHub CLI lookup may send the repository remote, current branch, authentication context, and PR lookup request to GitHub., Hook output can print sanitized PR title, PR URL, branch name, latest commit subject, and allowed type pattern values to local stderr., No files are uploaded by the script itself, but terminal logs, CI transcripts, screenshots, or support bundles can retain the printed metadata., Use commit-only offline mode for repositories where branch names, PR titles, or private remote metadata should not be queried through GitHub CLI.
Author
MkDev11
Submitted by
MkDev11
Claim status
unclaimed
Last verified
2026-06-05
Decision playbook
Review trust signals before you adopt
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
Compare context
Selected
0
Current score
63
Baseline
—
Delta
No baseline selected
No major trust-signal divergence detected in the current selection.
Source and provenance checks
Needs review
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Done
Source provenance statusRequired
Marked as source-backed.
Done
Metadata reviewed
No reviewed flag detected in metadata.
Pending
Safety and privacy checks
Complete
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Done
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Done
Trust level risk gateRequired
Trust level does not block evaluation.
Done
Package and install checks
Needs review
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Done
Package verification flag
No package verification flag provided.
Pending
Checksum metadata
No checksum provided for downloaded artifact.
Pending
Compare-driven decision checks
Needs review
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
6 safety and 4 privacy notes across 4 risk areas. Review closely: credentials & tokens, network access.
4 areas
SafetyCredentials & tokensRuns as a Claude Code Stop hook at the end of a session, not after every file edit.
SafetyGeneralReads the current git branch, repository root, latest commit subject, and, when GitHub CLI is available, the current branch's PR title and URL.
SafetyLocal filesRead-only by default: it does not edit PRs, rewrite commits, stage files, push branches, or create release notes.
SafetyGeneralDefault mode is advisory and exits 0 on mismatches so it will not block Claude Code from stopping.
SafetyGeneralSet `PR_TITLE_REMINDER_STRICT=1` only after review; strict mode exits 2 when the PR title or fallback commit subject does not match the configured pattern.
SafetyGeneralSet `PR_TITLE_REMINDER_OFFLINE=1` to skip GitHub CLI lookup and use the latest commit subject only.
PrivacyNetwork accessThe GitHub CLI lookup may send the repository remote, current branch, authentication context, and PR lookup request to GitHub.
PrivacyGeneralHook output can print sanitized PR title, PR URL, branch name, latest commit subject, and allowed type pattern values to local stderr.
PrivacyNetwork accessNo files are uploaded by the script itself, but terminal logs, CI transcripts, screenshots, or support bundles can retain the printed metadata.
PrivacyNetwork accessUse commit-only offline mode for repositories where branch names, PR titles, or private remote metadata should not be queried through GitHub CLI.
Safety notes
Runs as a Claude Code Stop hook at the end of a session, not after every file edit.
Reads the current git branch, repository root, latest commit subject, and, when GitHub CLI is available, the current branch's PR title and URL.
Read-only by default: it does not edit PRs, rewrite commits, stage files, push branches, or create release notes.
Default mode is advisory and exits 0 on mismatches so it will not block Claude Code from stopping.
Set `PR_TITLE_REMINDER_STRICT=1` only after review; strict mode exits 2 when the PR title or fallback commit subject does not match the configured pattern.
Set `PR_TITLE_REMINDER_OFFLINE=1` to skip GitHub CLI lookup and use the latest commit subject only.
Privacy notes
The GitHub CLI lookup may send the repository remote, current branch, authentication context, and PR lookup request to GitHub.
Hook output can print sanitized PR title, PR URL, branch name, latest commit subject, and allowed type pattern values to local stderr.
No files are uploaded by the script itself, but terminal logs, CI transcripts, screenshots, or support bundles can retain the printed metadata.
Use commit-only offline mode for repositories where branch names, PR titles, or private remote metadata should not be queried through GitHub CLI.
Prerequisites
Claude Code CLI with hooks enabled.
bash, git, grep, sed, and tr available on PATH.
GitHub CLI is optional but recommended; the hook uses `gh pr view` only for read-only PR-title lookup.
A repository PR-title policy based on Conventional Commits or a custom `PR_TITLE_CONVENTIONAL_TYPES` allowlist.
Schema details
Install type
cli
Reading time
6 min
Difficulty score
31
Troubleshooting
Yes
Breaking changes
No
Source repository stats
Scope
Source repo
Runtime and command metadata
Trigger
Stop
Script language
bash
Script body
#!/usr/bin/env bash
set -u
# Claude Code Stop hook. Checks the current PR title with GitHub CLI when a
# branch has an open PR, then falls back to the latest commit subject. The
# default mode is advisory and exits 0. Set PR_TITLE_REMINDER_STRICT=1 to exit
# 2 on a mismatch.
DEFAULT_TYPE_PATTERN="build|chore|ci|content|docs|feat|fix|perf|refactor|revert|style|test"
TYPE_PATTERN="${PR_TITLE_CONVENTIONAL_TYPES:-$DEFAULT_TYPE_PATTERN}"
TYPE_PATTERN=$(printf '%s' "$TYPE_PATTERN" | tr ',' '|')
CONVENTIONAL_RE="^(${TYPE_PATTERN})(\\([A-Za-z0-9._/-]+\\))?!?: .+"
is_conventional() {
printf '%s\n' "$1" | grep -Eq "$CONVENTIONAL_RE"
}
sanitize_for_terminal() {
# PR titles, branch names, and commit subjects can come from untrusted
# repositories. Strip C0 and DEL control bytes before printing them so
# terminal escape sequences (for example OSC 52) are not emitted raw.
printf '%s' "$1" | LC_ALL=C tr -d '\000-\037\177'
}
finish_mismatch() {
label=$(sanitize_for_terminal "$1")
value=$(sanitize_for_terminal "$2")
extra=$(sanitize_for_terminal "${3:-}")
type_pattern=$(sanitize_for_terminal "$TYPE_PATTERN")
printf 'PR title reminder: %s does not look like a Conventional Commits title.\n' "$label" >&2
printf ' Found: %s\n' "$value" >&2
printf ' Expected: type(scope): summary, for example content(hooks): add reminder hook\n' >&2
printf ' Allowed types: %s\n' "$type_pattern" >&2
if [ -n "$extra" ]; then
printf ' %s\n' "$extra" >&2
fi
if [ "${PR_TITLE_REMINDER_STRICT:-0}" = "1" ]; then
exit 2
fi
exit 0
}
if ! command -v git >/dev/null 2>&1; then
exit 0
fi
PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || true)
if [ -z "$PROJECT_ROOT" ]; then
exit 0
fi
cd "$PROJECT_ROOT" 2>/dev/null || exit 0
BRANCH=$(git branch --show-current 2>/dev/null || true)
if [ -z "$BRANCH" ]; then
exit 0
fi
case "$BRANCH" in
main|master|trunk)
if [ "${PR_TITLE_REMINDER_CHECK_DEFAULT:-0}" != "1" ]; then
exit 0
fi
;;
esac
if [ "${PR_TITLE_REMINDER_OFFLINE:-0}" != "1" ] && command -v gh >/dev/null 2>&1; then
PR_DATA=$(gh pr view --json title,url,headRefName --template '{{.title}}{{"\n"}}{{.url}}{{"\n"}}{{.headRefName}}{{"\n"}}' 2>/dev/null || true)
PR_TITLE=$(printf '%s\n' "$PR_DATA" | sed -n '1p')
PR_URL=$(printf '%s\n' "$PR_DATA" | sed -n '2p')
PR_HEAD=$(printf '%s\n' "$PR_DATA" | sed -n '3p')
if [ -n "$PR_TITLE" ]; then
if is_conventional "$PR_TITLE"; then
exit 0
fi
EXTRA="PR: $PR_URL"
if [ -n "$PR_HEAD" ]; then
EXTRA="PR: $PR_URL (head: $PR_HEAD)"
fi
finish_mismatch "current PR title" "$PR_TITLE" "$EXTRA"
fi
fi
SUBJECT=$(git log -1 --pretty=%s 2>/dev/null || true)
if [ -z "$SUBJECT" ]; then
exit 0
fi
if is_conventional "$SUBJECT"; then
exit 0
fi
finish_mismatch "latest commit subject on $BRANCH" "$SUBJECT" "No current PR title was available; install and authenticate gh, or set PR_TITLE_REMINDER_OFFLINE=1 for commit-only mode."
This hook gives a final local reminder before a Claude Code session stops: is
the current PR title ready for release tooling?
It uses Conventional Commits
as the default title shape, including the repository-specific content type
used by this directory's content PR workflow. When gh is installed and
authenticated, the hook reads the current branch's PR title with
gh pr view. When no PR is available, it falls back to the latest commit
subject so a contributor still gets a useful reminder before pushing or opening
a PR.
Features
Checks the current GitHub PR title at session stop, after Claude has finished
editing and before a human is likely to open or update a PR.
Falls back to the latest commit subject when GitHub CLI is missing,
unauthenticated, offline, or the current branch has no PR.
Accepts common Conventional Commits types plus content by default:
build, chore, ci, content, docs, feat, fix, perf,
refactor, revert, style, and test.
Supports custom type policy with PR_TITLE_CONVENTIONAL_TYPES, using either
a pipe-separated or comma-separated list.
Stays advisory by default and can be made blocking only with the explicit
PR_TITLE_REMINDER_STRICT=1 opt-in.
How It Works
On Stop, the hook confirms it is running inside a git work tree and skips
default branches such as main, master, and trunk unless
PR_TITLE_REMINDER_CHECK_DEFAULT=1 is set.
For feature branches, it first tries a read-only gh pr view --json title,url,headRefName. If a PR title is found, the title must match:
type(scope): summary
The scope is optional and a breaking-change bang is allowed, so
feat!: remove legacy endpoint and fix(api): handle empty cursor both pass.
If no PR title is available, the same check runs against git log -1 --pretty=%s.
Use Cases
Keep squash-merge PR titles release-note ready in repositories that generate
changelogs or release notes from merge commit subjects.
Nudge Claude to update a vague title such as updates before the contributor
requests review.
Support content repositories whose PR titles use a custom type like
content(hooks): add package policy hook.
Keep the reminder local and lightweight instead of adding a repository-wide
required check.
Installation
Create the hooks directory: mkdir -p .claude/hooks
Create the hook file:
touch .claude/hooks/pr-title-conventional-commit-reminder.sh
Paste the script body into that file and make it executable:
chmod +x .claude/hooks/pr-title-conventional-commit-reminder.sh
Add the configuration below to .claude/settings.json for a project hook or
~/.claude/settings.json for a user hook.
Authenticate GitHub CLI with gh auth login if you want PR-title lookup.
PR_TITLE_CONVENTIONAL_TYPES - allowed type names, separated by | or ,.
Defaults to build|chore|ci|content|docs|feat|fix|perf|refactor|revert|style|test.
PR_TITLE_REMINDER_STRICT=1 - exit 2 on a mismatch. Leave unset for the
default advisory behavior.
PR_TITLE_REMINDER_OFFLINE=1 - skip GitHub CLI lookup and check only the
latest commit subject.
PR_TITLE_REMINDER_CHECK_DEFAULT=1 - check main, master, or trunk
instead of skipping default branches.
Limitations
The hook checks title shape, not whether the title accurately describes the
diff.
GitHub CLI looks up the PR for the current branch, so forks, renamed remotes,
or multiple matching PRs can require normal gh configuration first.
Custom scopes are treated syntactically; the hook does not know whether
api, docs, or hooks are approved scopes for a repository.
Strict mode can interrupt a stop workflow, so enable it only after the team
agrees on title policy and false-positive handling.
Related Content Fit
This entry is intentionally narrower than the existing git-smart-commit command,
git pre-commit validator hook, Husky commit governance skill, and contributor
commit/changelog rules. Those entries help create or review commits and release
policy. This hook adds a session-end runtime reminder focused on the current PR
title, with explicit GitHub CLI network/account disclosure and an offline
fallback.
Show that PR Title Conventional Commit Reminder - Claude Code Hook is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/pr-title-conventional-commit-reminder-hook)
How it compares
PR Title Conventional Commit Reminder - Claude Code Hook side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
3 trust signals differ across this comparison (Package trust, Source provenance, Submitter).
Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.
Read-only Claude Code Stop hook that checks the current GitHub pull request title against a Conventional Commits style pattern before the session ends, then falls back to the latest commit subject when no PR title is available.
Source-backed rules for contributor pull requests that need clear commit messages, release-note-ready changelog entries, issue links, breaking-change markers, and privacy-safe history.
✓Runs as a Claude Code Stop hook at the end of a session, not after every file edit.
Reads the current git branch, repository root, latest commit subject, and, when GitHub CLI is available, the current branch's PR title and URL.
Read-only by default: it does not edit PRs, rewrite commits, stage files, push branches, or create release notes.
Default mode is advisory and exits 0 on mismatches so it will not block Claude Code from stopping.
Set `PR_TITLE_REMINDER_STRICT=1` only after review; strict mode exits 2 when the PR title or fallback commit subject does not match the configured pattern.
Set `PR_TITLE_REMINDER_OFFLINE=1` to skip GitHub CLI lookup and use the latest commit subject only.
✓Read-only with respect to your repository when refs are validated and passed as git arguments; it only reads git history (tags and commit log) and never creates tags, commits, branches, or release artifacts.
Validate the optional ref or discovered tag with `git rev-parse --verify --quiet <ref>^{commit}` and reject refs containing shell metacharacters before reading history.
It proposes a version bump and notes for you to review; it does not publish a release or push anything.
✓Commit messages, PR titles, and changelog entries become durable release history; misleading text can cause incorrect SemVer bumps, missed migrations, or hidden breaking changes.
Do not hide security fixes, data migrations, dependency trust changes, deprecations, or public API changes inside vague commit messages such as update, cleanup, or misc.
When release tooling parses commit history, malformed types, missing breaking-change markers, or noisy commits can publish incorrect release notes.
✓May produce commands or configuration for live infrastructure, CI, releases, or indexing; test changes in staging or dry-run mode first.
Use least-privilege API tokens and review workflow, deploy, DNS, cache, and release changes before applying them to production.
Privacy notes
✓The GitHub CLI lookup may send the repository remote, current branch, authentication context, and PR lookup request to GitHub.
Hook output can print sanitized PR title, PR URL, branch name, latest commit subject, and allowed type pattern values to local stderr.
No files are uploaded by the script itself, but terminal logs, CI transcripts, screenshots, or support bundles can retain the printed metadata.
Use commit-only offline mode for repositories where branch names, PR titles, or private remote metadata should not be queried through GitHub CLI.
✓Commit subjects, bodies, and author names from the selected range are included in the model's context to draft the notes.
If commit messages contain internal identifiers, customer names, or unreleased details, those become part of the prompt; review the range before running on a private history.
The command writes nothing to disk on its own.
✓Commit subjects, changelog entries, issue links, and release notes can expose customer names, account IDs, private roadmap items, vulnerability details, incident context, internal hostnames, or partner information.
Use synthetic examples and public-safe wording in changelog entries; move sensitive incident or vulnerability details to approved private advisories or security channels.
Review generated release notes before publication because they may combine private branch names, issue titles, commit bodies, and contributor text.
✓Inputs can include repository metadata, workflow logs, deployment settings, domain names, analytics exports, and service configuration.
Redact tokens, account IDs, private URLs, customer data, and proprietary deployment details before sharing generated reports or prompts.
Prerequisites
Claude Code CLI with hooks enabled.
bash, git, grep, sed, and tr available on PATH.
GitHub CLI is optional but recommended; the hook uses `gh pr view` only for read-only PR-title lookup.
A repository PR-title policy based on Conventional Commits or a custom `PR_TITLE_CONVENTIONAL_TYPES` allowlist.
— none listed
A contributor pull request with commit history, PR title, PR body, and enough diff context to decide whether release notes are needed.
Repository guidance for commit style, squash/merge behavior, changelog format, issue-linking expectations, and release process.
Access to the current changelog, release notes, linked issues, and any generated release-preview output used by maintainers.
Permission to request a title, commit, changelog, or PR body update before merge.