Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add estuary/agent-skills --skill derivation-stateful-logicgit clone --depth 1 https://github.com/estuary/agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/estuary/agent-skills/derivation-stateful-logic)<a href="https://agentmods.dev/skills/estuary/agent-skills/derivation-stateful-logic"><img src="https://agentmods.dev/badge/skills/estuary/agent-skills/derivation-stateful-logic/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/estuary/agent-skills/derivation-stateful-logic"><img src="https://agentmods.dev/badge/skills/estuary/agent-skills/derivation-stateful-logic.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00112 | $0.03055 |
| Opus 5.5 | $0.00045 | $0.01222 |
| Sonnet 5.5 | $0.00022 | $0.00611 |
| Haiku 4.5 | $0.00011 | $0.00305 |
Grade A, and why
derivation-stateful-logic scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 248 lines — stays where its author put it; the contents beside it link to each section on GitHub.
derivation-stateful-logic
Estuary derivation that maintains internal SQLite tables to record state, and whose lambdas query and update that state to decide what to emit.
Prereq: read derivation-basics first — in particular the stateless-vs-stateful distinction and the role of migrations. This skill is the "stateful via SQLite tables" path.
Docs:
- https://docs.estuary.dev/getting-started/tutorials/derivations_acmebank/ — the canonical stateful tutorial (deposits, withdrawals, transfer approval) with the exact pattern this skill uses
- https://docs.estuary.dev/concepts/derivations/#internal-state — the concept page on internal task state
When to use this over alternatives
- Balance / account state: debit sender if funds available, reject otherwise
- Inventory: deduct stock, mark backordered if insufficient
- Approval workflows: accumulate approvers, emit "approved" once threshold met
- Deduplication with history: filter events by ID seen-before (beyond what collection-key uniqueness gives)
- Any business logic that depends on prior events for the same key
Reach for other skills when:
- Pure aggregations (sum/count/min/max) that reductions can express →
derivation-aggregate-metrics - Merging fields across sources →
derivation-join-collections - Time-bounded sliding state (last 24h) →
derivation-windowing(which also uses SQLite internal state, but withreadDelay) - Stateless per-doc transforms →
derivation-filter-transform
How it works (one paragraph)
You declare SQLite migrations in the derive.using.sqlite.migrations list — SQL that runs once at startup to create your state tables. Your lambda then queries and updates those tables as it processes each source document, and can SELECT a derived output row or not, depending on state. Each task shard owns its own SQLite database; events are routed to shards via a keyed shuffle, so all events for the same entity (e.g. the same account) reach the same shard and see the same state.
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2mo ago First seen · 248 lines · 112 tokens per session scan A ea92bd873a80
derivation-stateful-logic is a skill published in the GitHub repository estuary/agent-skills (7 stars, last pushed 4d ago), licensed Apache-2.0. It adds 112 tokens to every session and 3,055 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
derivation-stateful-logic compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| derivation-stateful-logicestuary/agent-skills | Skill | 7 | 4d ago | Apache-2.0 | A | 112 | Claude Code |
| cocoindexcocoindex-io/cocoindex | Skill | 12k | today | Apache-2.0 | A | 88 | Claude Code, Codex |
| change-data-capture-adminBanibrataChatterjee/AwesomeSalesforceSkills | Skill | 4 | 6mo ago | Apache-2.0 | B | 50 | Claude Code, Codex |
| stream-processing-designerbookforge-ai/bookforge-skills | Skill | 42 | 6mo ago | CC-BY-SA-4.0 | A | 240 | Claude Code |
| embeddingsruvnet/ruflo | Skill | 81k | yesterday | MIT | A | 62 | Claude Code |
| rag-pineconedavila7/claude-code-templates | Skill | 33k | today | MIT | A | 65 | Claude Code, Codex |
| data-engineerdavila7/claude-code-templates | Skill | 33k | today | MIT | A | 35 | Claude Code, Codex |