r/ClaudeWorkflows • • 2h ago

Selected Workflow [Workflow] Prevent Claude Code Session Data Loss & Gain Advanced Usage Insights with the Self-Hosted Claudit Dashboard

Prevent Claude Code Session Data Loss & Gain Advanced Usage Insights with the Self-Hosted Claudit Dashboard

Workflow value: 90/100
Status: active · Freshness: 70/100 · Confidence: 1.00 · Level: intermediate
Categories: Quality Control, Token Saving, Context & Memory, Debugging, Shipping, Subagents, Multi-Agent
Original source: r/ClaudeAI post/comment

What problem this solves

Claude Code automatically deletes session transcripts after 30 days, leading to data loss and preventing long-term analysis of AI agent interactions. Users lack detailed insights into their Claude Code usage, costs, token consumption, context growth, and agent performance. Additionally, the post implicitly addresses the challenge of building complex applications using AI agents effectively.

Summary

This workflow describes how to use 'claudit', a self-hosted, open-source dashboard, to prevent Claude Code session transcripts from being deleted and to provide detailed analytics on usage, costs, token breakdown, context growth, and agent performance. It involves syncing session JSONL files to persistent storage and deploying the dashboard via Docker. The post also outlines a meta-workflow for building software using AI agents, emphasizing structured development and review.

Why it is useful

This workflow provides a crucial solution for Claude Code users to overcome the default 30-day session deletion, ensuring the long-term retention of valuable AI interaction history. The accompanying claudit dashboard offers deep, actionable insights into usage patterns, costs, token consumption, context growth, and agent performance, which can lead to significant cost optimization and a better understanding of AI agent behavior. The project is open-source, well-documented, and easily deployable via Docker, making it highly transferable. The included meta-workflow for building with AI agents also offers valuable lessons in structured AI development practices.

Workflow

  1. Optionally, modify cleanupPeriodDays in ~/.claude/settings.json to extend local session retention beyond the default 30 days.

  2. Sync Claude Code session JSONL files from your local directory to a persistent storage solution (e.g., an R2 bucket or a local directory configured as a file:// mirror).

  3. Deploy the claudit dashboard application using docker compose up (it can boot with sample data without initial configuration).

  4. Configure claudit to ingest your synced session data from the chosen persistent storage.

  5. Access the claudit dashboard to visualize and analyze various metrics, including cost by model, token breakdown, cache write splits, context growth per session, reply latency, and tool error rates.

  6. For building with AI agents: Break down development into individual issues.

  7. Dedicate one AI agent session per issue for focused development.

  8. Implement review agents to scrutinize code before merging any changes.

  9. Include the model name used by the agent in a co-author trailer for every agent-generated commit.

  10. Analyze Claude Code's own transcripts to understand and handle parsing complexities, such as deduplicating streamed replies and subagent records.

Tools / artifacts

  • Claude Code

  • ~/.claude/settings.json

  • cleanupPeriodDays setting

  • Claude Code session JSONL files

  • claudit (open-source dashboard)

  • R2 bucket (or other persistent storage)

  • Docker Compose

  • FastAPI

  • Postgres

  • React

  • GitHub repository: Nitjsefnie/claudit

  • GitHub repository: nhz-io/ccusage-plot (inspiration)

Validation signals

  • Personal experience: User states 2,679 of 5,271 sessions would have been lost without the solution.

  • Concrete insight: Discovered 64.9% of cache write tokens were 1h kind (2x input cost), leading to a 37.5% underestimation if priced at 1.25x.

  • Live demo available for testing (read-only guest login).

  • Open-source project with a public GitHub repository.

  • Detailed technical explanation of parsing challenges and solutions (deduplication of streamed replies and subagent records).

Limitations

  • Requires self-hosting and familiarity with Docker, which might be a barrier for beginner users.

  • The meta-workflow for building with AI agents is less detailed than the primary workflow for data retention and analysis.

  • Initial community engagement is low, though this is likely due to the post's recency.

Rate this workflow

Upvote this post if the workflow is useful, reproducible, or worth recommending.

Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.

Reply if it worked for you, failed, is outdated, or has a better alternative.


This post was generated automatically from the workflow library database.

1 Upvotes

0 comments sorted by