pattern-implement
Use Skill("ct") for ct CLI documentation when running commands.
Implement Sub-Pattern
Core Rule
Write ONE sub-pattern with minimal stub UI. No styling, just basic inputs/buttons to verify data flow.
Always use pattern<Input, Output>() - expose actions as Stream<T> for testability.
Order
- Leaf patterns first (no dependencies on other patterns)
- Container patterns (compose leaf patterns)
- main.tsx last (composes everything)
Read First
docs/common/patterns/- especiallymeta/for generalizable idiomsdocs/common/concepts/action.md- action() for local statedocs/common/concepts/handler.md- handler() for reusable logicdocs/common/concepts/reactivity.md- Cell behavior, .get()/.set()docs/common/concepts/identity.md- equals() for object comparison
Key Patterns
action() - Closes over local state in pattern body:
const inputValue = Cell.of("");
const submit = action(() => {
items.push({ text: inputValue.get() });
inputValue.set("");
});
handler() - Reused with different bindings:
const deleteItem = handler<void, { items: Writable<Item[]>; index: number }>(
(_, { items, index }) => items.set(items.get().toSpliced(index, 1))
);
// In JSX: onClick={deleteItem({ items, index })}
Rendering sub-patterns - Use function calls, not JSX:
// ✅ Correct
{items.map((item) => ItemPattern({ item, allItems: items }))}
// ❌ Wrong - JSX fails with typed Output
{items.map((item) => <ItemPattern item={item} />)}
Done When
- Pattern compiles:
deno task ct check pattern.tsx --no-run - Minimal UI renders inputs/buttons
- Ready for testing
More from commontoolsinc/labs
knowledge-base
Shared foundation for Oracle & Corrector agents. Establishes the source hierarchy for resolving conflicts between documentation, code, and specs. Load this skill first when investigating how the system works.
97lit-component
Guide for developing Lit web components in the Common UI v2 system (@commonfabric/ui/v2). Use when creating or modifying cf- prefixed components, implementing theme integration, working with Cell abstractions, or building reactive UI components that integrate with the Common Fabric runtime.
61pattern-critic
Critic agent that reviews pattern code for violations of documented rules, gotchas, and anti-patterns. Produces categorized checklist output with [PASS]/[FAIL] for each rule.
54task-management
Guide for managing tasks within a session using bd (beads) for subtasks and local todo lists. Use this skill when breaking down plans into issues, tracking progress, managing dependencies, or coordinating work across sessions and agents. Triggers include requests to "manage tasks", "track progress", "break down this work", or questions about bd workflow.
52pattern-debug
Debug pattern errors systematically
51pattern-ui
Add UI polish with layout and styling
51