The Project Context File: AGENTS.md and CLAUDE.md for a Spring Boot Project
Every new session, a coding agent knows nothing about your project. A short AGENTS.md (project, commands, layout, house rules, what done means) goes in first, and a one-line CLAUDE.md with @AGENTS.md gives Claude Code the same rules.
What you will learn
- Explain why a coding agent needs a context file in every new session
- Write an AGENTS.md in five parts: project, commands, layout, house rules, done
- Share one set of rules with Claude Code through @AGENTS.md in CLAUDE.md
- Spot a context-file line that lets a red change look green
Before you start
- Your First Spring Boot 4 Project
- An AI coding agent in your IDE
Every time you open a new session, an AI coding agent knows nothing about your project: not the build command, not your rules, nothing. So you give it a small file to read first, the project context file. It comes with two names, AGENTS.md and CLAUDE.md, and you write it once.
One task, start to finish
Follow one session in IntelliJ with the AI chat open. The task is ten words: "Add an endpoint that lists the tasks of one assignee." The first thing the agent does is read AGENTS.md. Then it changes the service and the controller, adds two tests, and runs mvn test. Why that command? Because the file says so. The terminal shows 5 tests run, 0 failures, and you never typed the command. Start a new session and the chat is empty again, so the agent reads AGENTS.md again. Every new session reads it first.
AGENTS.md in five parts
Here is the file for a small Spring Boot task API:
# task-api
A small REST service for a team's task list. Spring Boot 4.1, Java 25, Maven.
## Commands
- Build and test: `mvn test`
- One test class: `mvn test -Dtest=TaskControllerTest`
- Run locally: `mvn spring-boot:run` (port 8080)
## Layout
- `src/main/java/org/studyeasy/tasks/` - records, services and controllers, one package
- `src/test/java/org/studyeasy/tasks/` - MockMvc tests, one class per controller
## House rules
- Dependencies come in through the constructor.
- Data types are Java records. No Lombok.
- A missing item is a 404 (`ResponseEntity.of(...)`), never a 200 with an empty body.
- Every new endpoint gets a MockMvc test, including the empty or 404 case.
- No new dependencies in `pom.xml` without asking me first.
## Before you say "done"
- `mvn test` passes with 0 failures and 0 errors.
- Show me the diff. Do not commit.
- What the project is. A name and the stack in one line.
- Commands. Build and test exactly as you'd type them.
- Layout. Where the code and the tests live.
- House rules. Only the ones the agent would get wrong, not everything you know.
- What done means. Tests pass, show me the diff, don't commit.
It's a plain file, like the note you'd give a new colleague on day one. The same shape works for any stack; here's the one for the React front end of the same app:
# task-web
The browser front end for task-api. React, Vite, plain CSS.
## Commands
- Install: `npm ci`
- Dev server: `npm run dev` (port 5173, calls the API on port 8080)
- Test: `npm test`
- Lint: `npm run lint`
## Layout
- `src/components/` - one component per file, named like the file
- `src/api.js` - every call to task-api goes through here
## House rules
- Function components and hooks only. No class components.
- Never call `fetch` inside a component: use `src/api.js`.
- Show a loading state and an error state for every request.
- No new npm packages without asking me first.
## Before you say "done"
- `npm test` and `npm run lint` pass.
- Show me the diff. Do not commit.
Two names, one set of rules
AGENTS.md is the open format that Codex, GitHub Copilot and Cursor read. CLAUDE.md is the file Claude Code looks for. You don't write the rules twice:
@AGENTS.md
## Claude Code only
- Start in plan mode for any change that touches more than one file.
- Keep this file short: the shared rules are in AGENTS.md.
Line one, @AGENTS.md, pulls the whole shared file in. Below it go only the extras for Claude, if you have any. So Claude Code gets the same rules as every other agent. For the bigger picture of where these files can live and how they stack, see the CLAUDE.md hierarchy and splitting CLAUDE.md with imports.
One line that hides failures
Change the build command in the Commands part to mvn package -DskipTests. Now the agent builds without running the tests, and a change that breaks them still looks green. The commands you write are the ones the agent will trust, so the test command has to actually run the tests.
Common mistakes
- Writing a long essay. The agent reads the whole file every session; keep only what it would get wrong.
- Copying the rules into both files. Put them in
AGENTS.mdand import them. - Leaving out "what done means". Without it the agent decides when it's finished.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE
Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)Related posts
CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.
Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.
One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.
Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.
