Skip to main content
RJL.pub logo

RJL.pub - AI-Native Development Journey

Templates for AI Coding Agents

6 min read Last updated

Complete example files from the book, collected in one place to copy and adapt.

CLAUDE.md starter

Use CLAUDE.md when you are primarily using Claude Code and need comprehensive project context, detailed architecture, and complex business logic documented.

From Chapter 3

Section 1: Project Overview

# Project Name - AI Context Documentation

      **Project**: [Name and brief description]
      **Version**: [Current version]
      **Last Updated**: [Date]
      **Tech Stack**: [Primary technologies]

      ## Project Vision
      [2-3 paragraphs describing what this project does,
      why it exists, and what problems it solves]

      ## Architecture Overview
      [High-level architecture description with diagrams if applicable]

Section 2: Technical Stack

## Technology Stack

      ### Backend
      - **Runtime**: Node.js 22.x
      - **Framework**: Express 4.x
      - **Database**: PostgreSQL 16.x with Sequelize ORM
      - **Authentication**: JWT with refresh tokens
      - **API Style**: RESTful with OpenAPI 3.1 documentation

      ### Frontend
      - **Framework**: React 19 with TypeScript
      - **State Management**: Redux Toolkit
      - **Styling**: Tailwind CSS v4
      - **Build Tool**: Vite

      ### DevOps
      - **Hosting**: AWS (ECS + RDS)
      - **CI/CD**: GitHub Actions
      - **Observability**: Datadog
      - **Error Tracking**: Sentry

Section 3: Coding Standards

## Coding Standards & Conventions

      ### CRITICAL RULES
      1. **Never** use `any` type in TypeScript - always define proper types
      2. **Always** validate user input at API boundaries
      3. **Always** use parameterized queries - never string concatenation for SQL
      4. **Never** commit secrets or API keys
      5. **Always** write JSDoc comments for public functions

      ### File Naming
      - Components: PascalCase (UserProfile.tsx)
      - Utilities: camelCase (dateFormatter.js)
      - Constants: UPPER_SNAKE_CASE (API_ENDPOINTS.js)
      - Test files: [name].test.js

      ### Code Style
      - Use ESLint with project config (no overrides)
      - Prettier for formatting (config in .prettierrc)
      - Maximum file length: 300 lines
      - Maximum function length: 50 lines
      - Prefer functional components over class components (React)

Section 4: Architecture Patterns

## Architecture Patterns

      ### API Endpoint Pattern
      All API endpoints follow this structure:

      ```javascript
      // routes/users.js
      const express = require('express');
      const router = express.Router();
      const { UserController } = require('../controllers');
      const { authenticate, authorize, validate } = require('../middleware');
      const { userSchema } = require('../schemas');

      router.post('/users',
        authenticate,
        authorize('admin'),
        validate(userSchema),
        UserController.create
      );

      module.exports = router;
      ```

      ### Service Layer Pattern
      Business logic lives in services, not controllers:

      ```javascript
      // services/UserService.js
      class UserService {
        async createUser(userData) {
          // 1. Validate business rules
          // 2. Transform data
          // 3. Database operation
          // 4. Return result
        }
      }
      ```

Section 5: Common Tasks

## Common Development Tasks

      ### Adding a New API Endpoint
      1. Define schema in `/schemas/[resource].js`
      2. Create controller method in `/controllers/[Resource]Controller.js`
      3. Add route in `/routes/[resource].js`
      4. Write integration test in `/tests/integration/[resource].test.js`
      5. Update OpenAPI spec in `/docs/openapi.yaml`

      ### Database Migrations
      ```bash
      # Create migration
      npx sequelize-cli migration:generate --name add-users-table

      # Run migrations
      npm run migrate

      # Rollback last migration
      npm run migrate:undo
      ```

Section 6: Testing Strategy

## Testing Requirements

      ### Unit Tests
      - Required for all services and utilities
      - Use Vitest or Jest with 80% coverage minimum
      - Mock external dependencies

      ### Integration Tests
      - Required for all API endpoints
      - Use Supertest with test database
      - Test authentication and authorization flows

      ### E2E Tests
      - Required for critical user flows
      - Use Playwright
      - Run in CI before deployment

AGENTS.md starter

Use AGENTS.md when you want cross-tool compatibility, concise action-oriented instructions, and a clean separation of AI context from human docs.

From Chapter 3

# AGENTS.md - AI Coding Agent Instructions

      ## Project Overview
      This is a React + Node.js e-commerce platform.
      - Frontend: React 19 + TypeScript + Tailwind
      - Backend: Express + PostgreSQL
      - Authentication: JWT with refresh tokens

      ## Quick Setup
      ```bash
      npm install
      cp .env.example .env
      npm run db:migrate
      npm run dev
      ```

      ## Build Commands
      - Development: `npm run dev`
      - Production build: `npm run build`
      - Tests: `npm test` (run before committing)
      - Linting: `npm run lint` (must pass with 0 errors)

      ## Testing Requirements
      - All new features require unit tests
      - API endpoints require integration tests
      - Coverage must stay above 80%

      ## Security Rules
      - NEVER commit API keys or secrets
      - Always validate user input at API boundaries
      - Use parameterized queries only
      - Authentication required for all /api/* routes except /api/auth/*

Intent specification

Every agent gets a spec before it ships: a short, executable contract that names the outcome the agent owes the business and the boundaries it cannot cross.

From Chapter 4

# migrate-legacy-page.intent.yaml  (v1)

      objective:
        Migrate a legacy page to a static HTML equivalent.

      success_criteria:
        - Visual diff vs. production within 2% pixel delta
        - All inbound links resolve (no 404s)
        - Lighthouse score >= 95 on mobile

      constraints:
        - Cost ceiling: $4.00 per page
        - No edits outside /src/migrated/
        - No new third-party JS

      tool_permissions:
        - mcp:filesystem (read+write, scoped path)
        - mcp:playwright (read-only screenshots)
        - mcp:git (commit, no push)

      escalate_to_human_when:
        - Original page contains a form
        - Visual diff exceeds 5%
        - Tool call retry count > 3

      stop_rule:
        Abort if cost spend exceeds 1.5x the ceiling
        or if any tool returns a permission error.

      owner: platform-engineering@

Eval file with a CI gate

Evals run as CI gates, so an agent's work is checked by independent measurement, not by the agent's own self-report.

From Chapter 21

# evals/migrate-page.eval.yaml
      target: migrate-legacy-page.intent.yaml
      checks:
        - name: visual_diff
          assert: pixel_delta <= 0.02
        - name: links_resolve
          assert: broken_links == 0
        - name: performance
          assert: lighthouse_mobile >= 95
        - name: constraint_cost
          assert: cost_usd <= 4.00
        - name: escalation_correctness
          assert: escalated_when_form_present == true
      gate: block_merge_on_failure

AI code review workflow

Review agents check pull requests for style violations, security vulnerabilities, test-coverage gaps, and dependency issues before a human reviewer sees the diff.

From Chapter 19

# .github/workflows/ai-review.yml
      name: AI Code Review
      on: [pull_request]
      jobs:
        review:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v4
            - name: AI Review
              uses: anthropics/claude-code-action@v1
              with:
                anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
                prompt: "Review this PR for security, performance, and our standards in CLAUDE.md"

.mcp.json project configuration

MCP servers are added with the CLI or declared in a project's .mcp.json.

From Chapter 5

// .mcp.json
      {
        "mcpServers": {
          "postgres": {
            "command": "npx",
            "args": ["-y", "@modelcontextprotocol/server-postgres"],
            "env": {
              "DATABASE_URL": "postgresql://localhost/mydb"
            }
          },
          "playwright": {
            "command": "npx",
            "args": ["-y", "@playwright/mcp"]
          }
        }
      }

Custom MCP server

A custom MCP server that exposes one tool, query_users, over stdio.

From Chapter 8

// custom-api-server.js
      import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
      import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
      import { z } from 'zod';

      const server = new McpServer({ name: 'custom-api', version: '1.0.0' });

      server.tool(
        'query_users',
        'Query users from our internal API',
        { filter: z.string(), limit: z.number().default(20) },
        async ({ filter, limit }) => {
          const res = await fetch(`https://internal/api/users?filter=${filter}&limit=${limit}`);
          const data = await res.json();
          return { content: [{ type: 'text', text: JSON.stringify(data) }] };
        }
      );

      await server.connect(new StdioServerTransport());

Project rules file (.cursor/rules)

Cursor reads versioned rule files from .cursor/rules/*.mdc; rules can be always-on, auto-attached by file globs, or invoked on demand.

From Chapter 7

---
      description: TypeScript project standards
      globs: ["**/*.ts", "**/*.tsx"]
      alwaysApply: true
      ---

      # TypeScript Standards
      1. Use functional components with hooks, never class components
      2. Define prop types with TypeScript interfaces
      3. Never use 'any' - use 'unknown' and type guards
      4. Prefer composition over inheritance
      5. Follow existing patterns in /src/patterns/

      # Testing
      - Vitest and React Testing Library
      - Test user behavior, not implementation
      - Mock external API calls

      # Style
      - Prettier config in .prettierrc
      - Max file length: 250 lines

Custom agent configuration

The constraints block in this configuration is an intent spec in miniature.

From Chapter 14

export const agentConfig = {
        role: "Senior Full-Stack Developer",
        model: "claude-opus-5-5",
        capabilities: ["code_generation", "refactoring", "test_creation", "docs"],
        tools: [
          { name: "filesystem", mcp: "filesystem", scope: "/src" },
          { name: "git", mcp: "git", permissions: ["commit"] },
          { name: "tests", command: "npm test" }
        ],
        constraints: {
          max_iterations: 10,
          cost_ceiling_usd: 5.0,
          require_human_approval: ["delete_files", "git_push", "deploy"]
        }
      };

Context summary file

Give agents a good map (context files, summaries) and let them pull the exact lines they need, rather than front-loading everything into the window.

From Chapter 11

// .claude/summaries/database-schema.md
      Quick reference without full SQL dumps:

      Users:    id, email, password_hash, created_at
      Posts:    id, user_id (FK), title, content, published_at
      Comments: id, post_id (FK), user_id (FK), content