pattern-dev
π―Skillfrom commontoolsinc/labs
Guides developers in creating reactive TypeScript patterns for CommonTools, focusing on efficient, iterative development from sketch to deployment.
Installation
npx skills add https://github.com/commontoolsinc/labs --skill pattern-devSkill Details
Guide for developing CommonTools patterns (TypeScript modules that define reactive data transformations with UI). Use this skill when creating patterns, modifying existing patterns, or working with the pattern framework. Triggers include requests like "build a pattern", "fix this pattern error", "deploy this charm/patch", or questions about handlers and reactive patterns.
Overview
Use Skill("ct") for ct CLI documentation when running commands.
You and the user are a team finding the efficient path to their vision.
Always Plan First
Use EnterPlanMode before building. Scale the plan to the task:
Simple pattern (todo list, counter):
- One file, types + handlers + UI together
- Minimal clarification needed
- Plan in 2-3 sentences
Medium pattern (form with validation, data viewer):
- Maybe split schemas if types get complex
- Clarify data shape and key actions
- Plan in a short list
Complex pattern (multi-entity system, integrations):
- Consider sub-patterns if genuinely distinct concepts
- Clarify entities, relationships, actions upfront
- Plan with structure, but don't over-specify
Always start simple. One file first. Split when it helps, not before.
Pattern Structure
Start simple:
```
packages/patterns/[name]/
βββ main.tsx # Everything in one file to start
```
Split when it helps (not before):
```
packages/patterns/[name]/
βββ schemas.tsx # Types, if complex
βββ main.tsx # Main pattern
βββ [other].tsx # Extract when reuse is clear
```
Don't create separate files for every entity. A Project with Task[] can live in one file until complexity demands otherwise.
Development Approach: Sketch β Run β Iterate
Don't write finished code. Write the minimum to see something work:
- Sketch β Types, one handler, minimal UI. Just enough to render.
- Run it β
deno task ct check main.tsxand see what happens. - Verify β Does it render? Does the handler fire? Check console.
- Iterate β Add the next piece, run again.
Each iteration should be deployable. If you can't run it, you've written too much.
Verification
Run the code, not just tests. The primary verification is: does it work when you run it?
deno task ct check main.tsxβ See it render, click things, check console- Tests for state logic that's hard to verify by clicking
- Don't write tests for obvious behavior or code that's still evolving
Pattern tests when needed: deno task ct test [file].test.tsx
Delegate to Agents
pattern-maker β Write Code
For implementing pattern code:
```
Task({
prompt: "Implement [feature]. Keep it simple, one file.",
subagent_type: "pattern-maker"
})
```
pattern-user β Deploy & Debug
For deploying and testing with ct CLI:
```
Task({
prompt: "Deploy and test [pattern].",
subagent_type: "pattern-user"
})
```
pattern-critic β Review (when needed)
For checking violations before release or when stuck:
```
Task({
prompt: "Review [file] for violations.",
subagent_type: "pattern-critic"
})
```
Workflow
Not phases, just common sense:
- Build β Use pattern-maker to sketch and iterate locally (
ct check) - Review β Use pattern-critic before deploying to catch common mistakes
- Deploy β Use pattern-user to deploy to toolshed
- Fix what's broken β Iterate with maker, re-review, redeploy
- Commit β At milestones, offer to commit
Always run pattern-critic before first deploy. It's fast (uses haiku) and catches mistakes that cause runtime errors. Skip only for tiny fixes where you're confident.
Documentation
Start with docs/common/patterns/βespecially docs/common/patterns/meta/ which contains generalizable idioms that grow over time.
Prefer docs over existing patterns in packages/patterns/βdocs contain validated snippets while existing patterns may be outdated. Use packages/patterns/ as reference but don't copy blindly.
Phase skills consult as needed:
- Types:
docs/common/concepts/types-and-schemas/ - Actions/handlers:
docs/common/concepts/action.md,docs/common/concepts/handler.md - Testing:
docs/common/workflows/pattern-testing.md - Components:
docs/common/components/COMPONENTS.md - Debugging:
docs/development/debugging/
More from this repository8
Guides developers in creating and integrating Lit web components within the Common UI v2 system, focusing on reactive, theme-aware, and runtime-integrated UI components.
Guides developers in deploying, managing, and interacting with charms and recipes using the CommonTools CLI through precise command-line operations.
Establishes a hierarchical source resolution system for Oracle & Corrector agents, prioritizing specs, code, and documentation.
Deploys and manages Claude patterns via CLI, enabling syntax checking, deployment, inspection, and testing of pattern handlers.
Validates pattern implementation by writing and executing structured test sequences for pattern-based components.
Applies standardized UI components and layout patterns to polish and structure user interfaces with consistent design.
Breaks down complex tasks into manageable subtasks using bd (beads), tracking progress and dependencies across sessions.
Generates TypeScript schemas with Input/Output types for patterns, ensuring type safety and testability through structured type definitions.