codex for finance

Codex for Finance: How to Build and Edit Financial Models (2026)

Anthony Barbey

Anthony Barbey

· 12 min read

Share

Codex is OpenAI's agent for work on files. Developers use it to read a codebase, run commands and ship changes. Finance people who try it notice the same strengths apply to their work: it holds a long task, it runs code to check its own arithmetic, and it edits real files instead of pasting snippets into a chat.

This guide is for the finance practitioner who already uses ChatGPT and wants to know whether Codex is worth the step: what it does well on financial models, where it breaks, what it should work on, and the four-step setup that makes the result something you can sign. It is the Codex counterpart of Claude Code for Finance; the two agents differ in details, not in what a finance setup needs.


What Is Codex, for a Finance Person?

An agent that works on a folder, not a conversation. You give it a task ("rebuild the revenue lines by product", "reconcile these two exports", "check that the cash flow closes into the balance sheet"), and it reads the files, writes and runs code, and reports what it did.

Codex runs in four places, sharing the same configuration:

  • The terminal (Codex CLI): the most direct, and the one this guide uses for commands.
  • An IDE extension, for people who already work in an editor.
  • A desktop app, for people who do not.
  • Cloud tasks from ChatGPT, which run in OpenAI's environment rather than on your machine.

Codex is included in ChatGPT plans, from Free and Go to Pro, Business and Enterprise, with usage limits that depend on the plan; cloud tasks are reserved for the paid tiers. Check OpenAI's current page before you plan a month-end close around it.

Two features matter more for finance than the model behind it. Codex reads an AGENTS.md file at the root of the folder, so your rules apply at every session without being repeated. And it runs inside a sandbox with an approval policy: read-only, allowed to write in the folder, or full access, with Codex asking before it runs a command or not, as you choose.


Where Does Codex Break on a Raw Spreadsheet?

On the part of the model that decides whether it is right. Pointed at an Excel file, Codex does what any agent does: it reads cells, infers the structure, and writes cells back. Three failures follow.

Links break silently. A spreadsheet stores results, not intent. "Revenue equals price times volume" exists only as an arrangement of cells. When Codex rewrites a block for a new assumption, a reference two tabs away can stop pointing where it should, with no error. Independent benchmarks put the scale on it: the best model on FinSheet-Bench reaches 82.4% accuracy on financial spreadsheets, and around 20% on complex aggregation tasks (AI financial model risks).

The logic is re-inferred every session. The file persists, the reasoning does not. Next week, Codex reads the grid again and rebuilds its understanding of which line is a driver and how the statements connect. Usually the same conclusion; not always.

The figures come from its last read. When Codex reports "EBITDA is 1.2m", that number is either read from a cell it trusts or computed by a script it wrote for the occasion. Both can be right. Neither leaves a trace someone else can check next month.

None of this is a prompt problem, and none of it is specific to Codex. It is what happens when an agent works on a format that hides the logic.


What Should Codex Work On?

A model whose logic is written down explicitly, separate from its data. In a structured model, "revenue", "headcount cost" and "closing cash" are named variables, each with a formula, a timeline and explicit dependencies. Actuals and scenarios sit alongside the logic, not inside it.

What the agent doesOn a spreadsheetOn a structured model
Finds a lineScans cells, guesses the labelAddresses the variable by name
Changes an assumptionRewrites cells, links may breakThe change propagates through the graph
Reports a figureReads a cell or computes it ad hocReads the value the engine computed
Starts the next sessionRe-reads the gridOpens the same model and its history

Two traps to avoid. Asking Codex to write the whole model as a Python script is tempting, because it is good at Python; it works for one analyst and fails the day a colleague or a board wants to read it. And letting Codex compute the figures itself, rather than an engine, brings the arithmetic risk back through the side door. Codex edits the structure; an engine computes the numbers. We made the general case in Why Finance Agents Need a Model Layer.


How Do You Set Up Codex for Finance?

Four steps. The first two take ten minutes and help even if you stop there.

Step 1: write an AGENTS.md with your finance rules

Codex reads AGENTS.md at the start of every session: a personal one in ~/.codex/AGENTS.md for rules that apply everywhere, and one at the root of a folder for that folder. Keep it short:

# Finance rules
- Natural signs: revenue positive, costs and outflows negative.
- Never hardcode a value in a statement line: every line is a formula
  on an assumption or on imported actuals.
- Three statements that tie: net income feeds equity, closing cash
  equals cash on the balance sheet, a balance check equals 0.
- Before editing a model, read its FINANCE.md.
- Never report a figure you computed yourself: read it from the model.

AGENTS.md is an open convention several agents read, so the same file serves if you also use another agent on the folder.

Step 2: give each model a FINANCE.md

Conventions specific to one model (currency, units, fiscal year, EBITDA definition, glossary, how the statements are built) belong with that model, not in the session. FINANCE.md is an open standard for that file. Start with three lines (units, sign, fiscal year end) and add a definition each time a term gets misread.

Step 3: connect a model layer over MCP

MCP (Model Context Protocol) is the open standard agents use to call external tools, and Codex supports it. Connected to a model layer, Codex works on named variables and a dependency graph instead of cells. With Layerz there are two routes.

From the plugin directory: Layerz is an official plugin, listed in the directory OpenAI shares between ChatGPT and Codex. Add it from the directory and sign in.

From the terminal, two commands: the first adds the remote server to Codex's configuration, the second opens the sign-in (OAuth, no key to paste).

codex mcp add layerz --url https://layerz.cc/mcp
codex mcp login layerz

From there, Codex can create a model, read its FINANCE.md, add assumptions and formulas, load actuals, build a scenario as a variant of the base case, run the model's checks, and ask the dependency graph "what depends on gross margin?" rather than scanning a sheet. Every change is recorded in the model's version history, with a diff and a restore.

Step 4: keep Excel as the export

Your board, your lender and your auditor open a standard .xlsx. Build in the structured layer, export to Excel on demand with formulas intact. The spreadsheet is the format on the way out, not the place the logic lives.


What Does a Session Look Like?

  1. Codex loads AGENTS.md, connects to the model, reads its FINANCE.md.
  2. You ask: "Move the second sales hire from April to July and show me what moves."
  3. It changes one assumption; the change propagates; it lists the affected lines from the dependency graph.
  4. It runs the model's validation (balance sheet ties, cash closes, no orphan lines) and reports what fails.
  5. You read the diff, keep it or restore, and export to Excel if someone needs a file.

Next week, a new session opens the same model and its history. Nothing is re-inferred from a grid. If you keep your procedures and scripts in a repository, GitHub for Finance Teams shows how review and history carry over.


Which Sandbox and Approval Settings Suit Finance Work?

The strictest that still lets the task run. Codex's sandbox decides what it may touch (read-only, write inside the folder, or full access) and its approval policy decides when it asks you before running a command.

  • Reading an inherited model or a client export: read-only. Codex can analyse, it cannot change anything on disk.
  • Building or editing a model on the layer: writing in the folder is enough, because the model changes go through the model layer's tools, which keep their own history.
  • Full access: almost never needed for finance, and never on a machine that holds other clients' files.

Cloud tasks run in OpenAI's environment rather than on your machine. That is convenient for long jobs on your own data; for a client's data, check what the engagement allows first (AI and Confidential Financial Data).


When Is Plain Codex Plus Excel Enough?

For one-shot work. "Reconcile these two exports", "find the duplicate invoices", "explain what this formula does", "draft a sensitivity table on this file": Codex on a raw file does it well, and checks its arithmetic with code. Use it.

The structured setup becomes necessary when four conditions meet: the agent modifies the model, it works across sessions, conventions must be honoured and not only formulas, and the output must be defensible to a board, an investor or a data room. For a budget, a cash forecast or a deal model you update every month, they usually all apply.


Codex or Claude Code for Finance?

Both work, and the setup above is the same for both: a rules file at the root (AGENTS.md for Codex, CLAUDE.md for Claude Code), a FINANCE.md per model, a model layer over MCP, Excel as the export. Pick the one your team already pays for and is comfortable with. What decides the quality of the result is where the model lives, not which agent edits it. The Claude Code version of this setup is in Claude Code for Finance.


FAQ

Can Codex build a financial model? Yes. It can build the structure, write the formulas and check the result with code. The question is what it builds on: on a raw spreadsheet, links can break as it rewrites cells; on a model layer over MCP, it edits named variables and an engine computes the figures.

Do I need to know how to code to use Codex for finance? No. The desktop app and the IDE extension work without a terminal, and the setup above has two text files and, at most, two commands. Instructions are written in plain English.

Is Codex included in ChatGPT? Yes, Codex is included in ChatGPT plans, with usage limits that depend on the plan. Cloud tasks are reserved for the paid tiers. Check OpenAI's current pricing page for the details of yours.

Can Codex edit my Excel model directly? It can, and for a one-off change that is fine. For a model you update every month, import the workbook into a structured layer, let Codex work on that, and export back to Excel with formulas intact.

Does Codex use the same plugin as ChatGPT? Yes. OpenAI's plugin directory is shared between ChatGPT and Codex, so a plugin such as Layerz, added once, is available in both. What it does in ChatGPT is in ChatGPT Plugin for Financial Models.

Does Codex keep my financial data? Codex sends to OpenAI what it reads in a session, under your plan's data terms. Keep credentials out of the files it reads, prefer the local sandbox for client data, and connect client data only where the engagement allows it.


The Bottom Line

Codex is a strong agent for financial work: it holds a long task, runs code, and works on real files. On a raw spreadsheet it inherits the failure modes of any agent on a grid. The fix is structural, and it is the same whatever the agent: rules in an AGENTS.md, conventions in a FINANCE.md, the model on a layer Codex edits over MCP, Excel as the export, and a sandbox no wider than the task.

For the wider approach to AI-built models, start with The Right Way to Generate a Financial Model with AI.


Keep Reading


Layerz is a structured spreadsheet, ready for AI. It holds the model so the agent does not have to: named variables and formulas separate from data, a FINANCE.md per model, every change versioned, clean Excel export anytime. Codex connects through the official plugin or over MCP. Free for one person working alone, with unlimited models.

Anthony Barbey

Anthony Barbey · Founder, Layerz

Anthony spent his career in finance and consulting, close to the modeling workflows of M&A, transactions, and advisory. He now builds Layerz, the finance workspace that keeps Claude in the context of your model so it doesn’t drift, forget between sessions, or burn tokens on grids.

Related articles

Ready to build models that are defensible by design?

Layerz separates model structure from data so every number is traceable.

Explore Layerz