- Home
- Skills
- Commontoolsinc
- Labs
- Pattern Schema
pattern-schema_skill
- TypeScript
25
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill commontoolsinc/labs --skill pattern-schema- SKILL.md1.8 KB
Overview
This skill generates a complete schemas.tsx file that defines all data types and Input/Output interfaces for patterns before any pattern code is written. It enforces the project conventions for Default, Writable, Stream, NAME and UI fields so generated types are testable and compile without TypeScript errors. It is focused on correctness, testability, and adherence to the documented rules.
How this skill works
The skill reads the pattern specification and emits TypeScript interfaces and supporting type imports following the provided template. It wraps editable fields with Writable<>, marks optional-initial values with Default<,>, declares actions as Stream<>, and adds required sub-pattern markers [NAME] and [UI] in Output interfaces. The output file passes the type check command deno task ct check schemas.tsx --no-run when conventions are followed.
When to use it
- Starting a new pattern: generate all types before implementing behavior.
- Refactoring patterns to ensure Input/Output consistency and testability.
- Onboarding or enforcing team-wide schema conventions across patterns.
- Preparing patterns for automated tests that use .send() or Stream linking.
Best practices
- Always use pattern<Input, Output>() — never single-type pattern<State>().
- Wrap every editable field in Input with Writable<> to allow writes.
- Use Default<T, value> for fields that may be undefined initially.
- Declare actions in Output as Stream<T> so they are testable and linkable.
- Include [NAME]: string and [UI]: VNode on Output interfaces for sub-patterns.
Example use cases
- Generate schemas.tsx for a todo item pattern with Item, ItemInput and ItemOutput.
- Create schema for a list-of-items pattern where list and item sub-patterns expose NAME and UI.
- Update an existing pattern to convert mutable fields into Writable<> and mark outputs correctly.
- Produce types that enable unit tests to call .send() against Stream actions.
FAQ
Single-type patterns are not testable with .send(); using pattern<Input, Output>() ensures streams and actions are exposed and testable.
When should I use Default<T, value>?
Use Default for fields that may start undefined or have an initial default value to reflect their runtime initialization state.