This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run dev- Start development server with turbo modenpm run build- Build for productionnpm run start- Start production servernpm run lint- Run oxlint with type-aware rules and type-check (tsgolint)npm run lint:fix- Auto-fix oxlint issues where possiblenpm run typecheck- Type-check via oxlint/tsgolint (same aslint)npm run fmt- Format code with oxfmt (TS/TSX/CSS/JSON/MD/YAML)npm run fmt:check- Check formatting without writing files
This is a headless WordPress starter using Next.js 15 App Router with TypeScript. Key architectural patterns:
- All WordPress API interactions go through
lib/wordpress.ts - Type definitions in
lib/wordpress.d.tsdefine Post, Page, Category, Tag, Author, Media interfaces - Error handling uses custom
WordPressAPIErrorclass - Functions use Next.js cache tags for granular revalidation (e.g.,
tags: ['posts',post-${slug}])
- Dynamic routes:
/posts/[slug],/pages/[slug] - Archive pages:
/posts,/posts/authors,/posts/categories,/posts/tags - API routes:
/api/revalidate(webhook),/api/og(OG images)
- Server Components for data fetching with parallel
Promise.all()calls - URL-based state management for search and filters
- Debounced search (300ms) with
useSearchParams - Pagination with 9 posts per page default
- WordPress plugin sends webhooks on content changes
- Next.js endpoint validates webhook secret and calls
revalidateTag() - Default cache duration: 1 hour (
revalidate: 3600)
- Use strict typing with interfaces defined in
lib/wordpress.d.ts - Prefer type annotations over type assertions
- Use type inference when the type is obvious
- React components: PascalCase (e.g.,
PostCard.tsx) - Functions and variables: camelCase
- Types and interfaces: PascalCase
- Constants: UPPERCASE_SNAKE_CASE for true constants
- Page components:
/app/**/*.tsx - Reusable UI components:
/components/**/*.tsx - API and utility functions:
/lib/**/*.ts - WordPress data functions must use cache tags for proper revalidation
- Use
try/catchblocks for API calls - Utilize
WordPressAPIErrorclass for consistent API error handling
Required environment variables (see .env.example):
NEXT_PUBLIC_WORDPRESS_URL- Full URL of WordPress siteNEXT_WORDPRESS_WEBHOOK_SECRET- Secret for webhook validation
- Next.js 15.3.3 with React 19.1.0
- TypeScript with strict mode
- Tailwind CSS with shadcn/ui components
- React Hook Form for form handling
- Lucide React for icons