Automated summary
This skill guides building and querying TES projections (current-state views) derived from an event stream, using a Durable Object pattern and an event fan-out router.
Strengths
- Provides a full Durable Object skeleton with idempotency check, reduce function, and state persistence
- Clearly enumerates projection types and their keys (item, listing, participant, campaign)
- Shows queue-router fan-out with conditional routing by entity_type and event type
- Includes query examples via idFromName/get to wire a projection into an API handler
Limitations
- Assumes a Cloudflare Workers + Durable Objects setup and an already-defined TES event schema
- The router code is partial (getRoutes is truncated) and does not cover every routing case
- Does not address projection rebuilds/replays, snapshots, or listing all existing projections
Use it when you need to add or query a current-state view fed by TES events on Cloudflare Workers.
Avoid it if your project does not use Durable Objects or if you want general event-sourcing advice unrelated to this architecture.
Security analysis
SafeThe skill is pure documentation/guidance for implementing Cloudflare Durable Object projections; the declared tools (Read, Grep, Glob, Edit, Write) are consistent with editing source files, and there are no shell executions, network fetches, credential handling, obfuscated payloads, or destructive instructions. The example code is illustrative and operates only on in-repo Workers code, so listing it carries no meaningful execution risk.
No concerns found
How this analysis is madeExamples
Add a ListingCurrentState projection Durable Object that reduces item.listed and item.sold events into a listing status, and wire it into the TES router fan-out.My ItemProjection returns {"error":"Not found"} for an item that definitely has events — walk through the TES router and idempotency logic to find why the event was never applied.Write a getItemState helper for my API handler that resolves the ItemProjection Durable Object by canonical_id and returns the current state.name: projections description: Build or query TES projections (current state views). State is derived from TES events - projections are the queryable current truth. allowed-tools: Read, Grep, Glob, Edit, Write
Projections Skill
Core Principle
State is derived from TES events. Projections are the queryable current truth.
Projection Types
| Projection | Purpose | Key | |------------|---------|-----| | ItemCurrentState | Current state of an item | item canonical_id | | ListingCurrentState | Current listing status | listing canonical_id | | ParticipantInventory | What a user owns | participant canonical_id | | CampaignState | Campaign metrics | campaign canonical_id |
Durable Object Pattern
// workers/projections/ItemProjection.js
export class ItemProjection {
constructor(state, env) {
this.state = state;
this.env = env;
}
async fetch(request) {
const url = new URL(request.url);
if (request.method === "GET") {
const currentState = await this.state.storage.get("state");
return Response.json(currentState || { error: "Not found" });
}
if (request.method === "POST" && url.pathname === "/apply-event") {
const event = await request.json();
return this.applyEvent(event);
}
}
async applyEvent(event) {
// Idempotency check
const processedEvents = await this.state.storage.get("processed") || [];
if (processedEvents.includes(event.id)) {
return Response.json({ status: "already_processed" });
}
// Get current state
let state = await this.state.storage.get("state") || this.initialState();
// Apply event
state = this.reduce(state, event);
state.last_event_id = event.id;
state.last_updated = event.timestamp;
// Save
await this.state.storage.put("state", state);
await this.state.storage.put("processed", [...processedEvents.slice(-100), event.id]);
return Response.json({ status: "applied", state });
}
reduce(state, event) {
switch (event.type) {
case "item.captured":
return { ...state, status: "captured", media: event.payload.image_urls };
case "item.identified":
return { ...state, status: "identified", product_ref: event.payload.product_ref };
case "item.listed":
return { ...state, status: "listed", listing_id: event.payload.listing_id };
case "item.sold":
return { ...state, status: "sold", sold_at: event.timestamp };
default:
return state;
}
}
initialState() {
return { status: "unknown", created_at: new Date().toISOString() };
}
}
Querying Projections
// Get current item state
async function getItemState(env, itemId) {
const doId = env.ITEM_PROJECTION.idFromName(itemId);
const stub = env.ITEM_PROJECTION.get(doId);
const response = await stub.fetch(new Request("https://do/"));
return response.json();
}
// In API handler
const itemState = await getItemState(env, "ptc_item_abc123");
TES Router (Event Fan-out)
// workers/tes-router.js
export default {
async queue(batch, env) {
for (const message of batch.messages) {
const event = message.body;
// Route to appropriate projections
const routes = getRoutes(event);
await Promise.all(routes.map(async (route) => {
const doId = env[route.binding].idFromName(route.key);
const stub = env[route.binding].get(doId);
await stub.fetch(new Request("https://do/apply-event", {
method: "POST",
body: JSON.stringify(event),
}));
}));
message.ack();
}
},
};
function getRoutes(event) {
const routes = [];
if (event.entity_type === "item") {
routes.push({ binding: "ITEM_PROJECTION", key: event.entity_id });
}
if (event.type === "item.sold") {
routes.push({ binding: "LISTING_PROJECTION", key: event.payload.listing_id });
routes.push({ binding: "PARTICIPANT_PROJECTION", key: event.payload.seller_id });
routes.push({ binding: "PARTICIPANT_PROJECTION", key: event.payload.buyer_id });
}
return routes;
}
Anti-Patterns
- Querying D1 for "current truth" instead of projections
- Mutating projection state without event
- Global projections (hot-key bottleneck)
- Not handling idempotency
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/tes-projections-mmbizjn2/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/tes-projections-mmbizjn2' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/tes-projections-mmbizjn2/download' --output '.skill-downloads/tes-projections-mmbizjn2/SKILL.md.part' && mv '.skill-downloads/tes-projections-mmbizjn2/SKILL.md.part' '.skill-downloads/tes-projections-mmbizjn2/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Grep, Glob, Edit, Write
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/tes-projections-mmbizjn2/SKILL.md' && test -s '.skill-downloads/tes-projections-mmbizjn2/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/projections' && cp -R '.skill-downloads/tes-projections-mmbizjn2' '.claude/skills/projections'Cursor
test -f '.skill-downloads/tes-projections-mmbizjn2/SKILL.md' && test -s '.skill-downloads/tes-projections-mmbizjn2/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/projections' && cp -R '.skill-downloads/tes-projections-mmbizjn2' '.cursor/skills/projections'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/tes-projections-mmbizjn2'openskills read 'tes-projections-mmbizjn2'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/tes-projections-mmbizjn2/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.