| 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