Skip to content

Session Intelligence

Wallace Ricardo edited this page Jun 3, 2026 · 1 revision

Session Intelligence

claude-code-graphql is not just a raw hook log. Because hooks, transcripts, project metadata, tools, skills, prompts, edits, subagents, errors, and token usage are queryable together, it becomes a session intelligence layer for Claude Code.

Use it to answer questions like:

  • What is Claude working on right now?
  • Which skills are actually being used?
  • Which tools dominate a session or project?
  • What files did a session edit?
  • What did the user ask that led to those edits?
  • Which subagents were spawned and what were they assigned?
  • What failed, and in which tool call?
  • Which sessions mention a feature, bug, table, endpoint, or file?
  • Which sessions are expensive or long-running?

Active or recent sessions

claudegql query '{ sessions(limit:10) { id status cwd model gitBranch lastSeenAt hookCount } }'

Skills: available vs. actually used

List skills discovered from ~/.claude/skills:

claudegql query '{ userSkills { name dirName description } }'

Find skills invoked in recent sessions:

claudegql query '{ sessions(limit:10) { id status skillsUsed { name count } } }'

Find skills used across projects:

claudegql query '{ projects { path sessionCount skillsUsed { name count } } }'

Tool usage and errors

claudegql query '{ stats { topTools(limit:10) { name count } toolErrorRates { toolName totalCalls errorCount errorRate } } }'

Per-session tool breakdown:

claudegql query '{ sessions(limit:5) { id toolUsage { name count } errorCount errors { toolName errorMessage recordedAt } } }'

Edited files and user prompts

claudegql query '{ sessions(limit:5) { id editedFiles prompts } }'

Recent user prompts globally:

claudegql query '{ hooks(filter:{eventType:UserPromptSubmit}, sort:{field:recordedAt,direction:DESC}, limit:10) { sessionId recordedAt prompt cwd } }'

Subagent work

claudegql query '{ sessions(limit:5) { id subagents { agentType description } } }'

This is useful for reconstructing delegated work, such as schema agents, resolver agents, frontend agents, reviewers, or test writers.

Recent edits with parsed payloads

claudegql query '{ hooksPaged(toolName:"Edit", first:5) { totalCount pageInfo { hasNextPage endCursor } edges { node { sessionId recordedAt parsedInput { __typename ... on EditInput { filePath oldString newString replaceAll } } } } } }'

Search remembered context

Search across prompts, tool inputs, and tool outputs:

claudegql query '{ search(query:"webhook", cwd:"/path/to/project", limit:5) { matchField snippet hook { sessionId recordedAt eventType toolName } } }'

Great searches include feature names, file paths, database tables, endpoint paths, error text, commands, ticket IDs, and user phrases.

Token usage / expensive sessions

claudegql query '{ sessions(limit:10) { id model durationSeconds tokenUsage { inputTokens outputTokens cacheReadTokens cacheCreationTokens } } }'

Print the schema for ad-hoc exploration

claudegql schema

The schema output is compact and description-free, making it easy to paste into an LLM context before asking it to design more queries.

Clone this wiki locally