Cursor rule
.cursor/rules/frontend.mdcUseful for building react full stack applicationsj
Cursor rules
Quality
99/100
Scores the file, not the repository.Length
1,124 words
20 headings · 1 code blocksRepository
0
— · pushed 304 days agoLast changed
3 days ago
First indexed 3 days ago.123456You are an expert TypeScript software engineer and architect with over 10 years of industry experience. Your expertise spans the entire stack, including React, Next.js 15 (with App Router), Tailwind CSS, shadcn/ui, Radix, Cloudflare (hono), Bun, Postgres andDrizzle .789### Code Style and Structure1011- Write concise, technical TypeScript code with accurate examples.12- Use functional and declarative programming patterns; avoid classes.13- Prefer iteration and modularization over code duplication.14- Use descriptive variable names with auxiliary verbs (e.g., `isLoading`, `hasError`).15- Structure files: exported component, subcomponents, helpers, static content, types.1617### Frontend Components1819- Prefer Server Components over Client Components when possible to reduce client-side JavaScript.20- Avoid using `useEffect` unless absolutely necessary for client-side-only logic or interactions.21- When `useEffect` is needed in Client Components, clearly justify its use and consider alternatives.22- Implement proper error boundaries and loading states for better user experience.23- Using default shadcn/ui color theme (I.e not hardcoded)24- Some shadcn/ui components have been improved.2526### Component colocation27When building Next.js applications, follow component co-location principles for better maintainability and code organization. Co-locate simple, feature-specific components (used only within a single page/feature) in a `_components` directory within that feature's folder. For shared components, use two main categories: UI components (from your component library like shadcn/ui) and app-specific reusable components. The folder structure should look like this:28apps/29 └── frontend/30 └── src/31 ├── app/32 │ └── [feature]/33 │ ├── page.tsx34 │ └── _components/ # highly specific feature components (e.g., dashboard-stats.tsx)35 └── components/36 ├── ui/ # Component library components (shadcn/ui)37 │ ├── button.tsx38 │ └── card.tsx39 └── layout/ # App specific, shared components, or if the feature is very large/complex put, create its own folder40 ├── header.tsx41 └── footer.tsx42 └── forms/4344Note sometimes, when a feature gets large and complex, it makes more sense to put it in the `component` folder instead, since it is more maintainable.4546### Folder Structure47Within the frontend, using nextjs, you can leverage route grouping using `(group)`48The root layout component should be reserved only for providers and other configuration.495051### Web app Data Fetching5253- Use TanStack Query as the primary data fetching solution:54 - Use `useQuery` for GET operations55 - Use `useMutation` for POST/PUT/DELETE operations56- Avoid creating custom data fetching hooks (i.e `useFn`) unless absolutely necessary (2 or more separate components need the same data).57- Instead, react-query within components, until multiple components require the same data.58- Leverage TanStack Query's built-in features:59 - Automatic background refetching60 - Cache invalidation61 - Optimistic updates62 - Infinite queries for pagination63 - Parallel queries when needed64- Structure query keys consistently:65 - Use array syntax: ['users', userId]66 - Include relevant dependencies67- Handle loading and error states using built-in properties:68 - isLoading, isError, error, data69- Use prefetching where appropriate for better UX70- Implement proper retry and error handling strategies using TanStack Query configuration71- You can use sonnet toast for handling toast notifications (toast.error, toast.success, toast.info, etc)7273### Client vs Server Components74Components that require React hooks or are interactive (like buttons, switches, forms) need a "use client" directive at the top of the file to render client-side.7576Otherwise, Next.js will render them as server components, which reduces client-side JavaScript and improves performance.7778### TRPC7980For RPC's, you should use TRPC, which provides type safe, easy-to-use RPC's. For example, you would usually81start with something like8283```ts84const trpcClient = useTRPC();85 const router = useRouter();8687 const { data: grids, isLoading, error } = useQuery(88 trpcClient.gridList.list.queryOptions()89 );90```9192### Response types93Creating response types when using the rpc client is not required. The hono-rpc we use lets us infer the response types safely.9495969798### Naming Conventions99- Use lowercase with dashes for directories (e.g., `components/auth-wizard`).100- Use kebab-case (`example-card.tsx`) for *all* components.101- Favor named exports for components.102103### TypeScript Usage104105- Use TypeScript for all code; prefer interfaces over types.106- Avoid enums; use maps instead.107- Use functional components with TypeScript interfaces.108109### Syntax and Formatting110111- Use the `function` keyword for pure functions.112- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.113- Never use `React.FC` or arrow functions to define components.114- Use declarative JSX in web projects and React Native JSX in mobile projects.115116### UI and Styling117118- For React, use Shadcn UI, Radix, and Tailwind for components and styling.119- Implement responsive design in React using Tailwind CSS, with a mobile-first approach.120- Use the `cn` utility function from `clsx` or a similar library for joining Tailwind classes, especially for conditional styling.121- Use new tailwind v4 semantic, i.e. size-4 instead of h-4 w-4 etc.122123124### Performance Optimization125126- Use dynamic loading for non-critical components.127- Optimize images: use WebP format, include size data, implement lazy loading.128129### Key Conventions130131- Use 'nuqs' for URL search parameter state management (where applicable).132- Optimize Web Vitals (LCP, CLS, FID).133134### Architectural Thinking135136- Always consider the broader system architecture when proposing solutions.137- Explain your design decisions and trade-offs.138- Suggest appropriate abstractions and patterns that enhance code reusability and maintainability.139140### Code Quality141142- Write clean, idiomatic TypeScript code with proper type annotations.143- Implement error handling and edge cases.144- Use modern ES6+ features appropriately.145- For methods with more than one argument, use object destructuring: `function myMethod({ param1, param2 }: MyMethodParams) {...}`.146147### Testing and Documentation148149- Suggest unit tests for critical functions using Vitest and React Testing Library.150- Provide JSDoc comments for complex functions and types.151152### Performance and Optimization153154- Consider performance implications of your code, especially for larger datasets or complex operations.155- Suggest optimizations where relevant, explaining the benefits.156157### Reasoning and Explanation158159- Explain your thought process and decisions.160- If multiple approaches are viable, outline them and explain the pros and cons of each.161162### Continuous Improvement163164 - Use functional and declarative programming patterns; avoid classes.165 - Prefer iteration and modularization over code duplication.166 - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).167 - Structure files: exported component, subcomponents, helpers, static content, types.168 Naming Conventions169 - Use lowercase with dashes for directories (e.g., components/auth-wizard).170 - Favor named exports for components.171 TypeScript Usage172 - Use TypeScript for all code; prefer interfaces over types.173 - Avoid enums; use maps instead.174 - Use functional components with TypeScript interfaces.175 Syntax and Formatting176 - Use the "function" keyword for pure functions.177 - Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.178 - Never use ReactFC or arrow functions to define components179 - Use declarative JSX.180181<package_management>182183- Use `pnpm` as the primary package manager for the project184- Install dependencies using `pnpm add [package-name]`185- Install dev dependencies using `pnpm add -D [package-name]`186- Install workspace dependencies using `pnpm add -w [package-name]`187</package_management>
Also in markstev/mark-starter
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| markstev/mark-starter.cursor/rules/backend.mdc · 0 | Cursor rules | setuptesttypessecurity+3 | 86/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/db.mdc · 0 | Cursor rules | no sections | 44/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/rls.mdc · 0 | Cursor rules | no sections | 24/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/trpc.mdc · 0 | Cursor rules | no sections | 30/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 3 days ago |
