Audit logs for Claude Code and Codex: what each records, how long, and what you can keep
Published · Updated
There is no single audit log for either tool. What exists is a local transcript, an optional telemetry stream to a collector you run, and, on enterprise plans, a vendor Compliance API that exposes part of the same activity. Each has its own contents, owner and retention clock.
Where the records live
| Layer | Who holds it | Contains prompts and commands? | Default retention |
|---|---|---|---|
| Local transcript | The developer's machine | Yes, in plaintext | Claude Code: 30 days. Codex: not documented as time-based |
| OpenTelemetry stream | Your collector | Only if you switch content on | Whatever your collector keeps |
| Vendor Compliance API | The vendor | Depends on plan and surface | Vendor-defined, partly unclear |
Match the layer to the question. "Who ran what, when" is telemetry, "what exactly did the agent do in this session" is the transcript, and "show a regulator the account activity" is the vendor API.
Claude Code transcripts
Claude Code writes transcripts to ~/.claude/projects/<project>/<session>.jsonl. The Claude directory reference says these files are plaintext and hold messages, tool calls and tool results, plus the system prompt, tool definitions and request parameters.
The same page says transcripts, subagent transcripts, tool-result spills, file-history snapshots and debug logs are deleted once they are older than cleanupPeriodDays. The default is 30 days, the minimum is 1, and 0 is a validation error. ~/.claude/history.jsonl, the prompts you typed, is kept until you delete it, with one exception for HIPAA-configured sessions.
A company that treats the local transcript as its record therefore has a 30-day record unless it changes the setting. That default has its own guide, and the file layout is in where Claude Code stores sessions.
Managed settings can set cleanupPeriodDays for every machine, and Claude Code then sweeps at the managed value. It also emits a claude_code.retention_sweep event (described on the monitoring page), so your collector can confirm each machine sweeps at the period you chose.
Claude Code telemetry
The monitoring documentation says Claude Code exports metrics, events and, in beta, traces. The events include claude_code.user_prompt, claude_code.tool_result, claude_code.tool_decision, claude_code.api_request and claude_code.assistant_response.
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector.example.com:4317
Content is off by default. Prompt text is redacted unless OTEL_LOG_USER_PROMPTS=1, and tool parameters such as the Bash command appear only with OTEL_LOG_TOOL_DETAILS=1. Assistant responses follow the prompt setting unless OTEL_LOG_ASSISTANT_RESPONSES overrides it, and OTEL_LOG_TOOL_CONTENT and OTEL_LOG_RAW_API_BODIES are also off.
For a team, put these under env in the managed settings file. A repository's .claude/settings.json cannot turn the exporter on or pick its destination. The exporter selectors, though, are not locked by the endpoint rules: a developer can still set one to none unless the selectors are in managed settings too. Telemetry the user can switch off is a convenience, not evidence.
What Anthropic keeps
The data usage page gives these numbers for commercial plans (Team, Enterprise, API): standard retention of 30 days, and zero data retention for qualified Enterprise accounts, enabled per organization. Consumer plans keep data 5 years if the user allows model improvement and 30 days if not. Transcripts sent through /feedback are kept for 5 years.
The Compliance API FAQ describes the enterprise audit view. The Activity Feed retains 6 years of organization activity, but only from the moment the API was enabled, and it records who did what and when, not prompt text. With a Compliance Access Key, Enterprise organizations can pull Claude Code session transcripts, prompts, assistant text and tool calls and results included, through the local session endpoints.
Coverage is narrower than people assume. Claude Code sessions are captured only while the user is signed in with the Claude Enterprise account; sessions on a Console API key, on Bedrock, Google Cloud or Foundry, and Claude Code cloud sessions are not, and neither are sessions under zero data retention. Tool inputs and results are truncated to 10,000 bytes each by default, and thinking blocks are left out. Turning the API off stops recording, and what was not recorded cannot be recovered.
One point stays unsettled in those pages: how long the session transcripts behind the Compliance API are retained, other than 30 days for HIPAA-ready organizations. The FAQ says chat, file and project content follows the organization's retention rules, indefinite by default, while the data usage page says 30 days standard for commercial plans, and the two are not reconciled. Ask your Anthropic account team which applies to session transcripts.
What Codex records
The Codex configuration pages (advanced config and config reference) document history.persistence, either save-all or none, which controls whether transcripts are saved to history.jsonl under CODEX_HOME (default ~/.codex). history.max_bytes caps that file by dropping the oldest entries. It is the only retention control documented there, and it is size-based, not time-based.
There is also an [otel] block, disabled by default. log_user_prompt is off unless you enable it, and exporter takes none, otlp-http or otlp-grpc. A project-local .codex/config.toml ignores otel, and admins can enforce exporter settings through requirements.toml.
The per-session rollout files are covered in where Codex stores sessions. The configuration pages do not mention a sessions directory, so they cannot be cited for that path.
Codex on the vendor side
The governance page points to the Compliance API for "security, legal, and governance workflows that need auditable records". Local computer access with Work Cloud has the same Compliance API support as Work Cloud, and records appear as conversation_message and codex_log types. The page also warns that conversation visibility alone is not a complete record of local actions; local execution produces separate OTel events.
The Compliance API page defers retention to the API reference, tells you not to assume the source retention window replaces your own policy, and needs an Enterprise Compliance API key.
No retention period for Codex data on the Business plan is documented, and neither is an OpenAI statement of zero data retention for the CLI. A search result suggested Enterprise supports it, but no page found says so. Check with OpenAI. All the vendor documentation above was read on 2026-11-10.
Building a record you control
Combine layers rather than trusting one.
- Turn on OTel through managed settings (Claude Code) and
requirements.toml(Codex), lock the exporter selectors, and decide deliberately whether prompts and tool details are logged. They contain code and may contain secrets. - Set
cleanupPeriodDaysin managed settings to your retention period, so deletion is policy and not an accident. - Copy transcripts somewhere you control before the sweep removes them. That is the only way to keep tool results in full.
- Scan what you keep. Secrets end up in transcripts, which makes an audit archive a secrets archive.
- Write the rules down. The policy template is a starting point.
Sealkeep's part
Sealkeep covers step 3 and part of step 4. It seals Claude Code and Codex session files on each machine, uploads them to storage you choose, and lets you search them with sealkeep search <query> --content. sealkeep scan policy record|block-high flags pasted secrets at backup time, and an admin can attach a scanner to a project with sealkeep org scanner.
It does not watch what agents do in real time, does not replace OpenTelemetry or the vendors' Compliance APIs, and cannot see machines that do not run it. sealkeep audit reports what Sealkeep did to your files, not what an agent did. The transcripts it keeps are only as complete as what the tool wrote locally, and its encryption format has not been independently audited.
FAQ
Does Claude Code keep an audit log by default?
Not one you can hand to an auditor. It keeps local transcripts for 30 days and sends telemetry only if you configure it. On Enterprise, the Compliance API can return session transcripts for users signed in with the Enterprise account.
Can developers turn the telemetry off?
The content flags and endpoint follow managed settings. A developer can still set the exporter selectors to none or console unless you set them in managed settings as well.
Does the Compliance API include Claude Code sessions on Bedrock or an API key?
No. The FAQ says those sessions are not captured, and neither are Claude Code cloud sessions.