ai-first-nextjs-boilerplate
Health Gecti
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 121 GitHub stars
Code Gecti
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
The most opinionated, production-ready Next.js 16 boilerplate with first-class AI tooling. Claude Code, Cursor, Gemini CLI, Kiro, Windsurf — all produce consistent, reviewable code from day one.
AI-First Next.js Boilerplate
Stop prompting. Start shipping.
The only Next.js boilerplate where Claude Code, Cursor, Gemini CLI, Kiro, Copilot, and Windsurf all produce identical, production-grade code — without custom prompting.
The Problem
You open Cursor, type "create a user profile page," and get:
- A file in the wrong folder
useStatefor form fields instead of react-hook-form- Raw
fetch()instead of your HTTP client console.logeverywhere- No Zod validation, no error boundaries, no types
You spend more time fixing AI output than writing code yourself.
This boilerplate solves that. Every AI tool reads the same rules, follows the same architecture, and produces code that passes your linting, type-checking, and code review — on the first try.
Why Developers Are Switching
create-next-app |
t3-app |
AI-First Boilerplate | |
|---|---|---|---|
| AI understands your architecture | - | - | 6 AI configs, synced |
| Vertical slice architecture | - | Partial | Strict, ESLint-enforced |
| Pre-commit AI code review | - | - | Code Review Graph MCP |
| Type-safe server actions | - | - | next-safe-action v8 |
| Headless, accessible UI | - | - | Ark UI v5 (WAI-ARIA) |
| Canonical AI examples | - | - | src/__examples__/ |
| Docker (dev/staging/prod) | - | - | Three-tier setup |
| Security headers (CSP/HSTS) | - | - | OWASP-ready |
What You Get
AI-First Development — The Core Differentiator
One rule file. Six AI tools. Zero drift.
Every AI coding assistant in your team reads the same architecture rules from a single source (.ai/rules.md), auto-synced to each tool's config format:
| AI Tool | Config | Status |
|---|---|---|
| Claude Code | CLAUDE.md + .claude/steering/ |
Fully configured |
| Cursor | .cursorrules |
Fully configured |
| Windsurf | .windsurfrules |
Fully configured |
| GitHub Copilot | .github/copilot-instructions.md |
Fully configured |
| Gemini CLI | .gemini/GEMINI.md + hooks |
Fully configured |
| Kiro | .kiro/steering/ |
Fully configured |
What this means in practice: Two developers — one using Cursor, one using Claude Code — generate code that looks like it was written by the same person. No "fix the AI output" phase. No style wars. No architectural drift.
Pre-commit AI Code Review (Code Review Graph MCP)Every commit triggers a semantic impact analysis powered by a Tree-sitter knowledge graph:
- Detects which functions, components, and modules are affected
- Scores risk level of changes
- Flags architectural violations before they reach PR review
- Provides blast radius visualization
This isn't linting — it's structural understanding of your codebase.
Production-Grade Architecture
src/
app/ Routes ONLY — pages, layouts, route handlers
features/ Vertical slices — one folder per business domain
[name]/
_components/ Private UI (never imported outside feature)
_hooks/ Private hooks
adapters/ HTTP layer (calls shared/lib/xhr)
schemas/ Zod schemas + derived types
services/ Business logic
actions/ next-safe-action server actions
index.ts PUBLIC barrel — the ONLY export surface
shared/ Cross-cutting utilities
server/ Server-only code (iron-session, etc.)
Hard rules enforced by ESLint:
app/imports ONLY fromfeatures/[name]/index.ts— never deep paths- Features NEVER import from other features
shared/NEVER imports fromfeatures/orapp/- Adapters use
shared/lib/xhr.ts— never rawfetch()
Full-Stack Tech Stack
| Framework | Next.js 16 (App Router + Turbopack) |
| Language | TypeScript 6 (strict mode) |
| Styling | Panda CSS + Ark UI v5 (headless, WAI-ARIA) |
| Server State | TanStack Query v5 |
| Client State | Zustand v5 + nuqs (URL state) |
| Forms | react-hook-form + Zod v4 |
| Server Actions | next-safe-action v8 (end-to-end typed) |
| Tables | TanStack Table v8 |
| HTTP | ofetch v1 (browser + Edge + SSR) |
| Auth | iron-session v8 (encrypted cookies) |
| Animations | Motion (Framer Motion v12) |
| Testing | Vitest v4 + Testing Library + Playwright |
| Linting | Biome v2 + ESLint (architectural rules) |
| Monitoring | Sentry (error tracking + performance) |
| CI/CD | GitHub Actions (lint → type-check → test → build) |
| Containers | Docker (dev / staging / prod) |
Security — Not an Afterthought
- CSP, HSTS, X-Frame-Options, X-Content-Type-Options configured out of the box
import 'server-only'guard on server modules- Zod validation at every API boundary
- Middleware-based route protection
public/.well-known/security.txtfor responsible disclosure- No
eval(), nodangerouslySetInnerHTMLwithout DOMPurify
Testing — Mock Adapters, Never Services
npm run test # Vitest with interactive UI
npm run test:check # CI mode (exits with code)
npm run test:coverage # Coverage report (v8)
npx playwright test # E2E tests
- Mock at the HTTP layer (adapters), never at the service layer
@testing-library/reactfor behavior-driven component tests- MSW v2 for network-level API mocking
- Convention:
describe('[ServiceName]') > it('should [behavior] when [condition]')
Quality Gates — Every Commit
Husky runs automatically on every commit:
- Biome — format + lint (sub-second)
- ESLint — architectural rules (no
console.log, noany, no cross-feature imports) - TypeScript —
tsc --noEmit, zero errors - commitlint — enforces
type(scope): descriptionformat - Code Review Graph — semantic impact analysis
If it doesn't pass the gates, it doesn't get committed. Period.
Quick Start
# Clone
git clone https://github.com/NoahDuongMaster/ai-first-nextjs-boilerplate.git
cd ai-first-nextjs-boilerplate
# Install
npm install
# Start dev server (Turbopack)
npm run dev
Open http://localhost:3000.
Sync AI configs after editing rulesAll AI tool configs are generated from a single source (.ai/rules.md):
./scripts/gen-ai-config.sh
This updates CLAUDE.md, .cursorrules, .windsurfrules, .github/copilot-instructions.md, .gemini/GEMINI.md, and .kiro/steering/ — keeping every AI tool in sync.
# Development (hot-reload, source maps)
npm run build:development && npm run start:development # → :3001
# Staging (production build, staging env)
npm run build:staging && npm run start:staging # → :3002
# Production (standalone, minimal image)
npm run build:production && npm run start:production # → :80
Environment variables
Declared in src/shared/config/env.configuration.ts with Zod validation. Never use process.env directly.
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_APP_URL |
Yes | Public base URL |
SESSION_SECRET |
Yes | iron-session secret (32+ chars) |
NEXT_PUBLIC_API_URL |
Yes | External API base URL |
All Scripts
| Command | What it does |
|---|---|
npm run dev |
Dev server with Turbopack |
npm run build |
Production build |
npm run start |
Start production server |
npm run type-check |
TypeScript check (zero errors) |
npm run lint |
ESLint + architectural rules |
npm run lint:biome |
Biome check + auto-fix |
npm run format |
Biome format all files |
npm run test |
Vitest with UI |
npm run test:check |
Vitest CI mode |
npm run test:coverage |
Coverage report |
npm run build:development |
Docker build (dev) |
npm run build:staging |
Docker build (staging) |
npm run build:production |
Docker build (prod) |
Project Structure
.
├── .ai/rules.md Single source of truth for all AI rules
├── .claude/steering/ Claude Code steering rules
├── .cursorrules Cursor rules (auto-synced)
├── .windsurfrules Windsurf rules (auto-synced)
├── .github/copilot-instructions Copilot rules (auto-synced)
├── .gemini/ Gemini CLI config + hooks
├── .kiro/steering/ Kiro steering rules
├── docker/ Three-tier Docker setup
├── scripts/ AI config sync + setup scripts
├── src/
│ ├── app/ Next.js routes (zero business logic)
│ ├── features/ Vertical slices by domain
│ ├── shared/ Cross-cutting utilities
│ ├── server/ Server-only code
│ └── __examples__/ Canonical patterns for AI reference
└── tests/ Playwright E2E tests
Contributing
- Fork the repo
- Create a branch:
feat(scope)/issue-123-description - Follow patterns in
src/__examples__/ - Pass all gates:
npm run type-check && npm run lint && npm run test:check - Open a PR
Star History
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi