---
name: "astro-content-collections-zod"
description: "Manage Markdown, MDX, and JSON content with strict Zod frontmatter schema validation."
metadata:
  author: "Astro"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup astro content collections"
  - "define collection schema zod astro"
  - "getcollection astro"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Astro Content Collections & Type-Safe Zod Schemas

Configures Astro Content Collections: defining src/content/config.ts with defineCollection and z.object(), querying collections with getCollection and getEntry, automatic TypeScript typing, and generating static paths.

## When to Invoke
Invoke this skill whenever you need to:
- setup astro content collections
- define collection schema zod astro
- getcollection astro

## Execution SOP & Rules
1. Create src/content/config.ts defining collections using defineCollection({ type: 'content', schema: z.object(...) }).
2. Query entries in Astro pages: const entries = await getCollection('blog').
3. Render markdown content: const { Content } = await entry.render(); <Content />.
4. Catch missing or malformed frontmatter fields at build time via strict Zod schema errors.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
