Getting more out of Codex starts with durable repository instructions, an isolated worktree, measurable completion criteria for long tasks, and reviews backed by tests. These practices matter more than longer prompts. Here are ten features you can try in your own project, with the problems they solve and their limitations.

Four decisions before starting a Codex task
  1. Provide context AGENTS.md · Skills
  2. Choose a workspace Worktree · Local environment
  3. Manage the task Fork · Goals · Subagents · MCP
  4. Verify results Review · Structured output

This map is a starting point. A typo needs neither multiple agents nor a persistent goal. For longer development, separate directories reduce conflicts, goals hold scope steady, and reviews and tests verify the right change. The examples span Codex CLI and desktop. Each section says where its feature applies.

1. Carry project rules into every session with AGENTS.md

Codex can read AGENTS.md as a repository guide before it starts. Version common commands, file boundaries and delivery expectations in the repository. Start with what a new developer needs in their first hour. Setup, the right test command and a rule learned from a misplaced change usually make a good first draft.

In Next.js, record where form text comes from, that page copies are not edited separately, and how to generate the static output. In Python, specify the working directory, package manager and origin of test data. End with observable behaviour. ‘Report which check you ran and its result’ is easier to verify than ‘don’t compromise on quality’.

Codex layers user-level instructions with instructions along the project path. Keep shared rules at the root and directory-specific rules close to the code. After a change, start a fresh session or run and use a small task to see which rule applies. How Codex discovers AGENTS.md instructions

2. Turn repeatable work into a Skill

A Skill bundles instructions and resources for a task Codex recognises. Its scope is narrower than the repository guide. For publishing, it could specify checking the draft, building, verifying RSS and sitemap, then summarising the release package. A small CSS task in the same project needs none of those publishing steps.

Define when to use the Skill, inputs, outputs and repeatable checks. Reuse commands the team trusts. Put detailed business rules in references loaded as needed. Keeping reading overhead low in routine work matters as much as triggering the right Skill.

Try it on a completed task. Run once with plain instructions and once with the Skill and check which steps were missed. If output is still inconsistent, clarify step inputs and outputs before adding more text. Using Codex Skills

3. Use Git worktrees to isolate experiments

A worktree adds a separate working directory for the same repository. Starting a Codex desktop task with Worktree keeps edits apart from your open local files. This is useful for testing an alternative while continuing daily work or running two independent tasks.

Check which commit the task starts from. If the experiment needs an uncommitted fix, confirm it is present in the new directory. Ports, local databases and file caches may still be shared. Use different ports for parallel servers and know where test data goes.

Review the diff and tests first. In supported workflows, Handoff moves a task between local and worktree environments. If tasks touch the same file, order the merges and test the combined result. Codex worktree and Handoff documentation

4. Make worktree setup repeatable with a local environment

A new worktree may lack dependencies, untracked test settings or commands available in the main directory. Desktop local-environment setup lets you specify a script that runs when Codex creates a worktree. Developers opening the same project later can start from a comparable environment.

On a static site, I’d install dependencies from the lockfile first and run tests separately for the task at hand. If tests need a config file, version a template with test values. If setup depends on live customer data or production keys, revisit your test boundaries first.

Try the setup script in an empty directory. Verify that it can rerun and fails with a clear message. Assumptions about what is already installed undermine isolation. Codex local environments documentation

5. Choose between Resume and Fork deliberately

In the CLI, /resume returns to a saved conversation, and /fork starts a separate experiment from it. I use Resume to keep investigating a bug with the same approach and Fork to explore an independent solution. This keeps one thread’s success criteria separate from another’s assumptions.

A slow list might be due to the query or client rendering. Collect shared observations in one thread, then open a branch to inspect only the query. If both threads edit code, separate working directories too. Forking a conversation does not isolate Git files. Briefly recap prior commands and verification results in the new thread.

In a long CLI session, /compact can summarise earlier context. Write enduring decisions in the task notes. To fork with file isolation in one step, use the documented codex fork <SESSION_ID> --worktree. It requires an explicit session ID and local execution. Codex session commands

6. Use Goals to set measurable completion criteria

Goals attach a persistent objective to a conversation. Codex can use it to choose next steps across turns. A goal needs proof of completion. Replace ‘improve the site’ with a problem, route, test and scope. Where /goal is available, you can view, edit or pause the current goal.

/goal Fix the comparison table overflowing on mobile.
Verify there is no horizontal page overflow at 320, 390 and 768 px.
Show that the table scrolls within its container and all six rows are readable.
Stop when the build and site audit pass.

For a long task, state where to test and which files are in scope. A failed attempt is one result: Codex can measure again, make a small fix and recheck under the same goal. Decide separately whether to publish or take actions affecting other systems. OpenAI Goals walkthrough · Codex commands

7. Give subagents independent work

A subagent can carry out a bounded task on behalf of the main thread. While the main agent plans, one can read existing tests and another find call sites affected by a change. Results are easier to combine when each subagent says what it checked and supplies evidence.

Specify the deliverable. ‘List entry points by file and line, and the behaviour each test verifies’ beats ‘review this module’. Concurrent edits to one file often trade time gained for merge work. If writes are needed, separate file ownership or workspaces and test the merged result.

A subagent can add more context and review overhead than a small change warrants. Check whether the work is actually independent before splitting it. Codex Subagents documentation

8. Use MCP to get documentation and project context at the source

MCP connects Codex to external tools or resources. Start by reading current documentation. When a library changes, specify the documentation version and ask Codex to include the relevant section. A task in a tracker can likewise explain why a repo change is needed.

Adding a connection and authorising all its operations are separate decisions. Start read-only for documentation. Check the account and workspace in use. Interpret task text in context, and compare any outside request to initiate an action against the user’s intent and permissions.

Record what needs to be up to date to avoid unnecessary calls in every session. OpenAI documentation MCP · Codex customisation layers

9. Scope the code review to the change

Use /review in the CLI to pick a review target, or enabled Codex Code Review on GitHub to review a pull request. Local changes and a diff against a base branch answer different questions. Decide what the review covers first. If unrelated files appear, establish why before interpreting findings.

Start with product behaviour. Does submitting a form twice still have the same effect? Does a date filter work at midnight? Should roles behave alike? Verify a Codex finding with a test. Record why you reject a finding to spare the same debate next time.

Common review questions can become short rules in the applicable AGENTS.md. Test results, branch protection and human approval still govern delivery. Custom Codex review rules

10. Get automation-ready output with codex exec

codex exec invokes Codex without interactive chat. The CLI flag --json streams progress events as line-delimited JSON. --output-schema describes expected fields in the final answer. Use them to track progress and feed machine-readable results to another tool.

codex exec --sandbox read-only --output-schema rapor.schema.json \
  -o rapor.json "Summarise the test commands and verification gaps in the README."

In this example, you supply rapor.schema.json as JSON Schema and may define test_komutlari and dogrulama_bosluklari. The consumer should validate the format and required fields. Check the exit status and discard stale reports on failure. Even when a report succeeds, command output shows whether a test actually ran.

Save the schema below as rapor.schema.json. Empty arrays are valid, so an omitted field can be distinguished from ‘no findings for this category’.

{
  "type": "object",
  "properties": {
    "test_komutlari": {"type": "array", "items": {"type": "string"}},
    "dogrulama_bosluklari": {"type": "array", "items": {"type": "string"}}
  },
  "required": ["test_komutlari", "dogrulama_bosluklari"],
  "additionalProperties": false
}

Start locally with a read-only report. When moving to team automation, record the CLI version, access and execution path alongside the output. Codex CLI developer commands

Example workflow: preparing a blog post for release

For a static site, I’d start with the repository guide: where the sources live, which files are generated and how to build the release package. I’d then create a worktree for copy and images and run publishing checks via a Skill if needed. This keeps other drafts out and makes package contents easier to audit.

Set measurable acceptance criteria: correct heading and date, no mobile overflow, the expected canonical URL in the local feed and matching entries in the sitemap and reading indexes. Check visuals in a browser and file records automatically. Finally open the package and verify a few critical entries directly.

Codex can take on several steps. The developer still checks promises in the copy, whether visuals suit the site’s language and whether checks cover actual user journeys. See testing and quality for AI-generated code for more verification and the coding assistant comparison to choose a tool.

Which three settings would I try in week one?

On day one, add a short AGENTS.md at the root. Pick a small task and deliberately leave the test command out of its prompt. If Codex finds and runs the right command, the guide works. Fix stale commands in the guide itself so future tasks and other developers benefit.

Second, with another change in the local directory, create a single worktree and verify setup there. Third, have Codex review a PR and classify findings as reproducible behaviour, product decision needed or no evidence found. Next week, automate only the most repeated step with clear inputs and verifiable output.

These trials show where the workflow got more reliable. If delivery still slips, check whether the cause is instructions, environment or verification before adding features. A longer goal won’t fix tests run in the wrong directory. A new integration won’t supply missing acceptance criteria. Focus the next change on the observed problem.

Summary

  • Use AGENTS.md for repository-wide rules and Skills for processes repeated as needed.
  • Isolate files with a worktree and make setup repeatable with a local environment.
  • Resume to continue, Fork to explore an alternative, and set a measurable Goal for long tasks.
  • Assign independent work to subagents and restrict MCP to required access.
  • Review changes and test evidence before release. Use codex exec for structured reports.

Frequently asked questions

Do Codex CLI and desktop have the same features?

Many core features are shared. codex exec is a CLI command. The local environment configuration here is for desktop. Check current menus and command documentation for the surface you use.

Why isn’t Codex reading my AGENTS.md?

Check the session directory and Git root. At the same level, AGENTS.override.md takes priority. Start a new session and use a small task to see which guide applies.

Does a new worktree include my current changes?

Check the base commit and git status in the new directory. Do not assume uncommitted edits or local settings come along.

What’s the difference between Fork and worktree?

Fork branches the conversation. A worktree gives Git files a separate directory. To explore two code approaches from the same history, consider isolating both threads and files.

What if /goal doesn’t appear?

The CLI guide says that if /goal is missing, you can enable Goals with codex features enable goals. Check your version and workspace settings. Goals user guide

Does Codex need a separate subscription?

Access and limits depend on your ChatGPT plan and workspace. Check the current Codex plan terms before choosing.

Does Codex review replace testing?

Review helps spot risks and bad assumptions. Tests provide evidence of actual behaviour. Use both in the acceptance decision.