---
name: session-viewer
description: "Render Codex, Claude Code, OpenClaw, or Pi session JSONL transcripts as a searchable, shareable single-file HTML viewer."
title: session-viewer
canonical_url: https://skilld.dev/gh/openclaw/agent-skills/session-viewer
last_updated: 2026-11-12T12:14:50.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/agents/openai.yaml), [package.json](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/package.json), [scripts/core/detect.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/core/detect.ts), [scripts/core/jsonl.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/core/jsonl.ts), [scripts/core/types.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/core/types.ts), [scripts/html.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/html.ts), [scripts/importers/claude.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/importers/claude.ts), [scripts/importers/codex.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/importers/codex.ts), [scripts/importers/pi-openclaw.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/importers/pi-openclaw.ts), [scripts/open-browser.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/open-browser.ts), [scripts/read-session.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/read-session.ts), [scripts/session-viewer.test.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/session-viewer.test.ts), [scripts/session-viewer.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/session-viewer.ts), [scripts/styles.ts](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/scripts/styles.ts), [tsconfig.json](https://skilld.dev/api/skills-raw/openclaw/agent-skills/session-viewer/tsconfig.json).
>
> If the user asked to install this Skill, run `npx skilld install openclaw/agent-skills/session-viewer`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/session-viewer`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/openclaw/agent-skills/session-viewer) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/session-viewer`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/session-viewer --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/session-viewer --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Session Viewer

Use when asked to view, export, inspect, or share a Codex, Claude Code, OpenClaw, or Pi session transcript in a browser.

## Commands

Resolve `SESSION_VIEWER_SKILL_DIR` to the directory containing this `SKILL.md`.
Use that installed source for commands, independent of the current repository.

When the session path is not known and the `agent-transcript` skill is available, use it first to find the likely JSONL session:
Resolve `TRANSCRIPT_SKILL_DIR` from that skill's actual installation before running:

```bash
"$TRANSCRIPT_SKILL_DIR/scripts/agent-transcript" find \
  --query "$USER_GOAL_OR_TITLE $BRANCH_OR_URL" \
  --cwd "$PWD" \
  --since-days 14
```

Pick the highest-confidence `file` result, then render it with `session-viewer`.

Render with the resolved installation:

```bash
node "$SESSION_VIEWER_SKILL_DIR/scripts/session-viewer.ts" <session.jsonl> --out /tmp/session.html --open
```

Useful modes:

```bash
node "$SESSION_VIEWER_SKILL_DIR/scripts/session-viewer.ts" <session.jsonl> --out session.html
node "$SESSION_VIEWER_SKILL_DIR/scripts/session-viewer.ts" <session.jsonl> --raw --out session.html
node "$SESSION_VIEWER_SKILL_DIR/scripts/session-viewer.ts" --blank --out viewer.html --open
```

Defaults:

- detects `codex`, `claude`, or `pi-openclaw`
- embeds normalized session data into one HTML file
- keeps tool input/output text in the DOM so browser search can find it
- reads the complete session file, preserving full history in both export modes
- `--raw` embeds the original JSONL and lets the browser parse it
- `--blank` creates a reusable file-picker viewer

For an explicitly partial export, use `--max-read-bytes N` with a positive integer byte limit (for example, `--max-read-bytes 8388608` for 8 MiB). Oversized files retain the head and tail, with a visible omission warning in the CLI and exported viewer. Truncated boundary records may be omitted; `--raw` embeds only the retained JSONL. Files at or below the limit remain complete. Short reads are retried; an unexpected end of file fails the export instead of reporting a complete read.

This opt-in read limit applies only to CLI file exports. The browser's file picker continues to load complete files.

## Where Sessions Live

Codex:

```bash
find "${CODEX_HOME:-$HOME/.codex}/sessions" -name 'rollout-*.jsonl' -type f | sort
ls -t "${CODEX_HOME:-$HOME/.codex}"/sessions/*/*/*/rollout-*.jsonl | head
```

Current OpenClaw stores session indexes and transcripts in per-agent SQLite databases.
Use native session discovery:

```bash
openclaw sessions --agent "<agentId>" --json
```

This lists sessions; it does not export a JSONL transcript.
The viewer requires a supported JSONL transcript, not a SQLite database or session-list JSON.
Use OpenClaw's native session view when no compatible JSONL export is available.
See the [OpenClaw sessions reference](https://docs.openclaw.ai/cli/sessions).

Legacy OpenClaw JSONL:

```bash
AGENT_ID="<agentId>"
SESSION_DIR="${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/agents/$AGENT_ID/sessions"
ls -t "$SESSION_DIR"/*.jsonl | head
find "${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/agents" -path '*/sessions/*.jsonl' -type f | sort
```

Only legacy file stores use `sessions.json` beside those transcripts to map session keys to ids.
For standalone Pi, select its actual JSONL transcript rather than assuming the OpenClaw directory layout.

Claude Code:

```bash
find "$HOME/.claude/projects" -name '*.jsonl' -type f | sort
ls -t "$HOME/.claude/projects"/**/*.jsonl | head
```

Some Claude installs also keep exported JSON/JSONL under project-specific cache folders; prefer the newest JSONL with the target repo path in its parent folder.

## Development

Scripts are native Node TypeScript. Keep them erasable:

- ok: types, interfaces, unions, `satisfies`
- avoid: enums, namespaces, decorators, parameter properties
- no tsconfig path aliases; use relative imports

Importer ownership:

- `scripts/importers/codex.ts`: Codex rollout JSONL
- `scripts/importers/claude.ts`: Claude Code JSONL
- `scripts/importers/pi-openclaw.ts`: Pi/OpenClaw session JSONL

Validate:

```bash
npm ci --ignore-scripts
npm run typecheck
node --test skills/session-viewer/scripts/session-viewer.test.ts
scripts/validate-skills
```
