Astro Cursor Rules Template
Generate production-ready Astro Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Astro. Content-first web framework with island architecture and zero-JS defaults.
The Complete Astro Cursor Rules
The full rule set in all three formats Cursor understands — copy the one your project uses. Project Rules (.mdc) load per-file via globs, AGENTS.md is portable across AI tools, and .cursorrules is the legacy single-file format.
Replacing a legacy file? Read the guide to migrate .cursorrules to Cursor Project Rules (.mdc) before copying this template into your project.
---
description: "Component Model"
alwaysApply: false
---
- Use .astro files for static/server-rendered components.
- Use framework components (React, Vue, Svelte) only for interactive islands.
- Use spaces for indentation.
- Use camelCase for variable and function names.
- Keep component scripts (--- fences) server-side only.
- Use client:* directives only when client interactivity is needed.---
description: "Content & Data"
alwaysApply: false
---
- Use Content Collections for type-safe markdown/MDX content.
- Define collection schemas with Zod in src/content/config.ts.
- Use getCollection() for fetching content with filtering and sorting.
- Use getEntry() for single content items.
- Use Astro.glob() for non-collection file imports.
- Prefer static generation with getStaticPaths() for content pages.---
description: "Performance & Islands"
alwaysApply: false
---
- Ship zero JavaScript by default — add only where needed.
- Use client:load for immediately interactive components.
- Use client:idle for deferring to browser idle time.
- Use client:visible for lazy-loaded interactive components.
- Use client:media for media-query-driven hydration.
- Use client:only when a component must skip SSR entirely.---
description: "Routing & Pages"
alwaysApply: false
---
- Use file-based routing under src/pages/.
- Use [...slug].astro for dynamic routes.
- Use Astro.props to access page props.
- Use Astro.url for URL information in server context.
- Use Astro.redirect() for server-side redirects.
- Use middleware (src/middleware.ts) for request interception.Customize These Rules
The generator below is preloaded with the Astro template. Adjust indentation, quotes, naming, add your own rules, then download — no need to start from scratch on the homepage.
What This Template Covers
Required guidance
- - Component Model
- - Content & Data
- - Performance & Islands
- - Routing & Pages
Default style
- - Indentation: 2 spaces
- - Quotes: single
- - Semicolons: disabled
- - Naming: camelCase
Frequently Asked Questions
- What does the Astro Cursor rules template include?
- It includes 4 rule sections covering component model, content & data, performance & islands and other Astro development conventions.
- Can I generate Astro Project Rules and AGENTS.md from the same template?
- Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
- Should I combine Astro with other Cursor rules templates?
- Yes. You can combine Astro with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.