CLAUDE.md TemplatesTemplate

CLAUDE.md Template: NestJS + MySQL + Auth0 + Prisma ORM Enterprise Framework Configuration

A CLAUDE.md template page for configuring a NestJS API with MySQL, Auth0, and Prisma ORM in an enterprise context, with a copyable CLAUDE.md block and stack-specific guidance.

CLAUDE.md templateNestJSMySQLAuth0Prisma ORMClaude CodeEnterpriseAPI SecurityTypeScriptDevOps

Target User

Backend engineers and platform engineers building enterprise Node.js APIs

Use Cases

  • Bootstrapping NestJS apps with Prisma ORM on MySQL
  • Secure API endpoints with Auth0
  • Enforce architecture rules and testing practices

Markdown Template

CLAUDE.md Template: NestJS + MySQL + Auth0 + Prisma ORM Enterprise Framework Configuration

# CLAUDE.md
Project role: Enterprise NestJS Backend Architect
Architecture rules:
- Use modular NestJS with Clean Architecture (Domain, Application, Infrastructure).
- Prisma ORM for MySQL; migrations managed via Prisma Migrate
- Auth0 as the identity provider; validate tokens using RS256, audience, and issuer
- Enforce RBAC with Nest guards and policies; avoid client-side token validation alone
- Centralized configuration via environment variables and a config service
File structure rules:
- apps/api/src/main.ts as the app bootstrap
- apps/api/src/app.module.ts as the root module
- apps/api/src/modules/auth for authentication
- apps/api/src/modules/users for domain users
- prisma/schema.prisma with datasource db provider = mysql
Authentication rules:
- Validate access tokens with Auth0; require audience param match
- Use refresh tokens only on confidential clients
Database rules:
- Prisma schema uses MySQL datasource; migrations tracked in prisma/migrations
- Use UUIDs for primary keys where appropriate
Validation rules:
- DTOs with class-validator decorators; global ValidationPipe with fail-fast
Security rules:
- Use helmet, rate limiting, and TLS in production
- Do not hardcode secrets in code; use environment variables
Testing rules:
- Unit tests for services; integration tests for controllers; mock external calls
- Use test database and Prisma migrate deploy in CI
Deployment rules:
- Dockerized deployment with multi-stage builds; production image size minimized
- Prisma migrate deploy run in entrypoint before app start
Things Claude must not do:
- Do not generate code that stores plaintext passwords
- Do not bypass input validation or authorization checks
- Do not propose insecure CORS policies

Overview

The CLAUDE.md template is a copyable Claude Code instruction block designed for NestJS + MySQL + Auth0 + Prisma ORM enterprise configurations. It provides architecture guidelines, file structure, and production rules so you can generate consistent, secure code with Claude Code.

When to Use This CLAUDE.md Template

  • When configuring a new NestJS API backed by MySQL with Prisma ORM and Auth0.
  • When you need enterprise-grade authentication, RBAC, and data validation.
  • When you want a repeatable, checkable CLAUDE.md block for codegen.

Copyable CLAUDE.md Template

# CLAUDE.md
Project role: Enterprise NestJS Backend Architect
Architecture rules:
- Use modular NestJS with Clean Architecture (Domain, Application, Infrastructure).
- Prisma ORM for MySQL; migrations managed via Prisma Migrate
- Auth0 as the identity provider; validate tokens using RS256, audience, and issuer
- Enforce RBAC with Nest guards and policies; avoid client-side token validation alone
- Centralized configuration via environment variables and a config service
File structure rules:
- apps/api/src/main.ts as the app bootstrap
- apps/api/src/app.module.ts as the root module
- apps/api/src/modules/auth for authentication
- apps/api/src/modules/users for domain users
- prisma/schema.prisma with datasource db provider = mysql
Authentication rules:
- Validate access tokens with Auth0; require audience param match
- Use refresh tokens only on confidential clients
Database rules:
- Prisma schema uses MySQL datasource; migrations tracked in prisma/migrations
- Use UUIDs for primary keys where appropriate
Validation rules:
- DTOs with class-validator decorators; global ValidationPipe with fail-fast
Security rules:
- Use helmet, rate limiting, and TLS in production
- Do not hardcode secrets in code; use environment variables
Testing rules:
- Unit tests for services; integration tests for controllers; mock external calls
- Use test database and Prisma migrate deploy in CI
Deployment rules:
- Dockerized deployment with multi-stage builds; production image size minimized
- Prisma migrate deploy run in entrypoint before app start
Things Claude must not do:
- Do not generate code that stores plaintext passwords
- Do not bypass input validation or authorization checks
- Do not propose insecure CORS policies

Recommended Project Structure

.
├── apps
│   └── api
│       └── src
│           ├── main.ts
│           ├── app.module.ts
│           ├── modules
│           │   ├── auth
│           │   │   ├── jwt.strategy.ts
│           │   │   ├── jwt.guard.ts
│           │   │   └── auth.controller.ts
│           │   └── users
│           │       ├── users.controller.ts
│           │       └── users.service.ts
│           └── prisma
│               └── prisma.service.ts
│           └── config
│               └── config.service.ts
│       └── …
├── prisma
│   └── schema.prisma
├── migrations
│   └── 
└── .env

Core Engineering Principles

  • Single responsibility at module boundaries; clear domain vs. infrastructure separation
  • Explicit dependencies; avoid circular imports; prefer dependency injection
  • Type safety with Prisma types and NestJS DTOs
  • Environment-driven configuration; no hard-coded values
  • Respect secure defaults; default deny for endpoints

Code Construction Rules

  • Use NestJS modules for auth, users, and prisma integration
  • Define Prisma models in prisma/schema.prisma; mirror in Nest services
  • Implement Auth0 integration in a dedicated Auth module with JWT strategy
  • Validate all inputs with class-validator; enable global ValidationPipe
  • All database queries via Prisma client; handle errors gracefully
  • Write unit tests for services; integration tests for controllers
  • Use environment variables for secrets; avoid hard-coded credentials

Security and Production Rules

  • Enforce JWT validation with Auth0 issuer and audience
  • Use Helmet and rate limiting; enable TLS in production
  • Enable CSRF protection for non-GET endpoints if needed
  • Do not log sensitive tokens; redact in logs
  • Regularly rotate secrets and rotate keys via Auth0

Testing Checklist

  • Unit tests for services and guards
  • Integration tests for controllers using a test DB
  • CI runs Prisma migrate deploy against a test database
  • End-to-end tests simulate authenticated requests

Common Mistakes to Avoid

  • Overlooking RBAC in Auth0; granting broad access
  • Forgetting to seed test data in Prisma during tests
  • Storing tokens in logs or insecure storage
  • Ignoring migrations in production; using raw SQL edits

FAQ

What is the purpose of this CLAUDE.md template?
A copyable instruction block that guides Claude Code to configure a NestJS + MySQL + Auth0 + Prisma enterprise stack.
Which stack is covered?
NestJS API with Prisma ORM on MySQL, Auth0 for authentication, designed for enterprise use.
What should I include in the copyable block?
Project role, architecture rules, file structure, authentication, database, validation, security, testing, deployment, and things Claude must not do.
How do I adapt for a different database?
Update Prisma datasource in schema.prisma and corresponding config, migrations, and environment variables.
Where do I put this template?
Under the CLAUDE.md Templates collection; each stack gets a dedicated Claude-MD-Template page.