Skip to content

Commit ad3e9a0

Browse files
committed
1 parent e1013c5 commit ad3e9a0

File tree

1 file changed

+81
-55
lines changed

1 file changed

+81
-55
lines changed

README.md

Lines changed: 81 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Tests](https://github.com/simonw/claude-code-publish/workflows/Test/badge.svg)](https://github.com/simonw/claude-code-publish/actions?query=workflow%3ATest)
66
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/claude-code-publish/blob/main/LICENSE)
77

8-
Convert Claude Code `session.json` files to clean, mobile-friendly HTML pages with pagination.
8+
Convert Claude Code session files (JSON or JSONL) to clean, mobile-friendly HTML pages with pagination.
99

1010
[Example transcript](https://static.simonwillison.net/static/2025/claude-code-microjs/index.html) produced using this tool.
1111

@@ -23,108 +23,134 @@ uvx claude-code-publish --help
2323

2424
## Usage
2525

26-
When using [Claude Code for web](https://claude.ai/code) you can export your session as a `session.json` file using the `teleport` command (and then hunting around on disk).
26+
This tool converts Claude Code session files into browseable multi-page HTML transcripts.
2727

28-
This tool converts that JSON into a browseable multi-page HTML transcript.
28+
There are three commands available:
2929

30-
The quickest way to view a recent session is to import it directly and open in your browser:
30+
- `local` (default) - select from local Claude Code sessions stored in `~/.claude/projects`
31+
- `web` - select from web sessions via the Claude API
32+
- `json` - convert a specific JSON or JSONL session file
33+
34+
The quickest way to view a recent local session:
3135

3236
```bash
33-
claude-code-publish import --open
37+
claude-code-publish
3438
```
3539

3640
This shows an interactive picker to select a session, generates HTML, and opens it in your default browser.
3741

38-
For a local session file:
39-
40-
```bash
41-
claude-code-publish session.json -o output-directory/
42-
```
43-
44-
This will generate:
45-
- `index.html` - an index page with a timeline of prompts and commits
46-
- `page-001.html`, `page-002.html`, etc. - paginated transcript pages
42+
### Output options
4743

48-
### Options
44+
All commands support these options:
4945

50-
- `-o, --output DIRECTORY` - output directory (default: current directory)
46+
- `-o, --output DIRECTORY` - output directory (default: writes to temp dir and opens browser)
47+
- `-a, --output-auto` - auto-name output subdirectory based on session ID or filename
5148
- `--repo OWNER/NAME` - GitHub repo for commit links (auto-detected from git push output if not specified)
52-
- `--open` - open the generated `index.html` in your default browser
49+
- `--open` - open the generated `index.html` in your default browser (default if no `-o` specified)
5350
- `--gist` - upload the generated HTML files to a GitHub Gist and output a preview URL
54-
- `--json` - include the original JSON session file in the output directory
51+
- `--json` - include the original session file in the output directory
5552

56-
### Publishing to GitHub Gist
53+
The generated output includes:
54+
- `index.html` - an index page with a timeline of prompts and commits
55+
- `page-001.html`, `page-002.html`, etc. - paginated transcript pages
5756

58-
Use the `--gist` option to automatically upload your transcript to a GitHub Gist and get a shareable preview URL.
57+
### Local sessions
5958

60-
If you use that with the `import` command with no other options you can directly select a session to publish to a Gist:
59+
Local Claude Code sessions are stored as JSONL files in `~/.claude/projects`. Run with no arguments to select from recent sessions:
6160

6261
```bash
63-
claude-code-publish import --gist
62+
claude-code-publish
63+
# or explicitly:
64+
claude-code-publish local
6465
```
65-
The `--gist` option is available for other commands too:
66+
67+
Use `--limit` to control how many sessions are shown (default: 10):
6668

6769
```bash
68-
claude-code-publish session.json --gist
69-
claude-code-publish import session_01BU6ZZoB7zTHrh9DAspF5hj --gist
70+
claude-code-publish local --limit 20
7071
```
7172

72-
Each of these will output something like:
73-
```
74-
Gist: https://gist.github.com/username/abc123def456
75-
Preview: https://gistpreview.github.io/?abc123def456/index.html
76-
Files: /var/folders/.../session-id
73+
### Web sessions
74+
75+
Import sessions directly from the Claude API:
76+
77+
```bash
78+
# Interactive session picker
79+
claude-code-publish web
80+
81+
# Import a specific session by ID
82+
claude-code-publish web SESSION_ID
83+
84+
# Import and publish to gist
85+
claude-code-publish web SESSION_ID --gist
7786
```
7887

79-
The preview URL uses [gistpreview.github.io](https://gistpreview.github.io/) to render your HTML gist. The tool automatically injects JavaScript to fix relative links when served through gistpreview.
88+
On macOS, API credentials are automatically retrieved from your keychain (requires being logged into Claude Code). On other platforms, provide `--token` and `--org-uuid` manually.
89+
90+
### JSON/JSONL files
8091

81-
When using `--gist` without `-o`, files are written to a temporary directory (shown in the output). You can combine both options to keep a local copy:
92+
Convert a specific session file directly:
8293

8394
```bash
84-
claude-code-publish session.json -o ./my-transcript --gist
95+
claude-code-publish json session.json -o output-directory/
96+
claude-code-publish json session.jsonl --open
8597
```
8698

87-
**Requirements:** The `--gist` option requires the [GitHub CLI](https://cli.github.com/) (`gh`) to be installed and authenticated (`gh auth login`).
99+
When using [Claude Code for web](https://claude.ai/code) you can export your session as a `session.json` file using the `teleport` command.
88100

89-
### Including the JSON source
101+
### Auto-naming output directories
90102

91-
Use the `--json` option to include the original session JSON file in the output directory:
103+
Use `-a/--output-auto` to automatically create a subdirectory named after the session:
92104

93105
```bash
94-
claude-code-publish session.json -o ./my-transcript --json
95-
```
106+
# Creates ./session_ABC123/ subdirectory
107+
claude-code-publish web SESSION_ABC123 -a
96108

97-
This will output:
109+
# Creates ./transcripts/session_ABC123/ subdirectory
110+
claude-code-publish web SESSION_ABC123 -o ./transcripts -a
98111
```
99-
JSON: ./my-transcript/session_ABC.json (245.3 KB)
112+
113+
### Publishing to GitHub Gist
114+
115+
Use the `--gist` option to automatically upload your transcript to a GitHub Gist and get a shareable preview URL:
116+
117+
```bash
118+
claude-code-publish --gist
119+
claude-code-publish web --gist
120+
claude-code-publish json session.json --gist
100121
```
101122

102-
The JSON file preserves its original filename. This is useful for archiving the source data alongside the HTML output.
123+
This will output something like:
124+
```
125+
Gist: https://gist.github.com/username/abc123def456
126+
Preview: https://gistpreview.github.io/?abc123def456/index.html
127+
Files: /var/folders/.../session-id
128+
```
103129

104-
## Importing from Claude API
130+
The preview URL uses [gistpreview.github.io](https://gistpreview.github.io/) to render your HTML gist. The tool automatically injects JavaScript to fix relative links when served through gistpreview.
105131

106-
You can import sessions directly from the Claude API without needing to export a `session.json` file:
132+
Combine with `-o` to keep a local copy:
107133

108134
```bash
109-
# List available sessions
110-
claude-code-publish list-web
135+
claude-code-publish json session.json -o ./my-transcript --gist
136+
```
111137

112-
# Import a specific session
113-
claude-code-publish import SESSION_ID -o output-directory/
138+
**Requirements:** The `--gist` option requires the [GitHub CLI](https://cli.github.com/) (`gh`) to be installed and authenticated (`gh auth login`).
114139

115-
# Import with interactive session picker
116-
claude-code-publish import
140+
### Including the source file
117141

118-
# Import and publish to gist
119-
claude-code-publish import SESSION_ID --gist
142+
Use the `--json` option to include the original session file in the output directory:
120143

121-
# Import and save the JSON session data
122-
claude-code-publish import SESSION_ID --json
144+
```bash
145+
claude-code-publish json session.json -o ./my-transcript --json
123146
```
124147

125-
On macOS, the API credentials are automatically retrieved from your keychain (requires being logged into Claude Code). On other platforms, provide `--token` and `--org-uuid` manually.
148+
This will output:
149+
```
150+
JSON: ./my-transcript/session_ABC.json (245.3 KB)
151+
```
126152

127-
The `--json` option for the import command saves the session data fetched from the API as `{session_id}.json` in the output directory.
153+
This is useful for archiving the source data alongside the HTML output.
128154

129155
## Development
130156

0 commit comments

Comments
 (0)