← Back to list

Claude Code + MLflow Traces: Log Every Prompt You Send

Log and analyze every Claude Code conversation with MLflow, locally or on Databricks

Sudarshan Koirala · 2026-05-30 07:01 · 1 claps · 2.8 min read
#claude-code #mlflow #databricks #llm-traces #prompt-engineering
Open on Medium ↗
Wiki topics: LLM · Large Language Models 🔧 · Data Engineering

Claude Code + MLflow Traces: Log Every Prompt You Send

Log and analyze every Claude Code conversation with MLflow, locally or on Databricks

👨🏾‍💻 GitHub ⭐️ | 🐦 Twitter | 📹 YouTube | 👔 LinkedIn | ☕️ Ko-fi

Image by Author

Image by Author

When you use Claude Code, every prompt you type lives only in the session history. Once you close the terminal, it’s gone. No trace, no audit, no way to look back at what was asked or how much it cost.

This post is about fixing that, using MLflow to log every conversation from Claude Code so you can inspect prompts, token counts, latency, and session details. I’ll show two setups: running MLflow locally on your machine, and using Databricks managed MLflow with Unity Catalog and Genie on top.

What gets logged?

For every question you ask in Claude Code, MLflow captures:

  • The full prompt and model response
  • Token count (input, output, cache read/write)
  • Latency
  • Session ID
  • Tool calls (like web search) with the queries and results

If you’re using an API key instead of a Pro subscription, cost is included too.

Setup: what you need

Two things before anything else:

  • UV installed (uv --version to check)
  • Claude Code installed (claude --version to check)

Then create a project folder and add MLflow (version 3.4 or higher for the autolog feature):

mkdir mlflow_claude_code_traces && cd mlflow_claude_code_traces
uv init
uv add "mlflow>=3.4"

Option 1: Local MLflow server

Start the MLflow tracking server:

uvx mlflow server

It runs on localhost:5000. Open that in your browser, you'll see the MLflow UI with no traces yet.

Now enable autologging for Claude Code:

uv run mlflow-autolog claude

This configures a stop hook inside Claude Code. Every time you finish a prompt, the hook fires and sends the trace to MLflow.

Open Claude Code and ask something. Then refresh the MLflow UI, the trace appears under the default experiment with all the details.

One thing to note: run the MLflow server after your Claude session if traces aren’t showing up. The server reads from the SQLite file on disk, so order of operations matters.

Option 2: Databricks managed MLflow

The local setup works fine, but Databricks gives you persistence (no managing servers), Unity Catalog governance, and Genie on top.

First, authenticate your Databricks CLI:

databricks auth login --host <your-workspace-url>

Then enable autologging pointing to Databricks:

uv run mlflow-autolog claude --databricks -e /Users/your-email/mlflow-claude-traces

This creates an experiment in your Databricks workspace. No local server needed, traces go directly to Databricks.

Open Claude Code, ask a few questions, and check the experiment in the Databricks UI. You’ll see the same trace details as locally, plus web search tool calls with queries and source URLs.

Sync to Unity Catalog + Genie

Once traces are logging to Databricks, you can sync them to a Unity Catalog Delta table. In the experiment view, click “Delta sync not enabled” and set a table name like catalog.schema.mlflow_claude_traces. Hit Enable.

After a short sync delay, the table appears in Unity Catalog with all traces as rows, full governance and lineage included.

From there, open a Genie space and point it at the table. You can ask questions like:

  • “Which sessions used the most tokens?”
  • “What tools were called and how often?”
  • “Show me performance trends across sessions”

Genie reads the Delta table and gives you natural language insights on top of your actual Claude Code usage, great for teams that want to track AI usage across projects.

I have made this post for all readers. Not under the paid wall.

I will keep posting content under the free plan, all I need is your support:

  • Clap 50 times: each one helps more than you think! 👏
  • Follow me here on Medium and subscribe for free to catch my latest posts. 🫶

No more text here -> this is the content covered in the video 👇

Link to video 👇 Happy learning 😎

[embed]

👨🏾‍💻 GitHub ⭐️ | 🐦 Twitter | 📹 YouTube | 👔 LinkedIn | ☕️ Ko-fi

Thank you for your time in reading this post!

Make sure to leave your feedback and comments. See you in the next blog, stay tuned 📢


메타데이터
post_id
d35e9ee4b1de
slug
claude-code-mlflow-traces-log-every-prompt-you-send-d35e9ee4b1de
url
https://medium.com/@sudarshan-koirala/claude-code-mlflow-traces-log-every-prompt-you-send-d35e9ee4b1de
canonical_url
https://medium.com/@sudarshan-koirala/claude-code-mlflow-traces-log-every-prompt-you-send-d35e9ee4b1de
author_url
https://medium.com/@sudarshan-koirala
status
ok
fetched_at
2026-06-09 15:37:30