{"id":"66edbef3-a52a-410f-aab3-2beab3227c0d","shortId":"bNTDfT","kind":"skill","title":"cache-identical-fork-prefix-construction","tagline":"Build forked conversation prefixes that stay identical across turns so prompt caching keeps working.","description":"# SKILL: Cache Identical Fork Prefix Construction\n**Domain:** caching\n**Trigger:** Use this when a forked agent must reuse the parent prompt cache and needs byte-identical prefixes for each invocation.\n**Source Pattern:** Distilled from reviewed subagent orchestration, isolation, and lifecycle implementations.\n\n## Core Method\nDuplicate the parent assistant message wholesale, then generate a single user message containing standardized tool_result placeholders (all with the same text) followed by the directive text. Keeping every byte of the assistant message and placeholder deterministic ensures that identical tool_use sequences map to the same cache key. Build a child-specific directive message by wrapping it in `<fork-boilerplate>` and appending fork directive prefix before the per-worker instructions.\n\n## Key Rules\n- Never mutate the cached assistant message; copy it to a new object and only append the uniform tool_result blocks and directive text afterward.\n- Use identical placeholder text (`Fork started — processing in background`) for every tool_result so the child prefix byte stream stays constant across runs.\n- Append the directive text as the final block after the placeholders, ensuring fork children encode their own instructions without altering earlier bytes.\n- Provide the directive in the same build child message helper so the cached prefix always ends with the same sentinel.\n\n## Example Application\nWhen the model triggers a fork from an inline agent, reuse this method to build the fork prompt so the fork shares the cache of the parent — future identical tasks reuse the same cached prefix and avoid redundant API calls.\n\n## Anti-Patterns (What NOT to do)\n- Do not recompute the assistant message or tool_result text differently per turn; any divergence breaks the cache key.\n- Avoid embedding random IDs or timestamps inside the prefix; keep only stable verbatim text before the directive block.","tags":["cache","identical","fork","prefix","construction","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents"],"capabilities":["skill","source-ychampion","skill-cache-identical-fork-prefix-construction","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-identical-fork-prefix-construction","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,933 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.135Z","embedding":null,"createdAt":"2026-04-18T22:19:56.107Z","updatedAt":"2026-04-22T06:56:46.135Z","lastSeenAt":"2026-04-22T06:56:46.135Z","tsv":"'across':14,182 'afterward':160 'agent':35,237 'alter':203 'alway':220 'anti':269 'anti-pattern':268 'api':266 'append':125,151,184 'applic':227 'assist':67,96,141,279 'avoid':264,294 'background':169 'block':156,191,311 'break':290 'build':7,113,212,242 'byte':45,93,178,205 'byte-ident':44 'cach':2,18,22,28,41,111,140,218,251,261,292 'cache-identical-fork-prefix-construct':1 'call':267 'child':116,176,213 'child-specif':115 'children':197 'constant':181 'construct':6,26 'contain':76 'convers':9 'copi':143 'core':62 'determinist':100 'differ':285 'direct':89,118,127,158,186,208,310 'distil':53 'diverg':289 'domain':27 'duplic':64 'earlier':204 'embed':295 'encod':198 'end':221 'ensur':101,195 'everi':92,171 'exampl':226 'final':190 'follow':86 'fork':4,8,24,34,126,165,196,233,244,248 'futur':255 'generat':71 'helper':215 'id':297 'ident':3,13,23,46,103,162,256 'implement':61 'inlin':236 'insid':300 'instruct':134,201 'invoc':50 'isol':58 'keep':19,91,303 'key':112,135,293 'lifecycl':60 'map':107 'messag':68,75,97,119,142,214,280 'method':63,240 'model':230 'must':36 'mutat':138 'need':43 'never':137 'new':147 'object':148 'orchestr':57 'parent':39,66,254 'pattern':52,270 'per':132,286 'per-work':131 'placehold':80,99,163,194 'prefix':5,10,25,47,128,177,219,262,302 'process':167 'prompt':17,40,245 'provid':206 'random':296 'recomput':277 'redund':265 'result':79,155,173,283 'reus':37,238,258 'review':55 'rule':136 'run':183 'sentinel':225 'sequenc':106 'share':249 'singl':73 'skill':21 'skill-cache-identical-fork-prefix-construction' 'sourc':51 'source-ychampion' 'specif':117 'stabl':305 'standard':77 'start':166 'stay':12,180 'stream':179 'subag':56 'task':257 'text':85,90,159,164,187,284,307 'timestamp':299 'tool':78,104,154,172,282 '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':29,231 'turn':15,287 'uniform':153 'use':30,105,161 'user':74 'verbatim':306 'wholesal':69 'without':202 'work':20 'worker':133 'wrap':121","prices":[{"id":"6c26cab5-d2d3-44ec-a0e2-a64c8a777aa5","listingId":"66edbef3-a52a-410f-aab3-2beab3227c0d","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:56.107Z"}],"sources":[{"listingId":"66edbef3-a52a-410f-aab3-2beab3227c0d","source":"github","sourceId":"ychampion/cskill-agents/cache-identical-fork-prefix-construction","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/cache-identical-fork-prefix-construction","isPrimary":false,"firstSeenAt":"2026-04-18T22:19:56.107Z","lastSeenAt":"2026-04-22T06:56:46.135Z"}],"details":{"listingId":"66edbef3-a52a-410f-aab3-2beab3227c0d","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"cache-identical-fork-prefix-construction","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":"9b82987755fd7c3b75641f3e531f3726946d7fce","skill_md_path":"skills/cache-identical-fork-prefix-construction/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/cache-identical-fork-prefix-construction"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"cache-identical-fork-prefix-construction","description":"Build forked conversation prefixes that stay identical across turns so prompt caching keeps working."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/cache-identical-fork-prefix-construction"},"updatedAt":"2026-04-22T06:56:46.135Z"}}