agentleFS
alexjmiller5alexjmiller5/agent-config-public/skills/claude-sessions/SKILL.md

claude-sessions

Skill0 starsChanged 43 days agoMITView on GitHub

Finds and recovers content from Claude Code session history files. This skill should be used when searching for deleted files, tracking changes across sessions, analyzing conversation history, or recovering code from previous Claude interactions. Triggers include mentions of "session history", "recover deleted", "find in history", "previous conversation", or ".claude/projects".

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Search across every session of a project (add -i, drop -c for hits):

    line 43
  2. Distinctive:

    Every file a project's sessions ever wrote:

    line 56
  3. Very specific:

    Only Write calls carry full content.

    line 72

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “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

Claude Sessions

Claude Code writes every session as JSONL at ~/.claude/projects/<encoded-project-path>/<session-id>.jsonl. Everything below is jq/rg over those files - no tooling to install.

Finding the project directory

The directory name is the project's ABSOLUTE working-directory path with every / AND . replaced by - - never the basename. So /Users/<name>/.config/agent-config becomes -Users-<name>--config-agent-config, and a bare agent-config matches nothing.

D=~/.claude/projects/$(echo /abs/path/to/project | tr '/.' '-')

A failed ls is not proof there is no history - reverse-look-up instead:

ls ~/.claude/projects/ | grep -i <project-name>

Sessions run from Claude Desktop's cowork / built-in Claude Code mode also land here (Desktop runs a bundled CLI); only Desktop's native chat lives elsewhere (a LevelDB store, not JSONL). "It ran inside Desktop" does not mean it is missing.

Operations

List sessions, newest first:

ls -lt "$D"/*.jsonl | head

Search across every session of a project (add -i, drop -c for hits):

rg -c 'search term' "$D"/*.jsonl | sort -t: -k2 -rn | head

Tool-usage breakdown for one session:

jq -r '.message.content[]?|select(.type=="tool_use")|.name' "$D"/<session>.jsonl \
  | sort | uniq -c | sort -rn

Every file a project's sessions ever wrote:

jq -r 'select(.message.content|type=="array")|.message.content[]
       |select(.type=="tool_use" and .name=="Write")|.input.file_path' \
  "$D"/*.jsonl | sort -u

Recover one of them (last write wins, so tail/redirect the final copy):

jq -r --arg f /abs/path/to/lost.py 'select(.message.content|type=="array")
       |.message.content[]|select(.type=="tool_use" and .name=="Write"
       and .input.file_path==$f)|.input.content' "$D"/*.jsonl

Only Write calls carry full content. Edit calls carry old_string/new_string deltas (same filter, name=="Edit"); a file only ever edited cannot be reconstructed whole.

Schema details and older-session field locations: references/session_file_format.md.

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.