agentleFS
xiaolaixiaolai/echo-sleuth-for-claude/skills/jsonl-core/SKILL.md

jsonl-core

Skill9 starsChanged 8 months agoISCView on GitHub

This skill should be used when the user asks to "analyze conversation history", "parse JSONL files", "read past sessions", "search conversation logs", "find what happened in a session", or needs to work with Claude Code's .jsonl conversation format. It provides the canonical parsing infrastructure for echo-sleuth agents.

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 1

    1. taxueseek/session-digger★ 3429% same

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 1 is distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All parsing logic lives in ${CLAUDE_PLUGIN_ROOT}/scripts/echolib.py — a single Python module (stdlib only, Python 3.6+).

    line 11
  2. Very specific:

    Important: Only ~10% of projects have sessions-index.json.

    line 23
  3. Very specific:

    Always start with the index before opening any .jsonl file:

    line 27
  4. Very specific:

    Only open the full .jsonl when you need message-level detail.

    line 39
  5. Very specific:

    All scripts are at ${CLAUDE_PLUGIN_ROOT}/scripts/.

    line 63
  6. Very specific:

    If unsure, use list-sessions.sh which handles the lookup automatically (including fuzzy matching via sessions-index.json originalPath).

    line 155
  7. Very specific:

    When reading raw .jsonl, skip these:

    line 159
  8. Very specific:

    Use --skip-noise with parse-jsonl.sh for automatic noise filtering, or use the convenience scripts which handle this internally.

    line 166
  9. Distinctive:

    When parsing results look unexpected, use the schema-scout agent or run:

    line 176

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

JSONL Core — Conversation Parsing Infrastructure

Architecture

All parsing logic lives in ${CLAUDE_PLUGIN_ROOT}/scripts/echolib.py — a single Python module (stdlib only, Python 3.6+). The shell scripts are thin wrappers around it.

Data Locations

  • Session index (fast path): ~/.claude/projects/<encoded-path>/sessions-index.json
  • Fallback index (built by echo-sleuth): ~/.claude/projects/<encoded-path>/.echo-sleuth-index.json
  • Full conversations: ~/.claude/projects/<encoded-path>/<uuid>.jsonl
  • Subagent conversations: ~/.claude/projects/<encoded-path>/<uuid>/subagents/agent-<id>.jsonl
  • Global prompt history: ~/.claude/history.jsonl

The <encoded-path> is the project's absolute path with / replaced by - (e.g., -Users-joker-github-myproject).

Important: Only ~10% of projects have sessions-index.json. The scripts automatically build a fallback index from raw .jsonl files for the remaining 90%, cached in .echo-sleuth-index.json.

Strategy: Fast Path First

Always start with the index before opening any .jsonl file:

bash ${CLAUDE_PLUGIN_ROOT}/scripts/list-sessions.sh "current" --limit 20
bash ${CLAUDE_PLUGIN_ROOT}/scripts/list-sessions.sh "all" --grep "search term" --limit 10
bash ${CLAUDE_PLUGIN_ROOT}/scripts/list-sessions.sh "/path/to/project"

Output is tab-separated: SESSION_ID CREATED MODIFIED MSG_COUNT BRANCH SUMMARY FIRST_PROMPT PROJECT_PATH FULL_PATH

The FULL_PATH field (9th column) is the absolute path to the .jsonl file. Use this to pass to other scripts.

Only open the full .jsonl when you need message-level detail.

Canonical Parser

bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-jsonl.sh <file.jsonl> [options]

Key modes:

  • Schema detection (check if format has changed):
    bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-jsonl.sh <file.jsonl> --detect-schema
  • Filtered extraction (skip noise, ~38% faster on large files):
    bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-jsonl.sh <file.jsonl> --types user,assistant --skip-noise --limit 20
  • Field selection (only extract specific fields):
    bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-jsonl.sh <file.jsonl> --types user --fields timestamp,message --format tsv

Convenience Scripts

All scripts are at ${CLAUDE_PLUGIN_ROOT}/scripts/. They require only bash + python3 (stdlib only, no pip packages, minimum Python 3.6+). The git scripts additionally use git.

Extract human-readable messages

bash ${CLAUDE_PLUGIN_ROOT}/scripts/extract-messages.sh <file.jsonl> [--role user|assistant|both] [--no-tools] [--limit N] [--thinking [LIMIT]]

Note: --thinking without a number shows full thinking blocks. --thinking 500 truncates to 500 chars. Default: thinking blocks are hidden.

Extract tool calls with results

bash ${CLAUDE_PLUGIN_ROOT}/scripts/extract-tools.sh <file.jsonl> [--tool NAME] [--errors-only] [--limit N]

List files edited in a session

bash ${CLAUDE_PLUGIN_ROOT}/scripts/extract-files-changed.sh <file.jsonl> [--with-versions]

Uses reverse-read on large files (>50MB) to find the last snapshot efficiently.

Quick session statistics (single-pass)

bash ${CLAUDE_PLUGIN_ROOT}/scripts/session-stats.sh <file.jsonl>

Build fallback index

bash ${CLAUDE_PLUGIN_ROOT}/scripts/build-index.sh [project-path|"all"]

Pre-warm the cache for projects without sessions-index.json.

Subagent Discovery

Sessions with subagent work have a <session-uuid>/subagents/ directory. Check for it:

ls "$(dirname <full_path>)/$(basename <full_path> .jsonl)/subagents/" 2>/dev/null

Subagent files follow the same JSONL format and can be parsed with the same scripts.

Performance Notes

  • Python3 startup (80ms) dominates for files < 1MB (97% of all files)
  • --limit N enables early exit — near-instant for small N
  • --skip-noise avoids json.loads on progress/queue-operation lines by string pre-filter
  • For files > 10MB: json.loads is the CPU bottleneck (63% of time), not I/O
  • extract-files-changed.sh uses reverse-read on files > 50MB
  • session-stats.sh counts errors in the same pass (no double-read)
  • grep is NOT faster than Python for this format — avoid grep-then-parse pipelines

When Scripts Are Not Enough

For targeted searches within large .jsonl files, use Grep directly:

# Find user messages containing a keyword (two-step workflow):
# Step 1: Find lines matching the record type
Grep pattern='"type":"user"' path="<file.jsonl>" output_mode="content"
# Step 2: From those results, visually scan or re-grep for your keyword.
#         Alternatively, combine both conditions in one regex:
Grep pattern='"type":"user".*keyword' path="<file.jsonl>" output_mode="content"

# Find error results
Grep pattern='"is_error"\s*:\s*true'

# Find specific tool usage
Grep pattern='"name"\s*:\s*"ToolName"'

# Find decisions (AskUserQuestion usage)
Grep pattern='"name"\s*:\s*"AskUserQuestion"'

Record Type Quick Reference

See references/record-types.md for the complete schema. The essential types:

TypeWhat It ContainsWhen to Use
user (string content)Human's actual requestUnderstanding intent, finding topics
assistant (text blocks)Claude's responses and reasoningFinding decisions, explanations
assistant (tool_use blocks)Tool invocationsUnderstanding what actions were taken
file-history-snapshotFiles edited with version countsKnowing which files were touched
summaryAI-generated session titleQuick identification (also in sessions-index.json)
system (compact_boundary)Context compaction markerSession was long enough to need compaction

Finding the Right Session Directory

To map a project path to its Claude session directory:

  1. Take the absolute project path (e.g., /Users/joker/github/myproject)
  2. Replace all / with - → Users-joker-github-myproject
  3. Prepend - → -Users-joker-github-myproject
  4. Look in ~/.claude/projects/-Users-joker-github-myproject/

If unsure, use list-sessions.sh which handles the lookup automatically (including fuzzy matching via sessions-index.json originalPath).

Noise Filtering

When reading raw .jsonl, skip these:

  • Records where type is progress or queue-operation (streaming/internal bookkeeping)
  • User records with isMeta: true (slash command injection)
  • User records with isCompactSummary: true (auto-generated context, not human input)
  • Assistant records with model: "<synthetic>" (passthrough, not real inference)
  • User records where content is an array of tool_result blocks (tool outputs, not human messages)

Use --skip-noise with parse-jsonl.sh for automatic noise filtering, or use the convenience scripts which handle this internally.

Schema Evolution Awareness

Claude Code evolves rapidly. The JSONL format has changed across versions:

  • New record types appear silently (e.g., progress at v2.1.14, pr-link later)
  • New optional fields are added to existing records (~3-5 per minor version)
  • Some record types (summary, pr-link, file-history-snapshot) lack common fields like version or uuid
  • The directory encoding is lossy for Unicode paths — use sessions-index.json's originalPath field as ground truth

When parsing results look unexpected, use the schema-scout agent or run:

bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-jsonl.sh <file.jsonl> --detect-schema

to check for unknown record types or field changes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.