Empty trigger short circuit before app state

From ychampion/cskill-agents · View interactive version

Empty trigger short circuit before app state is an AI agent skill from the GitHub repository ychampion/cskill-agents. Skip nested memory collection when no triggers exist so render-bound `getAppState()` is never invoked unnecessarily.

How to use this skill

Skill file

SKILL: Empty Trigger Short-Circuit Before App State

Domain: context-management

Trigger: Use when nested memory attachment triggers may be empty and you want to avoid React render-cycle work unless there is actual work to do.

Source Pattern: Distilled from reviewed context, compaction, and memory-governance patterns.

Core Method

Before calling expensive or render-bound helpers, check the cheap trigger state. If nestedMemoryAttachmentTriggers is missing or empty, return immediately so that the expensive getAppState() call does not fire on every turn. Only when work exists do you fetch the React-bound state and iterate over the trigger set, ensuring each attachment run still has access to the required context but only when needed.

Key Rules

Example Application

In a turn that has no nested memory triggers, return [] right away so getAppState() is never invoked; when triggers exist, call getAppState(), collect each nested attachment, and clear the set afterward as usual.

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.