When creating .astro pages or components, defining collections or reviewing performance.
description: Construye y mantiene sitios estáticos en Astro 4/5 con content collections, imágenes optimizadas e islas mínimas. Úsala al crear páginas, componentes .astro, colecciones de contenido o al revisar el rendimiento de un sitio Astro.
Content collections
astro:assets
Islands and client:*
Core Web Vitals
How you ask for it
> Add a notes content collection to this Astro site, with its listing page.
Say this to the agent as it is: the skill loads itself from its description, you do not have to name it.
The native route, and the only one that updates itself: add the marketplace once and `/plugin marketplace update` brings in new versions. Skills get their own namespace (`azure-devops:azure-pr-review`).
One command at the root of your project. Claude Code discovers it on its own: nothing to register.
curl -fsSL https://jesusprodriguez.com/skills/install.sh -o install.sh
sh install.sh astro-static-site
Download the script, read it, run it. Installs one skill, a whole stack or all of them, and pulls in the dependencies between skills. With `--check` it compares the sha256 of what you have installed and lists only what changed.
1Download the SKILL.md of the skill you want.
2Paste its contents into your tool’s rules file (.cursorrules, AGENTS.md, system instructions…).
3Keep the frontmatter block: the description is what tells the agent when to apply it.
The whole file
This is exactly what you download: no summaries, nothing trimmed.
Heads-up: the skill file itself is written in Spanish. Agents read it fine and answer in your language, but the prose below is not translated.
Astro: sitio estático rápido
Guía de trabajo para sitios Astro con salida estática. El objetivo por defecto
es cero JavaScript en cliente salvo donde la interacción lo exija.
Reglas de oro
HTML primero. Un componente .astro se renderiza en build. No añadas
client:* hasta que exista una interacción real que lo necesite.
client:visible antes que client:load. Si la isla está bajo el
pliegue, no debe competir con el primer render.
Imágenes siempre por astro:assets.<Image /> o <Picture /> con
widths y sizes. Una imagen en public/ no se optimiza: solo va ahí lo
que necesita una URL estable (favicon, PDF, robots.txt).
Fuentes self-hosted vía @fontsource*, nunca CDN de Google: elimina una
conexión de terceros y el FOUT asociado.
Content collections
Define el esquema en src/content/config.ts y deja que Zod valide en build:
import { defineCollection, z } from 'astro:content';const blog = defineCollection({ type: 'content', schema: ({ image }) => z.object({ title: z.string(), description: z.string(), pubDate: z.coerce.date(), tags: z.array(z.string()).default([]), draft: z.boolean().default(false), heroImage: image().optional(), }),});export const collections = { blog };
image() en el esquema es lo que permite optimizar la portada. Requiere que
el fichero viva dentro de src/, no en public/.
Filtra los borradores en una única función (getPublishedPosts()), no en
cada página: así no se escapa ninguno.
npm run build y comprueba que el bundle de _astro/*.js sea el esperado:
si aparece un framework entero, hay una isla de más.
Toda imagen debe llegar al HTML con width y height para no provocar CLS.
El script anti-FOUC del tema va inline en el <head>, antes del CSS.
Errores frecuentes
Síntoma
Causa habitual
La imagen no se optimiza
Está en public/ en vez de src/
CLS alto al cargar
Falta width/height o aspect-ratio
Parpadeo de tema
El script del tema no es inline y bloqueante
Tags con URLs rotas
Falta slugificar acentos y símbolos (.NET, C#)
---
name: astro-static-site
description: Construye y mantiene sitios estáticos en Astro 4/5 con content collections, imágenes optimizadas e islas mínimas. Úsala al crear páginas, componentes .astro, colecciones de contenido o al revisar el rendimiento de un sitio Astro.
version: 1.0.0
license: CC-BY-4.0
updated: 2026-08-16
---
# Astro: sitio estático rápido
Guía de trabajo para sitios Astro con salida estática. El objetivo por defecto
es **cero JavaScript en cliente** salvo donde la interacción lo exija.
## Reglas de oro
1. **HTML primero.** Un componente `.astro` se renderiza en build. No añadas
`client:*` hasta que exista una interacción real que lo necesite.
2. **`client:visible` antes que `client:load`.** Si la isla está bajo el
pliegue, no debe competir con el primer render.
3. **Imágenes siempre por `astro:assets`.** `<Image />` o `<Picture />` con
`widths` y `sizes`. Una imagen en `public/` no se optimiza: solo va ahí lo
que necesita una URL estable (favicon, PDF, `robots.txt`).
4. **Fuentes self-hosted** vía `@fontsource*`, nunca CDN de Google: elimina una
conexión de terceros y el FOUT asociado.
## Content collections
Define el esquema en `src/content/config.ts` y deja que Zod valide en build:
```ts
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
type: 'content',
schema: ({ image }) => z.object({
title: z.string(),
description: z.string(),
pubDate: z.coerce.date(),
tags: z.array(z.string()).default([]),
draft: z.boolean().default(false),
heroImage: image().optional(),
}),
});
export const collections = { blog };
```
- `image()` en el esquema es lo que permite optimizar la portada. Requiere que
el fichero viva dentro de `src/`, no en `public/`.
- Filtra los borradores en una única función (`getPublishedPosts()`), no en
cada página: así no se escapa ninguno.
## Rutas dinámicas
```astro
---
export async function getStaticPaths() {
const posts = await getCollection('blog', ({ data }) => !data.draft);
return posts.map((post) => ({ params: { slug: post.slug }, props: { post } }));
}
const { post } = Astro.props;
const { Content } = await post.render();
---
<Content />
```
## Revisión de rendimiento
- `npm run build` y comprueba que el bundle de `_astro/*.js` sea el esperado:
si aparece un framework entero, hay una isla de más.
- Toda imagen debe llegar al HTML con `width` y `height` para no provocar CLS.
- El script anti-FOUC del tema va **inline en el `<head>`**, antes del CSS.
## Errores frecuentes
| Síntoma | Causa habitual |
|---|---|
| La imagen no se optimiza | Está en `public/` en vez de `src/` |
| CLS alto al cargar | Falta `width`/`height` o `aspect-ratio` |
| Parpadeo de tema | El script del tema no es inline y bloqueante |
| Tags con URLs rotas | Falta slugificar acentos y símbolos (`.NET`, `C#`) |