{"id":"4862bfb2-17f4-42f2-a1cf-e63e3e01f2cd","shortId":"v4jXVw","kind":"skill","title":"main-thread-only-cache-editing","tagline":"Gate cached microcompact cache edits to the main thread so background forks cannot alter the shared cache state.","description":"# SKILL: Main Thread Only Cache Editing\n**Domain:** context-management  \n**Trigger:** Use when cached microcompact runs and you must prevent subagents or forks from writing cache edits that the main thread shares.\n**Source Pattern:** Distilled from reviewed context, compaction, and memory-governance patterns.\n\n## Core Method\nOnly perform cache-editing microcompactions when the executing query source is the main thread (`repl_main_thread` or unspecified). This avoids contaminating shared `cachedMCState` with tool results that belong to background runs like session-memory compact, prompt suggestion, or other forks. The guard also ensures the cached MC path is never triggered in non-ANT builds that disable the feature altogether.\n\n## Key Rules\n- Wrap the cached microcompact logic with `isMainThreadSource(querySource)` so only canonical queries can edit the global cache.\n- Gate the entire block behind `feature('CACHED_MICROCOMPACT')` to keep the functionality out of builds that do not support it.\n- The guard must look at `querySource.startsWith('repl_main_thread')` rather than strict equality so styled prompt contexts still match.\n- Reread the guard whenever adding new query sources to ensure no rogue forks affect cache edits.\n- Keep the cached state initializations and edits strictly within this guarded branch so other modules cannot mutate `cachedMCState` unexpectedly.\n\n## Example Application\nWhen a main-thread REPL session hits the cached microcompact trigger, the guard passes, allowing `registerToolResult` and `createCacheEditsBlock` to run. Forked agents such as session memory or prompt suggestion skip this block entirely, leaving the global cache untouched.\n\n## Anti-Patterns (What NOT to do)\n- Do not let background slices access or mutate `cachedMCState`; they should always defer to the main thread’s editing path.\n- Do not drop the guard when adding new caching features; the main-thread-only contract must remain explicit.","tags":["main","thread","only","cache","editing","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents"],"capabilities":["skill","source-ychampion","skill-main-thread-only-cache-editing","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/main-thread-only-cache-editing","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,957 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:50.514Z","embedding":null,"createdAt":"2026-04-18T22:20:38.789Z","updatedAt":"2026-04-22T06:56:50.514Z","lastSeenAt":"2026-04-22T06:56:50.514Z","tsv":"'access':281 'ad':197,302 'affect':206 'agent':252 'allow':245 'also':116 'alter':20 'altogeth':134 'alway':287 'ant':128 'anti':270 'anti-pattern':269 'applic':229 'avoid':92 'background':17,102,279 'behind':158 'belong':100 'block':157,262 'branch':220 'build':129,168 'cach':5,8,10,23,29,38,50,74,119,139,153,160,207,211,239,267,304 'cache-edit':73 'cachedmcst':95,226,284 'cannot':19,224 'canon':147 'compact':63,108 'contamin':93 'context':33,62,190 'context-manag':32 'contract':311 'core':69 'createcacheeditsblock':248 'defer':288 'disabl':131 'distil':59 'domain':31 'drop':298 'edit':6,11,30,51,75,150,208,215,294 'ensur':117,202 'entir':156,263 'equal':186 'exampl':228 'execut':79 'explicit':314 'featur':133,159,305 'fork':18,47,113,205,251 'function':165 'gate':7,154 'global':152,266 'govern':67 'guard':115,175,195,219,243,300 'hit':237 'initi':213 'ismainthreadsourc':143 'keep':163,209 'key':135 'leav':264 'let':278 'like':104 'logic':141 'look':177 'main':2,14,26,54,84,87,181,233,291,308 'main-thread':232 'main-thread-on':307 'main-thread-only-cache-edit':1 'manag':34 'match':192 'mc':120 'memori':66,107,256 'memory-govern':65 'method':70 'microcompact':9,39,76,140,161,240 'modul':223 'must':43,176,312 'mutat':225,283 'never':123 'new':198,303 'non':127 'non-ant':126 'pass':244 'path':121,295 'pattern':58,68,271 'perform':72 'prevent':44 'prompt':109,189,258 'queri':80,148,199 'querysourc':144 'querysource.startswith':179 'rather':183 'registertoolresult':246 'remain':313 'repl':86,180,235 'reread':193 'result':98 'review':61 'rogu':204 'rule':136 'run':40,103,250 'session':106,236,255 'session-memori':105 'share':22,56,94 'skill':25 'skill-main-thread-only-cache-editing' 'skip':260 'slice':280 'sourc':57,81,200 'source-ychampion' 'state':24,212 'still':191 'strict':185,216 'style':188 'subag':45 'suggest':110,259 'support':172 'thread':3,15,27,55,85,88,182,234,292,309 'tool':97 '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':35,124,241 'unexpect':227 'unspecifi':90 'untouch':268 'use':36 'whenev':196 'within':217 'wrap':137 'write':49","prices":[{"id":"b2eefb95-4136-4d08-b7bc-c67a5d2b8756","listingId":"4862bfb2-17f4-42f2-a1cf-e63e3e01f2cd","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:20:38.789Z"}],"sources":[{"listingId":"4862bfb2-17f4-42f2-a1cf-e63e3e01f2cd","source":"github","sourceId":"ychampion/cskill-agents/main-thread-only-cache-editing","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/main-thread-only-cache-editing","isPrimary":false,"firstSeenAt":"2026-04-18T22:20:38.789Z","lastSeenAt":"2026-04-22T06:56:50.514Z"}],"details":{"listingId":"4862bfb2-17f4-42f2-a1cf-e63e3e01f2cd","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"main-thread-only-cache-editing","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":"5ff420ffb3e82d845f9d2e4ce1c9979e0ed9091c","skill_md_path":"skills/main-thread-only-cache-editing/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/main-thread-only-cache-editing"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"main-thread-only-cache-editing","description":"Gate cached microcompact cache edits to the main thread so background forks cannot alter the shared cache state."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/main-thread-only-cache-editing"},"updatedAt":"2026-04-22T06:56:50.514Z"}}