CLAUDE.md TemplatesTemplate

Angular Material + FastAPI Knowledge Base App CLAUDE.md Template (CLAUDE.md Template)

A CLAUDE.md template for an Angular Material frontend + FastAPI backend Knowledge Base app; copyable instructions for Claude Code to scaffold and maintain the stack.

CLAUDE.md templateAngular MaterialFastAPIKnowledge BaseClaude CodeFrontendBackendPostgreSQLDockerJWT authenticationDeployment

Target User

Frontend and Backend developers building an Angular Material + FastAPI Knowledge Base

Use Cases

  • Generate a starter CLAUDE.md for a knowledge base app with Angular Material frontend and FastAPI backend
  • Standardize Claude Code instructions for stack-specific rules
  • Accelerate onboarding by copy-pasting the CLAUDE.md template

Markdown Template

Angular Material + FastAPI Knowledge Base App CLAUDE.md Template (CLAUDE.md Template)

# CLAUDE.md

Role: You are Claude, a CLAUDE.md template author for the Angular Material + FastAPI Knowledge Base stack. Provide precise, enforceable instructions suitable for Claude Code execution.

Architecture rules:
- Frontend: Angular Material (v15+)
- Backend: FastAPI with PostgreSQL
- API design: RESTful endpoints under api (e.g., articles, categories, auth)
- Data access: SQLAlchemy 2.x with Alembic migrations
- Authentication: JWT Bearer tokens, OAuth 2.0 as optional secondary flow
- Data models: articles, categories, users, audit_logs

File structure rules:
- backend/app/
  - main.py
  - api/
  - models/
  - core/
  - db/
- frontend/src/
  - app/
  - assets/
- docker-compose.yml

Authentication rules:
- JWT access tokens with 15m expiry; refresh tokens rotated
- Password hashing with bcrypt
- Protect endpoints using OAuth2PasswordBearer and dependency injection

Database rules:
- PostgreSQL database with schemas: public
- Use SQLAlchemy ORM models; migrations via Alembic
- Enforce unique constraints on user email and article slug

Validation rules:
- Pydantic schemas for requests/responses; strict types
- Validate article content length and allowed categories

Security rules:
- Use HTTPS in production; disable debug in prod
- CORS restricted to known origins
- Do not log secrets or raw passwords
- Rate limiting on auth endpoints

Testing rules:
- Backend: pytest with FastAPI TestClient; test cases for authentication, CRUD, and edge cases
- Frontend: unit tests for components/services; e2e tests with Cypress
- Run tests in CI for each PR

Deployment rules:
- Docker multi-stage builds; images tagged with version; docker-compose for dev
- Environment variables for secrets; avoid hard-coded credentials

Things Claude must not do:
- Do not assume a DB schema exists; do not bypass auth checks
- Do not generate or commit real secrets
- Do not perform network calls to external services during generation

Overview

Direct answer: This CLAUDE.md template provides a copyable CLAUDE.md script for building an Angular Material + FastAPI Knowledge Base app. It targets the frontend (Angular Material) and backend (FastAPI) stack and includes actionable Claude Code instructions for setup, validation, security, and deployment.

When to Use This CLAUDE.md Template

  • You are starting a new Angular Material + FastAPI Knowledge Base project and want a consistent CLAUDE.md template to guide Claude Code.
  • You need a stack-specific, copy-pastable CLAUDE.md to enforce architecture and security constraints.
  • You require a reusable blueprint for onboarding new engineers quickly.

Copyable CLAUDE.md Template

# CLAUDE.md

Role: You are Claude, a CLAUDE.md template author for the Angular Material + FastAPI Knowledge Base stack. Provide precise, enforceable instructions suitable for Claude Code execution.

Architecture rules:
- Frontend: Angular Material (v15+)
- Backend: FastAPI with PostgreSQL
- API design: RESTful endpoints under api (e.g., articles, categories, auth)
- Data access: SQLAlchemy 2.x with Alembic migrations
- Authentication: JWT Bearer tokens, OAuth 2.0 as optional secondary flow
- Data models: articles, categories, users, audit_logs

File structure rules:
- backend/app/
  - main.py
  - api/
  - models/
  - core/
  - db/
- frontend/src/
  - app/
  - assets/
- docker-compose.yml

Authentication rules:
- JWT access tokens with 15m expiry; refresh tokens rotated
- Password hashing with bcrypt
- Protect endpoints using OAuth2PasswordBearer and dependency injection

Database rules:
- PostgreSQL database with schemas: public
- Use SQLAlchemy ORM models; migrations via Alembic
- Enforce unique constraints on user email and article slug

Validation rules:
- Pydantic schemas for requests/responses; strict types
- Validate article content length and allowed categories

Security rules:
- Use HTTPS in production; disable debug in prod
- CORS restricted to known origins
- Do not log secrets or raw passwords
- Rate limiting on auth endpoints

Testing rules:
- Backend: pytest with FastAPI TestClient; test cases for authentication, CRUD, and edge cases
- Frontend: unit tests for components/services; e2e tests with Cypress
- Run tests in CI for each PR

Deployment rules:
- Docker multi-stage builds; images tagged with version; docker-compose for dev
- Environment variables for secrets; avoid hard-coded credentials

Things Claude must not do:
- Do not assume a DB schema exists; do not bypass auth checks
- Do not generate or commit real secrets
- Do not perform network calls to external services during generation

Recommended Project Structure

backend/
  app/
    main.py
    api/
      knowledge_base.py
    models/
      article.py
      user.py
    core/
      config.py
      security.py
    db/
      base.py
  requirements.txt
  Dockerfile
frontend/
  src/
    app/
      knowledge-base/
        knowledge-base.module.ts
        knowledge-base.component.ts
        knowledge-base.service.ts
  angular.json
  package.json
  tsconfig.json
docker-compose.yml

Core Engineering Principles

  • Clarity: code and instructions should be stack-specific and unambiguous
  • Idempotency: CLAUDE.md templates should be safe to re-run
  • Security-by-default: default to secure configurations and least privilege
  • Observability: include hooks for logging, tracing, and metrics
  • Reproducibility: deterministic scaffolding and dependency versions
  • Documentation as code: keep rules and structure versioned

Code Construction Rules

  • Frontend uses Angular Material components with ARIA labels; avoid custom CSS hacks
  • Backend endpoints follow REST conventions and proper HTTP status codes
  • Use Pydantic for input validation and SQLAlchemy for ORM
  • Environment-driven configuration; do not hard-code credentials
  • All database queries must be parameterized
  • Secrets must be sourced from env vars or secret managers

Security and Production Rules

  • Use HTTPS in production and disable debug
  • JWT tokens with short expiry and rotation
  • CORS restricted to known origins
  • Secure cookies and token storage considerations for SPA
  • Audit trails for knowledge-base edits

Testing Checklist

  • Backend: unit tests for models, validation, and endpoints
  • Integration tests for API endpoints with TestClient
  • Frontend: unit tests for components/services
  • End-to-end tests with Cypress
  • CI runs tests on push/PR

Common Mistakes to Avoid

  • Coupling frontend and backend logic too tightly
  • Omitting input validation or tests
  • Ignoring migrations and data migrations in production
  • Storing secrets in code or logs
  • Skipping accessibility considerations

FAQ

What is a CLAUDE.md Template?
A copyable CLAUDE.md block plus rules to craft Claude Code instructions for a specific stack.
Which stack is covered by this CLAUDE.md Template?
An Angular Material frontend with a FastAPI backend, built as a Knowledge Base application.
How do I run this locally?
Follow the included deployment rules in the CLAUDE.md block; use docker-compose for local dev or run frontend and backend separately with proper env vars.
Can I customize the data model?
Yes. Update the Pydantic models, SQLAlchemy schemas, and frontend DTOs to reflect your articles, categories, and users.
Where should I paste the CLAUDE.md Template?
Paste into a CLAUDE.md file at the project root and place the code block contents there for Claude Code.