Share Claude Code Chat
Requirements
Requires Python 3, Node.js >=18 for Markdown rendering, and the PreviewShip CLI. The workflow is local and offline before deploy: it reads Claude Code session JSONL files from ~/.claude/projects and does not launch, attach to, or control Claude Code.
How It Works
Claude Code stores project conversations under ~/.claude/projects/<project-key>/<session-id>.jsonl. This skill:
- Locates a Claude Code JSONL session (
scripts/render_chat_html.py --currentchooses the newest local session). - Converts Claude Code records into a visible transcript.
- Renders a self-contained
index.htmlwith user bubbles, assistant Markdown, context cards, and collapsed processing summaries shown before the related assistant answer. - Deploys the HTML with PreviewShip CLI and returns the public URL.
Privacy Rules
Render only visible, shareable chat content. Never publish hidden thinking text, raw tool results, tool stdout/stderr, system records, file-history snapshots, permission records, settings files, API keys, environment variables, or full selected-file contents. The renderer may show a non-verbatim "Claude Code 思考过程已隐藏" processing row, but it must not include the hidden thinking payload.
Claude Code attachment records can contain entire file contents. The renderer may show a file/directory/IDE-selection card, but it must not include the attachment body.
Workflow
1. Resolve the skill directory
SKILL_DIR="<directory containing this SKILL.md>"
Resolve this dynamically; do not hard-code a user-specific path.
2. Render the current Claude Code conversation
mkdir -p /tmp/claude-code-chat-share
python3 "$SKILL_DIR/scripts/render_chat_html.py" --current --output /tmp/claude-code-chat-share/index.html
--current picks the newest main ~/.claude/projects/**/*.jsonl session, skips subagents/agent-*.jsonl, and prints the resolved path to stderr.
If the wrong session is selected, list recent sessions and pass one explicitly:
python3 "$SKILL_DIR/scripts/render_chat_html.py" --list-recent
python3 "$SKILL_DIR/scripts/render_chat_html.py" \
--input "/Users/<you>/.claude/projects/<project-key>/<session-id>.jsonl" \
--output /tmp/claude-code-chat-share/index.html
The renderer also accepts a hand-written transcript JSON object with a messages array as a fallback.
3. Verify locally
python3 -m http.server 4174 --directory /tmp/claude-code-chat-share
Check that the page is not blank, message order is correct, Markdown/code blocks render cleanly, and no secrets or raw tool output are present.
4. Ensure PreviewShip CLI is available and authenticated
command -v previewship || command -v npx
previewship whoami || npx -y previewship whoami
If not authenticated, stop and ask the user to log in:
请前往 https://previewship.com 登录,创建 API Key,然后运行:
npx previewship login --key ps_live_YOUR_KEY
(或 export PREVIEWSHIP_API_KEY=ps_live_YOUR_KEY)
5. Choose a deployment name
Use the renderer-generated stable name by default:
PROJECT_NAME="$(python3 "$SKILL_DIR/scripts/render_chat_html.py" --current --print-project-name)"
Override it only when the user explicitly provides a project name. Existing PreviewShip project names are deployment identities; using one updates that project.
6. Deploy and return the URL
previewship deploy /tmp/claude-code-chat-share/index.html -n "$PROJECT_NAME" --json
# or
npx -y previewship deploy /tmp/claude-code-chat-share/index.html -n "$PROJECT_NAME" --json
Return the public previewUrl, the local HTML path, and any fidelity limitations.
What the Renderer Parses
type=userwith stringmessage.content-> visible user bubble.type=userwithtool_resultcontent -> tool result status only, no raw output. Safe status snippets such asReceived 19.8KB (200 OK)may be extracted.type=assistantwithmessage.content[].type=text-> visible assistant Markdown.type=assistantwithtool_use-> collapsed processing summary, attached to the preceding assistant progress message when present; otherwise shown before the next visible assistant answer.type=assistantwiththinking-> hidden thinking summary row only, never the thinking text.type=attachment-> context card with filename/path only; attachment body is ignored.- Ignored:
system,permission-mode,file-history-snapshot,last-prompt, sidechain records, rawtoolUseResult, and hidden settings/context records.
Transcript JSON Shape
{
"title": "Claude Code Chat",
"projectName": "claude-code-chat",
"messages": [
{
"role": "user",
"content": "用户消息",
"context": [{ "title": "src/App.tsx", "subtitle": "文件", "path": "/abs/path/src/App.tsx" }]
},
{
"role": "assistant",
"content": "助手 Markdown",
"tools": [{ "name": "Read", "summary": "src/App.tsx", "status": "completed", "result": "Received 2.1KB (200 OK)" }]
}
]
}
Only include fields that were visible or safe to summarize. Add "visible": false to omit a message from rendering.
Error Handling
- No Claude Code sessions found: ask the user to provide
--inputwith a JSONL path. - Wrong current session: use
--list-recentand rerun with--input. - Unknown event types: ignore them unless they contain visible
message.content[].text. - Quota/plan/project-count deploy error: stop and report the error. Do not retry by switching to an unrelated existing project name.