agentsclimarketplace

Atomic post await state commit

Skill vishuwa2004/cskill-agents/agents/claude-code/skills/atomic-post-await-state-commit

Build curated agent skills for coding CLIs, terminal tools, context engines, remote bridges, and multi-agent runtimes

Install
npx -y skills add vishuwa2004/cskill-agents --skill atomic-post-await-state-commit

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

After awaiting persistence work, update the shared budget state for each `tool_use_id` exactly once so no concurrent reader ever sees a half-committed decision.

SKILL.md

2.7 KB, 512 tokens by cl100k_base, as published. Nobody here has run it

SKILL: Atomic Post-Await State Commit

Domain: tool-orchestration
Trigger: Use this pattern when concurrently persisting large tool results and mutating ContentReplacementState once the awaited work completes, such as the freshReplacements loop inside enforceToolResultBudget. Source Pattern: Distilled from reviewed tool-loop and result-shaping patterns.

Core Method

Await all selected persistence jobs, then in the same synchronous loop mark each tool_use_id as seen and, if persistence succeeded, place the preview string into both the local replacement map and the shared ContentReplacementState.replacements. The state mutation happens after the await so other threads or resumed contexts never observe the ID as seen without its replacement (or vice versa), keeping the decision atomic.

Key Rules

  • Never add a tool_use_id to seenIds before the persist promise resolves; doing so risks another thread classifying the ID as frozen while the replacement string has yet to materialize.
  • Mark the ID as seen even when persistence fails so the failure case still freezes the original content and prevents reprocessing the same bytes later.
  • When persistence succeeds, update state.replacements and replacementMap together so immediate replays see the cached preview string with the same bytes that triggered the log/event.
  • Keep the loop synchronous after the await; avoid spreading the state updates across callbacks or other async code paths that might observe partial state.

Example Application

Inside enforceToolResultBudget, freshReplacements combines each candidate with the result of buildReplacement. The for-loop that follows immediately adds every candidate to state.seenIds, then conditionally sets state.replacements if a preview exists. That ensures when the same tool_use_id reappears (for example during a resume or in a forked agent) the code re-applies the cached preview without re-persisting the file.

Anti-Patterns (What NOT to do)

  • Do not call state.seenIds.add before awaiting persistence; the race can produce mustReapply entries without a matching cached preview.
  • Do not leave the replacements map empty after a successful persist; otherwise applyToolResultBudget will treat the ID as seen-but-unreplaced and may persist it again later.
  • Do not split the success and failure branches across multiple awaits or microtasks; the observer must never see a seen entry without the corresponding replacement when one exists.

Gives 0 of the 12 instructions most pr commit review skills give in 512 tokens

Counted across 888 of the 1,342 authors here whose files we hold, read 2026-08-06

  • use conventional commits formatin 123 of 888, across 110 files
  • keep subject line under 72 charactersin 60 of 888, across 46 files
  • delete branches after mergein 50 of 888, across 37 files
  • use imperative mood in subject linein 50 of 888, across 41 files
  • use imperative mood in commit messagesin 45 of 888
  • generate a conventional commit messagein 42 of 888
  • make atomic commitsin 37 of 888, across 25 files
  • run tests before committingin 36 of 888, across 24 files
  • run project test suite to verify clean baselinein 35 of 888, across 7 files
  • run detected project setup commandsin 34 of 888, across 6 files
  • wrap commit body at 72 charactersin 32 of 888, across 25 files
  • split unrelated changes into separate commitsin 32 of 888, across 27 files

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.