diff options
Diffstat (limited to 'mac/.cursor')
| -rw-r--r-- | mac/.cursor/rules/env.mdc | 31 | ||||
| -rw-r--r-- | mac/.cursor/rules/how-to-work.mdc | 7 | ||||
| -rw-r--r-- | mac/.cursor/rules/nextjs.mdc | 21 | ||||
| -rw-r--r-- | mac/.cursor/rules/postgres-raw-sql.mdc | 143 | ||||
| -rw-r--r-- | mac/.cursor/rules/react.mdc | 16 |
5 files changed, 218 insertions, 0 deletions
diff --git a/mac/.cursor/rules/env.mdc b/mac/.cursor/rules/env.mdc new file mode 100644 index 0000000..1cd84c0 --- /dev/null +++ b/mac/.cursor/rules/env.mdc @@ -0,0 +1,31 @@ +--- +description: product stacks +globs: +alwaysApply: true +--- +# environment information + +## stacks + +- framework: Next.js (latest) with app router +- styling: tailwind css + shadcn/ui (latest) +- state manager: jotai (latest) +- validation: zod (not always required) +- i18n/l10n: i18next (latest) +- database: postgres 17.2, orm: drizzle (latest) +- auth: next-auth (latest) + +## convention + +- use sonner when notification is required. +- there are lots of examples. search for examples. +- ignore `any` linter error. I will handle it later. +- server action's function must be async function. (nextjs 15) + +## Editting rules + +- Please, check the provided files(code) before editting. +- You don't have to check ALL. (ex: via CLI - npm run dev / npm run build / database sql / lint ...) I am monitoring together. +- If you got problem with CLI, stop and say 'Help me.' I will help you. +- You can use bash. + diff --git a/mac/.cursor/rules/how-to-work.mdc b/mac/.cursor/rules/how-to-work.mdc new file mode 100644 index 0000000..4474af9 --- /dev/null +++ b/mac/.cursor/rules/how-to-work.mdc @@ -0,0 +1,7 @@ +--- +description: +globs: +alwaysApply: true +--- +CLI 명령 중 변경사항을 적용하기 위한 drizzle-kit, npm run dev, npm run build 명령은 실행하지 마세요. +유저에게 확인을 부탁하세요.
\ No newline at end of file diff --git a/mac/.cursor/rules/nextjs.mdc b/mac/.cursor/rules/nextjs.mdc new file mode 100644 index 0000000..95d3454 --- /dev/null +++ b/mac/.cursor/rules/nextjs.mdc @@ -0,0 +1,21 @@ +--- +description: This rule explains Next.js conventions and best practices for fullstack development. +globs: **/*.js,**/*.jsx,**/*.ts,**/*.tsx +alwaysApply: false +--- + +# Next.js rules + +- Use the App Router structure with `page.tsx` files in route directories. +- Client components must be explicitly marked with `'use client'` at the top of the file. +- Use kebab-case for directory names (e.g., `components/auth-form`) and PascalCase for component files. +- Prefer named exports over default exports, i.e. `export function Button() { /* ... */ }` instead of `export default function Button() { /* ... */ }`. +- Minimize `'use client'` directives: + - Keep most components as React Server Components (RSC) + - Only use client components when you need interactivity and wrap in `Suspense` with fallback UI + - Create small client component wrappers around interactive elements +- Avoid unnecessary `useState` and `useEffect` when possible: + - Use server components for data fetching + - Use React Server Actions for form handling + - Use URL search params for shareable state +- Use `nuqs` for URL search param state management diff --git a/mac/.cursor/rules/postgres-raw-sql.mdc b/mac/.cursor/rules/postgres-raw-sql.mdc new file mode 100644 index 0000000..d252e27 --- /dev/null +++ b/mac/.cursor/rules/postgres-raw-sql.mdc @@ -0,0 +1,143 @@ +--- +description: This rule explains PostgreSQL database design patterns and advanced features usage. +globs: **/*.sql +alwaysApply: false +--- + +# PostgresSQL rules + +## General + +- Use lowercase for SQL reserved words to maintain consistency and readability. +- Employ consistent, descriptive identifiers for tables, columns, and other database objects. +- Use white space and indentation to enhance the readability of your code. +- Store dates in ISO 8601 format (`yyyy-mm-ddThh:mm:ss.sssss`). +- Include comments for complex logic, using '/*...*/' for block comments and '--' for line comments. + +## Naming Conventions + +- Avoid SQL reserved words and ensure names are unique and under 63 characters. +- Use snake_case for tables and columns. +- Prefer plurals for table names +- Prefer singular names for columns. + +## Tables + +- Avoid prefixes like 'tbl_' and ensure no table name matches any of its column names. +- Always add an `id` column of type `identity generated always` unless otherwise specified. +- Create all tables in the `public` schema unless otherwise specified. +- Always add the schema to SQL queries for clarity. +- Always add a comment to describe what the table does. The comment can be up to 1024 characters. + +## Columns + +- Use singular names and avoid generic names like 'id'. +- For references to foreign tables, use the singular of the table name with the `_id` suffix. For example `user_id` to reference the `users` table +- Always use lowercase except in cases involving acronyms or when readability would be enhanced by an exception. + +#### Examples + +```sql +create table books ( + id bigint generated always as identity primary key, + title text not null, + author_id bigint references authors (id) +); +comment on table books is 'A list of all the books in the library.'; +``` + +## Queries + +- When the query is shorter keep it on just a few lines. As it gets larger start adding newlines for readability +- Add spaces for readability. + +Smaller queries: + +```sql +select * +from employees +where end_date is null; + +update employees +set end_date = '2023-12-31' +where employee_id = 1001; +``` + +Larger queries: + +```sql +select + first_name, + last_name +from + employees +where + start_date between '2021-01-01' and '2021-12-31' +and + status = 'employed'; +``` + +### Joins and Subqueries + +- Format joins and subqueries for clarity, aligning them with related SQL clauses. +- Prefer full table names when referencing tables. This helps for readability. + +```sql +select + employees.employee_name, + departments.department_name +from + employees +join + departments on employees.department_id = departments.department_id +where + employees.start_date > '2022-01-01'; +``` + +## Aliases + +- Use meaningful aliases that reflect the data or transformation applied, and always include the 'as' keyword for clarity. + +```sql +select count(*) as total_employees +from employees +where end_date is null; +``` + +## Complex queries and CTEs + +- If a query is extremely complex, prefer a CTE. +- Make sure the CTE is clear and linear. Prefer readability over performance. +- Add comments to each block. + +```sql +with department_employees as ( + -- Get all employees and their departments + select + employees.department_id, + employees.first_name, + employees.last_name, + departments.department_name + from + employees + join + departments on employees.department_id = departments.department_id +), +employee_counts as ( + -- Count how many employees in each department + select + department_name, + count(*) as num_employees + from + department_employees + group by + department_name +) +select + department_name, + num_employees +from + employee_counts +order by + department_name; +``` diff --git a/mac/.cursor/rules/react.mdc b/mac/.cursor/rules/react.mdc new file mode 100644 index 0000000..b595c43 --- /dev/null +++ b/mac/.cursor/rules/react.mdc @@ -0,0 +1,16 @@ +--- +description: This rule explains React component patterns, hooks usage, and best practices. +globs: **/*.jsx,**/*.tsx +alwaysApply: false +--- + +# React rules + +- Use functional components with hooks instead of class components +- Use custom hooks for reusable logic +- Use the Context API for state management when needed +- Use proper prop validation with PropTypes +- Use React.memo for performance optimization when necessary +- Use fragments to avoid unnecessary DOM elements +- Use proper list rendering with keys +- Prefer composition over inheritance |
