Show Notes
Parker walks through turbocharging AI-assisted coding with Cursor rules and Taskmaster, then demonstratesBuilding a reusable data-fetching rule around a Supabase singleton, plus a global logger to improve reliability across server and client code.
Why Cursor rules matter
- Cursor rules define how the code-behind agent behaves for a given request, turning wild patterns into repeatable, reliable patterns.
- Start with official Cursor rules (e.g., Superbase official rules) for best practices and to align with the project’s tooling.
- Benefits: consistency, easier maintenance, better guidance for both humans and LLMs during debugging.
Getting official Cursor rules up and running
- Use the Superbase official Cursor rules package. Command and setup:
- Install via a shell command (Cursor rules from Superbase).
- Put rules into a cursor directory in your project with a clear folder structure.
- Structure you’ll typically see:
- DB functions, migrations, RLS policies, SQL style guide, edge functions
- Practical note: official rules are kept up to date; follow relevant creators on Twitter for updates.
Designing your own rules in a monorepo
- Organize for scale:
- Monorepo with nested apps (Next.js, React Router apps, Vite apps, etc.)
- Separate Superbase-related code into its own package
- Edge functions (Dino), migrations, queries, and mutations are neatly bucketed
- Data fetching patterns
- Start with queries (read) and then add mutations (writes) as needed
- Name endpoints and rules using kebab-case (lowercase with hyphens)
- Singleton pattern for the database client
- Create a single place that wires Superbase (server component -> client component)
- If the request is successful in one place, all dependent calls go through that same singleton
- Example structure (conceptual)
- apps/
- edX/
- marketing/
- packages/
- supabase/
- utils/
- logger.ts
- bore into:
- edge/
- migrations/
- queries/
- mutations/
- apps/
Global logger to standardize debugging
- Create a global logger.ts with levels: debug, info, warning, error
- Drive the log level from an environment variable
- Benefits:
- Consistent logging across server/client code
- Helpful for manual debugging and for guiding LLM reasoning
- Integrate into access points (e.g., get_prompts.ts) so every data fetch and prompt path is observable
Building a data-fetching rule (data-fetching.mdc)
- Goal: standardize how data is fetched, both server-side and client-side
- Key components of the MDC rule you’ll implement:
- Fence and description at the top
- Globs to indicate which files/folders the rule applies to
- Always apply flag (conditional vs. always) to control scope
- Server-side examples (server components, server-side fetching)
- Client-side examples (TSX usage, hooks or components that fetch data)
- Include a singleton import path for the Supabase client
- Include both server and client fetch patterns:
- Server: use a server component or server-side helper via the singleton
- Client: fetch via the appropriate client route or hook, still routed through the singleton
- Ensure type safety with the Supabase client types so TypeScript provides autocomplete and correctness
- Include the logger usage to surface lifecycle events (fetch start, fetch end, errors)
- Naming and organization tips:
- Descriptive prefixes (e.g., get_prompt, fetch_user, create_prompt)
- Use kebab-case naming for actions and endpoints
- Example updates you’ll likely add:
- Server-side query path
- Client-side fetch path
- Updated or additional import paths for the fetching helper
- Validation steps:
- Review the MDC output, ensure it mentions logger usage and singleton
- Confirm the generated rule covers both server and client scenarios
- Test by applying the rule to a real fetch path and verify the code adheres to the rule
Formatting and rule craftsmanship
- Use a well-formed MDC template:
- Start with a clear fence and description
- Put globs to target code sections
- specify always apply vs conditional
- Align with existing conventions:
- Naming conventions, path structure, and client/server separation
- Keep formatting clean to avoid lint/TS errors
- Dealing with tooling hiccups:
- If an editor/formatter or AI tool acts up, reload the window in your editor
- Don’t force edits that break the rule structure; preserve the template and refine incrementally
- Small, testable increments:
- Start with a small, useful rule (data fetching)
- Expand to client-specific examples or additional patterns if needed
Practical tips and caveats
- Expect occasional glitches when auto-formatting or generating code with AI; verify and adjust
- Biome ignore rules and strict linting help keep quality high, but use judiciously
- When adding new rules, document how to use them and how to opt-out if needed
How to use and share these rules
- The rules and templates are hosted in the featured educational project (example: I Vibe with AI)
- To get updates:
- Leave a comment requesting the rules
- You’ll get access to freebies/templates and updates to prompts and templates
- Optional extras:
- Email opt-in for updates on freebies and paid/free templates
- Daily channel for deeper dives into strategy and profitability
- Quick action items:
- Implement official Superbase Cursor rules as a base
- Build a data-fetching MDC for server and client
- Add a global logger and a Supabase singleton
- Apply the rule to your codebase and iterate based on results
Takeaways
- Cursor rules let you convert ad-hoc patterns into repeatable, engine-friendly behavior
- A singleton Supabase client plus a global logger creates a reliable foundation for both server and client code
- A focused data-fetching MDC rule can dramatically improve reliability and maintainability
- Start with one rule, test thoroughly, and expand as your project grows
Links
- Cursor rules resources and examples
- Supabase official cursor rules
- Task Master overview and related videos
- Turborepo monorepo structuring concepts
- Deno (edge functions) for server-side logic
- Biome or markdown preview tooling (for editing MDC files)
- I Vibe With AI (educational community context)
- Parker Rex Daily Channel (for deeper strategy content)