Code Style Principles
FromAGENTS.md:
- Follow existing code styles - Check neighboring files for patterns
- Composability - Write small, testable, pure functions when possible
- Simplicity - Prioritize the simplest correct solution over complexity
- Decoupling - Decouple pure business logic from UI and network layers
- Type-driven design - Let types guide function composition. DO NOT USE
any
Deprecated Patterns
Avoid blockSignals
Do NOT use these deprecated APIs:Component Patterns
Pure, Composable Components
Primitive UI components should be pure and prefer composition over props:Example: Button Component
Frompackages/ui/components/Button.tsx:
- Use
splitPropsto separate custom props from native attributes - Merge classes with
cn()utility (tailwind-merge) - Accept
childrenfor composition - Type-safe prop definitions
Reactive Patterns
Check solid-primitives First
Always check if a sufficientsolid-primitive exists before implementing custom utilities:
Macro uses several primitives from @solid-primitives:
package.json):
@solid-primitives/audio@solid-primitives/broadcast-channel@solid-primitives/context@solid-primitives/deep@solid-primitives/event-bus@solid-primitives/event-listener@solid-primitives/lifecycle@solid-primitives/mutation-observer@solid-primitives/platform@solid-primitives/promise@solid-primitives/resize-observer@solid-primitives/resource@solid-primitives/rootless@solid-primitives/scheduled@solid-primitives/storage
Signals and Stores
Example frompackages/block-md/signal/markdownBlockData.ts:
- Use
createStorefromsolid-js/storefor nested reactive objects - Use
createSignalfor primitive values - Use
createMemofor derived values - Use
createCallbackfrom solid-primitives for stable callbacks
Effects and Lifecycle
Styling Conventions
Use Semantic Color Tokens
Use semantic color tokens instead of default Tailwind colors:Tailwind Utilities
Macro uses Tailwind v4 with custom configuration:Pattern Matching
Use ts-pattern for Exhaustive Switches
For exhaustive switch statements, usematch from ts-pattern:
- Type-safe exhaustiveness checking
- Pattern matching with guards
- Better than traditional switch statements
Network Layer
Use Tanstack Query for All API Calls
All network calls to service clients MUST go through Tanstack Query in thequeries package.
- Centralized caching and invalidation
- Consistent error handling
- Request deduplication
- Offline support via persistence