PostToolUse hook that keeps a project's README in sync with the code. When the README or package.json is edited it checks for the standard-readme core sections (Install and Usage) and verifies that the CLI commands exposed via package.json bin are documented. Advisory only; it never edits files.
Runs after every Write, Edit, and MultiEdit but only acts when the edited file is a README or a package.json, then reads those files and the nearby README from disk., Read-only and advisory - it inspects text only, never edits, creates, or deletes files, and always exits 0., Section and command matching uses simple text heuristics, so it can miss an unconventional README layout or flag a command that is documented only indirectly.
Privacy notes
Reads the local README and package.json only; it makes no network calls., Prints missing section names and sanitized undocumented command names to local hook stderr; it writes no logs., Command and file names shown in output may reveal project structure in your terminal.
Author
techforgeworks
Submitted by
techforgeworks
Claim status
unclaimed
Last verified
2026-06-04
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
78
Baseline
—
Delta
No baseline selected
No major trust-signal divergence detected in the current selection.
Source and provenance checks
Complete
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
Registry metadata indicates a reviewed listing.
Done
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.
Current risk score 16/100. Use staged verification before broader rollout.
Risk 16
Pre-adoption checks
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Done
Confirm metadata review state
Listing has review metadata.
Done
Verify install payload
Install/config payload exists and can be inspected.
Done
Security checks
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Done
Review privacy notesRequired
Privacy notes are present.
Done
Verify package integrity metadata
No package verification/checksum metadata.
Pending
Rollout
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Pending
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Pending
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Pending
Evidence readiness
Evidence readiness matrix · balanced
Required evidence gates are covered (5/6 signals complete).
Risk 15
Source provenance
Present
Source repository/provenance is listed.
Required in this preset
Metadata review
Present
Review metadata is present.
Required in this preset
Safety notes
Present
Safety notes are present.
Required in this preset
Privacy notes
Present
Privacy notes are present.
Optional in this preset
Package integrity
Missing
Package integrity metadata is missing.
Optional in this preset
Install payload
Present
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
Decision timeline · balanced
5/6 steps complete with no blocking gaps for this preset.
Risk 14
triage
Confirm source provenanceRequired
Source/provenance metadata is available.
Done
triage
Check metadata review statusRequired
Review metadata is available.
Done
verify
Review safety notesRequired
Safety notes are available.
Done
verify
Review privacy notes
Privacy notes are available.
Done
verify
Validate package integrity metadata
Package integrity metadata is missing.
Pending
rollout
Verify install payload and commandsRequired
Install payload is available.
Done
No required blockers for this timeline preset.
Prerequisite readiness
Prerequisite readiness
2 prerequisites to line up before setup.
0/2 ready
Install & runtime1General1
Safety & privacy surface
Safety & privacy surface
3 safety and 3 privacy notes across 3 risk areas. Review closely: network access.
3 areas
SafetyLocal filesRuns after every Write, Edit, and MultiEdit but only acts when the edited file is a README or a package.json, then reads those files and the nearby README from disk.
SafetyLocal filesRead-only and advisory - it inspects text only, never edits, creates, or deletes files, and always exits 0.
SafetyExecution & processesSection and command matching uses simple text heuristics, so it can miss an unconventional README layout or flag a command that is documented only indirectly.
PrivacyNetwork accessReads the local README and package.json only; it makes no network calls.
PrivacyExecution & processesPrints missing section names and sanitized undocumented command names to local hook stderr; it writes no logs.
PrivacyLocal filesCommand and file names shown in output may reveal project structure in your terminal.
Safety notes
Runs after every Write, Edit, and MultiEdit but only acts when the edited file is a README or a package.json, then reads those files and the nearby README from disk.
Read-only and advisory - it inspects text only, never edits, creates, or deletes files, and always exits 0.
Section and command matching uses simple text heuristics, so it can miss an unconventional README layout or flag a command that is documented only indirectly.
Privacy notes
Reads the local README and package.json only; it makes no network calls.
Prints missing section names and sanitized undocumented command names to local hook stderr; it writes no logs.
Command and file names shown in output may reveal project structure in your terminal.
Prerequisites
Claude Code CLI with hooks enabled.
bash and jq on PATH; the hook fails open and stays silent when jq is missing.
Schema details
Install type
cli
Troubleshooting
No
Source repository stats
Scope
Source repo
Runtime and command metadata
Trigger
PostToolUse
Script language
bash
Script body
#!/usr/bin/env bash
set -u
# Claude Code PostToolUse hook. When a README or package.json is edited, it
# checks the README for the standard-readme core sections (Install, Usage) and
# verifies that every CLI command exposed via package.json "bin" is mentioned.
# Advisory only - it always exits 0, never edits files - and fails open when jq
# is unavailable.
command -v jq >/dev/null 2>&1 || exit 0
sanitize_output() {
# Strip ASCII control characters before printing untrusted package or path
# names to the terminal.
LC_ALL=C tr -d '\000-\037\177'
}
safe() {
printf '%s' "$1" | sanitize_output
}
INPUT=$(cat)
FILE=$(printf '%s' "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
readme=""
pkg=""
case "$FILE" in
*README.md|*README.markdown|*Readme.md|*readme.md) readme="$FILE" ;;
*/package.json|package.json) pkg="$FILE" ;;
*) exit 0 ;;
esac
dir=$(dirname -- "$FILE")
if [ -z "$readme" ]; then
for c in "$dir/README.md" "README.md" "$dir/readme.md"; do
[ -f "$c" ] && { readme="$c"; break; }
done
fi
if [ -z "$pkg" ]; then
for c in "$dir/package.json" "package.json"; do
[ -f "$c" ] && { pkg="$c"; break; }
done
fi
if [ -z "$readme" ] || [ ! -f "$readme" ]; then
[ -n "$pkg" ] && echo "README refresh: no README found near $(safe "$FILE") - add one with Install and Usage sections (see standard-readme)." >&2
exit 0
fi
low=$(tr '[:upper:]' '[:lower:]' < "$readme")
for sec in install usage; do
if ! printf '%s' "$low" | grep -qE "^#{1,3}[[:space:]].*${sec}"; then
echo "README refresh: missing a '${sec}' section (standard-readme expects Install and Usage)." >&2
fi
done
if [ -n "$pkg" ] && [ -f "$pkg" ]; then
bins=$(jq -r '
if (.bin | type) == "object" then (.bin | keys[])
elif (.bin | type) == "string" then (.name // empty)
else empty end' -- "$pkg" 2>/dev/null)
printf '%s\n' "$bins" | while IFS= read -r b; do
[ -z "$b" ] && continue
if ! printf '%s' "$b" | LC_ALL=C grep -qE '^[[:alnum:]_.@/:+-]+$'; then
echo "README refresh: skipping package.json bin with unsupported characters: '$(safe "$b")'." >&2
continue
fi
if ! grep -qiF -- "$b" "$readme"; then
echo "README refresh: CLI command '$(safe "$b")' (from package.json bin) is not mentioned in $(safe "$readme")." >&2
fi
done
fi
exit 0
Keeps the README in sync with the code by checking it whenever the README or package.json is edited.
Verifies the standard-readme core sections are present — Install and Usage.
Confirms every CLI command the package exposes through its package.jsonbin field is actually documented in the README.
Advisory only — it always exits 0 and never edits, creates, or deletes files.
Fails open and makes no network calls; it reads only the local README and package.json.
How it works
On PostToolUse, the hook acts only when the edited file is a README or a package.json. It locates the nearest README, lowercases it, and checks for Install and Usage headings. If a package.json is present, it reads the bin field (an object of command names, or a string command equal to the package name) and reports any exposed command that the README never mentions. Findings print to stderr; nothing is blocked.
Use cases
Catch a README that still lists an old command set after a CLI is renamed or added.
Enforce a minimum README shape (Install + Usage) on new packages.
Nudge an agent to document a new bin entry it just added to package.json.
Installation
Create the hooks directory: mkdir -p .claude/hooks
Create the hook file: touch .claude/hooks/readme-refresh-validator.sh
Paste the script body into that file and make it executable: chmod +x .claude/hooks/readme-refresh-validator.sh
Add the configuration below to .claude/settings.json (project) or ~/.claude/settings.json (user).
Section detection looks for Install and Usage headings; a README that documents those steps under different heading names will be flagged even though it is complete.
The command-coverage check uses npm package.jsonbin; it does not yet read CLI definitions from other ecosystems (for example Python entry points or Go cmd/ packages).
Show that README Refresh Validator - 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/readme-refresh-validator)
How it compares
README Refresh Validator - Claude Code Hook side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
1 trust signal differ across this comparison (Submitter).
PostToolUse hook that keeps a project's README in sync with the code. When the README or package.json is edited it checks for the standard-readme core sections (Install and Usage) and verifies that the CLI commands exposed via package.json bin are documented. Advisory only; it never edits files.
PostToolUse hook that compares a just-edited OpenAPI or JSON Schema document against the version committed in git and warns about backward-incompatible drift — removed OpenAPI paths and removed required properties — so breaking API changes are surfaced before they ship. Advisory only; it never blocks the edit.
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 after every Write, Edit, and MultiEdit but only acts when the edited file is a README or a package.json, then reads those files and the nearby README from disk.
Read-only and advisory - it inspects text only, never edits, creates, or deletes files, and always exits 0.
Section and command matching uses simple text heuristics, so it can miss an unconventional README layout or flag a command that is documented only indirectly.
✓Runs after every Write, Edit, and MultiEdit and only inspects JSON files that declare openapi, swagger, a $schema key, or paths.
Stays read-only and runs git show to read the committed version; it never edits, stages, or commits anything.
Advisory by design and always exits 0, so it never blocks a write even when drift is detected.
Uses key-set comparison heuristics for removed paths and required fields, so it catches common breaking changes but is not a full OpenAPI diff.
✓Runs after Write, Edit, and MultiEdit and inspects only the edited file path to decide whether a dependency manifest or lockfile changed.
Install this project-relative command only in the trusted project's `.claude/settings.json`; user/global hooks must point to a trusted absolute path outside project directories.
Default mode is advisory, prints the ORT command to run, and always exits 0 without reading dependency contents, creating reports, or contacting registries.
When `ORT_LICENSE_HOOK_RUN=1` is set, it runs `ort analyze` in the project root and writes reports under `.claude/ort-license-checks/` by default.
An opted-in ORT run may invoke package managers, inspect dependency graphs, read project configuration, fetch package metadata, and take several minutes on large repositories.
Strict mode exits 2 only when `ORT_LICENSE_HOOK_STRICT=1` is also set and the opted-in ORT analysis fails.
✓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
✓Reads the local README and package.json only; it makes no network calls.
Prints missing section names and sanitized undocumented command names to local hook stderr; it writes no logs.
Command and file names shown in output may reveal project structure in your terminal.
✓Reads the edited schema file and its committed HEAD version from the local repository only.
Prints removed path and required-field names to local hook stderr; it makes no network calls and writes no logs.
Path and field names shown in output may reveal internal API surface in your terminal.
✓Default advisory mode prints only the changed dependency file path and the suggested local ORT command.
Opted-in ORT runs can record dependency names, versions, package metadata, source URLs, license findings, project paths, package-manager output, and configuration details in local report files.
Package managers or ORT integrations may contact configured package registries, VCS hosts, or metadata services during analysis.
Review generated reports before sharing them because internal package names, private registry hostnames, source URLs, and license-policy exceptions can be sensitive.
✓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 and jq on PATH; the hook fails open and stays silent when jq is missing.
Claude Code CLI with hooks enabled.
git, jq, and bash on PATH; the hook fails open and stays silent when git or jq is missing.
The schema file must be tracked in git so a committed baseline exists to diff against.
Claude Code CLI with hooks enabled.
bash available on PATH; jq is recommended for parsing hook input.
OSS Review Toolkit installed and available as `ort` only when `ORT_LICENSE_HOOK_RUN=1` is used.
Java, package managers, and any project-specific ORT requirements prepared before running a real ORT analysis.
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.