修复克劳德导出对话
- 作者仓库星标 0
- 作者更新于 2026年8月24日 07:33
- 作者仓库 claude-code-skills
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @daymade · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- Python >=3.10
- 检测到的文件与系统行为
-
- 只读
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# 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 (53 automated checks)
uv run <skill-path>/scripts/validate-claude-export-fix.py <export.txt> fixed.txt
# Fixing Claude Code Export Conversations
Reconstruct broken line wrapping in Claude Code exported `.txt` files.
## Quick Start
```bash
# 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 (53 automated checks)
uv run <skill-path>/scripts/validate-claude-export-fix.py <export.txt> fixed.txt
```
Replace `<skill-path>` with the resolved path to this skill's directory. Find it with:
```bash
find ~/.claude -path "*/fixing-claude-export-conversations/scripts" -type d 2>/dev/null
```
## Workflow
Copy 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 user
```
**Step 1: Locate the file.** Claude Code exports use the naming pattern `YYYY-MM-DD-HHMMSS-<slug>.txt`.
**Step 2: Run the fix script.**
```bash
uv run <skill-path>/scripts/fix-claude-export.py <input.txt> -o <output.txt> --stats
```
Review the stats output — typical results: 20-25% line reduction, 80+ table borders fixed, 160+ table cells fixed.
**Step 3: Run the validation suite.**
```bash
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:
- Tables have intact borders (box-drawing characters on single lines)
- CJK/English mixed text has pangu spacing (`Portal 都需要`, not `Portal都需要`)
- Tool result blocks (`⎿`) have complete content on joined lines
- Diff output within tool results has each line number on its own line
**Step 5: Deliver** the fixed file to the user.
## What Gets Fixed
The script handles 10 content types using a state-machine with next-line look-ahead:
- **User prompts** (`❯` prefix, dw=76 padding) — paragraph joins with pangu spacing
- **Claude responses** (`●` prefix) — narrative, bullet, and numbered list joins
- **Claude paragraphs** (2-space indent) — next-line look-ahead via `_is_continuation_fragment`
- **Tables** — border reconstruction, cell re-padding with pipe-count tracking
- **Tool calls** (`● Bash(` etc.) — path and argument reconstruction
- **Tool results** (`⎿` prefix) — continuation joins including deeper-indented fragments
- **Plan text** (5-space indent) — next-line look-ahead via `_is_plan_continuation_fragment`
- **Agent tree** (`├─`/`└─`) — preserved structure
- **Separators** (`────`, `---`) — never joined
- **Tree connectors** (standalone `│`) — preserved
## Key Design Decisions
**Next-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`).
## Safety
- Never modifies the original file
- Marker counts verified: `❯`, `●`, `✻`, `⎿`, `…` must match input/output
- Runaway join detection: warns if any line exceeds 500 display-width
- Strict UTF-8 encoding — no silent fallbacks
## Dependencies
Python 3.10+ via `uv run` — zero external packages (stdlib only: `unicodedata`, `argparse`, `re`, `pathlib`, `dataclasses`). 章节与文件索引
按说明文件中的顺序排列。
快速入门
工作流程
修复了什么
关键设计决策
安全
文件/命令 -> .txt · <skill-path> · YYYY-MM-DD-HHMMSS-<slug>.txt · --verbose · Portal 都需要 · Portal都需要 · _is_continuation_fragment · ● Bash(
内容校验值 -> 00d664e90d48
当前原文的自动摘译,尚未人工审校。
快速入门
将
<skill-path>替换为该技能目录的解析路径。找到它:工作流程
复制此清单并跟踪进度: 第 1 步:找到该文件。 Claude Code 导出使用命名模式
YYYY-MM-DD-HHMMSS-<slug>.txt。步骤 2:运行修复脚本。查看统计输出 - 典型结果:行数减少 20-25%、固定 80 多个表格边框、固定 160 多个表格单元格。第 3 步:运行验证套件。修复了什么
该脚本使用具有下行前瞻功能的状态机处理 10 种内容类型: 用户提示(
❯前缀,dw=76 填充)— 段落以盘古间距连接 Claude 响应(●前缀)— 叙述性、项目符号和编号列表连接 Claude 段落(2 个空格缩进)— 通过_is_continuation_fragment进行下一行前瞻 表格 — 边框重建、单元格通过管道计数跟踪重新填充关键设计决策
下一行前瞻(不是 dw 阈值):而不是问“这行是否已换行?” (脆弱阈值),脚本询问“下一行看起来像延续吗?”通过检查其内容模式——小写开头、CJK 表意文字开头、左括号、连字符/斜杠/下划线延续。盘古间距:在连接边界处的 ASCII 字母数字字符和 CJK 表意文字之间插入空格。还会触发与 CJK 相邻的
%、#、+、:。安全
绝不修改原始文件 已验证的标记计数:
❯、●、✻、⎿、…必须匹配输入/输出 失控连接检测:如果任何行超过 500 显示宽度,则会发出警告 严格的 UTF-8 编码 — 无静默回退