Agent skill

OpenCode Session Visualizer

by nigo81 in nigo81/nigo-skills

Exports an OpenCode session from its local database into a single self-contained HTML page styled like the official share view, with folding and editing controls.

MITAuto-check passedAgent Workflows

SKILL.md written in Chinese; this summary is our English description.

Install OpenCode Session Visualizer

skills CLI
$ npx skills add nigo81/nigo-skills --skill opencode-session-visualizer -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install nigo81/nigo-skills opencode-session-visualizer --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/nigo81/nigo-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/opencode-session-visualizer .claude/skills/opencode-session-visualizer && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
opencode-session-visualizer
GitHub stars
133
Token cost
~1.3k tokens
SKILL.md length
238 words
Files
4 (incl. scripts, assets)
Skills in repo
13
Repo updated
First seen
Licence
MIT

At a glance

Exports an OpenCode session from its local database into a single self-contained HTML page styled like the official share view, with folding and editing controls.

  • Works in 2 steps: 导出 JSON:python3… → 生成 HTML:python3…
  • Exporting an OpenCode conversation as a shareable HTML page
  • SKILL.md covers 核心价值, 跨平台说明, 工作流程 and HTML 功能特性, plus 3 more sections
  • Runs Python scripts from its folder; calls python3

What it does

OpenCode's context compaction cannot be undone inside a session, but the local SQLite database still holds every message. This skill reads that database and builds one HTML file that copies the dark look of the official share page. The page renders Markdown with marked.js and highlights code with highlight.js, shows tool calls as collapsed cards with full input and output, folds reasoning, and marks compaction events as amber cards.

Two bundled Python scripts do the work: `export_session.py` lists recent sessions or exports one to JSON, and `generate_html.py` builds the page, either straight from the database with a session ID or from the exported JSON. The agent lists recent sessions first when you give no ID, then suggests opening the file in a browser. The scripts find the database on macOS, Linux and Windows without configuration.

In the browser the page has a left sidebar that lists user messages and jumps to them, a back-to-top button and editing tools: delete a message together with the assistant replies that follow, or truncate everything after a message, then download the cleaned HTML. The SKILL.md is written in Chinese.

When your agent uses it

  • Exporting an OpenCode conversation as a shareable HTML page
  • Recovering the full conversation from before context compaction
  • Trimming or deleting messages from a session before sharing it

Example prompts

  • “Export my latest OpenCode session to an HTML page.”
  • “List my recent OpenCode sessions so I can pick one to export.”
  • “Show me the full conversation from before the context was compacted.”
  • “Generate a share page for this OpenCode session and tell me how to open it.”

Requirements

  • Python 3 (`python3`, or `python` on Windows)
  • OpenCode's local `opencode.db` database

Workflow steps

2 steps, taken from the first numbered list in SKILL.md.

  1. 导出 JSON:python3 SKILL_DIR/scripts/export_session.py session.json
  2. 生成 HTML:python3 SKILL_DIR/scripts/generate_html.py session.json [output.html]

What it can do on your machine

Read from SKILL.md and the folder at commit 6468211. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

OpenCode Session Visualizer loads about 1.3k tokens when it runs. Until then it costs about 105 tokens; SKILL.md has 238 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~105
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from nigo81/nigo-skills at commit 6468211, republished under its MIT licence (© nigo81). 238 words, ~1,292 tokens.

Download SKILL.mdSave it as .claude/skills/opencode-session-visualizer/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
opencode-session-visualizer
description
将 OpenCode 会话导出为可视化的 HTML 网页,复刻官方 share 页面的暗色主题样式。 从本地 SQLite 数据库提取完整对话数据(包括上下文压缩前的早期消息), 生成的 HTML 包含 Markdown 渲染、代码高亮、工具调用折叠卡片(含完整 input/output)、 思考过程折叠、左侧对话导航边栏、删除/截断对话功能。 触发词:可视化会话、导出会话、会话分享、session visualizer、share session、 导出完整对话、查看压缩前对话、生成会话网页、会话 HTML、conversation visualizer、 opencode 会话导出、完整对话记录、删除对话、清理会话。 当用户提到任何与会话导出、可视化、分享、完整记录查看相关的需求时都应使用此 skill。 即使用户只说"帮我看下之前那个对话"或"导出这个会话"也应触发。
slug
nigo-opencode-session-visualizer
displayName
OpenCode会话可视化
version
1.0.0
summary
将 OpenCode 会话导出为可视化 HTML 网页,复刻官方 share 页面暗色主题,从本地 SQLite 提取完整对话数据含压缩前消息。
license
MIT

OpenCode 会话可视化

将 OpenCode 会话从本地数据库导出,生成复刻官方 share 页面样式的单文件 HTML。

核心价值

OpenCode 的上下文压缩(compaction)是不可逆的——恢复会话时只能看到 checkpoint 之后的内容。 但数据库里完整保存了所有消息。这个 skill 直接从数据库提取完整数据,生成可分享的 HTML 网页。

跨平台说明

脚本支持 macOS、Linux 和 Windows。无需额外配置。

  • Python 命令:macOS/Linux 用 python3,Windows 用 python(下方示例统一写 python3,Windows 用户自行替换)
  • 脚本路径:脚本通过 __file__ 自动定位自身目录,无需关心 skill 安装在哪个路径。下方命令中的 SKILL_DIR 指本 skill 的安装目录(因 AI Agent 工具而异,如 ~/.claude/skills/opencode-session-visualizer/、~/.config/opencode/skills/opencode-session-visualizer/ 等)
  • 数据库路径(脚本自动搜索,无需手动指定):
    • Linux: ~/.local/share/opencode/opencode.db
    • macOS: ~/.local/share/opencode/opencode.db 或 ~/Library/Application Support/opencode/opencode.db
    • Windows: %LOCALAPPDATA%\opencode\opencode.db 或 %APPDATA%\opencode\opencode.db

工作流程

快速路径(推荐)

一行命令从数据库直接生成 HTML(SKILL_DIR = 本 skill 目录):

bash
python3 SKILL_DIR/scripts/generate_html.py --session <session_id> [output.html]

如果用户没有提供 session_id,先列出最近会话:

bash
python3 SKILL_DIR/scripts/export_session.py --list -n 15
分步路径
  1. 导出 JSON:python3 SKILL_DIR/scripts/export_session.py <session_id> session.json
  2. 生成 HTML:python3 SKILL_DIR/scripts/generate_html.py session.json [output.html]

生成后提示用户在浏览器中打开(macOS: open <path>,Windows: start <path>,Linux: xdg-open <path>)。

HTML 功能特性

生成的 HTML 是完全自包含的单文件,具备以下交互功能:

渲染
  • Markdown 渲染:助手消息支持完整 Markdown(表格、代码块、列表、标题),用 marked.js
  • 代码高亮:highlight.js 语法高亮,深色主题
  • 暗色主题:背景 #131315,代码块 #0b0b0c,链接 #89b4fa,系统字体 13px
交互
  • 左侧导航边栏:列出所有用户消息摘要,点击平滑滚动跳转,滚动时自动高亮当前消息
  • 工具调用卡片:默认折叠,显示工具名+摘要(如 read · format.ts),点击展开显示完整 Input 和 Output(代码块样式,可滚动)
  • 思考过程折叠:reasoning 内容默认折叠,点击展开查看
  • 压缩事件标记:compaction checkpoint 显示为琥珀色卡片
  • 回到顶部按钮:长页面右下角浮动按钮
编辑(浏览器内操作)
  • 删除消息 🗑:悬浮用户消息显示删除按钮,删除该消息及其后续连续的助手回复
  • 截断对话 ✂️:悬浮用户消息显示截断按钮,删除该消息之后的所有内容(批量删除尾部对话)
  • 导出清理后的 HTML:执行删除/截断操作后,导航栏出现导出按钮,点击下载清理后的单文件 HTML

数据结构

导出的 JSON 结构:

json
{
  "session": {
    "id": "ses_xxx",
    "title": "会话标题",
    "stats": { "total_messages": 222, "user_messages": 59, ... }
  },
  "messages": [
    {
      "id": "msg_xxx",
      "role": "user|assistant",
      "timestamp": "2026-07-23 16:18:45",
      "agent": "Orchestrator",
      "model": "glm-5.1",
      "parts": [
        {"type": "text", "data": {"text": "markdown内容"}},
        {"type": "tool", "data": {"type": "tool", "tool": "bash", "callID": "...", "state": {"status": "completed", "input": {"command": "..."}, "output": "...", "title": "...", "time": {"start": 123, "end": 456}}}},
        {"type": "reasoning", "data": {"text": "思考内容"}},
        {"type": "step-start", "data": {...}},
        {"type": "step-finish", "data": {...}},
        {"type": "compaction", "data": {...}},
        {"type": "patch", "data": {...}}
      ]
    }
  ]
}

Part 类型处理:

  • text:渲染为 Markdown(用户消息和助手消息的正文)
  • tool:折叠卡片,显示工具名+摘要,展开显示 Input 参数和 Output 结果
  • reasoning:折叠卡片,点击展开查看思考过程
  • step-start / step-finish:步骤分隔标记(不在页面显示)
  • compaction:琥珀色压缩事件卡片
  • patch:代码补丁卡片
  • agent:agent 切换标记

Tool 的 input 字段因工具而异:

  • read/edit/write:{filePath: "/path/to/file"}
  • bash:{command: "ls -la"}
  • grep:{pattern: "...", include: "*.ts"}
  • glob:{pattern: "**/*.py"}
  • task:{description: "...", prompt: "..."}

文件结构

opencode-session-visualizer/
├── SKILL.md                      # 本文件
├── scripts/
│   ├── export_session.py         # 数据库导出脚本(session_id → JSON)
│   └── generate_html.py          # HTML 生成脚本(JSON/DB → HTML)
└── assets/
    └── template.html             # HTML 模板(含 __SESSION_DATA__ 占位符)
脚本说明

export_session.py — 从 opencode.db 导出完整会话数据

  • python3 export_session.py <session_id> [output.json] — 导出指定会话
  • python3 export_session.py --list -n 15 — 列出最近 15 个会话
  • session_id 支持部分匹配

generate_html.py — 将会话数据注入模板生成 HTML

  • python3 generate_html.py --session <session_id> [output.html] — 直接从数据库生成(推荐)
  • python3 generate_html.py <session.json> [output.html] — 从导出的 JSON 生成
  • 模板路径自动解析为同目录下 assets/template.html

template.html — HTML 模板

  • 占位符 __SESSION_DATA__ 位于 <script id="conv-data"> 内
  • generate_html.py 将 JSON 数据注入占位符位置
  • 包含完整的 CSS/JS(暗色主题、Markdown 渲染、交互功能、删除/截断/导出)
  • CDN 依赖:marked.js、highlight.js、JetBrains Mono 字体

注意事项

  • 数据库路径由脚本自动检测(见上方「跨平台说明」),通常 5GB+,查询务必带 WHERE session_id
  • session_id 支持部分匹配(脚本会自动补全)
  • 大会话(200+ 条消息)生成的 HTML 可能 5MB+,浏览器可正常处理
  • 删除/截断功能在浏览器端操作,不影响原始数据库数据
  • 导出清理后的 HTML 时,只包含未被删除的消息

作者:nigo 微信公众号:逆行的狗

© nigo81, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, assets) in opencode-session-visualizer of nigo81/nigo-skills.

  • SKILL.md
  • assets/template.html
  • scripts/export_session.py
  • scripts/generate_html.py

Open the folder on GitHubat commit 6468211

Compare with similar skills

OpenCode Session Visualizer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

OpenCode Session Visualizer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
OpenCode Session Visualizer this skillnigo81/nigo-skills133—~1.3kAutomated safety check: PassMIT
Retinuejklthinking/retinue112—~279Automated safety check: PassMIT
MCP Server BuildershareAI-lab/learn-claude-code78k5 repos~1.2kAutomated safety check: PassMIT
Agent Memorytigerless-labs/agent-memory2.4k—~1.3kAutomated safety check: PassMIT
Plan Previewu-ichi/reviewable-html-workbench2981 repos~1.8kAutomated safety check: PassMIT
Visual HTML Rendereru-ichi/reviewable-html-workbench2981 repos~8.7kAutomated safety check: PassMIT

Similar skills

  • Retinue

    jklthinking/retinue

    Coordinate work through a local Retinue workspace using its MCP tools.

    112 GitHub stars~279 tokensUpdated today
    Agent WorkflowsAuto-check passed
  • MCP Server Builder

    shareAI-lab/learn-claude-code

    Walks through building MCP servers in Python or TypeScript that expose tools, resources and prompts to Claude, with templates, registration and testing.

    78k GitHub starsUsed in 5 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • Agent Memory

    tigerless-labs/agent-memory

    Read and write the shared long-term memory store. An agent skill from tigerless-labs/agent-memory.

    2.4k GitHub stars~1.3k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Plan Preview

    u-ichi/reviewable-html-workbench

    Plan Mode の <proposedplan を出す直前に、計画の段階・依存関係・検証観点を一時HTMLで視覚確認したい時に使う agent-internal skill。Use this agent-internal skill to create a temporary HTML preview for a plan just before presenting…

    298 GitHub starsUsed in 1 repo~1.8k tokens
    Agent WorkflowsAuto-check passed
  • Visual HTML Renderer

    u-ichi/reviewable-html-workbench

    HTMLを最終成果物として生成・検証・プレビューしたい時に使う共通レンダラー。Use this shared renderer when the user wants content turned into a final, validated, previewable HTML artifact.

    298 GitHub starsUsed in 1 repo~8.7k tokens
    Agent WorkflowsAuto-check passed
  • Explains how cognee stores session memory by session_id and bridges it into the permanent graph with improve(), including the stages, results and settings.

    32k GitHub stars~3.2k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from nigo81/nigo-skills

All 13 skills in this repo
  • Looks up Chinese company registration data in the CICPA industry knowledge base, from a quick search to a full 61-dimension export, subsidiary discovery and Excel output.

    133 GitHub stars~2.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Audit Report Checker

    nigo81/nigo-skills

    Checks audit reports (financial statements and notes) for cross-reference, summation and text errors, with arithmetic done by script and results exported to Excel and Markdown.

    133 GitHub stars~4.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Merges bank statements from several banks and formats into one standard Excel layout, then reconciles them against the general ledger with a layered matching engine.

    133 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check passed
  • A Chinese-language persona that answers accounting-standards and audit questions in the style of forum moderator Chen Yiwei, checking standards text before it replies.

    133 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Chinese-language tool that turns a business process description into a swimlane flowchart for internal control and audit work, exported as .drawio, PNG, SVG or VSDX.

    133 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Cross-checks a client's own registry data against its customers' and suppliers' to surface undisclosed related-party relationships for an audit.

    133 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about OpenCode Session Visualizer

What does OpenCode Session Visualizer do?

Exports an OpenCode session from its local database into a single self-contained HTML page styled like the official share view, with folding and editing controls. OpenCode's context compaction cannot be undone inside a session, but the local SQLite database still holds every message. This skill reads that database and builds one HTML file that copies the dark look of the official share page.

When should I use OpenCode Session Visualizer?

OpenCode Session Visualizer fits situations like: exporting an OpenCode conversation as a shareable HTML page; recovering the full conversation from before context compaction; trimming or deleting messages from a session before sharing it.

How do I install OpenCode Session Visualizer in Claude Code?

Run `npx skills add nigo81/nigo-skills --skill opencode-session-visualizer -a claude-code`. Or copy the skill folder (opencode-session-visualizer in nigo81/nigo-skills) into .claude/skills/opencode-session-visualizer in your project. Claude Code loads it when a task matches its description.

How do I install OpenCode Session Visualizer in Codex?

Run `npx skills add nigo81/nigo-skills --skill opencode-session-visualizer -a codex`. Or copy the skill folder (opencode-session-visualizer in nigo81/nigo-skills) into .agents/skills/opencode-session-visualizer in your project. Codex loads it when a task matches its description.

Can I use OpenCode Session Visualizer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add nigo81/nigo-skills --skill opencode-session-visualizer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/opencode-session-visualizer, .gemini/skills/opencode-session-visualizer, .github/skills/opencode-session-visualizer and .opencode/skills/opencode-session-visualizer in your project.

What does OpenCode Session Visualizer need to run?

Going by SKILL.md and its folder, OpenCode Session Visualizer needs Python for the scripts in its folder and the command-line tools its instructions call (python3). Our summary lists: Python 3 (`python3`, or `python` on Windows); OpenCode's local `opencode.db` database.

Does OpenCode Session Visualizer access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is OpenCode Session Visualizer safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does OpenCode Session Visualizer use?

OpenCode Session Visualizer is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does OpenCode Session Visualizer use?

About 1.3k tokens (SKILL.md is roughly 5.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to OpenCode Session Visualizer?

Skills that share tags, products or a category with OpenCode Session Visualizer: Retinue (jklthinking/retinue, 112 stars), MCP Server Builder (shareAI-lab/learn-claude-code, 78k stars), Agent Memory (tigerless-labs/agent-memory, 2.4k stars) and Plan Preview (u-ichi/reviewable-html-workbench, 298 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains OpenCode Session Visualizer?

nigo81 (a GitHub user) maintains it in nigo81/nigo-skills, which has 133 GitHub stars. The repository holds 13 skills in this directory. The repository was last updated on August 23, 2026.

Source: nigo81/nigo-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.