Content Collections TypeScript-first build tool for Markdown/MDX content. Use for blogs, docs, content sites with Vite + React, MDX components, type-safe Zod schemas, Contentlayer migration, or encountering TypeScript import errors, path alias issues, collection validation errors.
View on GitHubsecondsky/claude-skills
content-collections
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/secondsky/claude-skills/blob/main/plugins/content-collections/skills/content-collections/SKILL.md -a claude-code --skill content-collectionsInstallation paths:
.claude/skills/content-collections/# Content Collections
**Status**: Production Ready ✅
**Last Updated**: 2025-11-07
**Dependencies**: None
**Latest Versions**: @content-collections/core@0.12.0, @content-collections/vite@0.2.7, zod@3.23.8
---
## What is Content Collections?
Content Collections transforms local content files (Markdown/MDX) into **type-safe TypeScript data** with automatic validation at build time.
**Problem it solves**: Manual content parsing, lack of type safety, runtime errors from invalid frontmatter.
**How it works**:
1. Define collections in `content-collections.ts` (name, directory, Zod schema)
2. CLI/plugin scans filesystem, parses frontmatter, validates against schema
3. Generates TypeScript modules in `.content-collections/generated/`
4. Import collections: `import { allPosts } from "content-collections"`
**Perfect for**: Blogs, documentation sites, content-heavy apps with Cloudflare Workers, Vite, Next.js.
---
## Quick Start (5 Minutes)
### 1. Install Dependencies
```bash
# Bun (recommended)
bun add -d @content-collections/core @content-collections/vite zod
# npm
npm install -D @content-collections/core @content-collections/vite zod
# pnpm
pnpm add -D @content-collections/core @content-collections/vite zod
```
### 2. Configure TypeScript Path Alias
Add to `tsconfig.json`:
```json
{
"compilerOptions": {
"paths": {
"content-collections": ["./.content-collections/generated"]
}
}
}
```
###
3. Configure Vite Plugin
Add to `vite.config.ts`:
```typescript
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import contentCollections from "@content-collections/vite";
export default defineConfig({
plugins: [
react(),
contentCollections(), // MUST come after react()
],
});
```
### 4. Update .gitignore
```
.content-collections/
```
### 5. Create Collection Config
Create `content-collections.ts` in project root:
```typescript
import { defineCollection, defineConfig } from "@content-collections/core";
impo