claude_storage
CLI tool for exploring and analyzing Claude Code's filesystem-based conversation storage.
Files
| File / Directory | Responsibility |
|---|---|
Cargo.toml |
Crate manifest: deps, features, build script |
build.rs |
Transforms YAML command definitions to static PHF registry |
unilang.commands.yaml |
Command definitions (9 commands) |
src/ |
CLI pipeline, command routines, binary entry points |
tests/ |
Integration and parameter validation tests (242 tests) |
docs/ |
Behavioral requirements: features, CLI reference, operation docs |
task/ |
Crate-level task tracking |
examples/ |
Usage examples for storage API |
changelog.md |
Notable changes by version |
overview
This crate provides a command-line interface for querying Claude Code's conversation storage at ~/.claude/. It wraps the claude_storage_core library with an interactive REPL and one-shot command interface.
v1.0 Status: Core library (claude_storage_core) is production-ready with comprehensive validation (122 tests, production session parsing). CLI wrapper commands .status, .list, and .count are fully validated. For programmatic access or advanced usage, we recommend using the claude_storage_core library API directly (see "library api" section below).
Extraction context: This is the CLI-focused crate after extracting core library functionality to claude_storage_core (2025-11-29).
installation
Or run directly:
usage
repl mode (interactive)
claude_storage> .status
Storage: "/home/user/.claude"
Projects: 230 (UUID: 14, Path: 216)
Sessions: 7546 (Main: 1061, Agent: 6485)
Entries: 323231
claude_storage> .list target::projects
UUID projects: 14
Path projects: 216
claude_storage> .count target::sessions
Total sessions: 7546
claude_storage> exit
one-shot mode (scripting)
# Get storage statistics
# Count projects
# List projects with filtering
# Show session details
commands
.status
Show storage statistics (projects, sessions, entries, tokens).
Parameters:
verbosity::N(0-5, default 1) - Detail level
Example:
.list
List projects or sessions with optional filtering.
Parameters:
type::{uuid|path|all}(optional, default: all) - Filter by project typeverbosity::N(0-5, default: 1) - Output detail levelsessions::{0|1}(optional, auto-detected) - Show sessions (auto-enabled when session filters provided)path::{value}(optional) - Filter projects by path (supports smart resolution, see below)agent::{0|1}(optional) - Filter sessions by type (auto-enables session display)min_entries::N(optional) - Filter sessions by minimum entry count (auto-enables session display)session::{substring}(optional) - Filter sessions by ID substring (auto-enables session display)
Path Parameter - Smart Resolution:
The path:: parameter supports both shell-style path resolution and pattern matching:
-
Special paths (resolved to absolute paths):
path::.→ Current working directorypath::..→ Parent directorypath::~→ Home directorypath::~/subdir→ Home directory + relative path
-
Patterns (substring matching):
path::assistant→ Match any path containing "assistant"path::storage→ Match any path containing "storage"
Examples:
# List all projects
# List path-based projects only
# Path resolution (current directory)
# Path resolution (parent directory)
# Path resolution (home directory)
# Pattern matching (backward compatible)
# Filter sessions with auto-enable
# Combine filters
.show
Display session or project details with conversation content by default (REQ-011: Content-First Display).
Smart Behavior (adapts to parameters):
- No parameters → Shows current directory project (all sessions)
- session_id only → Shows that session in current project with conversation content
- project only → Shows that project (all sessions)
- Both parameters → Shows that session in that project with conversation content
Parameters:
session_id::{uuid-or-agent-id}(optional) - Session UUID or agent-{hex}project::{path-or-id}(optional) - Project path or UUID (default: current directory)verbosity::N(0-5, default 1) - Output detail levelentries::1(optional) - Show all entries (backward compat with old UUID list format)metadata::1(optional) - Show metadata only (old behavior, no conversation content)
Default Behavior (NEW): Shows actual conversation content in readable chat-log format. No parameters needed to read messages.
Examples:
# Show current directory project (all sessions)
# Show session with conversation content (default)
# Show session in different project
# Metadata only (old behavior)
# Increase verbosity for metadata footer
Content Format:
Session: 79f86582... (2893 entries)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[2025-12-02 09:57] User:
last 3 biig tasks solved in this context?
[2025-12-02 09:57] Assistant:
I'll analyze the recent conversation history...
**Recent Major Tasks Completed:**
1. **tree_fmt Standardization**
2. **Path Filter Bug Investigation**
3. **Test Suite Fixes**
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
.count
Fast counting operations (projects, sessions, entries).
Parameters:
target::projects|sessions|entries(required)project::{id}(for sessions/entries)session::{id}(for entries)
Examples:
.search
Search session content for query string.
Parameters:
query::{text}(required) - Search query (case-insensitive by default)project::{id}(optional) - Limit search to specific projectsession::{id}(optional) - Limit search to specific sessioncase_sensitive::1(optional) - Enable case-sensitive matchingentry_type::user|assistant(optional) - Filter by entry typeverbosity::N(0-5, default 1) - Detail level
Examples:
.export
Export session to file (markdown, JSON, or text).
Parameters:
session_id::{id}(required) - Session ID to exportoutput::{path}(required) - Output file pathformat::markdown|json|text(optional, default: markdown) - Export formatproject::{id}(optional) - Project ID if not in current directory
Formats:
- markdown (.md) - Human-readable with metadata and formatted entries
- json (.json) - Machine-readable structured format
- text (.txt) - Simple conversation transcript
Examples:
Note: Sessions may contain non-conversation metadata entries (queue-operation, summary) which are automatically skipped during export. Only conversation entries (user/assistant messages) are included in the exported output.
.session
Check if a directory has Claude Code conversation history.
Parameters:
path::{value}(optional, default: current directory) - Directory to check
Examples:
# Check current directory
# Check specific directory
.sessions
Show active-session summary by default, or list sessions with scope control when any explicit parameter is given (session-first view).
Scope semantics:
| Scope | Project qualifies when |
|---|---|
local |
project path == base path |
relevant |
base path is under the project path (ancestor) |
under |
project path is under the base path (subtree) (default) |
global |
all projects regardless of path |
Parameters:
scope::{local|relevant|under|global}(optional, default:under) - Discovery scopepath::{value}(optional, default: cwd) - Base path for scope resolutionsession::{substring}(optional) - Filter by session ID substringagent::{0|1}(optional) - Filter by type (0=main only, 1=agent only)min_entries::N(optional) - Minimum entry count thresholdverbosity::N(0-5, default: 1) - Output detail level
Default output (summary mode):
Active session {8-char-id} {age} {N} entries
Project {rel-path}
Last message:
{text or first30...last30 if > 50 chars}
No active session found. when scope has no sessions.
List output (any explicit parameter given):
- verbosity 0: raw session IDs (one per line)
- verbosity 1: family-grouped list with path headers (default); agents shown as
[N agents: N×Type]per root - verbosity 2+: full UUIDs, agents tree-indented under their parent session
Examples:
# Active session summary (default — no args)
# Sessions for all projects under ~/pro
# All sessions across entire storage
# All agent sessions with 50+ entries
scripting integration
Exit codes:
- 0: Success
- 1: Error
Examples:
# Get project count
PROJECT_COUNT=
# Check if session exists
if ; then
fi
# Export statistics
library api
For programmatic access to Claude Code storage, use claude_storage_core directly:
[]
= "1.0.0"
# Or for local development:
# claude_storage_core = { path = "../claude_storage_core" }
use ;
architecture
Dependencies:
claude_storage_core- Core library for all storage operationsunilang- CLI framework for command parsingphf- Perfect hash functions for static command registry
Build system:
build.rs- Transforms YAML command definitions to static PHF registryunilang.commands.yaml- Command definitions (9 commands)- Generated code: Static command map with O(1) lookup
Command routines (src/cli/mod.rs):
status_routine- Global statistics aggregationlist_routine- Filtered listingshow_routine- Session detail displayshow_project_routine- Project detail displaycount_routine- Fast countingsearch_routine- Content searchexport_routine- Session exportsession_routine- Directory session checksessions_routine- Scoped session listing
documentation
- Documentation:
docs/- Behavioral requirements, CLI reference, feature docs (seedocs/entities.mdfor index) - Migration guide:
docs/MIGRATION.md- Migration from monolithic crate - Format docs:
docs/- Storage organization, file formats, advanced topics - Integration guide:
docs/integration_guide.md- Library integration examples
testing
Core library tests: 105 tests in claude_storage_core crate
- Entry parsing and validation
- Path encoding/decoding
- JSON parser
- Filtering system
- Content search
- Export functionality (markdown, JSON, text)
- Statistics aggregation
- Bug reproducers with comprehensive documentation
CLI tests: 17 integration tests
- Storage operations tests (global stats, project listing)
- Session operations tests (show, stats, entry counts)
- Counting operations tests (projects, sessions, entries)
- Full workflow integration test
- CLI sanity tests (build, features)
license
MIT