astro · przeprogramowani — Claude Code rule: what it does, how to install
Guidelines for Claude Code to generate server-side pages and endpoints in Astro. Ensures type safety, middleware handling, and request validation.
AGPL-3.0 ★ 267 updated 2026-02-20
.cursor/rules/astro.mdcWhat astro does
This rule teaches Claude Code how to structure Astro projects with hybrid rendering and server-side endpoints. The assistant enforces uppercase method names such as GET and POST, marks API handlers with export const prerender = false, and verifies incoming payloads using Zod schemas.
Content collections receive strict TypeScript schemas for documentation or blog posts. Environment flags read from import.meta.env, while cookie operations route through Astro.cookies. For unprotected routes, the assistant must edit src/middleware/index.ts so anonymous traffic does not get blocked.
What it helps with
- validate API route payloads using Zod schemas
- configure server endpoints with disabled prerendering
- build type-safe content collections for markdown articles
- read and write server cookies with
Astro.cookies
Example prompts for the agent
- Create a POST server endpoint to accept feedback with Zod schema validation.
- Set up a type-safe content collection for the documentation section.
- Update
src/middleware/index.tsto allow anonymous access to the landing page.
How to install astro
Manually: put the files in place
.cursor/rules/astro.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/astro.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/astro.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/astro.mdManually: put the files in place
.clinerules/astro.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about astro
How to install astro in Claude Code?
Place the rule configuration at .claude/rules/astro.md inside your repository.
What does the astro rule do?
It guides Claude Code on building hybrid Astro apps, enforcing uppercase HTTP methods, Zod validations, content collections, and cookie handling.
How does the rule handle public routes?
It directs the assistant to modify src/middleware/index.ts whenever generating public pages to allow unauthenticated access.
Similar IDE rules
All IDE rules for Frontend and UI →astro by other authors comes first.