Skip to content
stacks

CLAUDE.md examples for Go, Next.js and Python

Useful CLAUDE.md examples record tested commands, project boundaries and guardrails, with Go, Next.js and Python guidance kept in shared AGENTS.md.

Published 7 min read

Useful CLAUDE.md examples give Claude Code commands you've actually run and the project rules it would otherwise miss. Include a single-test command and explain where changes belong.

Start an existing repository with Claude Code's /init, then review and trim the draft. For a project shared with other agents, you can keep project knowledge in AGENTS.md and import it from CLAUDE.md with @AGENTS.md. The examples below use that arrangement, with separate guidance for a Go CLI, a Next.js app and a Python API.

What should a CLAUDE.md file contain?

Write the instructions a developer needs before making their first change. Commands deserve the most space: how to install dependencies, run the app and check a change. Include the working directory when it matters. A command that runs one test file lets the agent investigate a failure without repeatedly running the whole suite.

Use /init to discover a starting point in a repository that already has code. Run it inside Claude Code from the project directory, then compare its suggested commands with your scripts or Makefile. Anthropic documents this workflow in setting up a project CLAUDE.md. Run each command before keeping it in the file; delete guesses about folders that don't exist.

Describe boundaries that affect where code goes. "Services do not import the web framework" helps decide where a function belongs. "Keep code clean" leaves the same decision unresolved. Add the path that owns environment configuration and identify generated files with their regeneration command.

Keep guardrails concrete enough to act on. Specify what to do after a hook blocks a command, or how to proceed when a fix keeps failing. A sentence in CLAUDE.md guides the agent; enforcement needs configured controls. Anthropic distinguishes instructions from hooks in its explanation of project memory.

A shared file avoids maintaining two copies of the same project commands. This excerpt is the opening of the CLAUDE.md shipped by stacks (@steamfield/stacks), a CLI that writes projects from curated recipes. It is identical across the three recipes here:

CLAUDE.md, opening excerpt
@AGENTS.md

## Claude Code

The rest of that file contains Claude-specific notes, including where its hook documentation and path rules live. Project knowledge goes in AGENTS.md. The agent setup documentation explains which files each selected agent receives, and AGENTS.md vs CLAUDE.md covers why the import beats a symlink.

AGENTS.md ships as a skeleton, with sections for Commands and an Architecture map. It also has Conventions, Testing and Error handling, followed by operational context such as Debugging and Build workarounds. The agent fills the project-specific sections after building the project. These fixed Testing rules already appear in the template:

AGENTS.md template, fixed Testing rules
- Behavior-focused tests against real dependencies where practical. Fake only what crosses the network to third parties.
- A bug fix starts with a test that reproduces the bug.
- Weakening or skipping a test to get green is a failure, not a fix.

What should you leave out of CLAUDE.md?

Leave out formatting instructions your formatter already enforces. Record the command that checks formatting and any workflow the agent must follow. Repeating every lint rule creates another place to update when configuration changes.

Move detailed reference material into a document and name when to read it. A paragraph about the request path belongs in the root guide; an endpoint-by-endpoint API reference can stay elsewhere. For Claude-specific guidance that applies to one area, path-scoped rules are another option. Anthropic's rules documentation describes their configuration.

Keep the current task out of the permanent guide. A requested feature can take several pages to explain and stop mattering once it ships. In a generated project, .stacks/BRIEF.md holds that build task, while AGENTS.md holds ongoing project instructions. The brief and manifest explanation covers those files' different lifetimes.

Remove speculative commands and promises about future architecture. If the repository has no database, an instruction about its transaction layer makes the guide misleading. Record deliberately omitted work under Deferred so an agent has a reason to leave it alone.

What does a CLAUDE.md example for Go look like?

A Go CLI needs commands that distinguish unit tests from integration tests. The go-cli recipe ships a Makefile and gives the agent this instruction:

go-cli recipe, command instruction excerpt
Adapt recipes, keep the names, mirror them in AGENTS.md.

The Makefile's targets include make vet, make lint and make test. Integration tests have their own make test-integration target, and make smoke builds and exercises the binary's help and version flags. AGENTS.md should explain those differences so the agent can choose a focused check while editing a command.

Go-specific conventions belong beside the command list. This recipe asks for a fresh command constructor for each command and keeps domain packages independent of the CLI package. Those are useful facts to preserve when the agent fills Conventions. A copied instruction about an unrelated Go web server would send it toward the wrong boundaries.

The Claude adapter pre-approves commands such as make test and make lint in .claude/settings.json. That permission configuration is separate from the documentation. Adding a command to AGENTS.md describes how to run it; the file itself grants no permission.

The scripted demo reads excerpts from the generated files for team-cli. It compares the Go recipe with the unfilled AGENTS.md, then reads CLAUDE.md and the hook README. It shows the starting skeleton, before the agent has documented the built project.

Agent + stacks
Demo

You: Show me what belongs in CLAUDE.md for this Go CLI.

Agent: I’ll compare the stack’s commands with its generated instruction files.

●Bash(stacks show go-cli)
Go CLI (go-cli), stack, origin bundled, trusted
Tools: go, make, git, golangci-lint
Command: vet: Type-check every package, including tagged integration tests (go vet)
Command: lint: Run golangci-lint
Command: lint-fix: Run golangci-lint with --fix
Fragments: required none; default agent-ops, git-hooks, ci-github; optional goreleaser, rr, ce-plugin
test: make test (layer test)
Output abbreviated
●Bash(cat team-cli/AGENTS.md)
# team-cli
## Overview
<!-- stacks:fill Two or three sentences: what this project is, who uses it, and the main technologies. -->
## Commands
| Command | What it does |
| --- | --- |
## Architecture map
## Agent harness
Output abbreviated

Agent: AGENTS.md starts as a template. It needs the real overview, commands and architecture. CLAUDE.md keeps the Claude-specific notes.

●Bash(cat team-cli/CLAUDE.md)
@AGENTS.md
## Claude Code
Output abbreviated
●Bash(cat team-cli/.claude/README.md)
# `.claude/`: Claude Code config
Project instructions live in `AGENTS.md` at the repo root, which every coding agent reads. The root `CLAUDE.md` imports it and adds only Claude-specific notes, so edit `AGENTS.md` for anything that isn't Claude-specific.
## Hooks
| Hook | Event | What it does |
Output abbreviated

Agent: I’ll put the Go commands and project conventions in AGENTS.md, and keep CLAUDE.md’s import. The hook details already have their own .claude/README.md.

Example agent conversation. Playback can be paused.

A scripted agent reads the CLAUDE.md and AGENTS.md that the Go CLI stack wrote, then checks the hook documentation.

What does a CLAUDE.md look like for a Next.js app?

A Next.js app needs an explicit server/client boundary in its shared instructions. The nextjs recipe asks the agent to document that boundary and the actual package scripts in AGENTS.md. Its CLAUDE.md uses the same import shown above.

The recipe puts detailed guidance in a directory shared with every selected agent:

nextjs recipe, shared guidance instruction
Read `docs/guidance/nextjs/index.md` and link it from AGENTS.md.

Claude also gets path rules that point at this guidance. Keeping the explanation in a shared document gives the agent a place to look up details without duplicating them in the root guide. The root file can identify server modules and tell the agent which document applies before it changes an app component.

The command instructions include a concrete single-file test example:

nextjs recipe, Commands excerpt
Mirror them in AGENTS.md, including a scoped example such as `bun run test src/lib/item-schema.test.ts`.

That command belongs to this recipe's scripts. Check your own package.json before copying it into another app. This recipe uses Bun to install dependencies and run scripts, while Node runs Next.js, Vitest and Playwright. Its browser tests exercise a production build, so the guide should distinguish them from the unit-test loop.

The recipe also tells the agent to retain an AGENTS.md block that next dev may add with links to bundled docs. Preserve useful framework guidance when updating your own sections; check the installed release's documentation when an upgrade changes behavior.

What does a CLAUDE.md look like for a Python API?

A Python API benefits from documenting its HTTP contract and generated schema workflow. The python-api recipe uses FastAPI with uv and make. Its AGENTS.md starts from the same skeleton, and the agent records the chosen Python and uv versions during setup.

The recipe explicitly asks for a focused pytest command:

python-api recipe, Commands excerpt
Mirror them and a single-file command (`uv run pytest tests/test_http.py`) in AGENTS.md.

The HTTP rules become especially useful when adding another resource. When the optional rest-api fragment is selected, the recipe includes this instruction:

python-api recipe, instruction with rest-api selected
Record /v1, the tag/message/retryable envelope, cursor limits (20 default, 100 maximum), 400 validation and 405 with Allow in AGENTS.md.

Those values describe this recipe's API contract. Use your own service's pagination limits and error format when adapting the example. A framework name alone cannot tell the agent what clients expect from your endpoints.

The Claude path rule for Python code includes the schema workflow verbatim:

.claude/rules/python-api.md, excerpt
After any route or model change, run `make openapi` and commit `openapi.json` with the change. Never edit it by hand.

The recipe's verify steps include make check-openapi to detect schema drift. AGENTS.md should identify the generation command so the agent can fix a stale schema through the supported workflow.

How do you keep CLAUDE.md accurate as the project grows?

Update instructions in the same change that alters a command or boundary. If a test moves, update the single-file example and run it from the documented directory. Delete a workaround when its removal condition is met. A guide that still names an old runner wastes time even when its general advice remains sensible.

Keep shared edits in AGENTS.md when CLAUDE.md imports it. In these recipes, the agent replaces the skeleton's stacks:fill markers with real content; stacks does no repository analysis to fill them itself. The agents-md-filled verify step fails while markers remain. That check detects unfinished documentation, but command accuracy still requires running the commands.

Review new projects' instructions after setup, once their layout exists. The new-project guide explains how recipes and fragments become a build brief. For later changes, give the agent a specific documentation task: compare Commands against the scripts, run the listed single-file test and report stale paths before editing them.