{"id":"49ea403c-452b-48a5-be7e-e6a080d2136f","shortId":"ABR8Bu","kind":"skill","title":"main-agent-vs-background-memory-extraction-exclusion","tagline":"Skip the background memory extractor when the main agent already persisted memory during the same turn to avoid duplicates and race hazards.","description":"# SKILL: Main Agent Vs Background Memory Extraction Exclusion\n**Domain:** context-management  \n**Trigger:** Apply whenever the background memory agent must determine whether the parent already saved the same memories so it can safely skip processing.\n**Source Pattern:** Distilled from reviewed context, compaction, and memory-governance patterns.\n\n## Core Method\nTrack a cursor UUID pointing to the last assistant message where an auto-memory write occurred and compare incoming messages to that cursor before running extraction. If the parent thread already wrote to memory paths after the cursor, skip launching the background agent. Otherwise, proceed with the forked extraction and reset the cursor to the new save point so the next turn knows what’s already handled.\n\n## Key Rules\n- Keep the cursor state outside the extraction loop so the check is read-only and does not mutate shared context.\n- Only permit a single background extraction per turn; once the main agent wrote to a memory path, mark the cursor so the forked agent sees the change and bails out.\n- When detection fails (cursor missing or memory writes unknown), default to running the extractor but emit telemetry so the system tracks unexpected duplications.\n- Always update the cursor when the background agent runs successfully, so future turns know the latest covered UUID.\n\n## Example Application\nUse this skill by having the background extractor call `hasMemoryWritesSince` before proceeding; if it returns true, emit a “already handled” log and skip, otherwise continue persistence and store the current assistant UUID for the next check.\n\n## Anti-Patterns (What NOT to do)\n- Don’t let the forked agent write memories unconditionally; that duplicates entries and races with the parent.\n- Don’t reset the cursor until after successful writes; resetting prematurely can cause the system to skip future required extractions.","tags":["main","agent","background","memory","extraction","exclusion","cskill","agents","ychampion","agent-skills","ai-agents","cli"],"capabilities":["skill","source-ychampion","skill-main-agent-vs-background-memory-extraction-exclusion","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-agent-vs-background-memory-extraction-exclusion","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,899 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.352Z","embedding":null,"createdAt":"2026-04-18T22:20:37.249Z","updatedAt":"2026-04-22T06:56:50.352Z","lastSeenAt":"2026-04-22T06:56:50.352Z","tsv":"'agent':3,17,33,49,123,182,194,231,292 'alreadi':18,55,111,146,262 'alway':224 'anti':281 'anti-pattern':280 'appli':44 'applic':243 'assist':88,274 'auto':93 'auto-memori':92 'avoid':26 'background':5,11,35,47,122,175,230,250 'bail':199 'call':252 'caus':316 'chang':197 'check':160,279 'compact':72 'compar':98 'context':41,71,170 'context-manag':40 'continu':268 'core':78 'cover':240 'current':273 'cursor':82,103,118,133,152,190,204,227,308 'default':210 'detect':202 'determin':51 'distil':68 'domain':39 'duplic':27,223,297 'emit':216,260 'entri':298 'exampl':242 'exclus':8,38 'extract':7,37,106,129,156,176,323 'extractor':13,214,251 'fail':203 'fork':128,193,291 'futur':235,321 'govern':76 'handl':147,263 'hasmemorywritessinc':253 'hazard':30 'incom':99 'keep':150 'key':148 'know':143,237 'last':87 'latest':239 'launch':120 'let':289 'log':264 'loop':157 'main':2,16,32,181 'main-agent-vs-background-memory-extraction-exclus':1 'manag':42 'mark':188 'memori':6,12,20,36,48,59,75,94,114,186,207,294 'memory-govern':74 'messag':89,100 'method':79 'miss':205 'must':50 'mutat':168 'new':136 'next':141,278 'occur':96 'otherwis':124,267 'outsid':154 'parent':54,109,303 'path':115,187 'pattern':67,77,282 'per':177 'permit':172 'persist':19,269 'point':84,138 'prematur':314 'proceed':125,255 'process':65 'race':29,300 'read':163 'read-on':162 'requir':322 'reset':131,306,313 'return':258 'review':70 'rule':149 'run':105,212,232 'safe':63 'save':56,137 'see':195 'share':169 'singl':174 'skill':31,246 'skill-main-agent-vs-background-memory-extraction-exclusion' 'skip':9,64,119,266,320 'sourc':66 'source-ychampion' 'state':153 'store':271 'success':233,311 'system':220,318 'telemetri':217 'thread':110 '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' 'track':80,221 'trigger':43 'true':259 'turn':24,142,178,236 'uncondit':295 'unexpect':222 'unknown':209 'updat':225 'use':244 'uuid':83,241,275 'vs':4,34 'whenev':45 'whether':52 'write':95,208,293,312 'wrote':112,183","prices":[{"id":"825793ac-603c-4a1e-9e6e-3e7f5a037322","listingId":"49ea403c-452b-48a5-be7e-e6a080d2136f","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:37.249Z"}],"sources":[{"listingId":"49ea403c-452b-48a5-be7e-e6a080d2136f","source":"github","sourceId":"ychampion/cskill-agents/main-agent-vs-background-memory-extraction-exclusion","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/main-agent-vs-background-memory-extraction-exclusion","isPrimary":false,"firstSeenAt":"2026-04-18T22:20:37.249Z","lastSeenAt":"2026-04-22T06:56:50.352Z"}],"details":{"listingId":"49ea403c-452b-48a5-be7e-e6a080d2136f","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"main-agent-vs-background-memory-extraction-exclusion","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":"275771fa01123f8d98ae8ca025afc00aea1c56a5","skill_md_path":"skills/main-agent-vs-background-memory-extraction-exclusion/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/main-agent-vs-background-memory-extraction-exclusion"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"main-agent-vs-background-memory-extraction-exclusion","description":"Skip the background memory extractor when the main agent already persisted memory during the same turn to avoid duplicates and race hazards."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/main-agent-vs-background-memory-extraction-exclusion"},"updatedAt":"2026-04-22T06:56:50.352Z"}}