Layered command cache invalidation

From ychampion/cskill-agents · View interactive version

Layered command cache invalidation is an AI agent skill from the GitHub repository ychampion/cskill-agents. Clear every memoized layer in a command or skill pipeline so dynamic updates invalidate outer derived views as well as inner source caches.

How to use this skill

Skill file

SKILL: Layered Command Cache Invalidation

Domain: Command Architecture

Trigger: Use when commands, skills, or search indexes are cached in layers and a refresh must make newly added or removed entries visible immediately.

Source Pattern: Distilled from reviewed command-surface, skill-discovery, and CLI capability implementations.

Core Method

Treat cache invalidation as a stack problem, not a single-cache problem. When one memoized command view is built on top of other memoized loaders, clear the outer derived cache alongside the inner source caches in the same invalidation path. Otherwise the outer memoized function can keep returning its old result without ever touching the refreshed inner layers, so callers never observe the update.

Key Rules

Example Application

An agentic IDE may memoize the merged command registry, memoize the slash-command projection derived from that registry, and memoize a local skill-search index built on top of both. When a new skill is installed, invalidate all three layers together. Clearing only the registry caches is insufficient if the search index still serves its own cached snapshot.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.