Learning resourcesReviewed · OpenAI

Custom instructions with AGENTS.md

This guide helps developers give Codex reusable instructions, but where files are saved determines which guidance it reads. It explains global defaults, project overrides, alternative filenames, size limits and ways to inspect loaded instructions.

Researched 13 Nov 2026

In short.

This guide shows developers how to give Codex reusable instructions, but file placement and loading limits can leave expected guidance out. It documents how global and project files combine, how overrides take priority, and how to configure alternate filenames and profiles. Its examples cover team conventions, service-specific testing and code review rules. Runtime behavior, instruction-following reliability and compatibility with a particular Codex release are not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete page at the exact selected address: discovery, global and project setup, code review rules, fallback filenames, profiles, verification and troubleshooting. Linked configuration references, GitHub setup, prompting guidance, the documentation index and the AGENTS.md website are excluded. No license notice appears in the selected text. Commands, configuration loading, logs, GitHub behavior and instruction adherence were not executed or tested.

The overview

Identity

Custom instructions with AGENTS.md is a documentation guide for configuring Codex through persistent instruction files. The source address is [https://learn.chatgpt.com/docs/agent-configuration/agents-md.md].

The resource teaches a feature through explanations, configuration snippets and example commands. It does not provide a standalone tool or a ready-made instruction set for every project.

Assessment

The guide is useful when developers repeatedly need Codex to follow the same testing commands, dependency preferences or documentation conventions. Its most practical detail is the distinction between files that combine across directories and files that replace one another within a directory.

It provides enough detail to prepare a configuration and investigate missing guidance. It does not establish whether Codex consistently follows loaded instructions or whether using these files improves code quality or task completion.

Users

Individual developers can use the global file for preferences shared across repositories. Teams can place common expectations in a repository root and specialized rules in service directories. Maintainers using Codex code review in GitHub also receive a brief example of review-specific guidance.

Beginners will need to understand directories, text files and basic terminal commands. Experienced developers get the filename precedence, configuration keys, profile behavior and logging details needed to diagnose more complex setups.

Capabilities

The page explains persistent global guidance, repository instructions, nested overrides, custom fallback filenames and separate configuration profiles through CODEX_HOME. It also shows how to add a Code Review Rules section near the code it governs.

Verification and troubleshooting cover reporting active instruction sources, inspecting optional logs, restarting after changes, checking empty files, finding unexpected overrides and diagnosing instruction truncation. Detailed GitHub review setup is linked separately.

Using it

Requirements

Following the examples requires access to Codex, permission to edit the relevant instruction files and familiarity with the command line. Changing fallback filenames or the size limit also requires editing the Codex configuration.

A Git repository is not described as mandatory: when Codex cannot find a project root, the page says it checks only the current directory. Installation instructions, minimum Codex version, operating system coverage and account requirements are not supplied.

Mechanism

Codex builds its instruction chain once per run; in the interactive terminal interface (TUI), this usually means once per launched session. Global discovery uses the Codex home directory, which defaults to ~/.codex unless CODEX_HOME changes it. The page gives AGENTS.override.md priority over AGENTS.md and says only one non-empty global file is used.

Project discovery walks from the project root to the current working directory. Each directory contributes at most one file, checked in this order: AGENTS.override.md, AGENTS.md, then configured fallback names. Files are concatenated from broader to more local scope, with later guidance taking precedence.

Empty files are skipped. The combined instruction size is limited by project_doc_max_bytes, whose documented default is 32 KiB. Discovery stops at the current directory, so guidance in deeper directories is outside that search.

Setup

The documented starting point is to create ~/.codex/AGENTS.md for reusable preferences and an AGENTS.md at the repository root for project expectations. Add a nested instruction file where a service needs specialized guidance. An AGENTS.override.md replaces the ordinary instruction file in its own directory.

For existing filenames, configure project_doc_fallback_filenames in ~/.codex/config.toml. The example adds TEAM_GUIDE.md and .agents.md and raises project_doc_max_bytes to 65536 bytes. A custom CODEX_HOME changes which home directory supplies the profile.

After configuration changes, start a new run or restart the session. Ask Codex to report its active instruction sources from both the repository root and a specialized directory, then compare the reported order with the intended hierarchy.

Example

The page illustrates a payments service inside a larger repository. Global guidance can express a package-manager preference, the repository file can request linting, and services/payments/AGENTS.override.md can specify make test-payments as the service's test command.

Launching Codex from the payments directory is expected to load global guidance, then repository guidance, then the payments override. A services/payments/AGENTS.md alongside that override is ignored. These are documented examples and expected results; no commands were executed.

A separate Code Review Rules example tells Codex code review to flag treatment comparisons filtered on post-exposure behavior, such as conversion or retention. It identifies building cohorts from assignment or exposure and reporting conversion as an outcome as the safe path for the code under review.

Assessment & evidence

Limitations

The described discovery process does not search every directory in a repository. Starting from the wrong directory, using an unconfigured filename or leaving an override in place can change which guidance loads. The combined size limit can also exclude or truncate instructions.

Changes are not described as automatically reloading into an existing session. The page recommends restarting when guidance appears stale.

The page documents intended loading behavior but supplies no runtime traces, adherence benchmarks or task-quality measurements. Behavior across Codex versions and interfaces is not established.

Reasoning

The structure supports a practical division between personal defaults, shared repository conventions and local service rules. From the documented merge order, local instructions can specialize broader guidance without requiring every convention to be repeated.

That benefit depends on understanding two different behaviors: files across directories are combined, while competing filenames within one directory are alternatives. Keeping this distinction clear should help explain unexpected loading results, although the page does not quantify any productivity benefit.

Alternatives

Within the documented approach, a regular AGENTS.md holds ordinary guidance, AGENTS.override.md provides an override, and configured fallback names accommodate an existing repository convention. CODEX_HOME offers a separate profile when a different instruction environment is needed.

The page links to conversational prompting guidance but does not compare it with persistent files. Other coding assistants and instruction systems are not assessed.

Evidence

The evidence consists of the complete selected documentation page at [https://learn.chatgpt.com/docs/agent-configuration/agents-md.md], captured on 2026-11-13 at 02:04:44.178 UTC. The recorded source SHA-256 is 9d1f87a2d1cb55b4782b95abe710692b35b9659789c2db31a22c7074a3383e8e.

The page supports the described discovery rules, configuration options and troubleshooting advice. Its expected outputs are explanatory examples, not recorded execution results.

Access & freshness

Costs

The page provides no prices, subscription requirements, usage allowances or measurements of additional model usage from loading instructions. The cost of using Codex with this configuration is unknown.

It also gives no measured setup time or maintenance effort.

Rights

No license or redistribution grant appears in the selected page. Reuse and redistribution rights for its documentation text and sample material are unknown.

Freshness

The capture is dated 2026-11-13, but the page itself supplies no publication date, last-updated date or Codex release identifier. The capture date does not establish when the documented behavior was introduced.

Whether the live documentation or product behavior changed after that capture is unknown.

Actions

Start with a small set of recurring instructions and decide which belong globally, at the repository root or in a specialized directory. Check for existing override files before adding guidance.

For a future verification, start a fresh Codex run in each relevant directory and request the active instruction sources. Confirm filename priority, source order and the combined size limit. If guidance is missing, use the page's configuration and optional logging checks.

To assess whether the setup fits actual work, evaluate instruction adherence on representative tasks separately from checking whether files load. Neither outcome has been established through execution here.

Evidence for this report

selected-page.txtselected · checked 2026-11-13