AGENTS.md + template.md

The Living Context
Workflow

Keep agents oriented across every session

"The key to all projects like this is to keep a template.md up-to-date and an AGENTS.md to update it as you go."

Two Files, One Habit

AGENTS.md — The Context File

Tells any agent (or new team member) everything they need to know to work in this repo without breaking things. Structure, conventions, build commands, gotchas.

It's the answer to: "What do I need to know before touching anything here?"

# AGENTS.md — MyProject ## What This Is One sentence describing the project. ## File Map src/ → application code infra/ → infrastructure (CDK/Terraform) scripts/ → setup, deploy, migrate ## Build & Run npm install && npm run dev ## Conventions - Naming, branching, PR rules - What NOT to edit directly ## Security # (for public repos — see slide 5)

Keep It Light

AGENTS.md should be skimmable in 60 seconds. If it grows beyond a page or two, split by directory — each subdirectory can have its own AGENTS.md that a scoped agent inherits.

template.md — The Replication File

Captures the how and why behind every non-obvious decision so you (or an agent) can recreate the same architecture in a new project.

Think of it as a living ADR (Architecture Decision Record) — updated whenever a pattern solidifies or a gotcha is discovered.

# template.md — Project Template # Guide for creating a similar project. ## Architecture Pattern monorepo/ ├── infra/ → IaC (CDK/Terraform) ├── backend/ → API + business logic └── web/ → Frontend ## Key Design Decisions | Decision | Choice | Why | |----------|--------|-----| | IaC | CDK | Same lang as Lambda | | DB | RDS | Relational, PITR | | Registry | .npmrc | Avoid E401 errors | ## Setup Steps 1. Bootstrap: cdk bootstrap 2. Deploy: cdk deploy 3. Migrate: invoke migrate Lambda ## Gotchas - CDK uses npx internally — pin registry

The Relationship

AGENTS.md is for orientation — "here's the current state of the repo."
template.md is for replication — "here's how to build this again from scratch."

Both evolve. Neither is a spec written once and forgotten.

The Workflow: Update as You Go

The Core Loop

Every time something significant changes — a new pattern solidifies, a gotcha is discovered, a decision is made — update both files. The agent on the next session picks up exactly where you left off.

1
STARTAgent reads AGENTS.md → oriented instantly. No re-explaining the project.
2
BUILDYou and the agent implement a feature or fix. A new pattern emerges.
3
UPDATEAgent updates AGENTS.md with the new convention. Updates template.md with the architectural decision.
4
LOGChangelog entry written — what changed and why.
5
NEXTNew session. Fresh agent. Same orientation. Loop continues.

The Instruction in AGENTS.md

Explicitly tell the agent to maintain the files:

# AGENTS.md
**Remember to update this AGENTS.md
whenever structure, conventions,
or build system changes.**

Why This Works

LLM agents have no persistent memory between sessions. AGENTS.md is that memory — externalized, version-controlled, and always current.

Without it, every session starts from zero. You re-explain architecture, conventions, gotchas. You get inconsistency. The agent makes decisions that contradict earlier ones.

With it, you start at full context every time.

Scoping AGENTS.md

For a monorepo, each major layer can have its own:

AGENTS.md ← root: whole-repo context
infra/AGENTS.md ← CDK patterns, caveats
backend/AGENTS.md ← API layer conventions
web/AGENTS.md ← frontend specifics

Agent tools that support context inheritance will load the appropriate file for the directory they're working in.

Applies to Any Project Size

A solo weekend side project benefits just as much as a team repo. The cost is low — a few lines updated per session. The payoff compounds every time you come back after a week away.

Changelog Discipline + Git Hooks

Why a Changelog Matters Here

A changelog isn't just for users — it's context for future agents. "What changed and why" is exactly what an agent needs to understand why the codebase looks the way it does.

A well-maintained changelog is a compressed history of architectural decisions. It makes AGENTS.md shorter by offloading the "why things changed" narrative.

Structure That Works

Keep the changelog machine-readable so build scripts can embed it, and human-readable so it's useful at a glance. One source of truth.

# presentations.json → changelog "changelog": [ { "date": "2026-02-26", "entries": [ { "type": "added", "id": "agents_md_workflow", "note": "AGENTS.md workflow presentation." } ] } ] # build.sh embeds this into index.html # One source of truth → many surfaces

Git Hooks: Automate the Reminder

A post-commit hook catches the moment when the changelog is most likely to be forgotten — right after you commit.

#!/bin/sh # .git/hooks/post-commit # Check if relevant files changed if git diff HEAD~1 HEAD --name-only \ | grep -qE "^(src|lib|presentations)/"; then echo "" echo "📋 Don't forget to update the changelog." echo " Ask the agent: 'update changelog for" echo " my last commit'" echo "" fi

Ask the Agent to Write It

You don't have to write changelog entries manually. The agent can read the diff and write the right entries:

"update the changelog for my last commit"

The agent diffs HEAD~1..HEAD, maps changes to node IDs or components, infers added/changed/removed, and writes meaningful notes based on the actual diff content.

The Feedback Loop

Commit → hook reminds you → agent reads diff → changelog updated → AGENTS.md updated → next session starts with full context. The discipline becomes frictionless.

Security Precautions for Public Repos

AGENTS.md on a Public Repo

AGENTS.md is committed to the repo. On a public project, it's visible to everyone. That's mostly fine — it helps contributors — but a few things should never go in.

No credentials or API keys — not even "examples." Reference env var names instead: $STRIPE_SECRET_KEY
No internal URLs — private dashboards, internal tooling endpoints, VPN-gated services
No personal info — addresses, phone numbers, personal email addresses
No private repo references — internal package names, private registry URLs, org-internal tool names
No security-sensitive architecture details — exact vulnerability mitigations, WAF rule specifics, pen test findings
General security checklists: fine — "use SRP auth flow, enable MFA, set deletion protection" is public knowledge that helps contributors do the right thing

The Review Habit

Before committing an AGENTS.md update to a public repo, scan it the same way you'd scan any commit: would I be comfortable if anyone on the internet read this?

Ask the agent: "Review this AGENTS.md for anything that shouldn't be public."

Separate Public and Private Context

If a project spans public and private concerns, split the context:

AGENTS.md ← committed, public
AGENTS.private.md ← gitignored, local only

The private file holds internal URLs, credentials guidance, and org-specific conventions. Add it to .gitignore and document its existence in the public AGENTS.md:

# AGENTS.md
For internal deployment details, see
AGENTS.private.md (not committed).

template.md Is Usually Safe

Template files describe architecture patterns and design decisions — most of this is shareable and actually useful as public documentation. Still: no keys, no internal hostnames.

A good template.md with no sensitive data is a feature of a public repo — it's documentation that helps contributors understand the project deeply.

Putting It All Together

Minimal Starting Kit

For any new project, create these two files immediately — even before the first commit. They cost 10 minutes to seed and save hours over the project lifetime.

# Scaffold a new project touch AGENTS.md template.md # Install the post-commit reminder hook cat > .git/hooks/post-commit <<'EOF' #!/bin/sh if git diff HEAD~1 HEAD --name-only \ | grep -qE "^src/"; then echo "📋 Update changelog + AGENTS.md?" fi EOF chmod +x .git/hooks/post-commit

The Graph Overlay Idea

AGENTS.md makes the structure of a project explicit — like a dependency graph. When someone new joins, they read the graph. The delta (Δ) between what they already know and what the file says is exactly what needs to transfer.

Agents work the same way. The AGENTS.md is the overlay. The context gap closes immediately.

The Full Stack of Files

A
AGENTS.md — Current structure, conventions, build commands, security notes. The orientation file.
T
template.md — Architectural decisions and gotchas. How to recreate this from scratch.
C
changelog — What changed, when, and why. In-repo JSON or CHANGELOG.md — one source of truth.
H
post-commit hook — Reminds you to update context after every significant commit.
S
AGENTS.private.md — Gitignored. Internal details that shouldn't be public.

The Meta-Instruction

The most important line in any AGENTS.md — the one that keeps the whole system self-sustaining:

**Remember to update this AGENTS.md
whenever site structure, conventions,
or build system changes.**

One sentence. The agent reads it. The agent follows it. The context stays alive.

This presentation and this site are built using this workflow. Both have an AGENTS.md. The site's build script enforces changelog discipline automatically.
1 / 6