pattern-critic
Start with the shared critique guidance in:
docs/common/ai/pattern-critique-guide.md
Read that guide first. It is the canonical reference.
Then use the detailed references already maintained in the repo for:
docs/development/debugging/README.mddocs/development/debugging/gotchas/docs/common/components/COMPONENTS.mddocs/common/capabilities/llm.md- LLM integration
Quick Patterns
Correct action() Usage (Default Choice)
// action() inside pattern body - closes over pattern variables
export default pattern<MyInput, MyOutput>(({ items, title }) => {
const menuOpen = Writable.of(false);
// Action closes over menuOpen - no binding needed
const toggleMenu = action(() => menuOpen.set(!menuOpen.get()));
// Action closes over items - no binding needed
const addItem = action(() => items.push({ title: title.get() }));
return {
[UI]: (
<>
<ct-button onClick={toggleMenu}>Menu</ct-button>
<ct-button onClick={addItem}>Add</ct-button>
</>
),
items,
};
});
Correct handler() Usage (Only for Multi-Binding)
// handler() at module scope - will be bound with different items in .map()
const deleteItem = handler<
void,
{ item: Writable<Item>; items: Writable<Item[]> }
>(
(_, { item, items }) => {
const list = items.get();
items.set(list.filter((i) => i !== item));
},
);
export default pattern<MyInput, MyOutput>(({ items }) => ({
[UI]: (
<ul>
{items.map((item) => (
<li>
{item.name}
{/* Each item gets its own binding */}
<ct-button onClick={deleteItem({ item, items })}>Delete</ct-button>
</li>
))}
</ul>
),
items,
}));
Correct Reactive [NAME]
export default pattern<Input>(({ deck }) => ({
[NAME]: computed(() => `Study: ${deck.name}`),
// ...
}));
Correct Conditional Rendering
// Both are valid - ternaries auto-transform to ifElse()
return <>{showDetails ? <div>Details content</div> : null}</>;
return <>{ifElse(showDetails, <div>Details content</div>, null)}</>;
Correct Style Syntax
<div style={{ display: "flex", gap: "1rem" }}>
<ct-vstack style="flex: 1; padding: 1rem;">
Content
</ct-vstack>
</div>;
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.
61task-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
51pattern-schema
Design schemas.tsx with Input/Output types for patterns
51