Skip to main content

What is Memory?

Codex can remember project-specific instructions, preferences, and context through AGENTS.md files. These files act as “project documentation for AI agents” and help Codex understand your codebase, workflows, and conventions.
Think of AGENTS.md as persistent memory that travels with your project—Codex reads these files on startup and uses them to inform every action.

How AGENTS.md Files Work

Codex looks for AGENTS.md files in multiple locations and merges them top-down:
1

Global guidance

~/.codex/AGENTS.md - Personal preferences that apply to all projects
2

Project guidance

AGENTS.md at repo root - Shared project notes for all team members
3

Directory guidance

AGENTS.md in the current working directory - Sub-folder/feature specifics
All three files are merged together, with more specific (closer) files taking priority when there are conflicts.

Use Cases

Personal Preferences (~/.codex/AGENTS.md)

Your global AGENTS.md file can include personal coding preferences:

Project Standards (Project Root AGENTS.md)

The project-level file should document team conventions:

Feature-Specific Context (Subdirectory AGENTS.md)

Add context for specific parts of the codebase:

What to Include

Explain the organization of your codebase:
  • Key directories and their purposes
  • Where different types of files live
  • How modules are organized
Document the technologies you’re using:
  • Frameworks and libraries
  • Package managers and build tools
  • Runtime environments and versions
Define your conventions:
  • Code style and formatting rules
  • Naming conventions
  • File organization patterns
  • Testing requirements
Explain processes and procedures:
  • How to run the project locally
  • Testing and linting commands
  • Build and deployment processes
  • Git workflow and branching strategy
Provide context-specific information:
  • Business logic and rules
  • API integrations and authentication
  • Database schemas and relationships
  • External services and their purposes
Warn about common mistakes:
  • Known bugs or limitations
  • Performance considerations
  • Security requirements
  • Things that are easy to break

Best Practices

Keep It Concise

Codex’s context window is limited. Include only information that:
  • Isn’t obvious from the code itself
  • Codex would struggle to infer
  • Affects how Codex should work
Don’t duplicate information that’s already in documentation, comments, or the code. Focus on conventions, workflows, and non-obvious context.

Use Clear Structure

Organize your AGENTS.md with headers:

Be Specific

Instead of:
Write:

Include Examples

Codex learns better from examples:

Tool-Specific Configuration

Team Conventions

Disabling Project Docs

If you want Codex to ignore AGENTS.md files:

Via Command Line

Via Environment Variable

In Configuration

Examples

Example: TypeScript Project

Example: Python/Django Project

Testing

Run tests:
Use factories from tests/factories.py for test data.
Add a dependency to a specific package:

Building

Build all packages:
Build a specific package: