Codex basics: from install to a useful AGENTS.md
Follow OpenAI's official video to install Codex in your own project, run a first task, write an AGENTS.md, then try MCP and non-interactive mode.
The external player loads when you choose to watch. The source link is always available.
Steps and prompts
Follow the steps, example prompts and result checks below.
Your deliverable
Use a small repository of your own, ideally with tests. You will finish with Codex installed and signed in, an AGENTS.md with your commands and rules, one reviewed code change, and a codex exec command you can put in a script.
Follow the five steps
-
Install and sign in
On macOS or Linux, run the official installer
curl -fsSL https://chatgpt.com/codex/install.sh | sh(the same command updates Codex). On Windows, follow the official page. Runcodexand choose Sign in with ChatGPT. The video covers both the CLI and the IDE extension from 0:00.Check: Codex opens in your terminal and shows the signed-in account.
-
Run a first task in a small repo
Run
codexin your project folder. Ask it to explain the project structure, then give it one small job such as “add a test for the date helper in utils”. Review each changed file before accepting. See 4:00 in the video.Check: Only the files you asked about changed, and the tests pass.
-
Create AGENTS.md with /init, then fill it in
Type
/initto generate AGENTS.md, then add what the example below covers: install and test commands, code style, folders that are off limits, and how to report back. The video explains good patterns at 8:12.Check: In a fresh session, Codex runs your test command without being reminded.
-
Set permissions before you let go
Type
/permissionsto choose what Codex may do on its own: read files, edit files, run commands. Start by approving edits and commands yourself, and loosen this once you trust the setup. Environment setup is at 14:14 and prompting patterns at 16:26.Check: You know which actions ask first and which run directly.
-
Add one MCP server, then go non-interactive
Run
codex mcpand follow the prompts to add a service you use, such as docs or GitHub. Then runcodex exec "summarize what the last commit changed"and watch it finish without the chat view. MCP is at 34:59; headless mode and the SDK at 46:50.Check: codex exec returns a result, and the command is ready for a script or CI job.
Try this original example
FindGoodAI wrote this example for practice. Adapt it to your project.
A practical AGENTS.md
# Project notes for Codex
- A small Python 3.12 command-line tool. Entry point: app/main.py.
- Install: pip install -r requirements.txt
- Test: pytest -q (run after every change)
- Style: type hints on functions; add a test for each new function.
- Do not edit files under data/ and never commit secrets.
- When done, explain in three sentences what changed, why, and how you verified it.
When the result needs work
Codex edits files it should not touch
List off-limits folders in AGENTS.md, name the file you want changed in the prompt, and require approval before edits.
You keep repeating the test command
Put install, test and format commands in AGENTS.md and say that tests must run after every change.
Results are inconsistent
Give one small task at a time with a clear finish line, such as “all tests pass and you list the lines you changed”. The prompting chapter at 16:26 has more patterns.
Before you finish
- Codex is signed in and opens in your project folder.
- AGENTS.md lists your commands, rules and limits.
- You reviewed the first change file by file, and tests pass.
- Permissions match how you like to work.
- codex exec has run successfully at least once.
Match the video to the current interface
Codex changes quickly, and some steps in the video are now different. The official docs now recommend the install script for installing and updating the CLI, /init to create AGENTS.md, /permissions for approvals, and codex mcp to add MCP servers. Follow the official Codex CLI docs where they differ.
Chapters: installing the CLI and IDE extension (0:00), setting up a repo and first runs (4:00), writing a great AGENTS.md (8:12), configuring your environment (14:14), prompting patterns (16:26), CLI and IDE tips (27:02), MCP configuration (34:59), headless mode and the SDK (46:50), resources (52:02).
Video by OpenAI on its official YouTube channel. The written steps, example and checklist are an editorial practice guide based on the official video and documentation. Practice time is an estimate.


