Skip to main content

Claude Code Session Schema

Complete reference for the graph schema produced by the Claude Code session connector (--connector claude-code).

Entity Types​

Core session structure​

LabelSourceKey PropertiesDescription
ProjectProject directories in ~/.claude/projects/name (decoded path), encodedPath, sessionCountOne per project directory. Name is the decoded filesystem path.
SessionJSONL session filessessionId, name (first prompt snippet), startedAt, endedAt, branch, messageCount, totalInputTokens, totalOutputTokens, progressCountOne per .jsonl file. Name is derived from the first user prompt.
MessageUser and assistant messagesuuid, role (user/assistant), content (truncated), timestampNamed as msg-{uuid[:12]}. Content length controlled by --claude-code-content.
ToolCalltool_use blocks in assistant messagestoolUseId, toolName (Read/Write/Edit/Bash/Grep/Glob/Agent/etc.), input (summary), output (truncated), isError, timestampNamed as {toolName}: {input_summary}.
FileExtracted from tool call inputspath (absolute), language (from extension), modificationCount, readCountDeduplicated across all sessions. Tracks how many times each file was read and modified.
GitBranchSession metadataname, projectDeduplicated. Links sessions to their active git branch.
ErrorTool results with is_error: truemessage (truncated), timestamp, toolUseIdNamed as error-{hash}.

Decision extraction​

LabelSourceKey PropertiesDescription
DecisionHeuristic extractiondescription, timestamp, outcome (ACCEPTED/REVISED/REJECTED/DEFERRED), confidence (0.0--1.0), category (correction/architecture/error-fix/dependency), sessionIdNamed as decision-{hash}.
AlternativePaired with decisionsdescription, wasChosen (boolean), reasonNamed as alt-{hash}-original or alt-{hash}-correction.

Preference extraction​

LabelSourceKey PropertiesDescription
PreferenceExplicit statements + behavioral patternscategory (coding_style/framework_choice/testing_approach/tool_configuration/naming_convention/documentation), key, value, confidence (0.0--1.0), extractedFrom (explicit_statement/package_frequency), firstSeenAt, sessionCountNamed as pref-{hash}.

Relationship Types​

Session structure​

RelationshipFromToDescription
HAS_SESSIONProjectSessionProject directory contains this session
HAS_MESSAGESessionMessageSession contains this message
NEXTMessageMessageSequential message ordering within a session
USED_TOOLMessageToolCallAssistant message invoked this tool
ON_BRANCHSessionGitBranchSession was on this git branch

Tool call chains and file tracking​

RelationshipFromToDescription
PRECEDED_BYToolCallToolCallTool call sequence within a session (reasoning chain)
MODIFIED_FILEToolCallFileWrite, Edit, or NotebookEdit tool changed this file
READ_FILEToolCallFileRead, Grep, or Glob tool accessed this file
ENCOUNTERED_ERRORToolCallErrorTool call produced an error

Decision provenance​

RelationshipFromToDescription
MADE_DECISIONSessionDecisionDecision was identified in this session
CHOSEDecisionAlternativeThe approach that was chosen
REJECTEDDecisionAlternativeAn approach that was rejected
RESULTED_INDecisionToolCallTool call that executed the chosen approach

Preference tracking​

RelationshipFromToDescription
EXPRESSES_PREFERENCEMessagePreferenceUser message that revealed this preference

Decision Categories​

CategoryDetection MethodExample
correctionUser overrides Claude's approach ("No, instead use X")"No, instead use OAuth2 with Google"
architectureAssistant discusses trade-offs with multiple deliberation markers"We could use FastAPI or Flask, the trade-off is..."
error-fixTool call fails, followed by corrective tool callspytest fails → edit file → pytest succeeds
dependencyPackage install commands (pip install, npm install, etc.)pip install pydantic

Preference Categories​

CategoryExample Patterns
coding_style"always use single quotes", "don't use X", "I prefer functional style"
framework_choice"prefer FastAPI over Flask", frequently installing pydantic
testing_approach"write tests first", "use pytest fixtures"
tool_configuration"use ruff", "use black for formatting"
naming_convention"use snake_case", "use PascalCase"
documentation"add docstrings", "use type hints"

Agent Tools​

When --connector claude-code is active, 8 session intelligence tools are injected into the generated agent:

ToolParametersDescription
search_sessionskeyword (string, required)Full-text search across session message content
decision_historytopic (string, required)Find decisions related to a file, package, or topic
file_timelinepath (string, required)Show modification/read history of a file across all sessions
error_patterns--Find recurring errors and how they were resolved
tool_usage_stats--Analytics on tool usage across sessions
my_preferencescategory (string, optional)Retrieve extracted preferences, optionally filtered by category
project_overviewproject_name (string, optional)Summary stats for a project
reasoning_tracesession_name (string, required)Trace the tool call chain for a specific session

Secret Redaction​

The following patterns are detected and replaced with [REDACTED] before content is stored:

  • Anthropic API keys (sk-ant-*)
  • OpenAI API keys (sk-proj-*, sk-*)
  • GitHub tokens (ghp_*, gho_*, github_pat_*)
  • Slack tokens (xoxb-*, xoxp-*)
  • AWS access keys (AKIA*)
  • Bearer/Authorization tokens
  • Password assignments (password=*)
  • Connection strings with embedded credentials (postgres://user:pass@host)
  • .env-style sensitive variable assignments (ANTHROPIC_API_KEY=*)

Redaction is enabled by default. Content mode none (--claude-code-content none) avoids storing message content entirely.

Example Graph Traversals​

Trace a decision back through the conversation​

MATCH (d:Decision)-[:MADE_DECISION]-(s:Session)-[:HAS_MESSAGE]->(m:Message)
WHERE d.description CONTAINS 'auth'
RETURN s.name AS session, m.role AS role, m.content AS message,
d.description AS decision, d.category AS type
ORDER BY m.timestamp

Find the most active files across all sessions​

MATCH (f:File)
RETURN f.path, f.language, f.modificationCount, f.readCount,
f.modificationCount + f.readCount AS total_touches
ORDER BY total_touches DESC
LIMIT 20

Reconstruct a reasoning chain​

MATCH chain = (tc:ToolCall)-[:PRECEDED_BY*1..10]->(root:ToolCall)
WHERE tc.toolName = 'Bash'
AND tc.input CONTAINS 'pytest'
RETURN [n IN nodes(chain) | {tool: n.toolName, input: n.input}] AS chain
LIMIT 5