astro

A set of coding rules for Astro, a web framework for building fast websites, covering page structure, content, browser-side code, and images.

In plain words
What is it for?
It helps build Astro sites with file-based pages, validated content collections, reusable components, static generation, and limited browser-side JavaScript.
Why use it?
It gives an Astro project consistent decisions about where files belong, when JavaScript should run, and how structured content is checked.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/astro
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection
Per session 408 This file is loaded in full into every session.
When invoked 408 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00408 $0.00408
Opus 5 $0.00204 $0.00204
Sonnet 5 $0.00082 $0.00082
Haiku 4.5 $0.00041 $0.00041

Measured yesterday against content hash 1b752df3fb35, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

astro scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/frameworks/astro.mdc · 46 lines

What it actually says

Astro Cursor Rules

You are an expert Astro developer. Follow these rules:

Architecture

  • Server-first: default to zero client JS. Add islands only for interactivity
  • Content collections with Zod schemas for all structured content
  • File-based routing in src/pages/. Dynamic routes with [...slug].astro
  • Layouts in src/layouts/, reusable components in src/components/

Islands Architecture

  • client:load only for immediately interactive components (nav menus, forms)
  • client:visible for below-fold interactive content (comments, carousels)
  • client:idle for non-critical interactivity (analytics widgets)
  • client:media for responsive islands (mobile-only menus)
  • Never client:load what could be client:visible

Content

  • Define collections in src/content/config.ts with strict Zod schemas
  • Use getCollection() and getEntry() — never raw file imports
  • MDX for content that needs components. Markdown for everything else
  • Frontmatter validation catches errors at build time — use it

Performance

  • Static generation (SSG) by default. SSR only for personalized/dynamic pages
  • Image component for all images — automatic format/size optimization
  • Inline critical CSS. Astro does this automatically — dont fight it
  • Prefetch visible links with data-astro-prefetch

Styling

  • Scoped styles in tags — they are component-scoped by default
  • Use :global() sparingly and only in layouts
  • CSS custom properties for theming over CSS-in-JS
  • No Tailwind classes in .astro files unless project-wide decision

Data Fetching

  • Fetch in frontmatter (server-side) — runs at build time for SSG
  • API routes in src/pages/api/ for dynamic endpoints
  • Use Astro.response for setting headers/status in SSR
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 46 lines · 408 tokens per session scan A 1b752df3fb35

Subscribe to this mod's changes

astro is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 408 tokens to every session, about $0.0020 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.