{"id":"80f6ebc0-e08f-4ea0-8a9f-efc38cc101d9","shortId":"QWJjbp","kind":"skill","title":"idempotent-tool-result-persistence","tagline":"Persist tool results once, avoid re-writing duplicates, and summarize via previews so long outputs stay accessible yet capped.","description":"# SKILL: Idempotent Tool Result Persistence\n**Domain:** persistence  \n**Trigger:** Use this when tool result blocks exceed their configured thresholds and you want to persist them once while still returning a preview.  \n**Source Pattern:** Distilled from reviewed tool execution, streaming, persistence, and output-budget implementations.\n\n## Core Method\nPersist oversized tool outputs to a deterministic artifact path derived from the tool call ID and content type. Create that artifact with exclusive-write semantics so retries and concurrent writers cannot clobber or duplicate the same payload. After the first successful write, return a compact preview plus metadata pointing at the persisted artifact; later retries should reuse the existing file and regenerate the same preview without rewriting the payload. This keeps large outputs accessible while making persistence safe and repeatable.\n\n## Key Rules\n- Create the parent directory once per storage root, but write each artifact with exclusive creation semantics.\n- If the target artifact already exists, treat that as a successful prior write and move directly to preview generation.\n- Keep preview metadata explicit: content type, truncation status, persisted path, and original size should all be recoverable downstream.\n- Log the persisted location and size so operators can trace where a large result went.\n\n## Example Application\nWhen a log-reading tool returns 60 KB of text, write it once to a stable artifact file such as `tool-results/<tool-call-id>.txt`, then send only a short preview plus the saved path. If the same result is replayed on retry, skip the write and reuse the same artifact reference.\n\n## Anti-Patterns (What NOT to do)\n- Don’t re-write the same file on retries; failing to check `EEXIST` causes EOS errors and clobbers the previous log.\n- Don’t drop the preview header; consumers depend on `<persisted-output>` tags to know the persisted location.","tags":["idempotent","tool","result","persistence","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents","context-engineering"],"capabilities":["skill","source-ychampion","skill-idempotent-tool-result-persistence","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/idempotent-tool-result-persistence","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,936 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:49.574Z","embedding":null,"createdAt":"2026-04-18T22:20:30.307Z","updatedAt":"2026-04-22T06:56:49.574Z","lastSeenAt":"2026-04-22T06:56:49.574Z","tsv":"'60':232 'access':23,146 'alreadi':175 'anti':278 'anti-pattern':277 'applic':224 'artifact':79,92,125,166,174,242,275 'avoid':10 'block':39 'budget':68 'call':85 'cannot':103 'cap':25 'caus':298 'check':296 'clobber':104,302 'compact':117 'concurr':101 'configur':42 'consum':312 'content':88,194 'core':70 'creat':90,155 'creation':169 'depend':313 'deriv':81 'determinist':78 'direct':186 'directori':158 'distil':58 'domain':31 'downstream':207 'drop':308 'duplic':14,106 'eexist':297 'eo':299 'error':300 'exampl':223 'exceed':40 'exclus':95,168 'exclusive-writ':94 'execut':62 'exist':131,176 'explicit':193 'fail':294 'file':132,243,291 'first':112 'generat':189 'header':311 'id':86 'idempot':2,27 'idempotent-tool-result-persist':1 'implement':69 'kb':233 'keep':143,190 'key':153 'know':317 'larg':144,220 'later':126 'locat':211,320 'log':208,228,305 'log-read':227 'long':20 'make':148 'metadata':120,192 'method':71 'move':185 'oper':215 'origin':201 'output':21,67,75,145 'output-budget':66 'overs':73 'parent':157 'path':80,199,259 'pattern':57,279 'payload':109,141 'per':160 'persist':5,6,30,32,48,64,72,124,149,198,210,319 'plus':119,256 'point':121 'preview':18,55,118,137,188,191,255,310 'previous':304 'prior':182 're':12,287 're-writ':11,286 'read':229 'recover':206 'refer':276 'regener':134 'repeat':152 'replay':265 'result':4,8,29,38,221,248,263 'retri':99,127,267,293 'return':53,115,231 'reus':129,272 'review':60 'rewrit':139 'root':162 'rule':154 'safe':150 'save':258 'semant':97,170 'send':251 'short':254 'size':202,213 'skill':26 'skill-idempotent-tool-result-persistence' 'skip':268 'sourc':56 'source-ychampion' 'stabl':241 'status':197 'stay':22 'still':52 'storag':161 'stream':63 'success':113,181 'summar':16 'tag':315 'target':173 'text':235 'threshold':43 'tool':3,7,28,37,61,74,84,230,247 'tool-result':246 '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' 'trace':217 'treat':177 'trigger':33 'truncat':196 'txt':249 'type':89,195 'use':34 'via':17 'want':46 'went':222 'without':138 'write':13,96,114,164,183,236,270,288 'writer':102 'yet':24","prices":[{"id":"76fa5c69-a673-42d0-b0c4-9740874314a8","listingId":"80f6ebc0-e08f-4ea0-8a9f-efc38cc101d9","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:30.307Z"}],"sources":[{"listingId":"80f6ebc0-e08f-4ea0-8a9f-efc38cc101d9","source":"github","sourceId":"ychampion/cskill-agents/idempotent-tool-result-persistence","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/idempotent-tool-result-persistence","isPrimary":false,"firstSeenAt":"2026-04-18T22:20:30.307Z","lastSeenAt":"2026-04-22T06:56:49.574Z"}],"details":{"listingId":"80f6ebc0-e08f-4ea0-8a9f-efc38cc101d9","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"idempotent-tool-result-persistence","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":"2f66df8af544de3802d70f14fa31bfe590b84188","skill_md_path":"skills/idempotent-tool-result-persistence/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/idempotent-tool-result-persistence"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"idempotent-tool-result-persistence","description":"Persist tool results once, avoid re-writing duplicates, and summarize via previews so long outputs stay accessible yet capped."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/idempotent-tool-result-persistence"},"updatedAt":"2026-04-22T06:56:49.574Z"}}