OKF bundle staleness reminder at stop
End no session without refreshing a stale knowledge base
At session end, re-checks the OKF bundle freshness and blocks the stop with a reminder if the bundle is stale and was not enriched during the session. Reuses the detection from session-start-okf-staleness. No-op when there is no OKF bundle.
What does the OKF bundle staleness reminder at stop hook do?
OKF bundle staleness reminder at stop is a Claude Code Stop hook. It fires automatically at that lifecycle event — outside the model, so it can't be skipped or forgotten. End no session without refreshing a stale knowledge base.
As a Stop hook it runs after the action, reacting to what just happened rather than blocking it. Because it is a deterministic Node.js script, it executes on every matching event without relying on the model to remember — the guarantee that makes agentic workflows safe to automate.
Use cases
- Definition-of-done: never close a session on a stale knowledge base
- Pair with session-start-okf-staleness for a full staleness loop
Tags
settings.json fragment
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "node $CLAUDE_PROJECT_DIR/.claude/hooks/stop-okf-staleness-check.mjs"
}
]
}
]
}
}Script · .claude/hooks/stop-okf-staleness-check.mjs
#!/usr/bin/env node
// @hookstack stop-okf-staleness-check
// Auto-bonification OKF : à la fin de session, rappelle si le bundle est périmé
// et n'a pas été enrichi pendant la session. Réutilise la détection de
// okf-staleness-check.mjs (SessionStart) — même règle, message adapté au Stop. (Stop)
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { run as checkOkfStale } from "./okf-staleness-check.mjs";
export function run(_input, deps) {
const context = checkOkfStale(deps);
if (!context) return null;
return {
message: `[okf-staleness] Bundle OKF périmé — enrichir avant de clore la session :\n${context}`,
};
}
/* v8 ignore next 5 */
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const input = JSON.parse(readFileSync(0, "utf8"));
const result = run(input);
if (result?.message) process.stderr.write(result.message);
}
Learn more
Related hooks
- Session summary generationAn automatic changelog of what the agent shipped
- Save compaction summary to logKeep a readable trail of every compaction
- Docs consistency reminderNo more READMEs telling two different stories
- Force implementation doc at stopNo code change ships without a doc/implementation/ trace