What Codex does for data analysis
- Answers questions with SQL against a read-only role or replica, and shows the query with the answer.
- Cleans and analyses CSV exports with Python, and draws the charts.
- Writes a weekly metrics digest: what moved, by how much, and the likely reason.
- Flags anomalies, such as a drop in sign-ups or a spike in errors, before someone has to notice.
Codex features for data analysis
| Feature | What it does | How to start |
|---|---|---|
| Database CLI or MCP server | Queries your database or warehouse with a read-only role | A CLI in the sandbox, or an MCP server in config.toml |
| Network access | Lets commands reach a warehouse or API; off by default | network_access = true under [sandbox_workspace_write] |
--output-schema | The final answer as JSON that matches your schema | codex exec --output-schema schema.json -o result.json |
| Scheduled tasks | A weekly digest from the ChatGPT desktop app or the web | Create it in Scheduled |
How to set up Codex for data analysis
Connect the tools
Give Codex a read-only role, and turn on network access only if the data isn't in the workspace. CSV exports in the project folder need nothing extra.
# ~/.codex/config.toml: let commands reach your warehouse [sandbox_workspace_write] network_access = trueWrite the rules in AGENTS.md
Codex reads AGENTS.md before any work:
~/.codex/AGENTS.md, then the files from the repository root down to the folder it's working in. Put the job's rules there, or in a skill under.agents/skills/if they're long. See the AGENTS.md guide.## Data rules - Read-only: use the analytics role, never the app's database user. No INSERT, UPDATE, DELETE or schema changes. - Show the query or script behind every number. - Compare with the period before, and say when a change is within normal noise. - Don't export personal data; aggregate before you write anything down. - Weekly digest: the five numbers that matter, what moved, and one question worth asking next week.Run it without the interactive interface
codex execruns one task and exits. Progress goes to stderr and the final message to stdout;-oalso writes it to a file and--jsonstreams events. The sandbox is read-only unless you pass--sandbox workspace-write.# Last week's numbers as JSON that matches your schema codex exec --sandbox workspace-write --output-schema metrics.schema.json \ -o metrics.json "Compute last week's sign-ups, activation and revenue vs the week before"Put it on a schedule
Create a scheduled task in the ChatGPT desktop app or on the web (the CLI doesn't manage them), or run
codex execfrom cron. See how to make Codex proactive.
Limits and safety
- Give it a read-only role. An agent with write access to the database can change it.
- It can misread what a column means. Write a short data dictionary and check its first answers.
- Large results cost context and usage. Query and aggregate before reading rows.
- Codex sandboxes commands by default: writes stay in the workspace and the network is off. Keep
danger-full-accessfor an isolated runner or container.
Claude Code or Codex for data analysis?
The rules carry over. Write them once in AGENTS.md and put @AGENTS.md in CLAUDE.md, and both agents read the same file.
Step by step for the other agent: data analysis with Claude Code.
| Claude Code | Codex | |
|---|---|---|
| Rules file | CLAUDE.md | AGENTS.md |
| Connect tools | claude mcp add | codex mcp add or config.toml |
| Run without you | claude -p | codex exec |
| Schedule | /schedule, desktop scheduled tasks, /loop | Scheduled tasks in the ChatGPT app, cron |
| Built in for data analysis | --json-schema structured output | --output-schema structured output |
Make data analysis someone's job
Commands run when someone remembers to run them. Crewmark turns your own Codex into an AI employee with a role, a goal in numbers, working hours and a heartbeat, so the work happens on schedule and shows up on a board.
Start from the role
The AI employee roles, with these rules in its brief.
Put the work on its board
Add the job as a recurring issue. The employee wakes on its heartbeat, does it and reports in a comment.
Related
The daily SEO report is a worked example of a recurring analytics job.
FAQ
Can Codex do data analysis?
Yes. It writes and runs SQL and Python, analyses CSVs and explains what changed. Keep its database access read-only.
Why can't Codex connect to my database?
Commands in the default workspace-write sandbox have no network access. Turn it on in config.toml, or work from exported files in the workspace.
How do I get JSON results from Codex?
Pass --output-schema with a JSON Schema to codex exec, and add -o to write the final answer to a file.
Checked against Claude Code's and OpenAI's Codex documentation on November 13, 2026.