Agent skill
wiring-framework
Use for API/SWR wiring in PierceDesk. Covers Supabase auth patterns, client-to-API wiring, data fetching for large datasets or high-frequency updates, and references to docs/system wiring guidance.
Stars
163
Forks
31
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/wiring-framework
SKILL.md
Wiring Framework Skill
Core wiring rules
- Supabase auth is the only auth system; always use the established Supabase auth flow.
- Client → API → Supabase: Client uses SWR/axios to call Next.js API routes; API routes use Supabase server client.
- Never call Supabase directly from UI components unless the existing pattern explicitly does so.
- Always scope by auth.uid() in API routes and rely on RLS enforcement.
- Reuse SWR hooks in
src/services/swr/api-hooks/instead of creating ad-hoc fetches.
Efficiency rules
Large datasets
- Prefer server-side filtering, pagination, and select lists (avoid
select('*')). - Use query params for filters in API routes (e.g.,
?contact_id=...&type=...). - Return grouped/aggregated data from API endpoints when UI expects grouped data.
High-frequency updates
- Use SWR
dedupingInterval,refreshInterval, andrevalidateOnFocusthoughtfully. - Use
mutatewith optimistic updates for drag/drop or fast UI state changes. - Avoid redundant API calls by caching or batching where possible.
Supabase auth patterns
- Server-side auth via
@supabase/ssrin API routes. - Root layout validates session; middleware can redirect authenticated users.
- Follow the documented auth/RLS decisions in docs/system.
Required references (read before wiring work)
references/system-docs-map.mdreferences/auth-patterns-map.md
Process checklist
- Identify existing SWR hooks for the feature; reuse or extend.
- Confirm API route patterns from docs/system design.
- Ensure API routes use Supabase server client + auth validation.
- Apply filtering/pagination strategy for large datasets.
- Add optimistic updates for high-frequency UI actions when needed.
- Verify responses match existing mock data shapes.
Didn't find tool you were looking for?