Logging AI conversations (Claude Code)

In talking to the Uk developers, about keeping a record of Claude Code conversations, it was mentioned that CC transcripts are kept for 30 days.

Google search AI gave this response about exporting these :

Keeping logs of Claude Code transcripts is crucial for maintaining context over long-term projects and reviewing AI-generated code. Claude Code locally stores your conversation history, which can be accessed, searched, and exported using various tools.

1. Default Local Logging

Claude Code automatically records sessions in your local environment, typically stored in JSONL format.

  • Location: ~/.claude/ (on Mac/Linux).

  • Project-Specific: Logs for specific projects are in ~/.claude/projects/, with folders named based on the project path.

  • Retention: By default, logs are retained for 30 days, though this is configurable.

2. Tools for Exporting and Viewing Logs

Several community tools help convert these raw logs into readable formats (Markdown/HTML):

  • claude-code-transcripts: A Python CLI tool (uvx claude-code-transcripts) that allows you to select local Claude Code sessions and convert them into detailed HTML pages.

  • claude-code-log: A Python tool to generate clean, chronological HTML pages of user prompts and assistant responses.

  • conversation-logger: A tool to save JSONL transcripts, parse them into markdown, and enable full-text search.

  • SpecStory: A wrapper that launches Claude Code and automatically saves conversations to .specstory/history/ in your project directory in Markdown.

3. Best Practices for Logging and Context

  • Search History: You can ask Claude Code directly to search through your past conversations: “What did we talk about regarding X today?”.

  • Use /clear: For long sessions, use the /clear command to reset the context while still saving the previous transcript, keeping the prompt history clean.

  • Commit Logs: Consider adding your log directory (e.g., .specstory/history/) to version control to document why changes were made.

  • Alternative Storage: For, very long sessions, consider having Claude create a summary or a “Decision State” (Plan/Stack/Constraints) to carry over to a new session.

4. Privacy and Security

  • Zero Data Retention: You can configure API keys to not retain chat transcripts on servers.

  • Local Storage: Be aware that ~/.claude/ may store detailed data, including inputs and outputs.

The first option mentioned lives here :

And seems to do a pretty good job :

Output options

All commands support these options:

  • -o, --output DIRECTORY - output directory (default: writes to temp dir and opens browser)

  • -a, --output-auto - auto-name output subdirectory based on session ID or filename

  • --repo OWNER/NAME - GitHub repo for commit links (auto-detected from git push output if not specified)

  • --open - open the generated index.html in your default browser (default if no -o specified)

  • --gist - upload the generated HTML files to a GitHub Gist and output a preview URL

  • --json - include the original session file in the output directory

The generated output includes:

  • index.html - an index page with a timeline of prompts and commits

  • page-001.html, page-002.html, etc. - paginated transcript pages

1 Like

Well.

Ahem.

There is also “ /export filename ” right in Claude Code.

How about that. :confused: