adding-a-new-durable-object-mixin

Add or modify Durable Object mixins with type tests and Cloudflare runtime checks.

198|19|Updated Sep 15, 2025
One-click install
npx skills add https://github.com/iterate/iterate --skill adding-a-new-durable-object-mixin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-a-new-durable-object-mixin
Source: https://github.com/iterate/iterate/tree/main/.agents/skills/adding-a-new-durable-object-mixin
Command: npx skills add https://github.com/iterate/iterate --skill adding-a-new-durable-object-mixin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents Durable Object mixins from drifting away from the repository’s required API design, type-safety rules, and Cloudflare runtime expectations, which otherwise leads to brittle compositions and failing tests.

Core Features & Use Cases

  • Spec and validate a mixin’s runtime behavior before implementation so the Durable Object surface, protected capabilities, and lifecycle interactions are unambiguous.
  • Compose mixins correctly with the repo’s Durable Object constructor/type patterns to keep Base<Env> compatibility, preserve generics, and ensure capability requirements remain correctly layered.
  • Add thorough documentation and tests for durable-object-utils including type tests, worker-pool unit tests, and optional E2E coverage when runtime behavior depends on Worker/DO/D1 realities.
  • Reference implementation guidance for common low-level mixin responsibilities such as protected ctx adaptation, lifecycle hooks, alarm multiplexing, scheduling, KV/SQLite helpers, and the shared test harness entrypoint.

Quick Start

Ask the AI to guide you through adding a new withX Durable Object mixin under packages/shared/src/durable-object-utils by first reviewing the needed route/method/state, the exact protected capabilities it should consume, and the specific tests and runtime checks required by the repo.

Frequently Asked Questions about adding-a-new-durable-object-mixin

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new mixin to a Cloudflare Durable Object without breaking type safety?

To add a new Durable Object mixin safely, you must follow the repository’s prescribed generic constructor patterns, preserve `Base<Env>` compatibility, and update type tests to ensure capability requirements remain correctly layered. This prevents brittle compositions and failing Cloudflare runtime checks.

What is Durable Object mixin composition and when is it needed?

Durable Object mixin composition is a technique for layering capabilities like KV helpers or alarm multiplexing onto a base class. It is needed when extending Durable Object behavior while preserving generic type safety, protected `ctx` adaptation, and strict API composition rules.

How do I test runtime-dependent behavior in Cloudflare Durable Objects?

To test runtime-dependent behavior in Cloudflare Durable Objects, you extend the `durable-object-utils` test harness with unit tests and optional E2E coverage, executing a specified command workflow to validate deterministic interactions across Worker, DO, and D1 realities.

Does vitest work for type testing Durable Object generics and mixin composition?

Yes, vitest is used for type tests to validate Durable Object generics and mixin composition. You must update type tests alongside worker-pool unit tests to guarantee that the TypeScript generics defining your mixin composition remain structurally sound.

What are the limitations of extending Durable Object mixins in a shared utils package?

Extending Durable Object mixins requires strict adherence to composition rules and generic type patterns; failing to document non-obvious type guarantees or skipping the specified test workflow will cause drift from the repository’s required API design and failing Cloudflare runtime expectations.

Can I use mixin composition to add SQLite helpers to my Durable Object?

Yes, mixin composition supports adding common low-level responsibilities such as SQLite helpers, scheduling, and protected `ctx` adaptation. You must ensure the mixin consumes the exact protected capabilities specified and passes the required type and runtime checks.