javascript-astro-tailwind-css-cursorrules-prompt-f: правило Cursor
Инструкция для Cursor по разработке на Astro и Tailwind CSS. Настраивает генерацию компонентов, маршрутизацию страниц и частичную гидратацию островков.
.cursor/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdcЧто делает javascript-astro-tailwind-css-cursorrules-prompt-f
Правило задаёт стандарты кода для проектов на Astro с Tailwind CSS. Оно фиксирует файловую структуру каталога src/, правила динамических маршрутов через getStaticPaths() и работу с контентом в Markdown или MDX. Для компонентов предписывается использовать расширение .astro, выносить общую разметку в макеты и подключать интеграцию @astrojs/tailwind.
Инструкция требует минимизировать объём клиентского JavaScript. Интерактивные острова подключаются строго через директивы client:load, client:idle или client:visible под конкретный сценарий. В стилях действует прямой запрет на директиву @apply: верстать придётся исключительно утилитарными классами в шаблоне.
Для работы в проекте нужны установленный Astro и пакет @astrojs/tailwind. Конфигурация темы выносится в файл tailwind.config.cjs.
Какие задачи решает
- настроить генерацию статических страниц через getStaticPaths()
- выбрать подходящие директивы гидратации вроде client:visible
- организовать структуру компонентов и макетов в папке src/
- подключить стили Tailwind без использования директивы @apply
Примеры запросов агенту
- Сделай динамическую страницу статьи блога на Astro через
[...slug].astro - Добавь интерактивную форму с отложенной гидратацией через
client:visible - Сверстай карточку товара на чистых классах Tailwind CSS без директивы
@apply
Как установить javascript-astro-tailwind-css-cursorrules-prompt-f
Вручную: положить файлы
.cursor/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/javascript-astro-tailwind-css-cursorrules-prompt-f.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdВручную: положить файлы
.clinerules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о javascript-astro-tailwind-css-cursorrules-prompt-f
Как установить javascript-astro-tailwind-css-cursorrules-prompt-f в Cursor?
Создайте файл .cursor/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdc в корне проекта и добавьте в него текст правила.
Зачем нужно это правило в Astro-проекте?
Оно удерживает архитектуру без лишнего клиентского JS, распределяет гидратацию по островам и задаёт единую структуру страниц.
Почему правило запрещает директиву @apply в Tailwind?
Запрет на @apply защищает проект от раздувания кастомного CSS и оставляет утилитарные классы прямо в разметке компонентов.
Исходный текст
javascript-astro-tailwind-css-cursorrules-prompt-f.mdc · CC0-1.0
---
description: "Cursor rules for JavaScript development with Astro and Tailwind CSS integration."
globs: **/*
alwaysApply: false
---
You are an expert in JavaScript, TypeScript, and Astro framework for scalable web development.
Key Principles
- Write concise, technical responses with accurate Astro examples.
- Leverage Astro's partial hydration and multi-framework support effectively.
- Prioritize static generation and minimal JavaScript for optimal performance.
- Use descriptive variable names and follow Astro's naming conventions.
- Organize files using Astro's file-based routing system.
Astro Project Structure
- Use the recommended Astro project structure:
- src/
- components/
- layouts/
- pages/
- styles/
- public/
- astro.config.mjs
Component Development
- Create .astro files for Astro components.
- Use framework-specific components (React, Vue, Svelte) when necessary.
- Implement proper component composition and reusability.
- Use Astro's component props for data passing.
- Leverage Astro's built-in components like when appropriate.
Routing and Pages
- Utilize Astro's file-based routing system in the src/pages/ directory.
- Implement dynamic routes using [...slug].astro syntax.
- Use getStaticPaths() for generating static pages with dynamic routes.
- Implement proper 404 handling with a 404.astro page.
Content Management
- Use Markdown (.md) or MDX (.mdx) files for content-heavy pages.
- Leverage Astro's built-in support for frontmatter in Markdown files.
- Implement content collections for organized content management.
Styling
- Use Astro's scoped styling with tags in .astro files.
- Leverage global styles when necessary, importing them in layouts.
- Utilize CSS preprocessing with Sass or Less if required.
- Implement responsive design using CSS custom properties and media queries.
Performance Optimization
- Minimize use of client-side JavaScript; leverage Astro's static generation.
- Use the client:* directives judiciously for partial hydration:
- client:load for immediately needed interactivity
- client:idle for non-critical interactivity
- client:visible for components that should hydrate when visible
- Implement proper lazy loading for images and other assets.
- Utilize Astro's built-in asset optimization features.
Data Fetching
- Use Astro.props for passing data to components.
- Implement getStaticPaths() for fetching data at build time.
- Use Astro.glob() for working with local files efficiently.
- Implement proper error handling for data fetching operations.
SEO and Meta Tags
- Use Astro's <head> tag for adding meta information.
- Implement canonical URLs for proper SEO.
- Use the <SEO> component pattern for reusable SEO setups.
Integrations and Plugins
- Utilize Astro integrations for extending functionality (e.g., @astrojs/image).
- Implement proper configuration for integrations in astro.config.mjs.
- Use Astro's official integrations when available for better compatibility.
Build and Deployment
- Optimize the build process using Astro's build command.
- Implement proper environment variable handling for different environments.
- Use static hosting platforms compatible with Astro (Netlify, Vercel, etc.).
- Implement proper CI/CD pipelines for automated builds and deployments.
Styling with Tailwind CSS
- Integrate Tailwind CSS with Astro @astrojs/tailwind
Tailwind CSS Best Practices
- Use Tailwind utility classes extensively in your Astro components.
- Leverage Tailwind's responsive design utilities (sm:, md:, lg:, etc.).
- Utilize Tailwind's color palette and spacing scale for consistency.
- Implement custom theme extensions in tailwind.config.cjs when necessary.
- Never use the @apply directive
Testing
- Implement unit tests for utility functions and helpers.
- Use end-to-end testing tools like Cypress for testing the built site.
- Implement visual regression testing if applicable.
Accessibility
- Ensure proper semantic HTML structure in Astro components.
- Implement ARIA attributes where necessary.
- Ensure keyboard navigation support for interactive elements.
Key Conventions
1. Follow Astro's Style Guide for consistent code formatting.
2. Use TypeScript for enhanced type safety and developer experience.
3. Implement proper error handling and logging.
4. Leverage Astro's RSS feed generation for content-heavy sites.
5. Use Astro's Image component for optimized image delivery.
Performance Metrics
- Prioritize Core Web Vitals (LCP, FID, CLS) in development.
- Use Lighthouse and WebPageTest for performance auditing.
- Implement performance budgets and monitoring.
Refer to Astro's official documentation for detailed information on components, routing, and integrations for best practices.
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules