Fixes broken line wrapping in Claude Code exported .txt conversation files — rebuilds tables, paragraphs, paths and tool calls hard-wrapped at a fixed width. Use for an export (YYYY-MM-DD-HHMMSS-*.txt) with broken tables, split paths, or mangled tool output, or "fix export" / "make export readable". Not for a live web conversation (use read-claude-web-conversation) or session history (use read-claude-code-history).
Reconstruct broken line wrapping in Claude Code exported .txt files.
# Fix and show stats
uv run <skill-path>/scripts/fix-claude-export.py <export.txt> --stats
# Custom output
uv run <skill-path>/scripts/fix-claude-export.py <export.txt> -o fixed.txt
# Validate the result (per-check PASS/FAIL with evidence; all must pass)
uv run <skill-path>/scripts/validate-claude-export-fix.py <export.txt> fixed.txtReplace <skill-path> with the resolved path to this skill's directory. Find it with:
find ~/.claude -path "*/fixing-claude-export-conversations/scripts" -type d 2>/dev/nullCopy this checklist and track progress:
- [ ] Step 1: Locate the exported .txt file
- [ ] Step 2: Run fix script with --stats
- [ ] Step 3: Run validation suite
- [ ] Step 4: Spot-check output (tables, CJK paragraphs, tool results)
- [ ] Step 5: Deliver fixed file to userStep 1: Locate the file. Claude Code exports use the naming pattern YYYY-MM-DD-HHMMSS-<slug>.txt.
Step 2: Run the fix script.
uv run <skill-path>/scripts/fix-claude-export.py <input.txt> -o <output.txt> --statsReview the stats output — typical results: 20-25% line reduction, 80+ table borders fixed, 160+ table cells fixed.
Step 3: Run the validation suite.
uv run <skill-path>/scripts/validate-claude-export-fix.py <input.txt> <output.txt>All checks must pass. If any fail, investigate before delivering. Use --verbose for full details on passing checks too.
Step 4: Spot-check. Open the output and verify:
Portal 都需要, not Portal都需要)⎿) have complete content on joined linesStep 5: Deliver the fixed file to the user.
The script handles 10 content types using a state-machine with next-line look-ahead:
❯ prefix, dw=76 padding) — paragraph joins with pangu spacing● prefix) — narrative, bullet, and numbered list joins_is_continuation_fragment● Bash( etc.) — path and argument reconstruction⎿ prefix) — continuation joins including deeper-indented fragments_is_plan_continuation_fragment├─/└─) — preserved structure────, ---) — never joined│) — preservedNext-line look-ahead (not dw thresholds): Instead of asking "was this line wrapped?" (fragile threshold), the script asks "does the next line look like a continuation?" by examining its content patterns — lowercase start, CJK ideograph start, opening bracket, hyphen/slash/underscore continuation.
Pangu spacing: Inserts spaces between ASCII alphanumeric characters and CJK ideographs at join boundaries. Also triggers for %, #, +, : adjacent to CJK.
Mid-token detection: Joins without space when boundaries indicate identifiers (BASE_ + URL), paths (documents + /05-team), or hyphenated names (ready + -together). Exception: -- prefix gets a space (run + --headed).
❯, ●, ✻, ⎿, … must match input/outputPython 3.10+ via uv run — zero external packages (stdlib only: unicodedata, argparse, re, pathlib, dataclasses).
daymade/claude-code-skills
7029e65
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.