agentsclimarketplace

Main thread only cache editing

Skill ychampion/cskill-agents/agents/codex/skills/main-thread-only-cache-editing

Gate cached microcompact cache edits to the main thread so background forks cannot alter the shared cache state.From its SKILL.md

Install
npx -y skills add ychampion/cskill-agents --skill main-thread-only-cache-editing

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

SKILL.md

2.1 KB, 396 tokens by cl100k_base, as published. Nobody here has run it

SKILL: Main Thread Only Cache Editing

Domain: context-management
Trigger: Use when cached microcompact runs and you must prevent subagents or forks from writing cache edits that the main thread shares. Source Pattern: Distilled from reviewed context, compaction, and memory-governance patterns.

Core Method

Only 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.

Key Rules

  • Wrap the cached microcompact logic with isMainThreadSource(querySource) so only canonical queries can edit the global cache.
  • Gate the entire block behind feature('CACHED_MICROCOMPACT') to keep the functionality out of builds that do not support it.
  • The guard must look at querySource.startsWith('repl_main_thread') rather than strict equality so styled prompt contexts still match.
  • Reread the guard whenever adding new query sources to ensure no rogue forks affect cache edits.
  • Keep the cached state initializations and edits strictly within this guarded branch so other modules cannot mutate cachedMCState unexpectedly.

Example Application

When 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.

Anti-Patterns (What NOT to do)

  • Do not let background slices access or mutate cachedMCState; they should always defer to the main thread’s editing path.
  • Do not drop the guard when adding new caching features; the main-thread-only contract must remain explicit.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. 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.