explaingit

w-yariki/claude-session-cleaner

Analysis updated 2026-05-18

0PythonAudience · developerComplexity · 2/5Setup · easy

TLDR

A small Python script that reformats messy Claude Code session log files into clean, readable text for studying how the AI works.

Mindmap

mindmap
  root((repo))
    What it does
      Cleans session logs
      Renders newlines
      Adds line separators
    Tech stack
      Python
    Use cases
      Study LLM behavior
      Debug Claude Code
    Audience
      Developers
      Learners

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Clean up a raw Claude Code session log to read it without noisy JSON fields.

USE CASE 2

Compare a fully cleaned output against a newline-only render to see what the script strips.

USE CASE 3

Study exactly what information gets fed into an LLM during a coding session.

What is it built with?

Python

How does it compare?

w-yariki/claude-session-cleaner0xhassaan/nn-from-scratch3ks/embedoc
Stars00
LanguagePythonPythonPython
Last pushed2023-06-08
MaintenanceDormant
Setup difficultyeasymoderatehard
Complexity2/54/51/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

In plain English

This project is a small Python script called clean_session.py. It takes the raw log files that Claude Code, an AI coding tool, creates while you work with it, and turns them into something a person can actually read. Claude Code saves every session as a .jsonl file, a format where each line is its own small chunk of data. These files record everything that happens during a coding session: your messages, the AI's replies, tool calls, and a lot of internal bookkeeping information most people never look at. Reading them directly is messy, since they are packed with technical fields and escaped characters instead of normal line breaks. This script cleans that up. It removes bookkeeping fields you would not care about, such as internal IDs, timestamps, and file paths. It turns escaped newline characters back into real line breaks so the text reads naturally. It also adds a separator before each remaining entry, showing its original line number and who or what produced it: a person, the AI, the system, or a summary. Because line numbers are kept from the original file, you can tell where something was removed just by seeing a gap in the numbering. At the top of the cleaned file, it prints a short summary with statistics about the session. The README frames this as a learning tool for people curious about how large language models like Claude actually work behind the scenes. It suggests running small experiments, such as clearing context, disabling parts of the interface, or comparing a fully cleaned file against a version where only the newline formatting was fixed, to notice what information is fed to the model and what is not. Using it requires only Python 3.8 or newer, no other dependencies. You run it from the command line, pointing it at one of your session log files, and it writes a cleaned version to an output folder you can customize. This is a niche, personal utility rather than a general-purpose tool, aimed at people who already use Claude Code and want to inspect what happens under the hood.

Copy-paste prompts

Prompt 1
Explain what each field in a Claude Code session log represents.
Prompt 2
Help me write a Python script that parses JSONL files like this one.
Prompt 3
Show me how to extend this script to also strip out tool-call outputs.
Prompt 4
Walk me through comparing the render-only output to the fully cleaned output.

Frequently asked questions

What is claude-session-cleaner?

A small Python script that reformats messy Claude Code session log files into clean, readable text for studying how the AI works.

What language is claude-session-cleaner written in?

Mainly Python. The stack also includes Python.

How hard is claude-session-cleaner to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is claude-session-cleaner for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.