Also covers MDX authoring with Remark/Rehype plugins and the astro sync workflow for generating collection types. Does not cover form submission via Astro Actions (astro-actions) or SEO metadata generation from content (astro-seo) — those are handled by their own skills.
Astro Content Layer Expert
Type-safe content management with loaders, Zod schemas, and the unified Content Layer API.
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Check existing collections, loaders, and content structure
- fuse-ai-pilot:research-expert - Verify latest Content Layer docs via Context7/Exa
- mcp__context7__query-docs - Get loader and schema examples
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
When to Use
- Managing blog posts, docs, or product descriptions in Markdown/MDX
- Fetching content from a CMS, API, or database with type safety
- Needing TypeScript autocomplete for frontmatter fields
- Migrating from Astro 4 legacy content collections
Why Content Layer API
| Feature |
Benefit |
src/content.config.ts |
Single config file at project root |
| Built-in loaders |
glob() and file() for local files |
| Custom loaders |
Fetch from any external source |
| Zod 4 schemas |
Full TypeScript type safety |
astro sync |
Generates types from collections |
Core Concepts
Config File Location
The config file moved from src/content/config.ts to src/content.config.ts in Astro 5+.
Collection Types
| Loader |
Use Case |
glob() |
Multiple files in a directory (MD, MDX, JSON, YAML) |
file() |
Single JSON/YAML file with multiple entries |
| Custom |
Remote API, database, or any async data source |
Key APIs
| API |
Description |
getCollection(name) |
Fetch all entries in a collection |
getEntry(name, id) |
Fetch a single entry by ID |
render(entry) |
Render a content entry to HTML + headings |
defineCollection() |
Define a collection with loader and schema |
Reference Guide
| Need |
Reference |
| Overview & concepts |
overview.md |
| Config file setup |
config.md |
| Glob, file, custom loaders |
loaders.md |
| getCollection / getEntry |
querying.md |
| render() + headings |
rendering.md |
| MDX + Remark/Rehype |
mdx.md |
| Blog collection example |
templates/blog-collection.md |
| Custom remote loader |
templates/custom-loader.md |
Best Practices
- Always define schemas — Never skip Zod validation
- Run
astro sync — After changing content.config.ts
- Use
glob() for local files — Supports MD, MDX, JSON, YAML, TOML
- Custom loaders for remote data — CMS, REST API, GraphQL
render() for MDX — Returns Content component + headings array
1---2name: astro-content3description: Use when managing structured content, blog posts, or typed data collections in Astro via the Content Layer API (content.config.ts).4versions:5 astro: 76 zod: 47user-invocable: true8references: references/overview.md, references/config.md, references/loaders.md, references/querying.md, references/rendering.md, references/mdx.md, references/templates/blog-collection.md, references/templates/custom-loader.md9related-skills: astro-7, astro-actions, astro-seo10metadata:11 source: https://skillmd.com/skills/fusengine/astro-content12---1314<objective>15Implements Astro's Content Layer API: the `src/content.config.ts` config file, built-in `glob()` and `file()` loaders for local Markdown/MDX/JSON/YAML content, custom loaders for remote APIs/CMS/databases, Zod 4 schemas for type-safe frontmatter, and the query APIs `getCollection()`, `getEntry()`, and `render()` (which returns a `Content` component plus headings).1617Also covers MDX authoring with Remark/Rehype plugins and the `astro sync` workflow for generating collection types. Does not cover form submission via Astro Actions (astro-actions) or SEO metadata generation from content (astro-seo) — those are handled by their own skills.18</objective>1920# Astro Content Layer Expert2122Type-safe content management with loaders, Zod schemas, and the unified Content Layer API.2324## Agent Workflow (MANDATORY)2526Before ANY implementation, spawn 3 agents in parallel, one `Agent` call each with a `name`:27281. **fuse-ai-pilot:explore-codebase** - Check existing collections, loaders, and content structure292. **fuse-ai-pilot:research-expert** - Verify latest Content Layer docs via Context7/Exa303. **mcp__context7__query-docs** - Get loader and schema examples3132After implementation, run **fuse-ai-pilot:sniper** for validation.3334---3536## Overview3738### When to Use3940- Managing blog posts, docs, or product descriptions in Markdown/MDX41- Fetching content from a CMS, API, or database with type safety42- Needing TypeScript autocomplete for frontmatter fields43- Migrating from Astro 4 legacy content collections4445### Why Content Layer API4647| Feature | Benefit |48|---------|---------|49| `src/content.config.ts` | Single config file at project root |50| Built-in loaders | `glob()` and `file()` for local files |51| Custom loaders | Fetch from any external source |52| Zod 4 schemas | Full TypeScript type safety |53| `astro sync` | Generates types from collections |5455---5657## Core Concepts5859### Config File Location6061The config file moved from `src/content/config.ts` to `src/content.config.ts` in Astro 5+.6263### Collection Types6465| Loader | Use Case |66|--------|----------|67| `glob()` | Multiple files in a directory (MD, MDX, JSON, YAML) |68| `file()` | Single JSON/YAML file with multiple entries |69| Custom | Remote API, database, or any async data source |7071### Key APIs7273| API | Description |74|-----|-------------|75| `getCollection(name)` | Fetch all entries in a collection |76| `getEntry(name, id)` | Fetch a single entry by ID |77| `render(entry)` | Render a content entry to HTML + headings |78| `defineCollection()` | Define a collection with loader and schema |7980---8182## Reference Guide8384| Need | Reference |85|------|-----------|86| Overview & concepts | [overview.md](references/overview.md) |87| Config file setup | [config.md](references/config.md) |88| Glob, file, custom loaders | [loaders.md](references/loaders.md) |89| getCollection / getEntry | [querying.md](references/querying.md) |90| render() + headings | [rendering.md](references/rendering.md) |91| MDX + Remark/Rehype | [mdx.md](references/mdx.md) |92| Blog collection example | [templates/blog-collection.md](references/templates/blog-collection.md) |93| Custom remote loader | [templates/custom-loader.md](references/templates/custom-loader.md) |9495---9697## Best Practices98991. **Always define schemas** — Never skip Zod validation1002. **Run `astro sync`** — After changing `content.config.ts`1013. **Use `glob()` for local files** — Supports MD, MDX, JSON, YAML, TOML1024. **Custom loaders for remote data** — CMS, REST API, GraphQL1035. **`render()` for MDX** — Returns `Content` component + headings array