Event-driven system prompt composition. Coordinates trinkets (modular content providers) through CNS events to build the final system prompt delivered to the LLM.
Files
types.py — TypedDicts for structures produced by composer and core: ComposedPrompt, TrinketState, AllTrinketStates
composer.py — SystemPromptComposer: collects sections from trinkets, routes by SECTION_LAYOUT (system/post_history/notification/conversation_prefix), returns ComposedPrompt
core.py — WorkingMemory: event-driven coordinator. Manages trinket registration, routes UpdateTrinketEvent to trinkets, collects TrinketContentEvent, composes and publishes SystemPromptComposedEvent
Subdirectory: trinkets/
base.py — EventAwareTrinket (ABC): base class with @abstractmethod generate_content(). StatefulTrinket: adds turn tracking with @abstractmethod _expire_items() and _clear_all_state()
domaindoc_trinket.py — Injects enabled domain knowledge documents with section collapse/expand state
lora_trinket.py — Injects user model observations from feedback synthesis pipeline
manifest_trinket.py — Displays conversation segment manifest in notification center
peanutgallery_trinket.py — Displays metacognitive guidance with TTL expiry (StatefulTrinket)
proactive_memory_trinket.py — Displays surfaced long-term memories in notification center
reminder_manager.py — Fetches and formats active reminders for notification center
time_manager.py — Injects current datetime into notification center
HOW_TO_BUILD_A_TRINKET.md — Guide for creating new trinkets
Patterns to Follow
Trinket Base Classes
All trinkets extend EventAwareTrinket (ABC). Must implement generate_content(context: Dict[str, Any]) -> str. Trinkets with turn-scoped state extend StatefulTrinket and implement _expire_items() and _clear_all_state().
Event Flow
ComposeSystemPromptEvent → WorkingMemory broadcasts UpdateTrinketEvent to all trinkets → each trinket calls generate_content() → publishes TrinketContentEvent → composer assembles ComposedPrompt → SystemPromptComposedEvent
Type Contracts
Composer returns ComposedPrompt (TypedDict from types.py)
get_trinket_state() returns TrinketState | None
get_all_trinket_states() returns AllTrinketStates
Trinkets are stored as Dict[str, EventAwareTrinket], not object
Event handler parameters are typed via TYPE_CHECKING imports
Infrastructure Failures
Trinket failures are isolated in core.py:_handle_update_trinket() — individual trinket exceptions don't crash the prompt composition. But trinkets themselves must NOT catch infrastructure failures (no try/except around DB/Valkey calls) — let them propagate to the isolation layer.
1---2name: 082-claude-26ccf0493description: working_memory/4---5# working_memory/67Event-driven system prompt composition. Coordinates trinkets (modular content providers) through CNS events to build the final system prompt delivered to the LLM.89## Files1011- `types.py` — TypedDicts for structures produced by composer and core: `ComposedPrompt`, `TrinketState`, `AllTrinketStates`12- `composer.py` — `SystemPromptComposer`: collects sections from trinkets, routes by `SECTION_LAYOUT` (system/post_history/notification/conversation_prefix), returns `ComposedPrompt`13- `core.py` — `WorkingMemory`: event-driven coordinator. Manages trinket registration, routes `UpdateTrinketEvent` to trinkets, collects `TrinketContentEvent`, composes and publishes `SystemPromptComposedEvent`1415## Subdirectory: trinkets/1617- `base.py` — `EventAwareTrinket` (ABC): base class with `@abstractmethod generate_content()`. `StatefulTrinket`: adds turn tracking with `@abstractmethod _expire_items()` and `_clear_all_state()`18- `domaindoc_trinket.py` — Injects enabled domain knowledge documents with section collapse/expand state19- `lora_trinket.py` — Injects user model observations from feedback synthesis pipeline20- `manifest_trinket.py` — Displays conversation segment manifest in notification center21- `peanutgallery_trinket.py` — Displays metacognitive guidance with TTL expiry (StatefulTrinket)22- `proactive_memory_trinket.py` — Displays surfaced long-term memories in notification center23- `reminder_manager.py` — Fetches and formats active reminders for notification center24- `getcontext_trinket.py` — Displays async context search results (StatefulTrinket)25- `time_manager.py` — Injects current datetime into notification center26- `HOW_TO_BUILD_A_TRINKET.md` — Guide for creating new trinkets2728## Patterns to Follow2930### Trinket Base Classes31All trinkets extend `EventAwareTrinket` (ABC). Must implement `generate_content(context: Dict[str, Any]) -> str`. Trinkets with turn-scoped state extend `StatefulTrinket` and implement `_expire_items()` and `_clear_all_state()`.3233### Event Flow34`ComposeSystemPromptEvent` → WorkingMemory broadcasts `UpdateTrinketEvent` to all trinkets → each trinket calls `generate_content()` → publishes `TrinketContentEvent` → composer assembles `ComposedPrompt` → `SystemPromptComposedEvent`3536### Type Contracts37- Composer returns `ComposedPrompt` (TypedDict from `types.py`)38- `get_trinket_state()` returns `TrinketState | None`39- `get_all_trinket_states()` returns `AllTrinketStates`40- Trinkets are stored as `Dict[str, EventAwareTrinket]`, not `object`41- Event handler parameters are typed via `TYPE_CHECKING` imports4243### Infrastructure Failures44Trinket failures are isolated in `core.py:_handle_update_trinket()` — individual trinket exceptions don't crash the prompt composition. But trinkets themselves must NOT catch infrastructure failures (no try/except around DB/Valkey calls) — let them propagate to the isolation layer.
Run npx skillmds@latest add tools-only/082-claude-26ccf049 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
working_memory/ It is listed under Research & Search on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.