Module 03.4

Codex repo memory

Stop reteaching Codex
the same repo rules every session.

The biggest jump in long-term Codex quality comes when repeated guidance leaves the chat and enters the system. This lesson shows what belongs in AGENTS.md, when to add rules, how skills help, and why MCP should solve a real workflow instead of looking impressive.

Outcomes

What better repo memory actually changes

Less re-explaining

Commands, conventions, and repo constraints move into stable instructions instead of living only in your head.

More consistent sessions

Codex starts from better defaults when it can read the same durable guidance every time.

Stronger tool leverage

Skills and MCP stop being shiny extras and start becoming reusable workflow components.

Workflow

How to externalize guidance without creating clutter

01

Start with AGENTS.md

Capture repo-specific commands, expectations, and constraints that recur often and matter to almost every session.

02

Nest when needed

Keep broad guidance near the repo root, then add more specific AGENTS.md files deeper in the tree only where local rules differ.

03

Add rules for policy

Use rules when certain commands, paths, or execution policies need enforcement beyond normal prompt instructions.

04

Add skills for repeatable expertise

When a workflow repeats, package it as a skill so Codex can invoke a clear reusable instruction set.

05

Add MCP last

Bring in external tools or systems only when a real workflow needs outside context, structured data, or remote actions.

Templates

Minimal examples for durable guidance

AGENTS.md

Keep it operational

# AGENTS.md

- Run `pnpm test` before shipping UI changes.
- Use `rg` for search and avoid broad grep scans.
- Keep edits ASCII unless the file already uses Unicode.
- Do not modify generated files directly.
- For reviews, prioritize bugs, regressions, and missing tests.
Skills and tools

Extend only when repetition proves the need

$skill-creator
$skill-installer
/mcp
codex mcp add <name> --url <server>

Practice

Three drills for building durable repo memory

Drill 1: draft a real AGENTS.md

  • Write only commands, constraints, and expectations that recur weekly.
  • Delete anything that reads like generic advice.
  • Test whether the file would save you explanation in the next session.

Drill 2: choose one workflow for a skill

  • Pick one repeated task such as migration reviews or release notes.
  • Write the skill around that bounded workflow.
  • Make it concrete enough that Codex can run it without guessing.

Drill 3: justify or reject MCP

  • List one external system you think Codex should connect to.
  • Explain the specific workflow it would improve.
  • If you cannot name the workflow, do not add the tool yet.
Common mistake

Stuffing AGENTS.md with project history

AGENTS.md is for operational instructions, not for turning your repo into a narrative archive.

Common mistake

Adding tools because they feel advanced

If a skill or MCP server does not remove real friction, it is probably increasing cognitive load instead.