Inspect Claude Code sessions with lnav

disintegrator1 pts0 comments

Inspect Claude Code sessions with lnav | Georges Haidar

Top of page

Inspect Claude Code sessions with lnav

Tip: LLM-generated article<br>For the most part, this article was LLM generated, especially the snippets and<br>examples.

I’m not sure if anyone will find this interesting but…

You can teach lnav about Claude Code session stored on your machines and then have it properly parse them and make them queryable.

Here’s the format file:

claude-code.json{

"$schema": "https://lnav.org/schemas/format-v1.schema.json",

"claude_code_session": {

"title": "Claude Code session transcript",

"description": "JSONL session transcripts written by Claude Code under ~/.claude/projects//.jsonl and ...//subagents/agent-*.jsonl",

"url": "https://docs.claude.com/en/docs/claude-code",

"json": true,

"file-pattern": "\\.claude/projects/.*\\.jsonl$",

"hide-extra": true,

"timestamp-field": "timestamp",

"opid-field": "sessionId",

"level-field": "type",

"level": {

"debug": "^(attachment|file-history-delta|file-history-snapshot|queue-operation)$",

"info": "^(user|assistant|started|result)$",

"notice": "^(system|pr-link|frame-link|fork-context-ref)$"

},

"line-format": [

{ "field": "__timestamp__" },

" ",

"field": "type",

"min-width": 10,

"max-width": 10,

"overflow": "truncate"

},

"field": "subtype",

"default-value": "",

"prefix": " [",

"suffix": "]"

},

"field": "operation",

"default-value": "",

"prefix": " [",

"suffix": "]"

},

"field": "attachment/type",

"default-value": "",

"prefix": " [",

"suffix": "]"

},

"field": "durationMs",

"default-value": "",

"prefix": " ",

"suffix": "ms"

},

{ "field": "attributionSkill", "default-value": "", "prefix": " skill=" },

{ "field": "attributionAgent", "default-value": "", "prefix": " agent=" },

{ "field": "agentId", "default-value": "", "prefix": " agentId=" },

" ",

{ "field": "message/content", "default-value": "" },

{ "field": "content", "default-value": "" },

{ "field": "prUrl", "default-value": "" },

{ "field": "trackingPath", "default-value": "" },

"field": "attachment",

"default-value": "",

"max-width": 400,

"overflow": "truncate"

],

"value": {

"type": {

"kind": "string",

"identifier": true,

"description": "Transcript entry kind (user, assistant, attachment, system, ...)"

},

"subtype": {

"kind": "string",

"identifier": true,

"description": "Sub-kind of a system entry (turn_duration, local_command, stop_hook_summary, ...)"

},

"operation": {

"kind": "string",

"identifier": true,

"description": "Queue operation (enqueue, dequeue, ...)"

},

"attachment/type": {

"kind": "string",

"identifier": true,

"description": "Attachment kind (hook_success, task_reminder, diagnostics, skill_listing, ...)"

},

"attachment": {

"kind": "json",

"description": "Full attachment payload"

},

"message/content": {

"kind": "json",

"description": "Message content: array of text/thinking/tool_use/tool_result blocks, or a bare string"

},

"content": {

"kind": "string",

"description": "Plain-text body of system and queue-operation entries"

},

"durationMs": {

"kind": "integer",

"unit": { "field": "ms" },

"description": "Turn duration reported by system/turn_duration entries"

},

"messageCount": { "kind": "integer", "hidden": true },

"message/role": { "kind": "string", "identifier": true, "hidden": true },

"message/model": { "kind": "string", "identifier": true, "hidden": true },

"message/id": { "kind": "string", "identifier": true, "hidden": true },

"message/stop_reason": {

"kind": "string",

"identifier": true,

"hidden": true

},

"message/usage/input_tokens": { "kind": "integer", "hidden": true },

"message/usage/output_tokens": { "kind": "integer", "hidden": true },

"message/usage/cache_read_input_tokens": {

"kind": "integer",

"hidden": true

},

"message/usage/cache_creation_input_tokens": {

"kind": "integer",

"hidden": true

},

"message/usage/service_tier": {

"kind": "string",

"identifier": true,

"hidden": true

},

"toolUseResult": {

"kind": "json",

"hidden": true,

"description": "Structured result of the tool call this user entry is replying to"

},

"uuid": { "kind": "string", "identifier": true, "hidden": true },

"parentUuid": {

"kind": "string",

"identifier": true,

"foreign-key": true,

"hidden": true

},

"sessionId": { "kind": "string", "identifier": true, "hidden": true },

"requestId": { "kind": "string", "identifier": true, "hidden": true },

"promptId": { "kind": "string", "identifier": true, "hidden": true },

"messageId": {

"kind": "string",

"identifier": true,

"foreign-key": true,

"hidden": true

},

"snapshotMessageId": {

"kind": "string",

"identifier": true,

"foreign-key": true,

"hidden": true

},

"sourceToolAssistantUUID": {

"kind": "string",

"identifier": true,

"foreign-key": true,

"hidden": true

},

"sourceToolUseID": {

"kind": "string",

"identifier": true,

"hidden": true

},

"agentId": { "kind": "string", "identifier": true },

"cwd": { "kind": "string", "identifier": true,...

true kind string identifier hidden field

Related Articles