What is Memory?
Codex can remember project-specific instructions, preferences, and context throughAGENTS.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 forAGENTS.md files in multiple locations and merges them top-down:
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 globalAGENTS.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
Codebase Structure
Codebase Structure
Explain the organization of your codebase:
- Key directories and their purposes
- Where different types of files live
- How modules are organized
Tech Stack & Dependencies
Tech Stack & Dependencies
Document the technologies you’re using:
- Frameworks and libraries
- Package managers and build tools
- Runtime environments and versions
Coding Standards
Coding Standards
Define your conventions:
- Code style and formatting rules
- Naming conventions
- File organization patterns
- Testing requirements
Development Workflows
Development Workflows
Explain processes and procedures:
- How to run the project locally
- Testing and linting commands
- Build and deployment processes
- Git workflow and branching strategy
Domain Knowledge
Domain Knowledge
Provide context-specific information:
- Business logic and rules
- API integrations and authentication
- Database schemas and relationships
- External services and their purposes
Common Pitfalls
Common Pitfalls
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
Use Clear Structure
Organize your AGENTS.md with headers:Be Specific
Instead of: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:tests/factories.py for test data.