A modern, AI-first Next.js monorepo template equipped with PostgreSQL, Prisma, Better-Auth, Ultracite, and native support for AI Agents (MCP & Skills).
English Β· EspaΓ±ol
- What is this?
- Tech Stack
- AI Integrations & Tooling
- Monorepo Structure
- Quickstart
- Environment Variables
- Files You Need to Edit
- Available Scripts
- Database Commands
- Code Quality
- Contributing
- License
Agentic Next.js Monorepo Starter is a production-ready monorepo template built for developers who want to ship fast, with quality guardrails and first-class AI assistant support baked in from day one.
It combines a curated set of modern tools into a single, coherent setup so you don't have to wire everything together yourself. Beyond the typical tech stack, what makes this template unique is its native support for AI Coding Assistants β it ships with pre-configured skills, MCP servers, and global prompt files that teach AI agents about your architecture so they give better, more context-aware suggestions out of the box.
| Tool | Purpose |
|---|---|
| Next.js 15+ | React framework β App Router, Server Components, Server Actions |
| PostgreSQL | Relational database engine |
| Prisma ORM | Type-safe database client and migration tool |
| Better Auth | Comprehensive TypeScript-first authentication library |
| Bun | Fast JavaScript runtime, bundler & package manager |
| Turborepo | High-performance monorepo build system |
| Ultracite | Zero-config linting + formatting preset (Oxlint + Oxfmt) |
| Ruler | Centralized standards for agentic workspaces |
| shadcn/ui | Accessible, unstyled component library |
| Zod | Schema validation for environment variables and forms |
| Husky | Modern native git hooks for code quality checks |
| Docker | Local PostgreSQL via Docker Compose |
This repository is uniquely optimized for AI Coding Assistants (Antigravity, GitHub Copilot, Cursor, Windsurf, Claude Code, Cline, etc.).
Pre-configured sub-agent skill packs that give AI assistants deep, domain-specific knowledge about this codebase. When activated, they guide the AI to follow project conventions without repetitive prompting.
| Skill | Description |
|---|---|
architect-nextjs |
Screaming Architecture + Scope Rule for Next.js 15+ |
better-auth-best-practices |
Auth config, sessions, plugins, environment setup |
interface-design |
Dashboards, admin panels, app UI design |
next-best-practices |
File conventions, RSC, data patterns, async APIs |
next-cache-components |
PPR, use cache, cacheLife, cacheTag |
prisma-cli |
Prisma CLI commands reference |
prisma-client-api |
CRUD queries, filters, transactions |
prisma-database-setup |
Database provider configuration |
turborepo |
Task pipelines, caching, monorepo best practices |
ultracite |
Linting, formatting, Oxlint configuration |
vercel-composition-patterns |
Compound components, render props, React 19 |
vercel-react-best-practices |
Performance patterns from Vercel Engineering |
web-design-guidelines |
Accessibility, UX auditing |
opentui |
Terminal UI with OpenTUI |
Model Context Protocol servers pre-configured for this project. These connect AI models to live documentation, component registries, and development tools:
| Server | Purpose |
|---|---|
Context7 (@upstash/context7-mcp) |
Live, version-accurate library documentation |
shadcn (shadcn@latest mcp) |
Browse and install shadcn/ui components |
next-devtools (next-devtools-mcp) |
Next.js runtime diagnostics and error reporting |
better-auth (mcp.inkeep.com) |
Better Auth documentation and API reference |
| File | Applies To | Purpose |
|---|---|---|
GEMINI.md |
Gemini / Antigravity | Code standards, Ultracite rules, React patterns |
AGENTS.md |
Codex / OpenAI | Global agent behavior rules |
CLAUDE.md |
Claude / Claude Code | Global agent behavior rules |
.cursor/rules/ |
Cursor | Editor-level agent rules |
.windsurf/ |
Windsurf | Editor-level agent rules |
.kilocode/ |
Kilocode | Editor-level agent rules |
.
βββ apps/
β βββ web/ # Next.js 15 application
β βββ app/ # App Router routes & layouts
β βββ components/ # UI components
β βββ ...
βββ packages/
β βββ auth/ # Better Auth server & client config
β βββ config/ # Shared TypeScript/tool configs
β βββ db/ # Prisma schema, migrations, Docker Compose
β βββ env/ # Typed environment variables (t3-env + Zod)
βββ .agents/skills/ # AI agent skills (domain knowledge packs)
βββ .mcp.json # MCP server definitions
βββ GEMINI.md # AI config for Gemini
βββ AGENTS.md # AI config for Codex/OpenAI agents
βββ CLAUDE.md # AI config for Claude
βββ turbo.json # Turborepo task pipeline
βββ package.json # Root workspace
git clone https://github.com/IvanTsxx/AI-Nextjs-Monorepo-Starter.git my-app
cd my-appImportant
Once you have cloned the repository, remember to replace all occurrences of your-repo-name (or the original project name) with your actual repository name in the root package.json and other configuration files.
bun installCopy the example below into a .env file at the root and in apps/web/:
# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/mydb"
# Better Auth
BETTER_AUTH_SECRET="your-secret-at-least-32-chars-long"
BETTER_AUTH_URL="http://localhost:3001"
# CORS
CORS_ORIGIN="http://localhost:3001"
NODE_ENV="development"See the Environment Variables section for the full reference.
bun run db:start # starts PostgreSQL via Docker Composebun run db:generate # generates the Prisma clientbun run db:push # syncs Prisma schema to your databasebun run dev # starts all apps in the monorepo
# or just the web app:
bun run dev:webOpen http://localhost:3001 π
All environment variables are validated at runtime using t3-env + Zod. Defined in packages/env/src/server.ts.
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
β | PostgreSQL connection string |
BETTER_AUTH_SECRET |
β | Secret key (min. 32 chars) for auth token signing |
BETTER_AUTH_URL |
β | Full URL where your app is hosted (e.g., http://localhost:3001) |
CORS_ORIGIN |
β | Allowed CORS origin URL |
NODE_ENV |
β | development, production, or test (defaults to development) |
When customizing this template for your own project, focus on these files:
| File / Path | What to change |
|---|---|
package.json |
Project name, description, repository URL (replace your-repo-name) |
apps/web/app/layout.tsx |
App name, metadata (title, description) |
packages/env/src/server.ts |
Add / remove environment variables |
packages/db/prisma/schema.prisma |
Add your own data models |
packages/db/docker-compose.yml |
Database name, port, credentials |
packages/auth/src/ |
Auth plugins, OAuth providers, session config |
.mcp.json |
Add or remove MCP servers for your AI tools |
.agents/skills/ |
Add custom skills for your domain |
GEMINI.md / AGENTS.md / CLAUDE.md |
Project-specific AI coding rules |
turbo.json |
Add new pipeline tasks if you add packages |
Run from the root of the monorepo:
bun run dev # Start all apps in development mode
bun run dev:web # Start only the web app
bun run build # Build all apps for production
bun run check-types # TypeScript type-check across the monorepo
bun run check # Lint & format check (Ultracite)
bun run fix # Auto-fix lint & formatting issues (Ultracite)
bun run ruler:apply # Apply Ruler standards (local only)
bun run prepare # Set up Husky git hooksThis repository uses Husky to enforce code quality before every commit.
- Pre-commit: Runs
lint-staged, which executesultracite fixon changed files to ensure all committed code is properly formatted and linted according to project standards.
bun run db:start # Start PostgreSQL container (Docker)
bun run db:stop # Stop PostgreSQL container
bun run db:down # Stop and remove PostgreSQL container
bun run db:push # Sync Prisma schema β database (no migration file)
bun run db:migrate # Create and apply a migration
bun run db:generate # Regenerate Prisma Client after schema changes
bun run db:studio # Open Prisma Studio (visual DB browser)
bun run db:watch # Watch for schema changesThis project uses Ultracite β a zero-config preset for Oxlint + Oxfmt.
bun run check # Check for issues
bun run fix # Auto-fix all fixable issues
bun x ultracite doctor # Diagnose setup problemsSee
GEMINI.mdfor the full coding standards reference used by both the team and AI assistants.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the repo
- Create your feature branch:
git checkout -b feat/amazing-feature - Commit changes:
git commit -m 'feat: add amazing feature' - Push and open a Pull Request
MIT Β© IvanTsxx