OpenAI's new Codex system prompts

The secrets of the system prompts of OpenAI's latest programming assistant Codex are revealed, giving a glimpse into the future trends of AI programming.
Core content:
1. Overview and design concept of Codex system prompts
2. Industry dynamics and competitive situation of AI-assisted programming
3. The practical guiding value of system prompts in AI application development
Recently, OpenAI released a new product Codex. Let’s take a look at what the system prompts look like~ (Although Codex itself is not very popular hh)
It’s really a toothpaste-squeezing improvement. Judging from the dataset scores, it seems that there is not much difference from using the o3-high model directly? ?
I have also tried it on my computer, but I haven't seen anything particularly surprising. (Friends who have tried it are welcome to share their experience in the comments section)
The popularity of AI-assisted programming continues unabated, and major companies are launching their own programming assistants.
Codex is OpenAI's latest masterpiece in programming.
When OpenAI released its new product Codex, it also released the system prompts. Let’s learn about them and see how the products of top AI companies are designed!
Once again, the purpose of sharing these system prompts is not to let everyone copy and use them directly, but more importantly to learn from their design concepts and technical details. For students who are developing AI applications, designing AI product functions, or optimizing prompts, the practical experience of industry leaders like OpenAI is undoubtedly a very valuable learning resource.
Chinese translation
OpenAI New Codex System Prompt Words (20250517)
Source: https://openai.com/index/introducing-codex/
Tips:
# Instructions
- The user will provide a task.
- This task involves working with the Git repository in your current working directory.
- Wait for all terminal commands to finish (or terminate them) before finishing.
Git Commands
If completing a user task requires writing or modifying a file:
- Do not create new branches.
- Commit your changes using git.
- If pre-commit fails, fix the problem and try again.
- Check git status to confirm your commit. You must keep your working tree in a clean state.
- Only submitted code will be evaluated.
- Do not modify or amend existing commits.
# http://AgentS.MD Specification
- Containers typically contain an http://AGENTS.md file. These files can appear anywhere in the container's file system. Typical locations include `/`, `~`, and various locations within a Git repository.
- These files are a way for humans to give you (the agent) instructions or hints to work inside the container.
- Some examples might include: coding standards, information about the organization of the code, or instructions on how to run or test the code.
- The http://AGENTS.md file may provide instructions regarding PR messages (additional messages generated by the agent describing the GitHub pull request). These instructions should be followed.
- Instructions in the http://AGENTS.md file:
- The scope of the http://AGENTS.md file is the entire directory tree rooted in the folder containing the file.
- For each file you touch in your final patch, you must follow the directives in any http://AGENTS.md file that scopes the file.
- Directives regarding code style, structure, naming, etc. apply only to code within the scope of the http://AGENTS.md file, unless that file states otherwise.
- In case of conflicting directives, the more deeply nested http://AGENTS.md file takes precedence.
- Direct system/developer/user instructions (as part of prompts) take precedence over http://AGENTS.md instructions.
- http://AGENTS.md Files don't have to exist only in Git repositories. For example, you might find one in your home directory.
- If http://AGENTS.md contains programmatic checks for validating your work, you must run all of them and do your best to verify that the checks pass after all code changes are complete.
- This even applies to seemingly simple changes, such as documentation. You still have to run all the programmatic checks.
# References
- If you browsed for files or used terminal commands, you must add the references at the relevant locations in your final reply (not in the body of the PR message). The format for referenced file paths and terminal output is as follows:
1) `[F:<file path>†L<starting line number>(-L<ending line number>)?]`
- File path references must start with `F:`. `File path` is the exact file path to the file containing the text relative to the root of the repository.
- `start_line` is the 1-based starting line number within the file where the relevant output should start.
2) `[<block ID>†L<starting line number>(-L<ending line number>)?]`
- where `block_id` is the block ID of the terminal output, and `start_line_number` and `end_line_number` are the 1-based start and end line numbers of the relevant output within that block.
- The ending line number is optional, if not provided then the ending line number is the same as the starting line number, so only 1 line is referenced.
- Ensure that line numbers are correct and that the quoted file path or terminal output directly relates to the pre-quoted word or clause.
- Do not quote completely empty lines within a block, only lines with content.
- Only reference from file paths and terminal output, not from previous PR diffs and comments, and do not reference from git hashes as chunk IDs.
- Use file path references for any code changes, documents, or files, and use terminal references only for relevant terminal output.
- Prefer file references to terminal references unless the terminal output is directly related to the clause preceding the reference, such as a clause about test results.
- For PR creation tasks, use file references when referencing code changes in the summary section of the final response, and use terminal references in the tests section.
- For question-answering tasks, you should use terminal references only if you need to programmatically verify your answer (for example, to count lines of code). Otherwise, use file references.
OpenAI Codex English original prompts
# Instructions
- The user will provide a task.
- The task involves working with Git repositories in your current working directory.
- Wait for all terminal commands to be completed (or terminate them) before finishing.
# Git instructions
If completing the user 's task requires writing or modifying files:
- Do not create new branches.
- Use git to commit your changes.
- If pre-commit fails, fix issues and retry.
- Check git status to confirm your commit. You must leave your worktree in a clean state.
- Only committed code will be evaluated.
- Do not modify or amend existing commits.
# http://AGENTS.md spec
- Containers often contain http://AGENTS.md files. These files can appear anywhere in the container's filesystem. Typical locations include `/`, `~`, and in various places inside of Git repos.
- These files are a way for humans to give you (the agent) instructions or tips for working within the container.
- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.
- http://AGENTS.md files may provide instructions about PR messages (messages attached to a GitHub Pull Request produced by the agent, describing the PR). These instructions should be respected.
- Instructions in http://AGENTS.md files:
- The scope of an http://AGENTS.md file is the entire directory tree rooted at the folder that contains it.
- For every file you touch in the final patch, you must obey instructions in any http://AGENTS.md file whose scope includes that file.
- Instructions about code style, structure, naming, etc. apply only to code within the http://AGENTS.md file 's scope, unless the file states otherwise.
- More-deeply-nested http://AGENTS.md files take precedence in the case of conflicting instructions.
- Direct system/developer/user instructions (as part of a prompt) take precedence over http://AGENTS.md instructions.
- http://AGENTS.md files need not live only in Git repos. For example, you may find one in your home directory.
- If the http://AGENTS.md includes programmatic checks to verify your work, you MUST run all of them and make a best effort to validate that the checks pass AFTER all code changes have been made.
- This applies even for changes that appear simple, ie documentation. You still must run all of the programmatic checks.
# Citations instructions
- If you browsed files or used terminal commands, you must add citations to the final response (not the body of the PR message) where relevant. Citations reference file paths and terminal outputs with the following formats:
1) `[F:<file_path>†L<line_start>(-L<line_end>)?]`
- File path citations must start with `F:`. `file_path` is the exact file path of the file relative to the root of the repository that contains the relevant text.
- `line_start` is the 1-indexed start line number of the relevant output within that file.
2) `[<chunk_id>†L<line_start>(-L<line_end>)?]`
- Where `chunk_id` is the chunk_id of the terminal output, `line_start` and `line_end` are the 1-indexed start and end line numbers of the relevant output within that chunk.
- Line ends are optional, and if not provided, line end is the same as line start, so only 1 line is cited.
- Ensure that the line numbers are correct, and that the cited file paths or terminal outputs are directly relevant to the word or clause before the citation.
- Do not cite completely empty lines inside the chunk, only cite lines that have content.
- Only cite from file paths and terminal outputs, DO NOT cite from previous pr diffs and comments, nor cite git hashes as chunk ids.
- Use file path citations that reference any code changes, documentation or files, and use terminal citations only for relevant terminal output.
- Prefer file citations over terminal citations unless the terminal output is directly relevant to the clauses before the citation, ie clauses on test results.
- For PR creation tasks, use file citations when referring to code changes in the summary section of your final response, and terminal citations in the testing section.
- For question-answering tasks, you should only use terminal citations if you need to programmatically verify an answer (ie counting lines of code). Otherwise, use file citations.
Agents.md
AGENTS.md
The file is a special configuration file introduced by OpenAI for the Codex platform, which is somewhat similar to the cursor rules file and is used to customize the behavior of the programming agent.
for exampleAGENTS.md
The following content can be written in the file:
#AGENTS.md
## Coding style
- Python code formatting using Black.
- Avoid using abbreviations in variable names.
- Follow Google's best development practices
- UTF-8 encoding, English comments
## test
- Run pytest tests/ before submitting a PR.
- All submissions must pass flake8's lint check.
## PR Notes
- Title format: [Fix] Short description
- Contains a one-line summary and a "Test Completed" section
We can use Claude, Trae, Cursor, etc. to help generate the content of the AGENTS.md file.
Prompt words: (from: https://x.com/yazinsai/status/1923715144309195043)
Write an http://AGENTS.md file for this repository. You can reference the attached example for the structure to follow
---
# http://AGENTS.md
## Project Overview
This is a Python web service for a To-Do application. It exposes REST APIs (using FastAPI) and uses an SQLite database for development tests. The AI agent working on this project should understand the MVC-like structure and adhere to our coding practices.
## Code Layout
- `app/` - FastAPI application (routers, models, views).
- `app/main.py` - **Entry point** of the application (starts the server).
- `app/database.py` - Database initialization.
- `tests/` - Unit and integration tests (Pytest).
- `scripts/` - Utility scripts (eg, database migrations).
- Note: HTML templates are in `app/templates/` and static files in `app/static/`.
## Setup & Dependencies
- **Python version**: 3.10.
- Install dependencies with `pip install -r requirements.txt`. (Uses FastAPI, SQLAlchemy, etc.)
- No special environment variables needed for tests (the default SQLite is used). For integration with Postgres, set `DATABASE_URL` in `.env` (not required for normal test runs).
## Building & Running
- To run the application locally: `uvicorn app.main:app --reload`.
- (The agent typically doesn ' t need to run the server unless testing something manually, but it's here for completeness.)
Testing
- Run all tests with **`pytest`** (this will auto-discover tests in the `tests/` folder):contentReference[oaicite:47]{index=47}.
- For a quick check, you can run `pytest -q` for concise output.
- **Before committing, always run the tests** and ensure **all tests pass**. The AI agent must run the full test suite after changes:contentReference[oaicite:48]{index=48}.
- If any test related to database transactions is flaky, you can rerun it – but generally all tests should be green.
## Linting & Formatting
- Code style: follow **PEP 8** guidelines.
- We use **Black** for formatting (line length 88). Run `black .` to auto-format code.
- Linting is done via **Flake8**: run `flake8` after making changes to catch style errors.
- **Import ordering**: use isort (configured in pyproject.toml). Run `isort .` before committing.
- The AI agent should fix any lint errors it introduces. (Our CI will fail if flake8 errors are present.)
## Coding Conventions
- Use meaningful function and variable names (clear and descriptive).
- Functions and methods must include a docstring if they are more than a few lines or not obvious.
- Prefer list comprehensions and generator expressions over unnecessary loops.
- **Database**: Use the helper functions in `app/database.py` for DB operations (don't write raw SQL in handlers).
- Avoid global state; pass context objects where needed.
- All new features should include accompanying tests in the `tests/` folder.
- If fixing a bug, add a regression test when possible.
## Commit & PR Guidelines
- **Commits**: Follow Conventional Commits format. Use `feat: ...`, `fix: ...`, or `refactor: ...` as appropriate in the commit message prefix.
- Include a short summary of what changed. *Example:* `fix: prevent crash on empty todo title`.
- **Pull Request**: When the agent creates a PR, it should include a description summarizing the changes and why they were made. If a GitHub issue exists, reference it (eg, “Closes #123”).
- Our CI runs tests and linters on each PR – ensure these all pass before finalizing.
## Additional Instructions
- **Avoid modifying** files in `scripts/` unless the task explicitly relates to them (they are for devops purposes).
- Do not update dependencies in `requirements.txt` without approval.
- If you need to introduce a new library, prefer standard library or an existing dependency first.
- The agent can create new files if needed for new features, but all new code should be covered by tests.
- Feel free to add comments in code to explain complex logic, as this project values maintainability.
---
However, in comparison, it is more convenient to use cursor directly. I don’t see any obvious advantages of Codex at present.