3 min read

Her: A Detective for Your Claude Code Sessions

Claude CodeSession AnalysisForensic ToolDeterministic EngineCode InsightsHugging Face

Executive Summary

Her, a detective tool for Claude Code sessions, transforms the traditionally opaque and complex task of analyzing execution traces into an engaging and informative process. This tool allows engineers to dissect JSONL session files and interpret the operational details with ease, enabling informed decisions based on actionable insights.

The Architecture / Core Concept

At its core, Her is designed to interpret and analyze Claude Code sessions by reading `.jsonl` files that capture every interaction, tool call, and token used in a session. Instead of going through thousands of lines of data manually, Her delivers a summary in plain English. This is achieved through a deterministic evaluation engine which processes each line of data. The model used, `Nemotron-Mini-4B-Instruct`, helps translate technical data into human-readable language but doesn’t intervene in the analysis itself, ensuring objectivity.

The session file analysis involves tracking command executions, tool usage, and identifying potential risks like deploys or configuration changes. Her’s capability to catalog tools using a built-in database enhances its utility, especially by recognizing executions and suggesting corrective patterns based on best practices from Anthropic and the developer community.

Implementation Details

Her operates on a decentralized architecture, running entirely within the secure confines of the Hugging Face space. It uses React for the frontend interface, enabling users to interact seamlessly with the core functions such as session review and project analysis. The backend employs a Gradio server, which works in tandem with the deterministic engine for thorough forensic analysis.

Here's a conceptual example of how Her might be invoked functionally in a project ecosystem:

class SessionAnalyzer:
    def __init__(self, session_file):
        self.session_file = session_file

    def analyze(self):
        session_data = self._parse_jsonl(self.session_file)
        report = self._generate_report(session_data)
        return report

    def _parse_jsonl(self, file_path):
        # Code to read and parse the JSONL file
        # Returns parsed structured data
        pass

    def _generate_report(self, data):
        # Code to analyze data and generate human-readable report
        pass

# Usage
analyzer = SessionAnalyzer("path/to/session.jsonl")
report = analyzer.analyze()
print(report)

This example illustrates the translation of complex data structures into summarized reports, crucial in backend operations.

Engineering Implications

Scalability and Performance: The architecture is designed to handle multiple session files concurrently, supporting both singular and project-wide analysis efficiently. Given the zero external dependencies on third-party AI APIs, Her minimizes latency and enhances the security of data processing.

Cost and Complexity: The in-house processing mechanism reduces potential costs associated with cloud service integrations, while the split between deterministic evaluation and language generation ensures a balance between complexity and reliability.

My Take

Her represents a significant advancement in how we approach code session analytics, particularly in the context of AI-driven coding environments. Its capacity to democratize code analysis without jeopardizing security makes it a valuable addition for engineering teams. As the reliance on automated tools continues to grow, future iterations of Her could further integrate proactive optimization mechanisms, enhancing its role not only as a detective but also as an advisor in coding sessions.

Share this article

J

Written by James Geng

Software engineer passionate about building great products and sharing what I learn along the way.