Skip to content

Commit 56083e3

Browse files
docs: add Cursor Rules (#1223)
* docs: add Cursor Rules * docs: add missing line * chore: run prettier
1 parent 78a3085 commit 56083e3

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

.cursor/rules/global.mdc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
description: Global rules
3+
globs:
4+
alwaysApply: true
5+
---
6+
You are an expert developer in TypeScript, Node.js, Next.js 15 App Router, React, HTML, CSS and modern UI/UX frameworks.
7+
8+
Code Style and Structure:
9+
- Write concise, technical TypeScript code with accurate examples.
10+
- Use functional and declarative programming patterns; avoid classes.
11+
- Prefer iteration and modularization over code duplication.
12+
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
13+
- Structure files: exported component, subcomponents, helpers, static content, types.
14+
15+
Naming Conventions:
16+
- Use lowercase with dashes for directories (e.g., components/auth-wizard).
17+
- Favor named exports for components.
18+
19+
TypeScript specific:
20+
- Use TypeScript for all code; prefer interfaces over types.
21+
- Avoid enums; use maps instead.
22+
- Use functional components with TypeScript types.
23+
24+
Documentation
25+
- Provide clear and concise comments for complex logic. Do not add comments for code that is not complex.
26+
- Keep the README files up-to-date with setup instructions and project overview.

.cursor/rules/nextjs.mdc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
description: Best Practices for Next.js
3+
globs: src/**/*.{ts,tsx}
4+
alwaysApply: false
5+
---
6+
Syntax and Formatting:
7+
- Use the "function" keyword for pure functions.
8+
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
9+
- Use declarative JSX.
10+
11+
Accessibility
12+
- Ensure interfaces are keyboard navigable.
13+
- Implement proper ARIA labels and roles for components.
14+
- Ensure color contrast ratios meet WCAG standards for readability.
15+
16+
Next.js Specifics:
17+
- Prioritize using server components (RSC) for performance, SEO, and data fetching
18+
- Use client components sparingly, only when interactivity is required
19+
- Take advantage of Next.js file-based routing system for simplicity
20+
- Centralize shared layouts in `layout.tsx` for consistency across pages
21+
- Implement custom error pages with `error.tsx` to handle errors gracefully
22+
- Use API route handlers to manage backend logic within the app structure
23+
- Store shared logic in `lib/` or `util/`.
24+
- Place static assets in `public/`.
25+
- Use [layout.tsx](mdc:src/app/layout.tsx) for global layout.
26+
- Wrap client components in Suspense with fallback
27+
- Use dynamic loading for non-critical components
28+
- Optimize images: use WebP format, include size data, implement lazy loading
29+
- Optimize Web Vitals (LCP, CLS, FID)
30+
- Refer to Next.js documentation for Data Fetching, Rendering, and Routing best practices

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- ⚡️ Next.js 15 (App Router)
3131
- ⚛️ React 19
3232
- ⛑ TypeScript
33+
- ⚡️ Cursor Rules — Cursor rules for an improved AI coding experience
3334
- 📏 ESLint 9 — To find and fix problems in your code
3435
- 💖 Prettier — Code Formatter for consistent style
3536
- 🐶 Husky — For running scripts before committing
@@ -149,6 +150,12 @@ The Content Security Policy (CSP) is a security layer that helps to detect and m
149150

150151
It contains a default and minimal policy that you can customize to fit your application needs. It's a foundation to build upon.
151152

153+
### Cursor Rules
154+
155+
This is the most opinionated part of the project, and it's just a starting point. We have cursor rules that will help you write code faster and more efficiently. If you don't use Cursor, feel free to delete the `.cursor` folder.
156+
157+
Regarding the rules, these are rules that I use as a foundation, and you can customize them as you want, and according to your project needs, or developer preferences. If you want some inspiration, check out the [Cursor Directory](https://cursor.directory).
158+
152159
## License
153160

154161
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for more information.

src/app/globals.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
:root {
22
--max-width: 1100px;
33
--border-radius: 12px;
4-
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono',
5-
'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
4+
--font-mono:
5+
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace',
6+
'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
67

78
--foreground-rgb: 0, 0, 0;
89
--background-start-rgb: 214, 219, 220;

0 commit comments

Comments
 (0)