Resources

Templates & playbooks

Copy-paste context files, the prompts we use to build them, and the practices that keep them accurate — for Next.js, Python, Java, Node.js, TypeScript, PHP, Rust, Go, React Native, Markdown and monorepos.

Templates & playbooks
Sample library

Sample library

Real, copy-paste context files our engine produces for common stacks.

Next.js 14
AGENTS.md

Next.js 14

Drop-in AGENTS.md for a Next.js 14 App Router project. Documents routing, data fetching, and the server/client boundary so agents stop hallucinating imports.

App RouterRSCTypeScript
# AGENTS.md — Next.js 14 App Router

## Stack
- Next.js 14 (App Router), React 18, TypeScript
- Data: React Server Components + Server Actions

## Conventions
- "use client" only at the leaf that needs interactivity.
- Server Components are the default; never import server-only
  modules (fs, db) into a client component.
- Routes live under app/<feature>/page.tsx (route) or
  app/<feature>/layout.tsx (shared shell).

## Data fetching
- Fetch in Server Components with async/await.
- Mutate via Server Actions; keep forms progressively enhanced.

## Gotchas
- Do not import "@/lib/server" from a "use client" file.
- Environment keys: NEXT_PUBLIC_* are client-visible.
Python · FastAPI
CLAUDE.md

Python · FastAPI

CLAUDE.md tuned for a FastAPI service: async patterns, Pydantic models, dependency injection, and the test layout your coding agent should follow.

FastAPIasyncPydantic
# CLAUDE.md — FastAPI service

## Stack
- Python 3.12, FastAPI, SQLAlchemy 2.0 (async), Pydantic v2

## Rules
- All DB access is async (asyncpg); never call blocking IO in a
  request handler without to_thread.
- Define request/response schemas as Pydantic models in api/schemas/.
- Share dependencies (auth, db session) via FastAPI Depends.

## Testing
- pytest + httpx.AsyncClient; tests under tests/ mirror app/ layout.
- Use the dependency_overrides registry to swap the DB for a fixture.

## Notes
- Run migrations with `alembic upgrade head`, never edit the DB directly.
Rust · CLI
AGENTS.md

Rust · CLI

AGENTS.md for a Rust CLI built with clap. Captures module layout, error handling with thiserror/anyhow, and the release workflow.

clapthiserrorcargo
# AGENTS.md — Rust CLI (clap)

## Layout
- src/main.rs: arg parsing + wiring only.
- src/commands/: one module per subcommand.
- src/lib.rs: pure logic, fully unit-tested.

## Error handling
- Define domain errors with thiserror.
- Propagate with anyhow in main; map to exit codes at the boundary.

## Build & release
- cargo build --release; binaries in target/release/.
- CI cross-compiles via cargo-zigbuild for linux/macos/windows.
- Version is sourced from Cargo.toml, not hard-coded.
Go · gRPC
Cursor Rules

Go · gRPC

Cursor Rules for a Go gRPC microservice: package conventions, context propagation, generated-code boundaries, and linting rules.

gRPCprotobufcontext
// Cursor Rules — Go gRPC service

- Accept ctx context.Context as the FIRST argument of every
  exported function; never store it in a struct.
- protoc output (*.pb.go, *_grpc.pb.go) is generated; do NOT edit.
  Regenerate with `make proto` after changing .proto files.
- Packages: internal/ for unexported code, api/ for the gRPC
  surface, pkg/ only for truly reusable helpers.
- Errors: wrap with fmt.Errorf("...: %w", err); surface gRPC
  status codes via status.Errorf.
- Run `golangci-lint run` before every commit.
React Native
Copilot Instructions

React Native

Copilot Instructions for a React Native app: platform-specific files, native module boundaries, and the styling approach to keep suggestions consistent.

Exponativestyles
<!-- Copilot Instructions — React Native (Expo) -->

- Use Platform.select() for platform-specific behavior; keep the
  shared component the default and branch only when necessary.
- Native modules live under /modules; never import 'react-native'
  internals directly.
- Styling: StyleSheet.create with design tokens from theme.ts.
  Do not use inline pixel values outside the token system.
- Navigation: React Navigation v7; screen params are typed.
- Avoid nativewind/tailwind mixing with StyleSheet in the same file.
Turborepo
AGENTS.md

Turborepo

AGENTS.md for a Turborepo monorepo: workspace graph, task pipelines, and which package owns what, so agents edit the right project.

pnpmworkspacespipelines
# AGENTS.md — Turborepo monorepo (pnpm)

## Packages
- apps/web: Next.js consumer app.
- packages/ui: shared React components (no business logic).
- packages/core: framework-agnostic domain logic.

## Rules
- Import shared code via workspace protocol: "@repo/ui".
- Never reach into another package's src/ directly.
- Run tasks through turbo: `pnpm turbo build --filter=web`.

## Pipelines
- build dependsOn ^build; test/test dependOn build.
- Cache is content-addressed; don't disable it for CI speed wins.
Java · Spring Boot
AGENTS.md

Java · Spring Boot

AGENTS.md for a Spring Boot service: layered packages, JPA repositories vs services, and the Maven layout agents should respect.

Spring BootMavenJPA
# AGENTS.md — Java Spring Boot service

## Stack
- Java 21, Spring Boot 3.2, Maven, JPA/Hibernate, PostgreSQL

## Package layout
- controller/: HTTP adapters, request/response DTOs only.
- service/: business logic; never expose repositories here.
- domain/: entities, value objects, and repository interfaces.
- infrastructure/: JPA implementations, config, and clients.

## Rules
- Use constructor injection; avoid field injection.
- Return ResponseEntity<T> from controllers; keep HTTP concerns out of services.
- Use Bean Validation on DTOs, never on entities.
- Run tests with `./mvnw test`; integration tests end in *IT.java.
HTML · CSS · JS
Cursor Rules

HTML · CSS · JS

Cursor Rules for a vanilla frontend project: progressive enhancement, file naming, and keeping DOM manipulations predictable.

VanillaDOMES modules
// Cursor Rules — Vanilla HTML/CSS/JS

- Prefer semantic HTML over div soup; use <template> for repeated
  markup.
- CSS lives next to its component (component.css) or in a shared
  styles/ folder. No inline styles.
- JS is modular: one file per component, imported as ES modules.
- Select elements with data-* attributes, not CSS classes meant
  for styling.
- Keep DOM reads/writes batched; never read layout inside a loop.
- Accessibility: every interactive element must be focusable and
  have an aria-label when the label isn't visible.
Node.js
AGENTS.md

Node.js

AGENTS.md for a Node.js/Express backend: middleware ordering, route handlers, error boundaries, and the ESM/CJS boundary.

ExpressCommonJS/ESMnpm
# AGENTS.md — Node.js + Express backend

## Stack
- Node.js 20 LTS, Express 4, esm module system

## Structure
- routes/: route definitions only, no business logic.
- controllers/: thin HTTP layer that calls services.
- services/: pure async business logic, fully unit-tested.
- middleware/: reusable Express middleware (auth, validation, errors).

## Rules
- Always pass errors to next(err); never swallow async errors.
- Validate request bodies with zod or joi before controllers.
- Environment config lives in config/ and is read once at startup.
- Use npm scripts (start, test, lint); pin Node version in .nvmrc.
PHP · Web Server
CLAUDE.md

PHP · Web Server

CLAUDE.md for a traditional PHP web app: request lifecycle, Composer autoloading, PDO usage, and keeping logic out of the document root.

Apache/nginxComposerPDO
# CLAUDE.md — PHP web application

## Stack
- PHP 8.3, Composer (PSR-4), Apache/nginx, MariaDB, PDO

## Layout
- public/: entry point (index.php) and static assets only.
- src/: application code (Controllers, Services, Models).
- config/: environment and service configuration.
- templates/: view templates; escape every output with htmlspecialchars.

## Rules
- Use Composer autoloading; no manual requires.
- All database access goes through PDO with prepared statements.
- Never commit vendor/ or .env; keep secrets outside document root.
- Routing is centralized in public/index.php or a dedicated router.
Markdown
AGENTS.md

Markdown

AGENTS.md for a documentation-first repo: Markdown flavor, frontmatter schema, asset paths, and review conventions.

DocsGFMFrontmatter
# AGENTS.md — Markdown documentation repo

## Flavor
- GitHub Flavored Markdown with YAML frontmatter.
- frontmatter keys: title, description, order, tags, status.

## File layout
- docs/: user-facing guides organized by product area.
- api/: OpenAPI-generated reference (do not edit by hand).
- assets/: images and diagrams referenced with relative paths.

## Rules
- One sentence per line for easier diff reviews.
- Use semantic line breaks; no hard wraps in the middle of a sentence.
- Status values are: draft | review | published | deprecated.
- Images must include alt text and be under 500 KB.
TypeScript
Cursor Rules

TypeScript

Cursor Rules for a TypeScript library or app: strict compiler flags, type inference, explicit return types, and how to avoid any.

tscstricttypes
// Cursor Rules — TypeScript project

- Enable strict, noImplicitAny, exactOptionalPropertyTypes and
  noUncheckedIndexedAccess in tsconfig.json.
- Prefer interfaces for object shapes; use type for unions and
  mapped types.
- Export public APIs with explicit return types so tsc errors
  surface where consumers see them.
- Avoid `any`; use `unknown` with runtime validation at system
  boundaries.
- Keep types co-located with the code they describe; shared types
  live in src/types.ts with a barrel export.
- Run `tsc --noEmit` and the test suite before every PR.
PHP · CLI
CLAUDE.md

PHP · CLI

CLAUDE.md for a PHP command-line tool: Symfony Console commands, exit codes, stdin/stdout conventions, and the Composer bin setup.

ComposerSymfony ConsoleCLI
# CLAUDE.md — PHP CLI tool

## Stack
- PHP 8.3 CLI, Symfony Console 7, Composer, PSR-4 autoloading

## Layout
- bin/: executable entry script (e.g., bin/myapp).
- src/Command/: one Symfony Console command per class.
- src/Service/: reusable business logic with no CLI coupling.

## Rules
- Return proper exit codes: 0 success, 1 general error, 2 usage
  error; avoid arbitrary magic numbers.
- Read stdin with stream_get_contents(STDIN); never assume argv
  is the only input source.
- Output must be testable: inject a SymfonyStyle or OutputInterface.
- Register the command class in bin/myapp and add it to composer.json
  bin array.
Prompt templates

Prompt templates

The prompts RepoContext runs to analyze, generate, and score your context.

Analysis
AnalysisBest for: Dissect a GitHub repository into structure, dependencies, and conventions.

Constraining the model to cite evidence prevents the most common failure mode: confident but fabricated architecture.

Prompt

You are a senior software architect. Given the file tree, package manifests, and a sample of key source files of a repository, produce a str…

Generation
GenerationBest for: Turn an analysis into a clean, agent-ready context file.

Leading with 'what the agent would get wrong' is what makes the output useful rather than a restatement of the README.

Prompt

You are writing a context file (AGENTS.md / CLAUDE.md / Cursor Rules / Copilot Instructions) for an AI coding agent. Input: a repository an…

Evidence
EvidenceBest for: Attach the source files that justify each generated claim.

A claim with no evidence is a liability. Surfacing 'unsupported' items lets humans review before shipping.

Prompt

For each statement in the context file, return the list of files that prove it. Output as a mapping: "<claim>" -> ["path/to/file.ext:line…

Quality
QualityBest for: Score how trustworthy the generated context actually is.

Breaking the score into four axes turns a vanity metric into an actionable checklist for improvement.

Prompt

Rate the context file on a 0-100 quality scale using: - COVERAGE: does it address the agent's likely tasks? - ACCURACY: are claims backed by…

i18n
i18nBest for: Translate a context file into another supported language without losing meaning.

Keeping code, paths, and commands verbatim is non-negotiable — translation should never touch anything an agent executes.

Prompt

Translate the following context file into {target_lang}. Rules: - Keep all code blocks, file paths, and commands verbatim. - Preserve Markdo…

Best practices

Best practices

How teams keep generated context accurate as code changes.

Tame large monorepos

Tame large monorepos

Monorepos hide ownership. A good context file makes the workspace graph explicit so agents edit the right package.

Tips
  • Generate one context file per package, not one for the whole repo.
  • Name the workspace graph: which package owns auth, which owns UI.
  • Forbid cross-package src imports; route everything through the public API.
Work with private repositories

Work with private repositories

Private code never leaves your control. RepoContext reads metadata and structure, not file contents, by default.

Tips
  • Connect via OAuth; scope the token to the repos you actually analyze.
  • Keep secrets in env vars; never let them enter the context file.
  • Review the generated file before committing it to a shared branch.
Handle multilingual codebases

Handle multilingual codebases

Mixed-language repos need per-language context. One generic file forces the agent to guess the wrong idioms.

Tips
  • Split context by language: Python services vs TypeScript frontends.
  • Note the interop boundary (e.g. REST/grpc) between languages explicitly.
  • Keep shared contracts (OpenAPI, protobuf) in their own documented section.
Wire context into CI/CD

Wire context into CI/CD

A context file that drifts from the code is worse than none. Regenerate it on every meaningful change.

Tips
  • Add a CI step that regenerates and diffs the context file on PRs.
  • Fail the build if coverage or accuracy drops below your threshold.
  • Store the generated file as an artifact so reviews see what changed.
Keep docs fresh

Keep docs fresh

Context decays the moment code changes. Treat the context file as a living artifact, not a one-time export.

Tips
  • Re-run analysis after refactors, not just at project start.
  • Pin a quality score gate in CI so regressions are caught early.
  • Audit existing files quarterly; stale context quietly misleads agents.

Generate your own context file

Paste a repository link and get an agent-ready file in seconds — no setup required.

Start analyzing →