preview
Display code, diffs, images, and other content in a tmux pane or popup. Auto-detects nvim/megaterm for floating popups.
Best use case
preview is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Display code, diffs, images, and other content in a tmux pane or popup. Auto-detects nvim/megaterm for floating popups.
Teams using preview should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/preview/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How preview Compares
| Feature / Agent | preview | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Display code, diffs, images, and other content in a tmux pane or popup. Auto-detects nvim/megaterm for floating popups.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# Preview Skill
Display content in a tmux pane or popup next to the pi agent. Supports code files, JSON, markdown, diffs, images, logs, and more.
## CRITICAL: Pane Safety Rules
**Never kill or disrupt the pane running pi.** Before killing, closing, or replacing ANY pane:
1. **Identify your own pane first:** `tmux display-message -p '#{pane_id}'` — this is pi's pane. Never kill it.
2. **Before `kill-pane -t X`:** Verify X is not pi's pane ID.
3. **Before sending keys to any pane:** Verify the expected app is actually running there:
```bash
# What's running in that pane?
tmux display-message -t "$TARGET" -p '#{pane_current_command}'
# Confirm visually
tmux capture-pane -p -t "$TARGET" -S -3
```
4. **Never send keys blindly.** If target pane doesn't have the expected process, STOP. Re-discover the correct pane.
5. **Never assume pane identity persists.** User may close, rearrange, or swap panes between your commands. Always re-verify.
## Requirements
- Must be running inside tmux
- `preview-ai` script must be in PATH (installed via dotfiles)
## Commands
### /preview
Display content in a preview pane or popup.
```
/preview [options] [type] <content>
```
**Options:**
- `-m, --mode <mode>` - Preview mode: `tmux-split`, `tmux-float`, `auto` (default)
- `--auto-close-after <seconds>` - Auto-close pane after N seconds
- `--delta` - Explicit delta flag (delta is now the default)
- `-h, --help` - Show help
**Modes:**
- `tmux-split` - Side pane (default outside nvim)
- `tmux-float` - Large popup window (default inside nvim/megaterm)
- `auto` - Auto-detect: popup if inside nvim, split otherwise
**Content Types:**
- `json` - JSON content (inline or file path)
- `markdown` - Markdown content (inline or file path)
- `diff` - jj diff arguments (e.g., "-r @") - uses delta
- `log` - jj log arguments (e.g., "-n 5")
- `bead` - Bead task ID - renders with glow
- `file` - File path to preview with bat
- `image` - Image file path (uses chafa or kitty protocol)
- `cmd` - Shell command to execute (prefix with "cmd:")
- `auto` - Auto-detect type (default)
**Examples:**
```
# Preview JSON
/preview json '{"foo": "bar"}'
/preview json /path/to/data.json
# Preview diffs
/preview diff -r @ # Uses delta for diff viewing
/preview diff # Current working copy changes
# Preview files
/preview file ~/.config/nvim/init.lua
/preview /tmp/output.log # Auto-detects type
# Preview markdown
/preview markdown "# Hello World"
/preview /path/to/README.md
# Preview images
/preview image /path/to/screenshot.png
# Preview with auto-close
/preview --auto-close-after 5 diff # Auto-close after 5 seconds
# Preview jj log
/preview log -n 10
/preview log -r 'main..'
# Explicit mode selection
/preview --mode tmux-float diff # Force popup mode
/preview -m tmux-split file foo.lua # Force split pane mode
```
## Keyboard Shortcuts
- `Ctrl+Shift+P` - Quick preview of current diff (equivalent to `/preview diff`)
## How It Works
The preview extension wraps the existing `preview-ai` bash script which:
1. **Auto-detection:**
- Inside nvim/megaterm (`$NVIM` set): Uses `tmux display-popup` (large floating window)
- Regular tmux: Uses `tmux split-window` (side pane)
2. **Safe pane management:**
- Never renders in the caller's pane
- Only searches current session/window for existing previews
- Reuses existing preview pane (kills and recreates)
2. **Content rendering:**
- JSON: Uses `jq` for formatting
- Markdown: Uses `glow` for rendering
- Diffs: Uses `delta` for syntax-highlighted diff viewing
- Images: Uses `chafa` for terminal display or kitty protocol
- Files: Uses `bat` with syntax highlighting
- Logs: Uses `jj log` with paging disabled
3. **Closing the preview:**
- Press `q` or `Escape` to close the preview pane/popup
## Limitations
- Requires tmux (will not work in plain terminal)
- Preview pane is created in current window only
- Large files may take time to render
- Image quality depends on terminal capabilities
## Troubleshooting
**Error: "Preview requires tmux"**
- Solution: Run pi inside a tmux session
**Error: "preview-ai failed"**
- Check if `preview-ai` is in PATH: `which preview-ai`
- Check if required tools are installed: `bat`, `glow`, `jq`, `delta`, `chafa`
**Preview pane not appearing:**
- Check if you're in the correct tmux window
- Try manually: `preview-ai diff` in a terminal
**Image preview not working:**
- Check if `chafa` is installed: `which chafa`
- Check terminal capabilities for image display
- Try `preview file /path/to/image.png` to see actual output
## Related
- **tmux skill** - For advanced tmux pane control
- **files extension** - Browse and manage files in the session
- `~/.dotfiles/bin/preview-ai` - The underlying bash scriptRelated Skills
writing-clearly-and-concisely
Apply Strunk's timeless writing rules to ANY prose humans will read - documentation, commit messages, error messages, explanations, reports, or UI text. Makes your writing clearer, stronger, and more professional.
web-search
Web search using DuckDuckGo (free, unlimited). Falls back to pi-web-access extension for content extraction.
web-browser
Interact with web pages using agent-browser CLI. MUST run 'browser connect 9222' FIRST to use existing browser with authenticated sessions.
tmux
Remote control tmux sessions for interactive CLIs (python, gdb, etc.) by sending keystrokes and scraping pane output.
ticket-worker
Work on a single tk ticket end-to-end. Use when the user says 'work on ticket X' or when spawned by work-tickets.sh.
ticket-creator
Create and refine tickets for the tk ticket system. Use when the user says 'create tickets for X', 'refine ticket X', 'break this into tickets', 'seed tickets from plan', or anything about creating or refining tk tickets.
tell
Delegate tasks to other agents - pi sessions or external agents (claude, opencode, aider). Non-blocking with task tracking and completion notifications.
task-pipeline
Structured workflow for research → plan → tickets → work. Use when starting or continuing a task with /task, /plan, or /tickets commands.
mcpctl
Manage MCP server configurations — add, remove, list, inspect, troubleshoot. Use when asked to "add mcp server", "remove mcp", "list mcp servers", "mcp status", "configure mcp", "troubleshoot mcp", or any MCP server management task.
handoff
Save session state for later pickup. Use /handoff when context is degrading, /pickup to resume in a new session.
github
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
git-worktrees
Git worktree conventions and commands. Use when creating, switching to, or cleaning up git worktrees for branch work.