Skip to main content

Convert Claude Code or Codex chat sessions to Markdown

Project description

cc2md

Convert Claude Code or Codex chat sessions to Markdown.

Install

pip install cc2md

Quick Start

# Extract the most recent session
cc2md --latest -o log

# Extract the most recent Codex session
cc2md --agent codex --latest -o log

If the session spawned subagents, output is a directory:

log/
  index.md                        # main conversation, with links to subagents
  reduce-min-host-层实现-a46d2ef.md
  reduce-min-device-层实现-a95f57b.md
  ...

Otherwise, a single log.md is written.

Agent Selection

Use --agent to choose which session format to read:

cc2md --agent claude --latest -o log
cc2md --agent codex --latest -o log
  • claude reads Claude Code session logs
  • codex reads Codex rollout logs

The default is claude.

Output Format

cc2md tries to keep the transcript easy to scan without losing tool detail:

  • Sessions without subagents export as a single Markdown file
  • Sessions with subagents export as a directory
  • The main conversation is written to index.md
  • Each subagent conversation is written to its own Markdown file
  • index.md links to subagent files at the point where the subagent was spawned

Tool rendering rules:

  • Tool calls remain expanded in the transcript
  • Tool results are wrapped in <details> blocks so long outputs stay collapsible
  • Code-editing operations are rendered inline instead of being collapsed
  • Code-editing operations are shown with diff blocks when the source log contains structured edit data

Code-editing rendering currently covers operations such as:

  • Write
  • Add
  • Edit
  • MultiEdit
  • apply_patch
  • Delete / DeleteFile

Example result layout:

**Tool: exec_command**
```bash
git status --short
```

<details><summary>Result: exec_command</summary>

**Result: exec_command**
```
 M README.md
```

</details>

Example edit layout:

**Tool: apply_patch**
Applying patch
```diff
*** Begin Patch
*** Update File: README.md
@@
-old line
+new line
*** End Patch
```

**Result: apply_patch**
```
Success. Updated the following files:
M README.md
```

Usage

cc2md --list                        # list all sessions
cc2md --latest -o log               # most recent session
cc2md --agent codex --latest -o log # most recent Codex session
cc2md 1 -o log                      # by index from --list
cc2md a1b2c3 -o log                 # by UUID prefix
cc2md "auth middleware" -o log      # by title substring
cc2md --all -d ./exports/           # export everything
cc2md --latest -p myapp -o log      # filter by project

Options

Flag Description
--list, -l List available sessions
--latest Most recent session
--all Convert all sessions
--agent Source backend: claude or codex
--project, -p Filter by project path substring
--dir Scan a custom directory instead of the default source directory
--output, -o Output path
--output-dir, -d Output directory for --all
--no-subagents Exclude subagent conversations
--no-tool-results Exclude tool call results

Requirements

Python 3.10+, no external dependencies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cc2md-0.3.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cc2md-0.3.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file cc2md-0.3.0.tar.gz.

File metadata

  • Download URL: cc2md-0.3.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cc2md-0.3.0.tar.gz
Algorithm Hash digest
SHA256 efc7bbdd50719f697dc42714a5403b5b4473186f5fd409b670a12eaa363506ad
MD5 9ca586160c8a2e7bcd0088b93f5f0f5a
BLAKE2b-256 3ded893909e0b1fff4aa52c4d59c45d6776e184b9c099595cd33f08cca9db572

See more details on using hashes here.

File details

Details for the file cc2md-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cc2md-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cc2md-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79d3d56f8d94b25031e045821b2c06017af95cabfd811a4c96f0f424cd05778e
MD5 c9b8a248c1f16a45c564b7a7040e34c4
BLAKE2b-256 f0c7ab8404880f8e334c806ebb457e7cb5598cb6a1b27a3e673c9c61b9acd8ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page