CLAUDE.md TemplatesCLAUDE.md Template

CLAUDE.md Template: SvelteKit + Turso Edge SQLite + Better-Auth + Drizzle ORM Baseline

Copyable CLAUDE.md template page for SvelteKit + Turso Edge SQLite + Better-Auth + Drizzle ORM. Provides a complete Claude Code baseline.

CLAUDE.md TemplateSvelteKitTurso Edge SQLiteBetter-AuthDrizzle ORMClaude Codeedge databasefull-stack baselineserverless authauthentication

Target User

Frontend and full-stack developers building modern apps with SvelteKit, Turso Edge SQLite, Better-Auth, and Drizzle ORM.

Use Cases

  • Baseline architecture for SvelteKit with edge DB; authentication and authorization with Better-Auth; ORM modeling with Drizzle; local development and edge deployments.

Markdown Template

CLAUDE.md Template: SvelteKit + Turso Edge SQLite + Better-Auth + Drizzle ORM Baseline

Overview

CLAUDE.md template for the stack SvelteKit + Turso Edge SQLite + Better-Auth + Drizzle ORM. This page is a copyable CLAUDE.md template you can paste into Claude Code to bootstrap a baseline app and maintain a consistent architecture across teams.

Purpose: provide a concrete, testable CLAUDE.md template tailored to the SvelteKit + edge DB stack, with explicit rules for project structure, security, testing, and deployment. It combines Claude Code style with stack-specific constraints to reduce architectural drift.

When to Use This CLAUDE.md Template

- Starting a new project that uses SvelteKit with an edge database (Turso Edge SQLite).
- Integrating Better-Auth for session management and protection of routes.
- Adopting Drizzle ORM for type-safe data access on Turso Edge SQLite.
- Defining a baseline architecture for rapid onboarding of team members and consistent deployments.
Copyable CLAUDE.md Template

# CLAUDE.md

Project role
- You are Claude Code, an engineer-assistant that outputs a complete, copyable CLAUDE.md template for the given stack.
- Your output must be ready to paste into a CLAUDE.md file used by Claude Code to generate code and guidance.

Architecture rules
- Stack: SvelteKit for the frontend, Turso Edge SQLite as the edge database, Better-Auth for authentication, Drizzle ORM for data access.
- Favor SSR when data is needed on initial render; use edge functions for data access where latency matters.
- Keep business logic in server-side modules; keep UI free of database access.
- Use type-safe data access with Drizzle ORM; map all queries to Drizzle models.
- All environment secrets must be accessed via environment variables only.

File structure rules
- src/ is the primary source folder.
- src/routes handles page routing per SvelteKit conventions.
- src/lib/db.ts configures Drizzle with Turso Edge SQLite.
- src/lib/auth.ts configures Better-Auth and session handling.
- db/migrations/ holds Drizzle migrations for Turso Edge SQLite.
- drizzle/ holds schema.ts and generated drizzle client.
- tests/ contains unit and integration tests.

Authentication rules
- Use Better-Auth for login, signup, and session validation.
- Ensure protected routes check for valid session on the server side.
- Do not store plaintext passwords; store securely hashed passwords only via Better-Auth.

Database rules
- Turso Edge SQLite is the primary data store.
- Define Drizzle ORM schemas for all entities in drizzle/schema.ts.
- Use migrations in db/migrations to evolve the schema.

Validation rules
- Use Zod for input validation on API routes and form handlers.
- Validate all request payloads at the boundary and throw meaningful errors.

Security rules
- Do not log secrets; never expose database credentials in code.
- Use HTTPS-only cookies and secure deployment; enable CSRF protection on state-changing routes.
- Validate user authorization for every restricted operation.

Testing rules
- Unit tests for utilities and helpers.
- Integration tests for auth flows and database interactions.
- End-to-end tests for critical user journeys (login, data fetch, write).

Deployment rules
- Ensure environment variables for DB connection, Better-Auth keys, and app secrets are configured in the target environment.
- Run migrations as part of deployment; verify schema compatibility on edge instances.
- Use a staging workflow before production rollout.

Things Claude must not do
- Do not generate insecure or hard-coded secrets.
- Do not bypass authentication for protected routes.
- Do not rely on client-side data as the source of truth.
- Do not emit raw SQL that concatenates user input into strings.

Overview

CLAUDE.md template for the stack SvelteKit + Turso Edge SQLite + Better-Auth + Drizzle ORM. This page is a copyable CLAUDE.md template you can paste into Claude Code to bootstrap a baseline app and maintain a consistent architecture across teams.

Purpose: provide a concrete, testable CLAUDE.md template tailored to the SvelteKit + edge DB stack, with explicit rules for project structure, security, testing, and deployment. It combines Claude Code style with stack-specific constraints to reduce architectural drift.

When to Use This CLAUDE.md Template

  • Starting a new project that uses SvelteKit with an edge database (Turso Edge SQLite).
  • Integrating Better-Auth for session management and protection of routes.
  • Adopting Drizzle ORM for type-safe data access on Turso Edge SQLite.
  • Defining a baseline architecture for rapid onboarding of team members and consistent deployments.

Copyable CLAUDE.md Template

# CLAUDE.md

Project role
- You are Claude Code, an engineer-assistant that outputs a complete, copyable CLAUDE.md template for the given stack.
- Your output must be ready to paste into a CLAUDE.md file used by Claude Code to generate code and guidance.

Architecture rules
- Stack: SvelteKit for the frontend, Turso Edge SQLite as the edge database, Better-Auth for authentication, Drizzle ORM for data access.
- Favor SSR when data is needed on initial render; use edge functions for data access where latency matters.
- Keep business logic in server-side modules; keep UI free of database access.
- Use type-safe data access with Drizzle ORM; map all queries to Drizzle models.
- All environment secrets must be accessed via environment variables only.

File structure rules
- src/ is the primary source folder.
- src/routes handles page routing per SvelteKit conventions.
- src/lib/db.ts configures Drizzle with Turso Edge SQLite.
- src/lib/auth.ts configures Better-Auth and session handling.
- db/migrations/ holds Drizzle migrations for Turso Edge SQLite.
- drizzle/ holds schema.ts and generated drizzle client.
- tests/ contains unit and integration tests.

Authentication rules
- Use Better-Auth for login, signup, and session validation.
- Ensure protected routes check for valid session on the server side.
- Do not store plaintext passwords; store securely hashed passwords only via Better-Auth.

Database rules
- Turso Edge SQLite is the primary data store.
- Define Drizzle ORM schemas for all entities in drizzle/schema.ts.
- Use migrations in db/migrations to evolve the schema.

Validation rules
- Use Zod for input validation on API routes and form handlers.
- Validate all request payloads at the boundary and throw meaningful errors.

Security rules
- Do not log secrets; never expose database credentials in code.
- Use HTTPS-only cookies and secure deployment; enable CSRF protection on state-changing routes.
- Validate user authorization for every restricted operation.

Testing rules
- Unit tests for utilities and helpers.
- Integration tests for auth flows and database interactions.
- End-to-end tests for critical user journeys (login, data fetch, write).

Deployment rules
- Ensure environment variables for DB connection, Better-Auth keys, and app secrets are configured in the target environment.
- Run migrations as part of deployment; verify schema compatibility on edge instances.
- Use a staging workflow before production rollout.

Things Claude must not do
- Do not generate insecure or hard-coded secrets.
- Do not bypass authentication for protected routes.
- Do not rely on client-side data as the source of truth.
- Do not emit raw SQL that concatenates user input into strings.