typescript-shadcn-ui-nextjs-cursorrules-prompt-fil — правило Cursor
Задаёт стандарты TypeScript, React Server Components и shadcn/ui для Next.js в Cursor. Пригодится при сборке интерфейсов на Tailwind и Radix.
.cursor/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdcЧто делает typescript-shadcn-ui-nextjs-cursorrules-prompt-fil
Правило настраивает генерацию кода под Next.js с упором на серверные компоненты. Оно ограничивает директиву 'use client', запрещая использовать её для загрузки данных или управления состоянием. Ожидаемые сбои в Server Actions возвращаются значениями, а формы проверяются через Zod.
В вёрстке предписан мобильный подход на Tailwind CSS, Radix UI и shadcn/ui. Для состояния поисковых параметров в URL используется библиотека nuqs. В структуре файлов интерфейсы располагаются после самого компонента и вспомогательных функций. Вместо enum используются структуры map, а вместо классов — чистые функции со словом function.
Стек жёстко зафиксирован. Если в проекте не используются Next.js, Zod или Tailwind CSS, предложенные паттерны войдут в прямой конфликт с вашей структурой кода.
Какие задачи решает
- ограничить неоправданное использование директивы 'use client'
- настроить валидацию форм через Zod и Server Actions
- внедрить компоненты shadcn/ui и Radix с мобильной адаптивностью Tailwind
- синхронизировать состояние URL-параметров с помощью nuqs
Примеры запросов агенту
- Создай форму авторизации на shadcn/ui с валидацией через Zod и Server Action
- Вынеси фильтры каталога в клиентский компонент с синхронизацией URL через nuqs
- Перепиши компонент карточки на React Server Component и оптимизируй WebP-изображения
Как установить typescript-shadcn-ui-nextjs-cursorrules-prompt-fil
Вручную: положить файлы
.cursor/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdВручную: положить файлы
.clinerules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о typescript-shadcn-ui-nextjs-cursorrules-prompt-fil
Как установить typescript-shadcn-ui-nextjs-cursorrules-prompt-fil в Cursor?
Сохраните файл правила по пути .cursor/rules/typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdc в корне вашего проекта.
Что делает typescript-shadcn-ui-nextjs-cursorrules-prompt-fil?
Инструкция заставляет Cursor предпочитать React Server Components, использовать интерфейсы вместо типов, избегать enum и оформлять интерфейсы с помощью shadcn/ui.
Какие библиотеки нужны для работы по этому правилу?
Инструкции рассчитаны на проекты с Next.js, схемой валидации Zod, библиотекой nuqs для URL-параметров, а также Radix UI и Tailwind CSS.
Исходный текст
typescript-shadcn-ui-nextjs-cursorrules-prompt-fil.mdc · CC0-1.0
--- description: "Cursor rules for TypeScript development with shadcn/ui and Next.js integration." globs: **/* alwaysApply: false --- Code Style and Structure: - Write concise, technical TypeScript code with accurate examples - Use functional and declarative programming patterns; avoid classes - Prefer iteration and modularization over code duplication - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError) - Structure files: exported component, subcomponents, helpers, static content, types Naming Conventions: - Use lowercase with dashes for directories (e.g., components/auth-wizard) - Favor named exports for components TypeScript Usage: - Use TypeScript for all code; prefer interfaces over types - Avoid enums; use maps instead - Use functional components with TypeScript interfaces Syntax and Formatting: - Use the "function" keyword for pure functions - Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements - Use declarative JSX Error Handling and Validation: - Prioritize error handling: handle errors and edge cases early - Use early returns and guard clauses - Implement proper error logging and user-friendly messages - Use Zod for form validation - Model expected errors as return values in Server Actions - Use error boundaries for unexpected errors UI and Styling: - Use Shadcn UI, Radix, and Tailwind Aria for components and styling - Implement responsive design with Tailwind CSS; use a mobile-first approach Performance Optimization: - Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC) - Wrap client components in Suspense with fallback - Use dynamic loading for non-critical components - Optimize images: use WebP format, include size data, implement lazy loading Key Conventions: - Use 'nuqs' for URL search parameter state management - Optimize Web Vitals (LCP, CLS, FID) - Limit 'use client': - Favor server components and Next.js SSR - Use only for Web API access in small components - Avoid for data fetching or state management Follow Next.js docs for Data Fetching, Rendering, and Routing
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules