Memoized command source aggregation

From ychampion/cskill-agents · View interactive version

Memoized command source aggregation is an AI agent skill from the GitHub repository ychampion/cskill-agents. Load independent command sources in parallel, then memoize the merged registry by cwd so repeated lookups stay cheap and ordered.

How to use this skill

Skill file

SKILL: Memoized Command Source Aggregation

Domain: command-architecture

Trigger: Use when a command or skill registry must combine several expensive sources, but repeated lookups from the same workspace should reuse one stable merged result.

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

Core Method

Wrap the expensive registry assembly behind a memoized async function keyed by the scope that changes the result, such as cwd. Inside that loader, start every independent source fetch at once with promise all so disk scans, plugin discovery, and optional workflow imports overlap instead of serializing. After all sources resolve, merge them in one explicit precedence order rather than in completion order. This keeps first-load latency down while making every later lookup for the same scope a cheap cache hit with deterministic command ordering.

Key Rules

Example Application

If an agentic IDE must expose commands from local extensions, workspace automations, and remote plugins, create a memoized load all commands workspace root function that fans out those three loaders in parallel, then returns them in the product's chosen precedence order followed by built-ins. Every later command palette lookup for that workspace can reuse the cached merged list instead of rescanning the filesystem and plugin graph.

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.