| name | share-session |
| description | Convert and share Claude Code conversation sessions as readable markdown files. Use when user wants to share a session transcript, export conversation history, or create a shareable markdown document from a Claude Code session. Triggered by requests like "share this session", "export conversation", "convert session to markdown". |
Share Session
Overview
Convert Claude Code sessions into readable markdown format for easy sharing. This skill finds sessions by fuzzy matching todo items and generates well-formatted markdown documents.
If this is loaded by user's explicit request but no comments there, just execute followings.
Workflow
Step 1: CRITICAL - Create Todo for Session Identification
MANDATORY: You MUST use TodoWrite tool to create a todo item that describes what this session is about.
IMPORTANT: You do NOT need to know the session ID. Describe the session content instead.
CORRECT Usage:
TodoWrite(todos=[{
"content": "share this session about ccusage integration and time tracking",
"status": "in_progress",
"activeForm": "Sharing session"
}])
Good Examples (describe session topic):
- โ
"share this session about ccusage integration"
- โ
"export conversation on implementing time tracking"
- โ
"share current session with share-session improvements"
Bad Examples (using session ID directly):
- โ "get session id of 62d3a2b2-102c-43d3-8414-0a30d7a5e5e0" (you don't know session ID yet!)
- โ "export 62d3a2b2" (session ID unknown)
How it works:
- You create todo with session description
- Claude Code saves todo as:
~/.claude/todos/{SESSION-ID}.json
- Script searches todo content using fuzzy matching (60% threshold)
- Script extracts SESSION-ID from the matching todo filename
- Script uses that SESSION-ID to find transcript
Why this is required:
- Without a todo, the script has no way to identify which session to export
- The todo file name is the ONLY place where session ID is stored
- Fuzzy matching allows flexible queries ("share this session" matches multiple variations)
Common mistakes:
- โ Forgetting to call TodoWrite before running the script
- โ Using session ID in todo content (you don't know it yet!)
- โ Query in Step 2 doesn't match todo content at all
Step 2: Run share_session.py
IMPORTANT: Always use the ABSOLUTE path to the script:
uv run --script /Users/yeongyu/local-workspaces/advanced-claude-code/claude-code-plugins/cc-plus/skills/share-session/scripts/share_session.py "your search query"
The search query should match your todo content from Step 1.
The script automatically:
- Searches todos using fuzzy matching (60% threshold)
- Locates transcript at
~/.claude/projects/*/{session-id}.jsonl
- Merges pre-compact backups if they exist
- Fetches accurate cost/token data from ccusage (NOT LiteLLM)
- Converts to markdown with full statistics
- Truncates before /share command (excludes the share request itself)
- Saves to
/tmp/claude-code-sessions/{session-id}-{timestamp}.md
- Copies the file path to clipboard
- Displays success message with cost breakdown
Step 3: Output
The script displays:
โ
Markdown saved to:
/tmp/claude-code-sessions/{session-id}-{timestamp}.md
๐ฐ Total Session Cost: $X.XXXXXX
๐ The path has been copied to your clipboard.
Generated Markdown Format
The script generates comprehensive markdown with:
Session Metadata:
- ๐ Session ID, generation timestamp, message count
- ๐ Models used (from ccusage data)
Content:
- ๐ฌ User messages with timestamps (meta messages filtered)
- ๐ค Assistant responses with timestamps
- ๐ง Thinking process (when available, shown as nested quotes)
- ๐ง Tool usage details (collapsed in
<details> tags)
- ๐ Subagent calls (Task tool usage)
Cost & Token Statistics (from ccusage):
- ๐ฐ Total session cost (accurate calculation from ccusage)
- ๐ Token breakdown:
- Input tokens
- Output tokens
- Cache creation tokens
- Cache read tokens
- Total tokens
- ๐ฏ Cache hit rate percentage
- ๐ Average cost per message
Session Timeline (NEW):
- โฑ๏ธ Total Session Time: First message โ Last message
- ๐ข LLM Active Time: User question โ Last assistant response (per turn)
- ๐ก LLM Idle Time: Last assistant โ Next user question
- ๐ LLM Utilization: (Active Time / Total Time) ร 100%
Special Features:
- ๐ฆ Compact markers shown for merged pre-compact backups
- ๐ช Auto-truncates before
/share command (excludes the export request itself)
- ๐ Multi-model support (tracks different models per message)
Script
share_session.py
The only script you need. Does everything from search to markdown generation.
Usage:
uv run --script /Users/yeongyu/local-workspaces/advanced-claude-code/claude-code-plugins/cc-plus/skills/share-session/scripts/share_session.py <query>
Dependencies (auto-installed by uv):
orjson: Fast JSON parsing
thefuzz: Fuzzy string matching for todo search
rich: Terminal formatting and progress display
Complete features:
- โ
Fuzzy search through todo files (60% threshold)
- โ
Automatic pre-compact backup merging
- โ
Accurate cost/token data from ccusage (via
bunx --bun ccusage session -i)
- โ
Turn-based time tracking:
- LLM Active Time (user โ last assistant per turn)
- LLM Idle Time (last assistant โ next user)
- Utilization percentage
- โ
Auto-truncation before
/share command
- โ
Multi-model session support (from ccusage data)
- โ
Clipboard integration (macOS
pbcopy)
- โ
Rich terminal output with colored progress
- โ
TypedDict-based type safety
Output: File path (stdout) + clipboard
Exit codes:
- 0: Success
- 1: Session not found or conversion failed
Performance:
- Typical execution: 2-5 seconds
- Timeout: 30 seconds (for ccusage call)
Error Handling
No session found:
- โ Cause: Todo item not created or query doesn't match
- โ
Solution:
- Verify you called
TodoWrite in Step 1
- Check query matches todo content (60% fuzzy threshold)
- Try exact session ID if known
Transcript not found:
- โ Cause: Session ID extracted but transcript missing
- โ
Solution:
- Confirm session ID is correct
- Check
~/.claude/projects/ directory exists
- Look for
{session-id}.jsonl file
- Check pre-compact backups at
~/.claude/pre-compact-session-histories/
ccusage data fetch failed:
- โ ๏ธ Symptom: "Could not fetch session usage data from ccusage"
- โ Possible causes:
ccusage command not available (check bunx --bun ccusage --version)
- Session ID not found in ccusage database
- JSON parsing error from ccusage output
- โ
Impact: Markdown still generated but without cost/token statistics
- โ
Fallback: Warning message displayed, conversion continues
Conversion failed:
- โ Cause: JSONL parsing or markdown generation error
- โ
Solution:
- Check transcript file is valid JSONL (each line = valid JSON)
- Review error message from stderr
- Check for corrupted transcript data
Clipboard copy failed:
- โ ๏ธ Symptom: "Warning: Could not copy to clipboard"
- โ Cause:
pbcopy command failed (macOS only)
- โ
Impact: Non-critical - file path still shown in stdout
- โ
Workaround: Manually copy the displayed path
Troubleshooting
Script says "No session found" even though todo exists:
ls -la ~/.claude/todos/ | grep $(date +%Y-%m-%d)
cat ~/.claude/todos/{session-id}*.json | jq .
Want to export specific session by ID:
TodoWrite(todos=[{"content": "export {exact-session-id}", "status": "in_progress", "activeForm": "Exporting"}])
uv run --script ... "{exact-session-id}"
ccusage returns wrong data:
- Verify ccusage version:
bunx --bun ccusage --version
- Test ccusage directly:
bunx --bun ccusage session -i {session-id} --json
- Check if session exists:
bunx --bun ccusage session