-
Goal: A small but realistic “Agent‑maintained service”: a REST API for a Task Manager (users, projects, tasks) where:
- Agents build most features.
- Repo is structured for agent-first work.
- Background agents do “garbage collection” on code and docs. vercel
-
Stack (boring, well-known tools):
- Backend: Spring Boot 3.x → later upgrade path to 4.x.
- DB: Postgres.
- Frontend: React (optional, not required for the sample).
- CI: GitHub Actions.
- Agent: Claude / GPT-based coding agent integrated via IDE + repo instructions. news.ycombinator
You can swap Spring Boot for Node/Django etc. and keep the same structure.
Top-level structure:
task-manager/
AGENTS.md
CLAUDE.md # optional, tool-specific shim
docs/
index.md
architecture.md
domain-task-manager.md
coding-standards.md
agent-playbook.md
patterns/
spring-rest-patterns.md
spring-data-patterns.md
react-patterns.md
plans/
roadmap.md
current-iteration.md
tech-debt.md
src/
main/
java/com/example/taskmanager/...
test/
java/com/example/taskmanager/...
tools/
garbage-collector/
semantic_purge.py
doc-gardener/
doc_gardener.py
linters/
architecture_linter.py
.github/workflows/
ci.yml
doc-gardener.yml
garbage-collector.yml
README.md
Key points:
- AGENTS.md is a table of contents, ~100 lines, with pointers into
docs/andplans/, not a full manual. openai - All decisions, specs, and plans live inside the repo (
docs/,plans/), never only in Slack / Google Docs. openai - Agents are expected to follow “progressive disclosure”: start with AGENTS.md, then dive deeper as linked. openai
Example skeleton (trim to your style):
# AGENTS.md – Agent Entry Point
You are working on the `task-manager` service: a Spring Boot REST API for managing users, projects, and tasks.
When starting any task, follow this sequence:
1. Read `docs/index.md` (project summary, directory map).
2. For backend tasks, read:
- `docs/architecture.md`
- `docs/domain-task-manager.md`
- `docs/coding-standards.md`
- `docs/patterns/spring-rest-patterns.md`
3. For frontend tasks, read:
- `docs/patterns/react-patterns.md`
Plans and work status:
- Long-term roadmap: `plans/roadmap.md`
- Current sprint / iteration: `plans/current-iteration.md`
- Known tech debt and cleanup areas: `plans/tech-debt.md`
Quality and guardrails:
- Always add or update tests under `src/test/...` for any behavior change.
- Do not introduce new libraries without editing `docs/architecture.md` and explaining why.
- Prefer existing patterns shown in:
- `docs/patterns/spring-rest-patterns.md`
- `docs/patterns/spring-data-patterns.md`
When you get something wrong:
- Explain what repo capability or documentation was missing.
- Suggest where a new doc or rule should live (e.g., `docs/patterns/...`, `docs/coding-standards.md`).
If you are unsure:
- Ask the user which part of the repo to read next.This matches the “AGENTS.md as navigational map, not encyclopedia” pattern. vercel
Example minimal docs:
docs/index.md- One‑page summary of project purpose, tech stack, folder map. openai
docs/architecture.md- Context, container, key components, and high‑level rules (e.g., controllers thin, services own logic; no DB access from controllers).
docs/domain-task-manager.md- Entities (User, Project, Task), invariants, lifecycle rules.
docs/coding-standards.md- Naming, logging, error handling, package structure, test strategy.
docs/patterns/spring-rest-patterns.md- Example controller+service+repository pattern, standard error responses.
docs/patterns/spring-data-patterns.md- How to use Spring Data, pagination, query patterns.
These are the “deeper docs” that AGENTS.md points to. vercel
plans/roadmap.md- Q1/Q2 themes, big features, expected migrations (e.g., Spring Boot 4 later). openai
plans/current-iteration.md- 5–10 concrete tasks with status (To‑do / In progress / Done).
plans/tech-debt.md- File‑level or module‑level debt, how to fix, priority. This becomes input for cleanup agents. openai
Agents read these instead of Jira. openai
Treat the agent like a junior dev:
- Human creates/updates a plan item in
plans/current-iteration.md. - Human writes or adjusts tests / high‑level spec in codebase (TDD where practical).
- Agent is asked to implement or modify code only via the repo context and AGENTS.md.
- Agent opens PR (or changeset) which:
- Follows patterns from
docs/patterns/. - Updates docs if behavior changed.
- Follows patterns from
- CI enforces style, tests, and architecture rules. openai
This matches the “progressive disclosure” recommendation and AGENTS.md usage model. vercel
Typical steps:
mvn testor./gradlew test.- Run code format / lint (e.g., Spotless, Checkstyle).
- Run
tools/linters/architecture_linter.pyto enforce repo rules (e.g., no direct DB in controllers). openai - Optionally run security scan (e.g.,
mvn verifywith plugins).
OpenAI describe encoding “golden principles” as mechanical rules and enforcing via linters and scheduled cleanup. openai
tools/linters/architecture_linter.py can:
- Fail if:
controllerpackages import repositories directly.- New modules bypass shared utility packages defined in
docs/architecture.md. openai
- Produce human‑readable hints that agents see in CI logs (“Move DB access to a Service class, see docs/patterns/spring-rest-patterns.md”). openai
This makes linting into coaching for both humans and agents. openai
You implement a scheduled workflow: .github/workflows/garbage-collector.yml:
- Runs nightly or weekly.
- Invokes
tools/garbage-collector/semantic_purge.py(or equivalent) to:- Detect “patch” instructions that accumulated in AGENTS.md or docs (e.g., “ALWAYS return JSON field X”) and classify them as:
- Syntax/Capability (high‑decay, purge on model upgrade).
- Business/Context (keep). dev
- Suggest removal / consolidation of outdated patches.
- Detect “patch” instructions that accumulated in AGENTS.md or docs (e.g., “ALWAYS return JSON field X”) and classify them as:
- Opens small PRs that:
- Remove or rewrite obsolete instructions.
- Simplify AGENTS.md back to ~100 lines. dev
This follows the “entropy and garbage collection” idea plus semantic purge for prompt rot. dev
Workflow: .github/workflows/doc-gardener.yml:
- Runs nightly.
- Steps:
- Use static analysis + LLM to compare:
- Public REST endpoints in code vs documented endpoints in
docs/domain-task-manager.mdanddocs/patterns/spring-rest-patterns.md. - Entity fields vs documented schema. reddit
- Public REST endpoints in code vs documented endpoints in
- If mismatches found, open a PR which:
- Updates docs to match code, or
- Highlights unclear discrepancies in a TODO block.
- Use static analysis + LLM to compare:
OpenAI describe a recurring “doc‑gardening” agent that opens fix‑up PRs when docs drift. reddit
When the agent makes a bad change:
- Do not just retry the same prompt.
- Ask inside the PR or comment:
- “What capability was missing from this environment?”
- “Where should that capability or rule live in the repo?”
- Use the answer to:
- Add/extend a doc under
docs/ordocs/patterns/. - Add or adjust an architecture rule or linter.
- Possibly add a small test pattern to guide future behavior.
- Add/extend a doc under
Then the garbage‑collector / semantic purge ensures that only durable, generalisable lessons remain, while brittle one-off patches decay. dev
- Create repo with:
- Basic Spring Boot app, one simple
HealthController. AGENTS.md,docs/index.md,docs/architecture.md,docs/coding-standards.md,docs/domain-task-manager.md.plans/roadmap.md,plans/current-iteration.md,plans/tech-debt.md.- CI workflow (tests + linters). vercel
- Basic Spring Boot app, one simple
- Define in
plans/current-iteration.md:- “Implement CRUD for Task with REST endpoints and basic validation.”
- Ask the agent to:
- Read AGENTS.md → docs.
- Implement
TaskController,TaskService,TaskRepository, entity, DTOs, tests. - Update docs for endpoints. vercel
- Implement architecture linter and wire it into CI. openai
- Add a few “golden principles” as static checks (no direct DB in controllers, use shared utils, etc.). openai
- Implement
semantic_purge.py(or similar) over AGENTS.md:- Classify instruction lines.
- Open PRs to remove outdated, syntax‑only patches on a schedule. dev
- Add
.github/workflows/garbage-collector.ymlto run weekly and open PRs. dev
- Implement
doc_gardener.pyto:- Parse controllers/endpoints, compare with docs.
- Open PRs when mismatches detected. reddit
- Add workflow
.github/workflows/doc-gardener.ymlto run nightly. openai
- Review PRs from garbage collector and doc‑gardener, refine heuristics.
- Tighten AGENTS.md back to ~100 lines, moving anything verbose into specific docs. vercel
- Capture learnings in
docs/agent-playbook.mdso the system becomes self‑documenting.
- Configure your IDE tools (Cursor, Claude Code, Copilot, etc.) so that:
- They always load AGENTS.md into system context for this repo. news.ycombinator
- They treat
docs/as primary reference for architecture/domain questions. openai
- Use one or more AGENTS.md files per package/module as the repo grows for more localized rules. news.ycombinator
- When you start your Spring Boot 3 → 4 migration later, add:
docs/spring-boot-4-migration.md.- A new plan file
plans/spring-boot-4-migration.md. - Pointers in AGENTS.md under a new “Migrations” section. vercel
This gives you a full sample project pattern: structure, instructions, background agents, and concrete day‑by‑day steps aligned with the agent‑first playbook you quoted.
Source:
⸻
𝗦𝗧𝗔𝗥𝗧 𝗛𝗘𝗥𝗘 (do these today)
1/ Your instruction file (CLAUDE md, AGENTS md, whatever you use) is a table of contents, not a manual. ~100 lines max. Just pointers to deeper docs agents read when they need them. When everything is "important," nothing is.
2/ If it's not in your codebase, it doesnt exist. That architecture decision you discussed on Slack? That spec sitting in Google Docs? Your agent will never see it. Move it into your repo as a markdown file. Simple as that.
3/ When the agent screws up, dont retry the same prompt. Instead, ask the agent directly: "What capability is missing from this environment, and how can I make it more visible and enforceable for you?" Let it tell you what it needs. It knows its own blind spots better than you do.
⸻
𝗦𝗧𝗥𝗨𝗖𝗧𝗨𝗥𝗘 𝗬𝗢𝗨𝗥 𝗥𝗘𝗣𝗢 𝗙𝗢𝗥 𝗔𝗚𝗘𝗡𝗧𝗦
4/ Check your plans into the repo. What you're building, what's done, what tech debt you know about. All as versioned files. Your agent reads a plan file in the codebase, not a Jira ticket it cant access.
5/ Use "progressive disclosure." Dont dump everything on the agent upfront. Give it a small entry point, then teach it where to look next. Same way you'd onboard a new hire: start small, go deep when needed.
6/ Choose boring tools. Stable APIs, predictable behavior, lots of examples in training data. Agents reason better about simple, well-known tech than clever, obscure libraries.
⸻
𝗔𝗨𝗧𝗢𝗠𝗔𝗧𝗘 𝗤𝗨𝗔𝗟𝗜𝗧𝗬 (this is where it gets wild)
7/ Agents copy patterns. Including bad ones. Left alone, your codebase quietly degrades. OpenAI's team spent every Friday (20% of their week) manually cleaning this up. Didnt scale.
8/ Their fix: automated garbage collection. Set up background agents that scan your code for bad patterns and open small cleanup PRs on a schedule.
9/ Run a "doc-gardening" agent. It checks if your docs still match your actual code. When they dont, it opens a fix-up PR automatically. Your docs stay alive without you babysitting them.
⸻
𝗔𝗗𝗩𝗔𝗡𝗖𝗘𝗗 (for the deep nerds)
Tips 10-12 in the comments. Linters as coaching, mechanical architecture enforcement, and why sometimes rewriting a library beats importing one. 👇
⸻