Mine Your Coding Agent's Conversation History: From JSONL Goldmine to Better Rules, Hooks, and Skills

Every conversation with your coding agent is already saved on your machine as JSONL files — every prompt, tool call, and failure. This is how to turn that overlooked goldmine into concrete improvements to your rules, hooks, and skills.

Video thumbnail — The Biggest AI Coding Agent Upgrade Is Already on Your Machine?!
🎬 Cole Medin ⏱️ 17:13 📅 Sep 2026
Claude Code Conversation History MCP Self-Improvement

🎯 The Goldmine: Your Conversations, Already Saved 0:00

No matter the coding agent, every single conversation is stored as a file on your computer — in Claude Code's case, as JSONL files split by project. "Whether you know it or not, your coding agent has probably already looked through these files" — they're so rich that when you ask about past conversations, the agent gravitates to them. Each file holds every prompt, every tool or MCP call, every thought.

The problem is that the files are so rich it's overwhelming: you scroll through and think "how am I even going to use this?" The answer is to extract the good parts into a structured table, then pull insights — identify opportunities for token efficiency, find common failures to fix with rules or skills. "We are using our AI coding assistant to learn from past mistakes to make itself more efficient and reliable."

🗄️ Why You Need a Database 2:09

Two things make this process work: permanent storage (Claude Code cleans up transcripts after 30 days by default) and a database for structure. The raw JSONL is "super messy — and it's not better for any other coding agent." A database lets you split it into structured tables: sessions, tool calls, and agent turns — just the information you need. The video uses Databricks (free edition) as the platform, but the method is what matters, not the tool.

⚡ The Simple Way: One Prompt 2:57

The easiest starting point is literally one prompt: "Do a deep dive into our past conversations to identify opportunities to make our coding agent (Claude Code) more efficient or reliable. Suggest the top 10 improvements in a concise bullet point list." The bounding matters — before Opus 5.5, asking an unbounded question got "a million different things that barely mattered," so explicitly cap it at the top 10.

The agent already knows where its own conversations live (ask "where are all Claude Code conversations stored on my machine?" or search for *.jsonl). Back in Claude Code, the prompt triggers a skill that runs shell commands to read the files and list common failures. From there, each failure becomes an action: "issue number three is that I'm hitting my concurrent sub-agent limit too often — what can I change in our AI layer to fix it?" The answer points at the specific sub-agent to change.

"AI layer" is a defined term built into the skill: it's a self-audit of your sub-agents, hooks, rules, and skills — everything in your global rules or .claude folder. The prompt makes the agent audit its own setup against its own history.

📈 Why the Simple Way Doesn't Scale 5:43

The catch with the one-prompt version: it asks the agent to read hundreds of thousands of tokens of messy JSONL. Either it reads everything (expensive, slow) or it samples a few files and misses the deep patterns — neither is ideal. Other open-source projects exist (ccusage, Claude Mem) and store memory, but none the author has seen is directed specifically at making the agent more efficient and reliable over time. That's what the structured approach fixes: build the pipeline once, query it cheaply forever.

🔌 Setup: Databricks CLI + MCP 7:22

Setup is a couple of commands: install the Databricks CLI, then databricks cli ai tools install --agent claude-code (or Pi, Codex). That registers it as an MCP server, so anything you can do in the Databricks UI — upload transcripts, create tables, query — you can do from inside your coding agent. You can also drive the platform's built-in agent directly: databricks ask "…".

Then you set up storage: create a volume in the catalog, and upload your conversation files (via the MCP server, or just drag them in — the author uploaded 62 of his biggest conversations rather than thousands).

Privacy, stated plainly: you're uploading your coding-agent conversations to a new platform. The video notes Databricks' paid terms commit to "not used to train"; the free edition has its own terms that allow improving their services from what you upload — so scrub anything sensitive first (or have your agent scrub before uploading). "You shouldn't be giving sensitive information to your coding agent in the first place."

🧠 Genie Builds the Tables 10:53

Here's where it stops being manual. Genie — the agent built into Databricks with access to your whole environment — takes the volume path and processes it with Spark, so you're not spending hundreds of thousands of tokens. The prompt names the real challenge: "these are Claude Code session transcripts with inconsistent nested schemas across records" — every conversation is formatted slightly differently. Genie reads the data, understands the inconsistencies, and generates an entire notebook (the author "never writes any code these days") that creates and populates the tables: turns, tool_calls, sessions, with row counts and columns.

His process was two steps — first have Genie understand the data and prove it out, then prompt it to create the tables and load everything — but it can be a single free-form prompt ("here's the volume, create some structure so I can get takeaways from the transcripts").

🔍 Query Your History From Claude Code 13:21

Once the tables exist, analysis becomes cheap and repeatable. Back in Claude Code, you ask the same questions as the simple demo — "what patterns of failures are you seeing? What do we change in our AI layer?" — but now the agent calls out to Genie instead of reading raw files. Genie writes the SQL, analyzes the tables efficiently, and returns the core failure patterns (three of them, in the demo). The division of labor is clean: Claude Code is the orchestrator asking the right questions; Genie is the brains reading the structured data.

And because the pipeline is built, bringing in more conversations later is "a piece of cake" — no re-reading, no hundreds of thousands of tokens per analysis.

🛠️ The Real Changes: Rules, Permissions, Session-Tree Hook 14:52

The payoff is concrete, and the author kept every change. From the analysis he made three real edits to his AI layer:

  • 38 new lines in global rules addressing the specific failures found — including "never guess a path," something agents do constantly unless told otherwise.
  • Better permissions in settings.json so the agent works more smoothly with Git.
  • A "session-tree" hook — the favorite — a script that runs at the start of every new conversation and injects the real repository layout, so the agent is far less likely to guess paths when reading files. The point over a static codebase map in rules: it's dynamic — a hand-maintained layout always goes stale, this one regenerates live.
The meta-lesson: the improvements are specific to his setup, but the loop generalizes — mine your own history, surface the recurring failures, and fix them in the layer you control. "Past conversations are a goldmine; there are a lot of different ways to structure and gather insights from them and act on them."

💡 Key Takeaways

  1. Your history is already saved. Every conversation is a JSONL file with prompts, tool calls, and thoughts — the agent already reads them.
  2. Start with one prompt. "Deep dive into past conversations, suggest the top 10 improvements" — and cap the output.
  3. Structure beats raw JSONL. Split into sessions / turns / tool_calls, and analysis stops costing hundreds of thousands of tokens.
  4. Store it permanently. Claude Code purges transcripts after 30 days; a volume keeps them.
  5. Let an agent build the pipeline. Genie reads the messy nested schemas with Spark and generates the tables — no manual code.
  6. Orchestrate, don't grind. Claude Code asks the questions; Genie reads the data; you act on the answers.
  7. Act on the findings. "Never guess a path," better Git permissions, and a session-tree hook that injects the live repo layout.
  8. Mind the privacy. Free tiers may train on what you upload — scrub sensitive data first.

🔗 Resources & Links

Source video: youtube.com/watch?v=td52e2tQFIU. Full disclosure in the video: Databricks sponsored it, and the "not used to train" commitment applies to paid terms (free edition differs). The method is tool-agnostic.

⏱️ Timestamp Index

0:00 Your conversations are a goldmine
2:09 Why you need a database
2:57 The simplest way to start
5:43 Why simple doesn't scale
7:22 Install CLI + MCP
8:55 Upload your conversations
10:53 Genie builds the tables
13:21 Query from Claude Code
14:52 The real changes made
16:43 Final thoughts
☰ View all