Run Codex inside a data pipeline with codex exec

Codex CLI is not only for a person at a terminal. codex exec runs one task with no interface, which fits a scheduled job: write the weekly data-quality summary, explain a failed load. How it works, the sandbox it starts in, and where to be careful.

Short answer: codex exec "your task" runs Codex once, with no interface: progress goes to stderr and only the final answer to stdout, so codex exec "summarise today's data-quality test results in tests/out/" > dq-summary.md just works in a scheduled job. It starts in a read-only sandbox; add --sandbox workspace-write only when it must change files. --json streams every event, and -o file saves the final answer.

Most data teams have a step after the pipeline where a person reads logs and writes a summary. That step is a good fit for an agent: it reads a lot, writes a little, and changes nothing.

Nothing loads from YouTube until you press play. Then Google receives your IP address and may set its own storage. Narrated with an AI-generated voice. Privacy

Where does it fit in a pipeline?

  1. 1
    Loadthe pipeline runs as usual
  2. 2
    Testdata-quality tests write their results to a folder
  3. 3
    codex execreads the results, writes a short summary (read-only)
  4. 4
    Sendthe summary goes to the team channel or an email
A nightly job with one Codex step

Which tasks suit it?

TaskFits?Why
Summarise test results in plain EnglishYesReads only, output is text
Explain why a load failed, from the logYesReads only
Draft release notes for model changesYesReads Git history
Fix failing data automatically in productionNoWrites, with nobody reviewing

What should you be careful with?

  • Keep the sandbox read-only for reporting tasks; the default already is.
  • Use an API key from the CI's secret store, never in the script.
  • Treat the output as a draft when it goes to people outside the team.

Where can you check this?

Where do you start?

Get comfortable with Codex at the terminal first: your first Codex task on a data repository. The tests it summarises can come from a data quality quarantine in a Fabric notebook.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.