claude-code-data
    Preparing search index...

    Type Alias ParsedSession

    Aggregated data extracted from a Claude Code session.

    type ParsedSession = {
        agentName: string | undefined;
        agentSetting: string | undefined;
        aiTitle: string | undefined;
        apiDurationMs: number;
        assistantMessageCount: number;
        claudeCharsByFile: Record<string, number> | undefined;
        contextByTurn: ContextTurn[];
        customTitle: string | undefined;
        durationMs: number;
        firstPrompt: string | undefined;
        firstTimestamp: string | undefined;
        gitBranch: string | undefined;
        hourOfDay: number[];
        lastContextTokens: number;
        lastModel: string | undefined;
        lastPrompt: string | undefined;
        lastTimestamp: string | undefined;
        mode: "coordinator" | "normal" | undefined;
        permissionMode: string | undefined;
        primaryModel: string | undefined;
        prNumber: number | undefined;
        prRepository: string | undefined;
        prUrl: string | undefined;
        sessionId: string | undefined;
        skillUsage: Record<string, number>;
        summary: string | undefined;
        tag: string | undefined;
        taskSummary: string | undefined;
        tokens: TokenBuckets;
        tokensByModel: Record<string, TokenBuckets>;
        toolUsage: Record<string, number>;
        userMessageCount: number;
        worktreeBranch: string | undefined;
        worktreePath: string | null | undefined;
    }
    Index

    Properties

    agentName: string | undefined

    Custom agent name set via /rename or swarm configuration.

    agentSetting: string | undefined

    Agent preset name used for this session (from --agent CLI flag or settings.agent). Displayed as @<agentSetting> in the Claude Code session list.

    aiTitle: string | undefined

    AI-generated title. Fallback after customTitle.

    apiDurationMs: number

    API duration in milliseconds — sum of system/turn_duration.durationMs events. The time Claude spent processing requests, excluding user idle time. Always less than ParsedSession.durationMs (wall-clock).

    assistantMessageCount: number

    Number of unique assistant API calls.

    Stricter than CC's raw count: deduplicated on messageId+requestId (so /resume replays of previous assistant entries are counted once) and excludes <synthetic> sentinel messages (compact summaries injected internally by CC).

    Like CC's own metric, includes subagent assistant turns — there is no isSidechain filter on the assistant side, mirroring the asymmetry with ParsedSession.userMessageCount.

    claudeCharsByFile: Record<string, number> | undefined

    Characters written by Claude per file path, from the last attribution-snapshot entry. Last-wins — CC never shrinks fileStates, so the final snapshot holds cumulative totals. undefined when the session has no attribution-snapshot events.

    Note: attribution-snapshot is gated behind CC's internal COMMIT_ATTRIBUTION feature flag and is not emitted by public CC builds. This field will be undefined for all users of the public CC release.

    Mirrors CC commitAttribution.ts restore logic: only the last snapshot is used, never summed across snapshots (which would cause quadratic count inflation).

    contextByTurn: ContextTurn[]

    Per-turn token snapshots, ordered chronologically. Useful for rendering context window fill over time.

    customTitle: string | undefined

    User-defined title set via /title. Wins over all other title sources.

    durationMs: number

    Wall-clock duration in milliseconds (lastTimestamp - firstTimestamp).

    firstPrompt: string | undefined

    First meaningful user prompt, extracted with CC-exact logic (mirrors extractFirstPromptFromHead from sessionStoragePortable.ts):

    • <bash-input>cmd</bash-input>! cmd
    • Skips XML-like prefixes (<tag>), [Request interrupted...], tool results, isMeta, isCompactSummary, and subagent turns
    • Truncated to 200 chars +
    • Falls back to the first <command-name> value (e.g. /voice"voice")
    firstTimestamp: string | undefined

    ISO timestamp of the first entry.

    gitBranch: string | undefined

    Git branch at session end (last-wins, mirrors Claude Code convention).

    hourOfDay: number[]

    Human user message count per local hour of day [0..23]. Mirrors insights.ts in Claude Code — tracks when the user actively typed, not when the model responded. Useful for "when do you work" heatmaps.

    lastContextTokens: number

    Context window fill at session end: input + cacheRead + cacheCreation of the last deduplicated assistant turn. output is excluded because it is not part of the prompt sent to the model — it represents what you'd resume from if you called /resume now. 0 if the session has no assistant turns with token data.

    lastModel: string | undefined

    Model used in the last assistant turn. CC uses the sentinel string '<synthetic>' for internally-injected messages (e.g. compact summaries) — those are excluded here.

    lastPrompt: string | undefined

    Last user prompt captured by Claude Code at session end.

    lastTimestamp: string | undefined

    ISO timestamp of the last entry.

    mode: "coordinator" | "normal" | undefined

    Session mode: 'coordinator' when orchestrating subagents, 'normal' otherwise.

    permissionMode: string | undefined

    Permission level active for the session (from permission-mode events). Observed values: 'default', 'acceptEdits', 'plan'. Not exhaustive — CC may emit additional values in future versions.

    primaryModel: string | undefined

    Most-used model by turn count (statistical mode). Excludes '<synthetic>' sentinel. Differs from lastModel when the user switched models mid-session. Tie-breaking is insertion-order dependent (first model with the highest count wins).

    prNumber: number | undefined

    GitHub PR number linked to this session.

    prRepository: string | undefined

    Repository in owner/repo form.

    prUrl: string | undefined

    Full PR URL as written by Claude Code. Never reconstructed from prRepository.

    sessionId: string | undefined

    Session UUID. undefined if the file is empty or contains no entry with a sessionId field.

    skillUsage: Record<string, number>

    Skill invocation counts keyed by skill name. Skills are Claude Code slash-command extensions invoked via the Skill tool (e.g. ultrareview, voice). Keyed by input.skill from the tool_use block.

    summary: string | undefined

    Most recent auto-compact summary injected when CC compressed the context. Last-wins — a session can have multiple compaction events.

    tag: string | undefined

    User-defined tag label attached to the session.

    taskSummary: string | undefined

    Most recent periodic fork summary written every min(5 steps, 2 min). Mirrors what claude ps shows as the current task description.

    tokens: TokenBuckets

    Cumulative token usage for the session. Deduplicated on messageId+requestId/resume replays are counted once.

    tokensByModel: Record<string, TokenBuckets>

    Token usage broken down by model key. Key format: <model> normally, <model>-fast when usage.speed === "fast" (Claude Code fast mode).

    toolUsage: Record<string, number>

    Tool invocation counts keyed by tool name (e.g. Read, Bash, Edit). Deduplicated on tool_use.id — streaming entries sharing the same call counted once. Skill invocations (Claude Code slash-command extensions) are tracked in skillUsage instead.

    userMessageCount: number

    Number of human user messages in the main transcript.

    Stricter than CC's userMessageCount (which only filters tool-result-only entries via isHumanMessage): also excludes isMeta, isCompactSummary, and subagent turns (isSidechain && agentId !== undefined). The intent is "actual user typing in the main thread", not "every user-typed entry CC writes to disk".

    worktreeBranch: string | undefined

    Git branch of the worktree when the session ran inside claude --worktree. undefined when no worktree event was seen, or after a worktree-exit event (mirrors worktreePath semantics: both reset to undefined / null on exit).

    worktreePath: string | null | undefined

    Worktree path if the session ran inside a claude --worktree. null = a worktree-exit event was seen (user left the worktree). undefined = no worktree event at all in this session.