Thank you for your interest in contributing! This document covers development setup, architecture, and coding guidelines.
- Go 1.20+
ghCLI installed and authenticated- Claude Code installed
# Clone the repository
git clone https://github.com/73ai/workbench.git
cd workbench
# Build and install
go install ./cmd/workbench
# Install the plugin in Claude Code
claude
/plugin marketplace add ./
/plugin install workbench@73ai# Build the binary
go install ./cmd/workbench
# Test HTML export
workbench share --project "$PWD" --output test.html
open test.html
# Test gist creation
workbench share --project "$PWD" --gistworkbench/
├── cmd/workbench/ # CLI entry point
│ └── main.go
├── internal/
│ ├── parser/ # JSONL session parsing
│ │ └── jsonl.go
│ ├── converter/ # HTML conversion
│ │ └── html.go
│ ├── gist/ # GitHub Gist operations
│ │ └── gist.go
│ └── template/ # HTML template
│ └── template.go
├── generic/
│ └── metadata/ # Session metadata storage
│ └── metadata.go
├── commands/ # Slash commands
│ └── share.md
└── .claude-plugin/ # Plugin configuration
├── manifest.json
└── scripts/
└── capture-session.sh
-
Session Discovery (
internal/parser/jsonl.go)- Locates JSONL session files in
~/.claude/projects/{encoded-project-path}/ - Project paths are encoded by replacing
/and.with-
- Locates JSONL session files in
-
JSONL Parsing (
internal/parser/jsonl.go)- Parses Claude Code session files
- Each line contains a JSON object with type, uuid, timestamp, and message fields
- Content blocks can be text, thinking, tool_use, or tool_result
-
HTML Conversion (
internal/converter/html.go)- Converts parsed messages to HTML
- Handles tool result merging (inserts results after their corresponding tool_use)
- Markdown rendering (headers, bold, code blocks, lists, links)
- Tool-specific rendering (WebFetch/WebSearch show URLs, Read shows file paths, Bash shows commands, Edit shows diffs)
-
Template (
internal/template/template.go)- Self-contained HTML template with inline CSS
- Prism.js for syntax highlighting
-
Gist Operations (
internal/gist/gist.go)- Creates and updates GitHub Gists via
ghCLI - Generates preview URLs using gistpreview.github.io
- Creates and updates GitHub Gists via
Sessions are linked in a doubly-linked list structure stored in workbench-metadata.json:
~/.claude/projects/{encoded-project-path}/workbench-metadata.json
When /clear is used:
- The current session ID is captured via the SessionStart hook
- Metadata links the new session to the previous one (prev/next pointers)
- When sharing, adjacent sessions' gists are updated with navigation links
Key metadata operations are in generic/metadata/metadata.go:
GetPrevSessionID/GetNextSessionID- Navigate the session chainGetGistID/SetGistID- Track gist IDs for each sessionWithLock- Thread-safe metadata operations using file locks
Each line in a session file is a JSON object:
{
"type": "user|assistant",
"uuid": "message-uuid",
"parentUuid": "parent-message-uuid",
"sessionId": "session-id",
"timestamp": "ISO-8601 timestamp",
"message": {
"role": "user|assistant",
"content": "string or array of content blocks"
}
}Content block types:
{"type": "text", "text": "..."}- Plain text{"type": "thinking", "thinking": "..."}- Claude's thinking{"type": "tool_use", "name": "...", "input": {...}}- Tool invocation{"type": "tool_result", "content": "..."}- Tool output
You can read more about how claude code stores threads here.
parser.Message- Parsed message with ID, Role, Timestamp, and Blocksparser.ContentBlock- Content block with Type, Content, ToolName, ToolUseID, ToolInput, IsErrorconverter.Config- HTML generation config with Title, Username, UserInitials, ProjectPath, PrevSessionURL, NextSessionURLmetadata.Session- Session metadata with PrevSessionID, NextSessionID, GistID, UpdatedAt
- Do not comment code unless absolutely necessary
- Use
anyinstead ofinterface{} - Do not use json tags in every struct; create separate structs for marshaling/unmarshaling
- Keep functions focused and small
- Handle errors explicitly; don't ignore them silently
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with
go install ./cmd/workbench - Submit a pull request
By contributing, you agree that your contributions will be licensed under the Apache 2.0 License.