CLAUDE.md TemplatesTemplate

CLAUDE.md Template: Nuxt 4 + Redis + Iron-Session + RedisOM Micro-Caching Setup – CLAUDE.md template

A CLAUDE.md template for Nuxt 4 apps using Redis for session storage with Iron-Session and RedisOM micro-caching.

claude-md-templatenuxt-4redisiron-sessionredisommicro-cachingclaude-codenuxt-authserver-cachesession-management

Target User

Nuxt 4 developers integrating Redis backed sessions and micro-caching

Use Cases

  • Session-based authentication in Nuxt 4 with Redis
  • HTTP route micro-caching with RedisOM
  • Secure cookie handling with Iron-Session
  • Centralized Claude Code prompts for Nuxt tasks

Markdown Template

CLAUDE.md Template: Nuxt 4 + Redis + Iron-Session + RedisOM Micro-Caching Setup – CLAUDE.md template

# CLAUDE.md
Project role
- You are a Senior Nuxt 4 Engineer responsible for building a secure SSR app with Redis backed sessions using Iron-Session and RedisOM for micro-caching.

Architecture rules
- Use a three-layer architecture: API (Nitro), service layer, and data layer.
- All Redis interactions must go through a single Redis client module.
- Cache responses at the route level using RedisOM; ensure cache keys are deterministic and include the route path and user id when available.
- Do not bypass RedisOM for reads; prefer cache-aside for data that changes rarely.

File structure rules
- Create a Nuxt 4 project structure with only relevant folders.
- Place Redis client in redis/redisClient.ts; place session config in session/ironSession.ts.
- Centralize Claude Code prompts in claude/ directory and export through a single entry.

Authentication rules
- Use Iron-Session for SSR cookies with Redis as the session store.
- secret must come from environment variables; cookie options must mark httpOnly and secure in production.
- Middleware must protect private routes and set req.session to the authenticated user.

Database rules
- Use RedisOM models for data that benefits from indexes.
- Do not mix RedisOM with direct Redis commands in the same layer for the same entity.

Validation rules
- Validate all incoming payloads with zod; return clear error messages and appropriate HTTP status codes.

Security rules
- Use CSRF tokens for state-changing requests; configure sameSite strict.
- Do not expose Redis credentials to the client; use a server-side Redis client.
- Log security events to a dedicated monitoring channel.

Testing rules
- Unit test RedisOM model definitions; integration test Nuxt route handlers; end-to-end test caching behavior.
- Mock Redis in unit tests; run real Redis in integration tests.
- Test both authenticated and anonymous access paths.

Deployment rules
- Use Nuxt 4 with Nitro; ensure environment variables are present in production.
- Run build, then start server with a Redis URL and RedisOM schema loaded.
- Rotate session secrets.

Things Claude must not do
- Do not use localStorage for session data.
- Do not bypass Iron-Session or RedisOM caches.
- Do not publish Redis credentials or secrets in code or logs.
- Do not mutate request state outside of controlled middleware.

Overview

CLAUDE.md template for Nuxt 4 apps that use Redis for session storage via Iron-Session and RedisOM based micro-caching. This page delivers a copyable CLAUDE.md template block you can paste into CLAUDE.md to configure the stack end-to-end.

Direct answer: This CLAUDE.md template gives you a structured, repeatable prompt surface for Nuxt 4 with Redis, Iron-Session, and RedisOM micro-caching, including architecture rules and file structure.

When to Use This CLAUDE.md Template

  • Setting up a Nuxt 4 project with server-side sessions backed by Redis
  • Implementing micro-caching using RedisOM for route-level performance
  • Standardizing Claude Code prompts for Nuxt based authentication and caching

Copyable CLAUDE.md Template

# CLAUDE.md
Project role
- You are a Senior Nuxt 4 Engineer responsible for building a secure SSR app with Redis backed sessions using Iron-Session and RedisOM for micro-caching.

Architecture rules
- Use a three-layer architecture: API (Nitro), service layer, and data layer.
- All Redis interactions must go through a single Redis client module.
- Cache responses at the route level using RedisOM; ensure cache keys are deterministic and include the route path and user id when available.
- Do not bypass RedisOM for reads; prefer cache-aside for data that changes rarely.

File structure rules
- Create a Nuxt 4 project structure with only relevant folders.
- Place Redis client in redis/redisClient.ts; place session config in session/ironSession.ts.
- Centralize Claude Code prompts in claude/ directory and export through a single entry.

Authentication rules
- Use Iron-Session for SSR cookies with Redis as the session store.
- secret must come from environment variables; cookie options must mark httpOnly and secure in production.
- Middleware must protect private routes and set req.session to the authenticated user.

Database rules
- Use RedisOM models for data that benefits from indexes.
- Do not mix RedisOM with direct Redis commands in the same layer for the same entity.

Validation rules
- Validate all incoming payloads with zod; return clear error messages and appropriate HTTP status codes.

Security rules
- Use CSRF tokens for state-changing requests; configure sameSite strict.
- Do not expose Redis credentials to the client; use a server-side Redis client.
- Log security events to a dedicated monitoring channel.

Testing rules
- Unit test RedisOM model definitions; integration test Nuxt route handlers; end-to-end test caching behavior.
- Mock Redis in unit tests; run real Redis in integration tests.
- Test both authenticated and anonymous access paths.

Deployment rules
- Use Nuxt 4 with Nitro; ensure environment variables are present in production.
- Run build, then start server with a Redis URL and RedisOM schema loaded.
- Rotate session secrets.

Things Claude must not do
- Do not use localStorage for session data.
- Do not bypass Iron-Session or RedisOM caches.
- Do not publish Redis credentials or secrets in code or logs.
- Do not mutate request state outside of controlled middleware.

Recommended Project Structure

Stack focused Nuxt 4 app layout for Redis backed sessions and micro-caching.

nuxt-app/
  app/
  components/
  layouts/
  pages/
  plugins/
  public/
  lib/
  redis/
    redisClient.ts
  session/
    ironSession.ts
  claude/
    prompts.md
  server/
    api/
    middleware/
  

Core Engineering Principles

  • Explicit dependencies and configuration to enable reproducible builds
  • Security by default: httpOnly cookies, CSRF protection, and proper Redis access controls
  • Cache-aside pattern with deterministic keys for predictable micro-caching

Code Construction Rules

  • All Redis calls must route through a single client wrapper
  • Use RedisOM models for data access that benefit from indexes
  • Client-side code must not access Redis directly
  • Nuxt 4 Nitro route handlers should be used for server-side logic

Security and Production Rules

  • Store secrets in environment variables; never commit to VCS
  • Secure cookies with httpOnly and secure flags in production
  • Enable CSP and strict CSP policies where possible

Testing Checklist

  • Unit tests for RedisOM models and utilities
  • Integration tests for authentication flow with Iron-Session
  • End-to-end tests of micro-caching behavior
  • CI must run with a Redis instance available

Common Mistakes to Avoid

  • Direct Redis commands in business logic; go through the Redis client
  • Storing sensitive data in client state
  • Weak cache keys that vary on non-deterministic data

FAQ

  • Is this template production-ready? It provides production-oriented patterns; ensure environment configuration and secrets management.
  • Can RedisOM be replaced? RedisOM is optional for simple data; this template assumes it for demonstration.
  • Does Iron-Session work with Nuxt 4 SSR? Yes, when configured with Redis as the session store.
  • How do I customize cache keys? Use route path and user id as part of the cache key to ensure determinism.