A good CLAUDE.md or AGENTS.md is mostly specific: the exact commands, the directories that matter, and the three or four rules the agent would otherwise get wrong. These templates give you that skeleton for the stacks we see most often. Copy one, replace the placeholders, and delete anything that doesn't apply to your project.
If you're still deciding between the two filenames, or want the reasoning behind what goes in them, start with our guide to CLAUDE.md, AGENTS.md and Copilot instructions. Everything below works as AGENTS.md. According to Anthropic's memory docs, Claude Code reads an AGENTS.md when there is no CLAUDE.md in your working directory or above it (on v2.1.277 or later), and if you keep both files, your CLAUDE.md can import the AGENTS.md. The Claude Code guide covers the Claude-specific parts.
The template skeleton
Every template below follows the same five blocks. The order matters less than keeping each block short.
## Stack
<framework + language + database, with versions>
## Commands
<build, test one file, test all, lint, typecheck: the exact strings>
## Structure
<the 4-6 directories an agent must understand>
## Rules
<conventions a linter can't enforce, and things never to do>
## Deploy
<how this ships, what the agent must not do>
Keep the whole file under about 100 lines. Anything a formatter or linter already enforces belongs in the tool config, not here. The framework and language versions in the templates are examples, so replace them with the ones your project actually runs.
1. Next.js (App Router)
## Stack
Next.js 15 (App Router), TypeScript strict, Tailwind CSS, PostgreSQL with Drizzle ORM
## Commands
- Dev: `npm run dev`
- Test one file: `npm test -- path/to/file.test.ts`
- Test all: `npm test`
- Lint: `npm run lint`
- Typecheck: `npx tsc --noEmit`
- Build: `npm run build`
## Structure
- `app/` routes and layouts (server components by default)
- `components/` shared UI; `components/ui/` primitives
- `lib/` server-only helpers and the database client
- `drizzle/migrations/` generated migrations, never hand-edited
## Rules
- Server components unless the file needs state or browser APIs; then add `"use client"` at the top and say why in a comment
- Validate every route handler and server action input with Zod
- Environment variables are read through `lib/env.ts`, never `process.env` directly
- Named exports only, except for files Next.js requires to have a default export
## Deploy
- Production builds run `npm ci && npm run build`; do not commit `.next/`
- Never edit `.env.production` or push to `main` directly; open a PR
- Deploys happen through DeployHQ after merge, not from this shell
Shipping a Next.js app to your own server? Our Next.js on a VPS walkthrough covers the build and process-manager side that this template points at.
2. Node.js / Express API
## Stack
Express 4, TypeScript, PostgreSQL, Redis, Vitest
## Commands
- Dev (hot reload): `npm run dev`
- Test: `npm test`
- Lint: `npm run lint`
- Typecheck: `npm run typecheck`
- Build: `npm run build` (outputs to `dist/`)
## Structure
- `src/routes/` HTTP handlers: parse input, call a service, return a response
- `src/services/` business logic, no HTTP concerns
- `src/repositories/` all database access
- `src/schemas/` Zod request schemas, one per endpoint
## Rules
- Responses use the envelope `{ data, error, meta }`
- Database calls happen only in `src/repositories/`
- Services return `Result<T, Error>`; they never throw
- No `any`; use `unknown` and narrow
- Log with `src/utils/logger.ts`, never `console.log`
## Deploy
- Build: `npm ci && npm run build && npm run migrate`
- Migrations must be reversible and safe to run while the old version is still serving
- A deploy is healthy when `/api/health` returns 200
Running this on your own box? See how to host a Node.js app on a DeployHQ Managed VPS.
3. Django
## Stack
Django 5, Python 3.12, PostgreSQL, Celery with Redis
## Commands
- Dev server: `python manage.py runserver`
- Tests: `pytest`
- Lint: `ruff check .`
- Types: `mypy .`
- New migration: `python manage.py makemigrations <app>`
## Structure
- `config/` settings split into base, dev and prod
- `apps/<name>/` one Django app per domain
- `apps/<name>/services.py` business logic; views stay thin
- `templates/` and `static/` at the project root
## Rules
- Business logic lives in `services.py` or model methods, not in views
- Background work goes through Celery; no threads
- One migration per model change; never squash without asking
- Secrets come from environment variables, never `settings/*.py`
## Deploy
- Build: `pip install -r requirements.txt && python manage.py collectstatic --noinput`
- Run `python manage.py migrate` as a separate step before the app restarts
- Gunicorn behind Nginx; do not change worker counts without asking
For a full Django deploy, there's a budget Django setup on Hetzner and a Django guide.
4. Ruby on Rails
## Stack
Rails 8, Ruby 3.3, PostgreSQL, Sidekiq, RSpec
## Commands
- Server: `bin/dev`
- Test one file: `bundle exec rspec spec/path/to_spec.rb`
- Test all: `bundle exec rspec`
- Lint: `bundle exec rubocop`
- Migrate: `bin/rails db:migrate`
## Structure
- `app/models/` ActiveRecord models, validations, scopes
- `app/services/` plain Ruby objects for business logic
- `app/jobs/` Sidekiq jobs, idempotent by design
- `spec/` mirrors `app/`
## Rules
- Fat models only for persistence concerns; business rules go in `app/services/`
- Every new job must be safe to run twice
- Never write raw SQL strings with interpolation
- Do not edit `db/schema.rb` by hand; run the migration instead
## Deploy
- Precompile assets in the build: `RAILS_ENV=production bundle exec rails assets:precompile`
- Run migrations as a deploy step, not at boot
- If you deploy with zero downtime, migrations must not lock large tables
There's a matching walkthrough for hosting Rails on a DeployHQ Managed VPS.
5. WordPress theme or plugin
## Stack
WordPress 6.x, PHP 8.2, Composer, a custom theme in `wp-content/themes/<name>/`
## Commands
- Install PHP deps: `composer install`
- Lint PHP: `./vendor/bin/phpcs`
- Build assets: `npm run build`
- Watch assets: `npm run dev`
## Structure
- `wp-content/themes/<name>/` the only directory in version control
- `inc/` PHP classes, autoloaded via Composer (PSR-4)
- `src/` JS and SCSS source; `dist/` is build output
## Rules
- Escape all output (`esc_html`, `esc_attr`, `esc_url`); sanitize all input
- Prefix functions and hooks with the theme slug
- Do not edit WordPress core, other plugins, or `wp-config.php`
- `dist/` is generated; never edit it by hand
## Deploy
- Only the theme directory is deployed; uploads and the database are not
- The build step runs `composer install --no-dev && npm ci && npm run build`
- Never deploy to production while the database schema is mid-migration
6. Monorepo (Turborepo + pnpm)
## Structure
- `apps/web/` customer site (Next.js)
- `apps/admin/` internal dashboard (Next.js)
- `apps/api/` Express API shared by both frontends
- `packages/ui/` shared React components
- `packages/config/` shared ESLint, TypeScript and Tailwind configs
## Commands
- Build everything: `pnpm turbo build`
- Test one package: `pnpm test --filter=<package>`
- Typecheck everything: `pnpm turbo typecheck`
## Rules
- Shared code goes in `packages/`; app-specific code stays in `apps/`
- Never import from one app into another; extract to a package first
- Run `pnpm turbo build` before committing a cross-package change
- A change under `packages/` can affect every app that imports it
## Deploy
- We recommend deploying each app as its own DeployHQ project
- A change to `packages/` means every dependent app needs a deploy
For deploying a monorepo as separate projects, see our monorepo deployment strategies with Nx and Turborepo. In a monorepo, you can also put a short AGENTS.md inside each app directory; Codex reads the nearest one, and Claude Code also loads CLAUDE.md files from subdirectories.
Add the deploy section once, then reuse it
Look at the last block in each template above. That block is what most AGENTS.md examples leave out, and it's the one that stops an agent from improvising a deploy. It does two jobs: it tells the agent how your build runs, and it tells it what it must not do.
Here's a version you can paste under any template:
## Deploy
- Deploys go through DeployHQ. Do not SSH into servers or copy files by hand.
- The build pipeline runs on every deploy; if you add a build step, add it to the pipeline too.
- To deploy and wait for the result: `dhq deploy --wait`
- To check state: `dhq status`
- To undo a bad release: `dhq rollback <deployment-id>`
- Never run `dhq rollback` or deploy to production without being asked.
Those three commands are the real DeployHQ CLI commands (the full command list covers the rest); the last line is the part that keeps a coding agent from using them unprompted. If you want the agent to deploy from your terminal, see how to deploy from your terminal. It can drive the same CLI without a browser.
If you don't have a pipeline yet, DeployHQ build pipelines run your install and build steps on every deploy, and one-click rollback gives you a safe undo path to reference in the file.
Laravel and PHP
The config files guide linked at the top already includes a full AGENTS.md example for a Laravel team, with deployment rules, so we don't repeat it here. To go from there to production, read how to host a Laravel app on a Managed VPS.
Adapting a template to your project
- Start from the nearest template, not a blank file. Replace the stack line first.
- Run every command in the Commands block yourself. If a command fails for you, it will fail for the agent, and it will guess a replacement.
- Cut anything the linter enforces. Formatting rules waste your instruction budget.
- Add a rule only after the agent gets something wrong twice. That's how you get a file that stays short.
- Review it after any stack or pipeline change. A stale
Deployblock is worse than none.
If your agent also touches the database, pair these files with our guidance on giving Claude Code read-only database access. And if you run agents unattended, see how to run AI coding agents in CI with headless mode.
Ready to give your agent a deploy section that actually works? DeployHQ deploys from Git to any server you own, with zero-downtime deployments, build pipelines and a CLI built for automation. Start a free account and wire up your first project.
For questions or feedback, reach out at support@deployhq.com or on X/Twitter.