Astro content collections setup, type-safe schemas, query patterns, and frontmatter validation. Use when building Astro sites, setting up content collections, creating collection schemas, querying content, validating frontmatter, or when user mentions Astro collections, content management, MDX content, type-safe content, or collection queries.
View on GitHubvanman2024/ai-dev-marketplace
website-builder
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/ai-dev-marketplace/blob/main/plugins/website-builder/skills/content-collections/SKILL.md -a claude-code --skill content-collectionsInstallation paths:
.claude/skills/content-collections/# Content Collections Management for Astro Complete content collections setup and management for Astro projects, including type-safe schemas, query patterns, frontmatter validation, and content organization. ## Overview This skill provides comprehensive support for Astro content collections: - Schema definition with Zod validation - Type-safe query patterns - Frontmatter validation and testing - Collection setup and configuration - Content organization best practices ## Instructions ### 1. Initial Setup Run the setup script to initialize content collections in an Astro project: ```bash bash scripts/setup-content-collections.sh [project-path] ``` This script: - Creates `src/content/config.ts` if not exists - Sets up collection directories - Adds TypeScript types generation - Configures content collection imports ### 2. Define Collection Schemas Use schema templates to define type-safe collection schemas: **TypeScript Schema (Recommended):** ```bash # Read template for reference Read: templates/schemas/blog-collection-schema.ts Read: templates/schemas/docs-collection-schema.ts ``` **Python Schema (for build scripts):** ```bash # For Python-based content generation Read: templates/python/collection-schema.py ``` ### 3. Generate TypeScript Types Generate TypeScript types from your collection schemas: ```bash bash scripts/generate-types.sh [project-path] ``` This creates: - `src/content/config.ts` exports - Type definitions in `.astro/types.d.ts` - Auto-completion for collection queries ### 4. Query Content Collections Use query builder patterns for type-safe content retrieval: **TypeScript Queries:** ```bash Read: templates/queries/basic-queries.ts Read: templates/queries/advanced-queries.ts Read: templates/queries/filtered-queries.ts ``` **Python Queries (for build scripts):** ```bash Read: templates/python/query-patterns.py ``` ### 5. Validate Frontmatter Validate content frontmatter against schemas: ```bash bash scripts/validate-frontmatter.sh