Home / All Skills / Workflow & Core Tools / fixing-claude-export-conversations
Workflow & Core Tools · daymade/claude-code-skills

fixing-claude-export-conversations

Fixes broken line wrapping in Claude Code exported conversation files (.txt), reconstructing tables, paragraphs, paths, and tool calls that were hard-wrapped at fixed column widths. Includes an automated validation suite (generic, file-agnostic checks). Triggers when the user has a Claude Code export file with broken formatting, mentions "fix export", "fix conversation", "exported conversation", "make export readable", references a file matching YYYY-MM-DD-HHMMSS-*.txt, or has a .txt file with broken tables, split paths, or mangled tool output from Claude Code.

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandWrite FileDual-pass Audit
Author daymadeGitHub daymade/claude-code-skills ↗Stars 1385License MIT(仓库根 LICENSE:Copyright (c) 2025 daymade;GitHub API spdx MIT)Commit d5c4678cb5
Control levels describe skill capabilities and suggested control measures; they do not represent quality or safety certifications, nor do they dictate usability. Usage decisions rest entirely with users and administrators. Different agent hosts apply varying constraints; do not assume hosts provide automatic protection. Third-party skill copyrights belong to their original authors. Use at your own risk.

1How It Works & Mechanism

Instead of relying on fixed line-wrap width thresholds, the core engine uses a state machine with next-line look-ahead: whenever an apparently hard-wrapped line is encountered, it checks whether the next line resembles a continuation (starting with lowercase, CJK character, opening bracket, or continuing a hyphen/slash/underscore) to decide on joining.

daymade-claude-code/claude-export-txt-better/SKILL.md
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.
Corresponds to predicates such as _is_continuation_fragment / _is_plan_continuation_fragment in fix-claude-export.py: they serve as the core decision logic for whether to join lines.

Separately handles 10 categories of content (user prompts, Claude responses, paragraphs, tables, tool calls, tool results, plan text, agent trees, dividers, and tree connectors), with tables receiving dedicated border reconstruction and column-width realignments.

daymade-claude-code/claude-export-txt-better/SKILL.md
The script handles 10 content types using a state-machine with next-line look-ahead
The script's process() method is a ~470-line state machine; table handling accounts for the majority of the code (_merge_multirow_table_cells / _realign_table_borders / _repad_table_row_to_widths, etc.).

Applies CJK-aware spacing (pangu spacing) and mid-token detection during joins: inserts a space between ASCII and CJK boundaries, but concatenates directly without spaces when broken in the middle of identifiers, paths, or hyphens.

daymade-claude-code/claude-export-txt-better/SKILL.md
**Pangu spacing**: Inserts spaces between ASCII alphanumeric characters and CJK ideographs at join boundaries.
smart_join/boundary_aware_join implements rules for CJK↔ASCII spacing and direct mid-token joining like BASE_+URL.

Output passes through multiple fidelity safety gates: strictly forbids overwriting the original file, enforces identical input/output counts for marker symbols (❯ ● ✻ ⎿ …), raises alerts for excessively wide lines (>500 display width), and uses strict UTF-8 with no silent fallbacks.

daymade-claude-code/claude-export-txt-better/SKILL.md
- Never modifies the original file - Marker counts verified: `❯`, `●`, `✻`, `⎿`, `…` must match input/output
In main(), input/output paths are resolved and output==input is rejected first; writes to disk only occur after marker-count and runaway-join checks pass.

Accompanied by a generic (file-agnostic) automated validation suite validate-claude-export-fix.py, serving as a quality gate after each fix.

daymade-claude-code/claude-export-txt-better/scripts/validate-claude-export-fix.py
Runs a comprehensive suite of checks against a fixed file and its original, reporting PASS/FAIL for each with evidence.
SKILL workflow Step 3 requires all checks to pass before delivery; referred to as '53 automated checks' in SKILL.md (asserted item by item grouped by category in the script).

Purely local with zero third-party dependencies: launched via uv run, relying solely on the Python standard library.

daymade-claude-code/claude-export-txt-better/SKILL.md
Python 3.10+ via `uv run` — zero external packages (stdlib only: `unicodedata`, `argparse`, `re`, `pathlib`, `dataclasses`).
The script makes no network or subprocess calls; uv serves merely as a runtime launcher (fetching Python 3.10+ on demand if missing on the local machine).

2Core Capabilities

01Fixes hard line-wrapping breaks in Claude Code .txt exports (paragraphs/tables/paths/tool calls/tool results)
02Applies state machine + look-ahead joining across 10 content categories while preserving agent trees and divider structures
03Table border reconstruction + column-width repadding (with pipe count tracking)
04CJK/ASCII boundary pangu spacing and mid-token unspaced direct joining
05Fidelity safety gates: preserves original files, identical marker counts, ultra-wide line alerts, strict UTF-8
06Generic automated validation suite (53 assertions) + --stats/--dry-run outputs

3External Dependencies

KindDependency / Endpoint
cliuv
clipython3 (>=3.10)

4Recommended Governance & Evidence

Suggested Controls for Safe Operation
For Agent Runtime
Graded/per-use authorization, sandbox recommended
For Administrators
Approval workflow, rollback support, full audit
Evidence & Triggers (File Paths & Excerpts)
  • scripts/: Executes local script or command: scripts/fix-claude-export.py
  • 本地工作目录: File I/O and artifact output: Outputs *-fixed.txt (defaults to <input-stem>-fixed.txt, configurable via -o; main() strictly enforces that output cannot equal input)
Audit Notes: Includes a built-in script that performs purely local text restructuring: reads user-provided export .txt files and writes to *-fixed.txt, enforcing output!=input, consistent marker counts, ultra-wide line warnings, and strict UTF-8 handling; performs no outbound network requests, reads no credentials, and accesses no settings/secret files. The only indirect touchpoint is uv run execution (which pulls Python 3.10+ from official sources on-demand if missing locally, adhering to standard toolchain behavior).

5Second-Pass Verification

  • [ok] 无网络外发(脚本层) — 全目录无 urllib/requests/http 调用,grep https?:// 零命中(连文档链接都没有)
  • [ok] 无凭证读取 — 无 os.environ/getenv/API_KEY/settings.json 读取;脚本只读用户显式传入的 export 路径
  • [ok] 不改原文件声明属实 — main() 先比较 resolve 后的 input/output 路径,相等即报错退出
  • [ok] marker 计数保真声明属实 — _count_markers 统计 ❯/●/✻/⎿/…,输出不一致打印 WARNING
  • [ok] '10 content types' 与 '53 automated checks' 能力声明 — SKILL.md What Gets Fixed 列出 10 类;validate 脚本为分 category 的断言套件,'53' 为 SKILL 侧声明数
  • [ok] 零第三方依赖声明 — 脚本 import 仅标准库;uv 只作为启动器出现于 SKILL.md 命令

6Verdict & Scenarios

  • Fix decisions are based on content patterns (look-ahead) rather than fragile width thresholds, handling real-world broken patterns such as tables, CJK, and long paths
  • Enforces original file protection programmatically in code (requiring output != input) rather than relying on prompt guidelines
  • Includes a generic validation suite and test files, establishing an automated, mechanical quality gate for deliveries
  • Zero-dependency, purely local execution with refined CJK/ASCII mixed-text formatting (pangu spacing + direct mid-token joining)
  • Best for: Suitable for any user who has a Claude Code exported .txt file with broken formatting (broken tables, wrapped paths, misaligned tool outputs, missing spaces in mixed CJK/English text) and needs to restore readability. With mechanical script fixes backed by a validation suite, human intervention is limited to spot checks, making it ideal for both individual developers and batch-processing scenarios.
    Not for: Not suitable for repairing non-.txt formats (such as raw JSON or Markdown files) or tasks requiring semantic rewriting of conversation contents; not suitable for scenarios requiring file uploads or delegation to external services (this skill is purely local); and not intended for use cases where line reduction is treated as a metric or KPI.
    Install Agent-Ready
    ① Verified Mirror 2026-09-09
    Option A · Direct DownloadDownload fixing-claude-export-conversations.tar.gz
    sha256: d5562a9e134ff1b7…
    Option B · Copy Guide for Agent
    install.json
    Agents automatically download and verify mirrors from this JSON guide.
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit d5c4678cb5.