A policy for coding-agent session data: what to keep, who may read it, for how long (template)
Published · Updated
If you have no policy for what Claude Code and Codex write to disk, the tools' defaults are your policy. Every engineer using them is producing a plaintext record of prompts, commands and file contents on their laptop. Below is a template to copy, and for each clause the setting or habit that makes it true.
What the defaults decide for you
Know what you are overriding before you write rules. These facts come from the vendors' documentation as it stood on 2026-11-10.
| Fact | Source |
|---|---|
Claude Code transcripts are plaintext under ~/.claude/projects/ and are deleted after cleanupPeriodDays, default 30 | Claude directory reference |
| Transcripts hold file contents, command output and pasted text, so a secret read by a tool lands in the file | same page, "Plaintext storage" |
| Anthropic's standard retention on commercial plans is 30 days; zero data retention is per-organization on Enterprise | Data usage |
Codex saves transcripts to history.jsonl under CODEX_HOME unless history.persistence = "none"; history.max_bytes caps its size | Codex advanced config |
| OpenTelemetry export is off by default in both tools, and prompt text is redacted unless you opt in | Claude Code monitoring, Codex config above |
What each vendor retains on its side, and where that is unclear, is in the audit guide. The policy below governs your copy of the data.
Four decisions only you can make
The template cannot choose these for you.
First, whether to keep transcripts at all. Keeping them gives you history, handoff and incident evidence, and it also creates a store of source code and secrets. Both choices are legitimate; not deciding is the bad one.
Second, for how long. Thirty days is the Claude Code default and nobody chose it for you. Pick a number from your own needs, such as incident review, contractor offboarding or legal hold.
Third, who reads it: per person, per project, or the whole company. A transcript is closer to a developer's private notebook than to a commit, and people behave differently when they know it is open.
Fourth, what must never go in: credentials, customer data, regulated data. Then decide how you will detect a violation.
The template
Copy this block, replace every [bracket], and delete the clauses you do not need.
CODING-AGENT SESSION DATA POLICY
Owner: [role, e.g. head of engineering] Version: [1.0] Review: [every 6 months]
1. Scope
This policy covers session data written by [Claude Code, Codex, other: ____]
on [company-managed machines only / also personal machines used for work].
2. What is recorded
Local transcripts, prompt history, file snapshots and debug logs written by
the tools. They may contain source code, command output, pasted text and
credentials. They are classified as [confidential / internal].
3. Retention
Local, on the developer machine: [__ days]. Enforced by managed settings
(cleanupPeriodDays for Claude Code).
Central archive, if any: [__ months / not kept]. Location: [bucket or system].
Legal hold: [who may suspend deletion, how it is recorded].
4. Access
A developer may read: [their own sessions].
Others may read: [project members for sessions in their project / security
team on incident only / nobody].
Access to another person's session requires: [approval from ____, logged in ____].
5. Prohibited content
[Production credentials, customer personal data, regulated data] must not be
pasted into a session or placed where an agent can read it. Agents are denied
read access to [.env files, ~/.aws, ~/.ssh] by permission rules.
6. Secret handling
Archives are scanned for credentials at [seal/upload time / weekly].
A finding is handled by [rotating the credential within __ hours], not by
deleting the transcript alone.
7. Telemetry
Usage telemetry is sent to [collector URL]. Prompt text [is / is not] logged.
Tool details (commands) [are / are not] logged. Set by managed settings;
developers may not disable it.
8. Vendor retention
Our plan: [Claude Team / Enterprise / API; ChatGPT Business / Enterprise].
Vendor retention as documented on [date]: [Claude Code: 30 days standard /
zero data retention]; [Codex: ____].
We do not use [consumer accounts] for work.
9. Departures
On departure, within [__ days]: sessions for projects the person worked on
are [kept in the project archive / deleted]. Personal-account data is
[out of scope / requested back]. Local copies are [wiped with the machine].
10. Deletion requests
A person may request deletion of their sessions from [central archive] via
[process]. Deletion is completed within [__ days] and recorded.
11. Exceptions and review
Exceptions are approved by [role] and listed in [location].
Incidents involving session data are reported to [role] within [__ hours].
How to make each clause true
A policy nobody enforces is a document, not a control.
Retention (clause 3)
In Claude Code, put cleanupPeriodDays in the managed settings file so developers cannot shorten or lengthen it. You can verify the sweep too, because Claude Code emits a claude_code.retention_sweep event to your collector. Codex's documented control is size, history.max_bytes, not time. If your policy says "90 days" and the tool offers only a size cap, say so in the policy and handle time-based deletion in your archive.
Prohibited content (clause 5)
Claude Code permission rules can deny reads of credential files, for example Read(./.env) in permissions.deny, as shown in the settings documentation. Know the limit: this stops the file tool from reading .env, and does not stop a developer pasting a key into a prompt or a shell command printing one. Secrets in transcripts shows how to find what already leaked.
Telemetry (clause 7)
Put CLAUDE_CODE_ENABLE_TELEMETRY and the OTEL_* variables in the managed settings env block, and set the exporter selectors there as well, or a developer can switch a signal off. Leave OTEL_LOG_USER_PROMPTS and OTEL_LOG_TOOL_DETAILS off unless clause 2's classification allows you to store that content. Codex makes the same decisions in [otel], enforced through requirements.toml.
Opting out entirely
If your answer to the first decision is "no transcripts", Claude Code supports CLAUDE_CODE_SKIP_PROMPT_HISTORY to skip writing transcripts and prompt history, and Codex supports history.persistence = "none". You lose resume and rewind, and you lose the record. Put that in the policy.
Access (clause 4)
Neither tool has per-project access control for local files. Anything on a developer's disk is readable by that developer and anyone with their account, so access rules for a central archive have to come from whatever holds the archive. Encrypting agent transcripts covers the encryption options.
Mistakes to avoid
- Writing a retention number the tools do not enforce.
- Logging prompts to telemetry and forgetting that the collector now holds source code.
- Deleting a transcript after a leak and calling it handled, when the secret stays valid until you rotate it.
- Ignoring personal accounts. Consumer plans retain data differently (5 years or 30 days depending on a model-improvement setting, per the data usage page), and your policy cannot see them.
Where Sealkeep can enforce it
For teams that want a central, encrypted archive, Sealkeep can implement clauses 3, 4 and 6. It seals sessions on each machine and stores them in a bucket you choose. An organization scopes access by project: sealkeep org join <project> needs an admin's approval, sealkeep org revoke cuts someone off, and sealkeep org scanner add <name> --policy block-high sets a secret scanner for a project. sealkeep org report lists membership, scanners and findings.
It does not set Claude Code or Codex retention, manage their telemetry, or stop secrets entering a session, and its scanner can miss secrets. It covers only machines that run it, and its encryption format has not had an independent audit.
FAQ
Do I need a policy if we only use agents on side projects?
If the sessions touch company repositories, yes. The transcripts contain that code whatever the project's importance.
Is 30 days a reasonable retention period?
It is the Claude Code default, not a recommendation. Choose from your incident-review and legal needs. If you need longer, Claude Code will not keep it for you unless you raise cleanupPeriodDays or copy the files elsewhere.
Does the vendor's zero data retention remove the local transcripts?
No. Zero data retention is a server-side arrangement, and the local files under ~/.claude/projects/ or CODEX_HOME exist until they are cleaned up.
See also: all guides.