Skip to main content

cchat

Tests codecov PyPI Python License: MIT

Browse and search Claude Code conversation history from the terminal.

cchat reads the JSONL conversation logs that Claude Code stores in ~/.claude/projects/ and presents them as readable conversation turns. It handles compaction stitching, branch detection, and the full UUID tree structure so you don't have to parse raw JSONL yourself.

Install

pip / pipx

pip install cchat
# or
pipx install cchat

curl (no pip needed)

curl -fsSL https://raw.githubusercontent.com/asparagusbeef/cchat/main/cchat.py \
  -o ~/.local/bin/cchat && chmod +x ~/.local/bin/cchat

wget

wget -qO ~/.local/bin/cchat \
  https://raw.githubusercontent.com/asparagusbeef/cchat/main/cchat.py && chmod +x ~/.local/bin/cchat

PowerShell (Windows without WSL)

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/asparagusbeef/cchat/main/cchat.py" `
  -OutFile "$env:LOCALAPPDATA\cchat\cchat.py"

Note: cchat reads ~/.claude/projects/ which is a Linux/macOS path. On native Windows (not WSL), Claude Code may store data differently.

Quick start

# List recent sessions in the current project
cchat list

# View the last 5 turns of the latest session
cchat view

# View a specific session (by index from list)
cchat view 2

# Search across all sessions
cchat search "error handling"

Commands

Command Alias Description
cchat list [N] ls List recent sessions (default: 10)
cchat view [SESSION] v View conversation turns
cchat copy [SESSION] cp Copy messages to clipboard (WSL)
cchat search PATTERN s Search across sessions
cchat tree [SESSION] Show conversation tree structure
cchat export [SESSION] Export full session (markdown or JSON)
cchat projects List all projects

View options

Flag Description
-n N Show last N turns
-r RANGE Show specific turns: 5, 3-7, -1, -3--1
--all Show all turns
--tools Show tool call summaries
--raw Show everything (tool I/O, thinking, system)
--json Output as JSON
--no-stitch Don't bridge compaction boundaries
--timestamps Show timestamps
--compact-summaries Include compaction summary messages
--truncate LEN Truncate length for raw content (default: 500)
-p PATH Use a different project directory

Session selection

Sessions can be specified by:

  • Index: cchat view 2 (2nd most recent from cchat list)
  • UUID prefix: cchat view a1b2c3 (matches session ID)
  • Omitted: uses the most recent session

How it works

Claude Code stores each conversation as a JSONL file in ~/.claude/projects/<project-key>/. Each line is a JSON entry with a type (user, assistant, system, etc.) and a UUID-based parent-child tree.

cchat:

  1. Resolves the active path by walking the UUID tree from the last entry backward
  2. Stitches across compaction boundaries using logicalParentUuid links (or positional fallback)
  3. Groups entries into turns (one user message + full assistant response)
  4. Detects branch points by filtering out mechanical fan-out (tool_use forks, progress entries)

Requirements

  • Python 3.8+
  • No dependencies (stdlib only)
  • Clipboard copy uses clip.exe (WSL) — other platforms not yet supported

Contributing

Setup

git clone https://github.com/asparagusbeef/cchat.git
cd cchat
pip install -e ".[test]"

Running tests

pytest -v                          # full suite
pytest tests/test_session.py -v    # single module
pytest --cov=cchat --cov-report=term   # with coverage

Project structure

cchat.py          # entire application (single-file)
tests/
  conftest.py     # shared fixtures, mock project dirs
  fixtures/       # synthetic JSONL sessions matching real Claude Code format
  test_utils.py
  test_formatting.py
  test_session.py
  test_message_extraction.py
  test_project_resolver.py
  test_session_index.py
  test_cli.py

Test fixtures are synthetic JSONL files that match the real Claude Code session format (streaming chunks, UUID trees, compaction boundaries). See tests/fixtures/ for examples of the expected data shape.

Guidelines

  • Keep it as a single Python file with zero runtime dependencies.
  • Tests go in tests/. Fixtures go in tests/fixtures/.
  • Run the full test suite before opening a PR.

License

MIT

Metadata

Release files for cchat 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cchat 1.0.0
File Size Uploaded Provenance Actions
cchat-1.0.0.tar.gz 20.8 kB With provenance Details for cchat-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cchat 1.0.0
File Interpreter ABI Platform Actions
cchat-1.0.0-py3-none-any.whl Python 3 none any Details for cchat-1.0.0-py3-none-any.whl

Total release size: 40.5 kB

Release files / cchat-1.0.0.tar.gz

Download URL cchat-1.0.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
db7c13fb74a4b19e7fa9c252b01ce32cf4216ec1cfafb3e3ae7cdd569db346af
BLAKE2b-256 checksum
How to use checksums
074de93214f2943e36f27e1a417bede56d4b038d3c37ebd5f650966621e1a1a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Release files / cchat-1.0.0-py3-none-any.whl

Download URL cchat-1.0.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3a329a4cf657a0afa1a03375abe0d8637c0c6681b72f6415a7efed41f5de62a
BLAKE2b-256 checksum
How to use checksums
d995586faa96a8d0424a76ef1f4cefc372eb645e76a0a281476b8f7ee2c29043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

Security for cchat 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cchat-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page