Fixing Claude Code Export Conversations
Reconstruct broken line wrapping in Claude Code exported .txt files. Triggers on "fix export / fix conversation / make export readable" or a .txt with broken tables, split paths, or mangled tool output.
Quick start
uv run <skill-path>/scripts/fix-claude-export.py <export.txt> --stats # fix + stats
uv run <skill-path>/scripts/fix-claude-export.py <export.txt> -o fixed.txt # custom output
uv run <skill-path>/scripts/validate-claude-export-fix.py <export.txt> fixed.txt # 53 checks
Resolve <skill-path>: find ~/.claude -path "*/fixing-claude-export-conversations/scripts" -type d 2>/dev/null.
Workflow
- Locate the file (pattern
YYYY-MM-DD-HHMMSS-<slug>.txt).
- Run fix script with
--stats (typical: 20-25% line reduction, 80+ borders, 160+ cells fixed).
- Run validation suite — all checks must pass; investigate any failure before delivering (
--verbose for detail).
- Spot-check: tables have intact single-line borders; CJK/English has pangu spacing (
Portal 都需要); tool-result blocks (⎿) joined fully; diff line numbers each on own line.
- Deliver fixed file.
What gets fixed (state machine + next-line look-ahead, 10 content types)
User prompts (❯), Claude responses (●), Claude paragraphs (2-space indent), tables (border + cell re-padding with pipe tracking), tool calls (● Bash(), tool results (⎿), plan text (5-space indent), agent tree (├─/└─ preserved), separators (────/--- never joined), tree connectors (standalone │ preserved).
Key design
- Next-line look-ahead (not width thresholds): asks "does the next line look like a continuation?" via lowercase start, CJK start, opening bracket, hyphen/slash/underscore.
- Pangu spacing: inserts spaces between ASCII alnum and CJK at join boundaries (also
%, #, +, : adjacent to CJK).
- Mid-token detection: joins without space for identifiers (
BASE_+URL), paths (documents+/05-team), hyphenated names; -- prefix gets a space (run+--headed).
Safety
Never modifies original. Marker counts (❯ ● ✻ ⎿ …) must match input/output. Warns if any line exceeds 500 display-width (runaway join). Strict UTF-8.
Dependencies
Python 3.10+ via uv run, stdlib only (unicodedata, argparse, re, pathlib, dataclasses).
1---2name: fixing-claude-export-conversations3description: Use when a Claude Code exported `.txt` conversation (often named YYYY-MM-DD-HHMMSS-*.txt) has broken line wrapping, mangled tables, split paths, or garbled tool output — reconstructs the formatting and validates the result.4tags: [claude-code, export, line-wrapping, tables, formatting, txt, conversation, validation]5source: daymade/claude-code-skills6derived_from: fixing-claude-export-conversations7metadata:8 source: https://skillmd.com/skills/aashutosh396/fixing-claude-export-conversations9---1011# Fixing Claude Code Export Conversations1213Reconstruct broken line wrapping in Claude Code exported `.txt` files. Triggers on "fix export / fix conversation / make export readable" or a `.txt` with broken tables, split paths, or mangled tool output.1415## Quick start16```bash17uv run <skill-path>/scripts/fix-claude-export.py <export.txt> --stats # fix + stats18uv run <skill-path>/scripts/fix-claude-export.py <export.txt> -o fixed.txt # custom output19uv run <skill-path>/scripts/validate-claude-export-fix.py <export.txt> fixed.txt # 53 checks20```21Resolve `<skill-path>`: `find ~/.claude -path "*/fixing-claude-export-conversations/scripts" -type d 2>/dev/null`.2223## Workflow241. Locate the file (pattern `YYYY-MM-DD-HHMMSS-<slug>.txt`).252. Run fix script with `--stats` (typical: 20-25% line reduction, 80+ borders, 160+ cells fixed).263. Run validation suite — all checks must pass; investigate any failure before delivering (`--verbose` for detail).274. Spot-check: tables have intact single-line borders; CJK/English has pangu spacing (`Portal 都需要`); tool-result blocks (`⎿`) joined fully; diff line numbers each on own line.285. Deliver fixed file.2930## What gets fixed (state machine + next-line look-ahead, 10 content types)31User prompts (`❯`), Claude responses (`●`), Claude paragraphs (2-space indent), tables (border + cell re-padding with pipe tracking), tool calls (`● Bash(`), tool results (`⎿`), plan text (5-space indent), agent tree (`├─`/`└─` preserved), separators (`────`/`---` never joined), tree connectors (standalone `│` preserved).3233## Key design34- **Next-line look-ahead** (not width thresholds): asks "does the next line look like a continuation?" via lowercase start, CJK start, opening bracket, hyphen/slash/underscore.35- **Pangu spacing**: inserts spaces between ASCII alnum and CJK at join boundaries (also `%`, `#`, `+`, `:` adjacent to CJK).36- **Mid-token detection**: joins without space for identifiers (`BASE_`+`URL`), paths (`documents`+`/05-team`), hyphenated names; `--` prefix gets a space (`run`+`--headed`).3738## Safety39Never modifies original. Marker counts (`❯ ● ✻ ⎿ …`) must match input/output. Warns if any line exceeds 500 display-width (runaway join). Strict UTF-8.4041## Dependencies42Python 3.10+ via `uv run`, stdlib only (`unicodedata`, `argparse`, `re`, `pathlib`, `dataclasses`).