---
name: ai-conversation-extractor
description: "Convert AI conversation transcripts (Claude Code, Codex CLI, ChatGPT JSONL; Cursor IDE SQLite) to readable Markdown. Use when the user wants to: (1) convert .jsonl conversation transcripts to .md, (2) strip binary/base64 data from AI conversation logs, (3) make AI conversation history human-readable, (4) process session exports from ~/.claude/ or ~/.codex/, (5) batch-convert a folder of conversation JSONL files, or (6) list, search, or export Cursor IDE chat/composer conversations. Triggers on mentions of JSONL conversations, transcript conversion, conversation export, readable conversation logs, or Cursor chat history."
title: ai-conversation-extractor
canonical_url: https://skilld.dev/gh/vicnaum/vics-agent-skills/ai-conversation-extractor
last_updated: 2026-09-28T16:26:05.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/cursor_extract.py](https://skilld.dev/api/skills-raw/vicnaum/vics-agent-skills/ai-conversation-extractor/scripts/cursor_extract.py), [scripts/extract.py](https://skilld.dev/api/skills-raw/vicnaum/vics-agent-skills/ai-conversation-extractor/scripts/extract.py), [scripts/README.md](https://skilld.dev/api/skills-raw/vicnaum/vics-agent-skills/ai-conversation-extractor/scripts/README.md).
>
> If the user asked to install this Skill, run `npx skilld install vicnaum/vics-agent-skills/ai-conversation-extractor`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/ai-conversation-extractor`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/vicnaum/vics-agent-skills/ai-conversation-extractor) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/ai-conversation-extractor`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/ai-conversation-extractor --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/ai-conversation-extractor --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# ai-conversation-extractor

Convert AI conversation transcripts (Claude Code, Codex CLI, ChatGPT/Gemini JSONL; Cursor IDE SQLite storage) to clean, readable Markdown files. Strips binary blobs (base64 images, PDFs — typically 95%+ of file size) while preserving all human-readable content: user messages, assistant text, thinking, tool calls, and tool results.

See `scripts/README.md` for full JSONL format documentation.

## Supported Formats

Auto-detected from file content — no flags needed:

| Format | Source | Typical location |
|--------|--------|------------------|
| **Claude Code** | Claude Code CLI sessions | `~/.claude/projects/*/*.jsonl` |
| **Codex CLI** | OpenAI Codex CLI sessions (event stream with `timestamp`/`type`/`payload`) | `~/.codex/sessions/*.jsonl` |
| **Codex history** | Codex CLI prompt history (`session_id`/`ts`/`text`) — user prompts only | `~/.codex/history.jsonl` |
| **Simple** | ChatGPT / Gemini exports (`role`/`message`) | varies |
| **Cursor** | Cursor IDE chat/composer conversations (SQLite, via `cursor_extract.py`) | `~/Library/Application Support/Cursor/User/globalStorage/state.vscdb` |

## Usage

Run the script at `scripts/extract.py` (within this skill's directory):

```bash
# Single file — outputs .md alongside the .jsonl
python3 <skill-dir>/scripts/extract.py <file.jsonl>

# Single file with custom output path
python3 <skill-dir>/scripts/extract.py <file.jsonl> -o output.md

# All .jsonl in a directory
python3 <skill-dir>/scripts/extract.py <directory>

# Recursive (includes subdirectories)
python3 <skill-dir>/scripts/extract.py <directory> --recursive

# Messages-only view (user + final assistant response per turn, no tools/thinking)
python3 <skill-dir>/scripts/extract.py <file.jsonl> --ua-final-only

# Batch convert to a specific output directory
python3 <skill-dir>/scripts/extract.py <directory> --out-dir ./converted/

# Keep Codex environment context and boilerplate in messages-only mode
python3 <skill-dir>/scripts/extract.py <file.jsonl> --ua-final-only --keep-env-context --keep-agent-boilerplate
```

No external dependencies — uses only Python 3.12+ stdlib (`json`, `re`, `pathlib`, `argparse`, `sqlite3`).

### Cursor IDE conversations

Cursor stores conversations in a global SQLite DB (`cursorDiskKV` table: `composerData:<id>` metadata rows + `bubbleId:<composerId>:<bubbleId>` message rows; old versions inline the conversation in `composerData`). Use `scripts/cursor_extract.py` (opens the DB read-only, safe with Cursor running):

```bash
# List all conversations (newest first): composerId, last-updated, message count, title
python3 <skill-dir>/scripts/cursor_extract.py --list [--limit 50]

# Find conversations whose content matches a regex (full DB scan — can take minutes on multi-GB DBs)
python3 <skill-dir>/scripts/cursor_extract.py --grep "AccessManager|rate.?limit"

# Extract specific conversations to Markdown (named <title-slug>-<id8>.md)
python3 <skill-dir>/scripts/cursor_extract.py <composerId> [<composerId>...] --out-dir ./converted/

# Extract everything / use a custom DB path (e.g. Linux/Windows)
python3 <skill-dir>/scripts/cursor_extract.py --all --out-dir ./converted/ --db <path/to/state.vscdb>
```

Output uses the same Markdown conventions as `extract.py`. Notes: per-message timestamps are not stored by Cursor (only conversation-level created/updated times, used for frontmatter and file mtime); tool results in very recent Cursor versions may live in encrypted blobs and show as tool calls without results.

### CLI Flags

| Flag | Description |
|------|-------------|
| `-o`, `--output` | Custom output path (single-file mode only) |
| `-r`, `--recursive` | Recurse into subdirectories |
| `--ua-final-only` | Messages-only view: keeps user messages and final assistant response per turn, drops tool calls/results/thinking |
| `--out-dir` | Output directory for batch mode (writes `<stem>.md` into this folder) |
| `--keep-env-context` | With `--ua-final-only`: retain Codex `<environment_context>` user messages (dropped by default) |
| `--keep-agent-boilerplate` | With `--ua-final-only`: retain Codex AGENTS.md/skills boilerplate messages (dropped by default) |

## What Gets Stripped

- Base64-encoded images and documents (biggest savings)
- `<system-reminder>` tags injected by the tool
- `file-history-snapshot` records (editor state backups)
- `progress` records (hook events)
- `system` records (turn durations, metadata)
- Meta messages (`isMeta: true`, like `/init` injections)
- Line-number prefixes from file reads (`   123→`)

## What Gets Preserved

- User text messages (full)
- Assistant text responses (full)
- Assistant thinking blocks (truncated at 3000 chars, in `<details>` tags)
- Tool calls (name + JSON input, truncated at 4000 chars)
- Tool results (text content, full; no truncation)
- Image/document placeholders (e.g., `*[attached document: application/pdf]*`)
- Error results from rejected tool uses
- Per-message timestamps (Claude Code format only)
- Source file metadata (YAML frontmatter) and filesystem mtime (output .md matches source .jsonl mtime for natural sort-by-date)

## Output Format

- **YAML frontmatter**: `source`, `modified` (ISO 8601) for parseable metadata
- **Filesystem**: Output .md file's modification time is set to match the source .jsonl, so `ls -t` or Finder sort-by-date preserves conversation order
- Markdown with `## User` / `## Assistant` headings separated by `---`. Per-message timestamps shown as `*2026-02-09T23:51:07Z*` when available (Claude Code format). Tool calls formatted as `**Tool: \`Name\`**` with JSON code blocks. Tool results as `**Result** (\`id\`):` with code blocks.
