Skip to main content
rule

javascript-astro-tailwind-css-cursorrules-prompt-f Cursor rule

Cursor rule for Astro and Tailwind CSS projects. Enforces clean component composition, static page generation, and disciplined island hydration.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdc
Open on GitHub

What javascript-astro-tailwind-css-cursorrules-prompt-f does

This instruction guides the assistant through building static Astro sites with Tailwind CSS styling. It establishes standard folder organization across src/components/, layouts/, and pages/. For dynamic routing, it mandates getStaticPaths() inside [...slug].astro templates alongside proper 404 pages.

Client-side script volume remains strictly controlled. Interactivity must use partial hydration directives such as client:load, client:idle, or client:visible based on component priority. When writing styles, the rule strictly bans the @apply directive, demanding direct utility classes in component templates instead.

The project requires @astrojs/tailwind configured in astro.config.mjs. Theme overrides belong in tailwind.config.cjs.

What it helps with

  • generate static routes using getStaticPaths()
  • assign appropriate hydration directives like client:idle and client:visible
  • structure components, layouts, and content collections in src/
  • enforce pure utility classes without using @apply

Example prompts for the agent

  • Create a dynamic route in Astro using [...slug].astro and getStaticPaths
  • Add a React island with client:visible hydration for our newsletter form
  • Style an Astro hero section using Tailwind classes without using @apply

How to install javascript-astro-tailwind-css-cursorrules-prompt-f

Manually: put the files in place

.cursor/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about javascript-astro-tailwind-css-cursorrules-prompt-f

How to install javascript-astro-tailwind-css-cursorrules-prompt-f in Cursor?

Save the rule contents into .cursor/rules/javascript-astro-tailwind-css-cursorrules-prompt-f.mdc in your project repository.

What does this Cursor rule enforce?

It guides code generation toward static-first Astro architecture, minimal client JavaScript, and Tailwind utility usage.

Why does the rule ban Tailwind's @apply directive?

It prohibits @apply to keep styles transparent inside .astro templates rather than hiding CSS bundles in custom classes.

Source text

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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set210

knative-istio-typesense-gpu-cursorrules-prompt-fil A Cursor rule that turns the assistant into a helper for serverless projects built on Knative with Istio, Typesense and HTMX. Useful when your search app runs on that stack. ★ 41,024repo stars jest-unit-testing-cursorrules-prompt-file Guides Cursor to generate structured Jest unit tests in JavaScript and TypeScript. Enforces dependency mocking before imports and covers edge cases. ★ 41,024repo stars javascript-typescript-code-quality-cursorrules-pro A Cursor rule for cleaner JavaScript and TypeScript work. It guides code structure, comments, function order, and narrowly scoped edits. ★ 41,024repo stars javascript-chrome-apis-cursorrules-prompt-file A Cursor rule that points the AI agent at Chrome extension work: manifest, architecture, Chrome API usage. ★ 41,024repo stars java-springboot-jpa-cursorrules-prompt-file This rule guides Cursor when building Java Spring Boot projects with JPA, DTOs, and layered APIs. Use it when generated code should follow a fixed structure. ★ 41,024repo stars htmx-go-fiber-cursorrules-prompt-file A Cursor rule for Go projects built on Fiber with HTMX: it pins down folder layout, routing and template rendering so the agent stops improvising. ★ 41,024repo stars htmx-go-basic-cursorrules-prompt-file Guides Cursor when building Go web apps with HTMX. Enforces standard project layout, html/template rendering, and idiomatic request handling. ★ 41,024repo stars htmx-flask-cursorrules-prompt-file A Cursor rule for HTMX projects built with Flask. It sets guidance for templates, forms, routes, database access, and project layout. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor