{"id":"1b72eb1f-7b32-471c-9c9b-3207380ea473","shortId":"Yg5qxE","kind":"skill","title":"cache-safe-stop-hook-snapshotting","tagline":"Persist a cache-safe stop-hook context snapshot only for main session queries so later helpers can resume from stable state without fork pollution.","description":"# SKILL: Cache-Safe Stop-Hook Snapshotting\n**Domain:** context-management  \n**Trigger:** Apply when end-of-turn hooks need to persist enough state for follow-up helpers, but background forks must not overwrite the main session snapshot.\n**Source Pattern:** Distilled from reviewed context, compaction, and memory-governance patterns.\n\n## Core Method\nBuild one structured hook context at turn end, then persist a cache-safe snapshot only when the query source belongs to the main interactive session or the SDK control path. This gives downstream helpers a stable resume surface while preventing side agents and background forks from clobbering shared state with their own narrower contexts. The snapshot gate lives outside optional prompt-suggestion features so every consumer that depends on the shared state still gets it.\n\n## Key Rules\n- Create the snapshot from the full stop-hook context, not ad hoc fragments, so later consumers see the same system, user, and tool state.\n- Gate snapshot persistence to the authoritative query sources such as `repl_main_thread` and `sdk`.\n- Keep forked or background agents out of the shared snapshot path; their contexts are partial and will pollute resume behavior.\n- Decouple snapshotting from optional background features so state persistence remains available even when prompt suggestions are off.\n\n## Example Application\nIf a REPL turn finishes and `/btw` or another side-question helper may run next, save a cache-safe snapshot from the main turn’s hook context. If a background memory extractor reaches the same stop-hook code, skip the snapshot so the main session state remains authoritative.\n\n## Anti-Patterns (What NOT to do)\n- Do not let every subagent write to the same cache-safe snapshot location; later helpers will resume from polluted or incomplete context.\n- Do not tie snapshot persistence to an unrelated feature flag when multiple consumers depend on it.","tags":["cache","safe","stop","hook","snapshotting","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents"],"capabilities":["skill","source-ychampion","skill-cache-safe-stop-hook-snapshotting","topic-agent-skills","topic-ai-agents","topic-cli","topic-coding-agents","topic-context-engineering","topic-developer-tools","topic-mcp","topic-multi-agent","topic-terminal-ui"],"categories":["cskill-agents"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/ychampion/cskill-agents/cache-safe-stop-hook-snapshotting","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add ychampion/cskill-agents","source_repo":"https://github.com/ychampion/cskill-agents","install_from":"skills.sh"}},"qualityScore":"0.467","qualityRationale":"deterministic score 0.47 from registry signals: · indexed on github topic:agent-skills · 34 github stars · SKILL.md body (1,917 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T06:56:46.291Z","embedding":null,"createdAt":"2026-04-18T22:19:57.602Z","updatedAt":"2026-04-22T06:56:46.291Z","lastSeenAt":"2026-04-22T06:56:46.291Z","tsv":"'/btw':251 'ad':177 'agent':129,210 'anoth':253 'anti':297 'anti-pattern':296 'appli':46 'applic':244 'authorit':196,295 'avail':236 'background':64,131,209,230,276 'behavior':225 'belong':107 'build':87 'cach':2,10,35,99,264,313 'cache-saf':9,34,98,263,312 'cache-safe-stop-hook-snapshot':1 'clobber':134 'code':285 'compact':79 'consum':154,182,338 'context':15,43,78,91,141,175,218,273,325 'context-manag':42 'control':116 'core':85 'creat':166 'decoupl':226 'depend':156,339 'distil':75 'domain':41 'downstream':120 'end':49,94 'end-of-turn':48 'enough':56 'even':237 'everi':153,306 'exampl':243 'extractor':278 'featur':151,231,334 'finish':249 'flag':335 'follow':60 'follow-up':59 'fork':31,65,132,207 'fragment':179 'full':171 'gate':144,191 'get':162 'give':119 'govern':83 'helper':24,62,121,257,318 'hoc':178 'hook':5,14,39,52,90,174,272,284 'incomplet':324 'interact':111 'keep':206 'key':164 'later':23,181,317 'let':305 'live':145 'locat':316 'main':19,70,110,202,269,291 'manag':44 'may':258 'memori':82,277 'memory-govern':81 'method':86 'multipl':337 'must':66 'narrow':140 'need':53 'next':260 'one':88 'option':147,229 'outsid':146 'overwrit':68 'partial':220 'path':117,216 'pattern':74,84,298 'persist':7,55,96,193,234,330 'pollut':32,223,322 'prevent':127 'prompt':149,239 'prompt-suggest':148 'queri':21,105,197 'question':256 'reach':279 'remain':235,294 'repl':201,247 'resum':26,124,224,320 'review':77 'rule':165 'run':259 'safe':3,11,36,100,265,314 'save':261 'sdk':115,205 'see':183 'session':20,71,112,292 'share':135,159,214 'side':128,255 'side-quest':254 'skill':33 'skill-cache-safe-stop-hook-snapshotting' 'skip':286 'snapshot':6,16,40,72,101,143,168,192,215,227,266,288,315,329 'sourc':73,106,198 'source-ychampion' 'stabl':28,123 'state':29,57,136,160,190,233,293 'still':161 'stop':4,13,38,173,283 'stop-hook':12,37,172,282 'structur':89 'subag':307 'suggest':150,240 'surfac':125 'system':186 'thread':203 'tie':328 'tool':189 'topic-agent-skills' 'topic-ai-agents' 'topic-cli' 'topic-coding-agents' 'topic-context-engineering' 'topic-developer-tools' 'topic-mcp' 'topic-multi-agent' 'topic-terminal-ui' 'trigger':45 'turn':51,93,248,270 'unrel':333 'user':187 'without':30 'write':308","prices":[{"id":"07714895-f8bb-4dda-a816-18492a70ee65","listingId":"1b72eb1f-7b32-471c-9c9b-3207380ea473","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"ychampion","category":"cskill-agents","install_from":"skills.sh"},"createdAt":"2026-04-18T22:19:57.602Z"}],"sources":[{"listingId":"1b72eb1f-7b32-471c-9c9b-3207380ea473","source":"github","sourceId":"ychampion/cskill-agents/cache-safe-stop-hook-snapshotting","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/cache-safe-stop-hook-snapshotting","isPrimary":false,"firstSeenAt":"2026-04-18T22:19:57.602Z","lastSeenAt":"2026-04-22T06:56:46.291Z"}],"details":{"listingId":"1b72eb1f-7b32-471c-9c9b-3207380ea473","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"cache-safe-stop-hook-snapshotting","github":{"repo":"ychampion/cskill-agents","stars":34,"topics":["agent-skills","ai-agents","cli","coding-agents","context-engineering","developer-tools","mcp","multi-agent","terminal-ui"],"license":"mit","html_url":"https://github.com/ychampion/cskill-agents","pushed_at":"2026-04-04T14:13:23Z","description":"Agent skills for coding CLIs, multi-agent runtimes, context engines, MCP extensions, and terminal tooling. Instead of using claude code's source code, give your agent skills to create your own!","skill_md_sha":"cccac712b99880623c3e83500508ded7cdf3570f","skill_md_path":"skills/cache-safe-stop-hook-snapshotting/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/cache-safe-stop-hook-snapshotting"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"cache-safe-stop-hook-snapshotting","description":"Persist a cache-safe stop-hook context snapshot only for main session queries so later helpers can resume from stable state without fork pollution."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/cache-safe-stop-hook-snapshotting"},"updatedAt":"2026-04-22T06:56:46.291Z"}}