Skip to content

Commit 5516c76

Browse files
brendanbeckerclaudesimonw
authored
Add batch command for converting all sessions to HTML archive (#11)
* Add batch command for converting all sessions to HTML archive Adds a new `batch` command that converts all local Claude Code sessions into a browsable HTML archive with: - Master index listing all projects with session counts - Per-project pages listing sessions by date - Individual session transcripts (using existing generate_html) New features: - `find_all_sessions()` - discovers sessions grouped by project - `get_project_display_name()` - extracts readable names from encoded paths - `--dry-run` flag to preview what would be converted - `--include-agents` flag to include agent-* session files - Progress indicator during conversion Usage: claude-code-transcripts batch -o ./my-archive 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Refactor batch command for better code reuse and error handling - Move datetime import to module level for consistency - Add progress_callback parameter to generate_batch_html() for progress reporting - Add try/except around individual session conversion with failed_sessions tracking - Refactor batch_cmd() to use generate_batch_html() instead of duplicating the loop - Add --quiet/-q flag to suppress non-error output for scripting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix --quiet flag not respected in dry-run mode - Wrap dry-run output in `if not quiet` check - Add test for --quiet with --dry-run combination - Add .playwright-mcp/ to .gitignore - Rename html variable to html_content to avoid shadowing html module - Remove unused imports from test file 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add batch command documentation to README Document the new batch command that converts all local Claude Code sessions to a browsable HTML archive with master and project indexes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Rename batch command to all https://gistpreview.github.io/?be627e42c25a1ffdf39cfb2f9a79f1ff/index.html Refs #11 (comment) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Simon Willison <swillison@gmail.com>
1 parent 68f7395 commit 5516c76

File tree

6 files changed

+894
-3
lines changed

6 files changed

+894
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
__pycache__
33
uv.lock
4+
.playwright-mcp/

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ uvx claude-code-transcripts --help
2626

2727
This tool converts Claude Code session files into browseable multi-page HTML transcripts.
2828

29-
There are three commands available:
29+
There are four commands available:
3030

3131
- `local` (default) - select from local Claude Code sessions stored in `~/.claude/projects`
3232
- `web` - select from web sessions via the Claude API
3333
- `json` - convert a specific JSON or JSONL session file
34+
- `all` - convert all local sessions to a browsable HTML archive
3435

3536
The quickest way to view a recent local session:
3637

@@ -99,6 +100,44 @@ claude-code-transcripts json session.jsonl --open
99100

100101
When using [Claude Code for web](https://claude.ai/code) you can export your session as a `session.json` file using the `teleport` command.
101102

103+
### Converting all sessions
104+
105+
Convert all your local Claude Code sessions to a browsable HTML archive:
106+
107+
```bash
108+
claude-code-transcripts all
109+
```
110+
111+
This creates a directory structure with:
112+
- A master index listing all projects
113+
- Per-project pages listing sessions
114+
- Individual session transcripts
115+
116+
Options:
117+
118+
- `-s, --source DIRECTORY` - source directory (default: `~/.claude/projects`)
119+
- `-o, --output DIRECTORY` - output directory (default: `./claude-archive`)
120+
- `--include-agents` - include agent session files (excluded by default)
121+
- `--dry-run` - show what would be converted without creating files
122+
- `--open` - open the generated archive in your default browser
123+
- `-q, --quiet` - suppress all output except errors
124+
125+
Examples:
126+
127+
```bash
128+
# Preview what would be converted
129+
claude-code-transcripts all --dry-run
130+
131+
# Convert all sessions and open in browser
132+
claude-code-transcripts all --open
133+
134+
# Convert to a specific directory
135+
claude-code-transcripts all -o ./my-archive
136+
137+
# Include agent sessions
138+
claude-code-transcripts all --include-agents
139+
```
140+
102141
### Auto-naming output directories
103142

104143
Use `-a/--output-auto` to automatically create a subdirectory named after the session:

0 commit comments

Comments
 (0)