How to edit Claude Code conversation history safely
A past answer can be wrong while everything after it is still useful. Repairing that answer is possible—but only if the edit preserves the structure Claude Code needs to resume the session.
A safe edit rewrites only the supported text block on one transcript line. It preserves message UUIDs, parent links, timestamps, tool-use and tool-result pairings, and every untouched JSONL line byte for byte. It also refuses stale or active writes and makes a recoverable backup before replacement.
Edit, rewind, regenerate, or branch?
These actions solve different problems. An edit corrects the historical record while retaining later turns. A rewind discards what came after a point. A regeneration asks the model to produce another response. A branch keeps the source conversation intact and starts a related line of work.
| Operation | Use it when | What happens to later work |
|---|---|---|
| Edit in place | One user or assistant text turn is wrong, but later turns are valuable. | Kept, with the original conversation structure around the corrected text. |
| Rewind | The conversation should continue again from an earlier point. | Turns after the selected point no longer belong to the active path. |
| Regenerate | You want a new model response to an existing user turn. | The new response becomes a distinct continuation; sendable blocks must be reconstructed completely. |
| Branch | You want an alternate path without altering the source. | The source stays intact and lineage points back to it. |
Anthropic documents native discovery and continuation through Claude Code sessions. Editing the stored transcript is a separate, higher-risk operation; treat it as structured data repair, not as editing a markdown file.
The invariants matter more than the editor.
A transcript is a graph of related records, not a flat chat export. A repair that looks correct on screen can still break resume, detach a tool result, or overwrite a live turn.
- Identity stays stable. Preserve the target record's UUID, its parent UUID, timestamp, and non-text fields.
- Tools remain paired. Never rewrite thinking, tool-use, or tool-result blocks as ordinary assistant text.
- Untouched bytes remain untouched. Copy all non-target JSONL lines as raw bytes instead of parsing and reserializing the entire file.
- The viewed version must still be current. Compare the transcript modification time before writing so a newly appended turn cannot be silently erased.
- Active sessions are protected. A transcript touched in roughly the last 15 seconds may still be running; refuse the write until the operator resolves that risk.
- Recovery exists before mutation. Create a timestamped backup and an audit record before atomically replacing the file.
A full parse-and-pretty-print pass violates the byte-identity guarantee even when the visible text is unchanged. Whitespace, key ordering, and escaping can all move.
Preview, validate, back up, replace, resume.
After · corrected in place
Select a supported turn
Choose a Claude user or assistant text block. Protected thinking and tool blocks remain read-only.
Preview the rendered correction
Confirm markdown, code fences, and links before touching the source transcript.
Revalidate the source
Resolve the real transcript path inside a registered Claude project root, verify the expected modification time, and check that the session is not active.
Create recovery evidence
Write a timestamped backup in .crowsnest-backups/ and append an audit record describing the before and after state.
Replace atomically
Write a temporary file containing the one changed line plus every untouched raw line, then use an atomic replacement so a partial write is never the final transcript.
Resume the same session
Open the corrected conversation through Claude Code's normal resume path. The identity and surrounding context remain the same; only the supported text changed.
Claude history is editable; completed Codex history is not.
Crowsnest applies deep in-place repair only to supported Claude transcript text. Completed Codex history stays immutable. Codex changes use native fork or retry operations through its app-server protocol, preserving provider behavior instead of inventing an equivalent-looking file edit.
A safe edit also does not rewrite reality. Later answers were produced from the original text. Keeping them is useful when the mistake is documentary or when you deliberately want the corrected record, but it does not retroactively rerun the model. Branch or regenerate when later reasoning must be recomputed.
Crowsnest keeps backups recoverable and bounded, but recovery still deserves an operator decision. It never treats transcript mutation as a casual bulk operation.
Sources and related field notes
Provider behavior reference: Anthropic's Claude Code sessions documentation. Crowsnest repair details were checked against the released transcript implementation and its safety tests on August 24, 2026.
Published and source-reviewed August 24, 2026. This article describes Crowsnest's released safeguards; provider storage formats can change, so use the current first-party documentation for native session behavior.