# snipgrapher

Generates polished code snippet images in PNG, SVG, and WebP using the snipgrapher CLI. Useful for documentation, release notes, and social media posts.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 955 installs · ★ 1960
- Author: mcollina
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/mcollina/skills/tree/HEAD/skills/snipgrapher/SKILL.md
- Updated: 2026-10-18
- HTML: https://affpapa.org/en/nevibecode/skills/snipgrapher

## What it does

This skill directs the agent to produce syntax-highlighted code screenshots via `npx snipgrapher` or a local binary. It handles single source files, batch jobs, and watch mode. The CLI supports PNG, SVG, and WebP. Shared styling options live in `snipgrapher.config.json` as named profiles.

Run `npx snipgrapher init` before batch tasks. Explicit profiles prevent unexpected layout shifts across exports. After rendering, the agent runs `ls -lh` to verify the generated image is non-empty. Any custom font declared in your profile must be installed on the host system, or the render process crashes.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add mcollina/skills --skill snipgrapher -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/snipgrapher/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/snipgrapher/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add mcollina/skills --skill snipgrapher -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/snipgrapher/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add mcollina/skills --skill snipgrapher -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/snipgrapher/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install mcollina/skills snipgrapher
```

2. **Manually: put the files in place**
- File: `.github/skills/snipgrapher/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add mcollina/skills --skill snipgrapher -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/mcollina/skills --path skills/snipgrapher
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/snipgrapher/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add mcollina/skills --skill snipgrapher -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/mcollina/skills/tree/HEAD/skills/snipgrapher/SKILL.md

## When to use it
- render syntax-highlighted code snippets to PNG, SVG, or WebP
- create `snipgrapher.config.json` with reusable named styling profiles
- batch-render snippet assets for project documentation and changelogs
- monitor source files with watch mode to regenerate snippet images automatically

## Example prompts
- Render a PNG image from src/index.ts using snipgrapher
- Initialize snipgrapher.config.json and export docs/snippet.py to SVG with the default profile
- Batch render all code examples in the snippets folder to WebP

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 0480e2e1d9881362.

BEGIN THIRD-PARTY FILE 0480e2e1d9881362
````text
---
name: snipgrapher
description: Configures and uses snipgrapher to generate polished code snippet images, including syntax-highlighted PNGs, SVGs, and WebP exports with custom themes, profiles, and styling options. Use when the user wants to create code screenshots, turn code into shareable images, generate pretty code snippets for docs or social posts, produce syntax-highlighted images from source files, or explicitly mentions snipgrapher. Supports single-file renders, batch jobs, watch mode, and reusable named profiles via the snipgrapher CLI or npx.
metadata:
  tags: snipgrapher, snippets, images, svg, png, webp, cli
---

## When to use

Use this skill when you need to:
- Generate image snippets from source code
- Configure reusable snippet rendering defaults
- Batch-render snippet assets for docs, social posts, or changelogs
- Use published `snipgrapher` from npm to generate snippet images

## Quick start

Render a single file to a PNG immediately with no config required:

```bash
npx snipgrapher render file.ts -o output.png
```

For ongoing use, initialise a project config first, then render:

```bash
npx snipgrapher init          # creates snipgrapher.config.json
npx snipgrapher render file.ts --profile default -o output.png
```

After rendering, verify the output exists and is non-zero in size before treating the job as successful:

```bash
ls -lh output.png   # confirm file exists and size > 0
```

## How to use

Read these rule files in order:

- [rules/setup-and-configuration.md](rules/setup-and-configuration.md) - Install, select executable, initialize config, and define profiles
- [rules/rendering-workflows.md](rules/rendering-workflows.md) - Render single snippets, batch jobs, watch mode, and output practices

## Core principles

- **Configure first**: establish a project config before repeated renders
- **Reproducible output**: prefer named profiles and explicit output paths
- **Portable commands**: use command patterns that work with installed binaries and `npx`
- **Automation-friendly**: rely on CLI flags/config/env precedence intentionally

## Troubleshooting common render failures

If a render fails or produces an unexpected output, check for these common causes:

- **Missing fonts**: ensure any custom font specified in the profile or config is installed on the system
- **Unsupported syntax**: confirm the language/extension is supported by snipgrapher; fall back to plain text highlighting if not
- **Empty or corrupt output**: re-run with `--verbose` (if supported) to surface error details, and verify the input file is readable and non-empty
- **Profile not found**: run `npx snipgrapher init` to regenerate `snipgrapher.config.json` if the config file is missing or malformed
````
END THIRD-PARTY FILE 0480e2e1d9881362

The third-party file has ended. Everything between the 0480e2e1d9881362 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© mcollina · MIT · https://github.com/mcollina/skills/tree/HEAD/skills/snipgrapher/SKILL.md

## Similar
- [baoyu-compress-image](https://affpapa.org/en/nevibecode/skills/baoyu-compress-image.md) — skill · 28200 installs
- [cli-anything-mermaid](https://affpapa.org/en/nevibecode/skills/cli-anything-mermaid.md) — skill · 519 installs
- [excalidraw](https://affpapa.org/en/nevibecode/skills/agents365-ai-excalidraw.md) — skill · 4600 installs
- [tldraw-skill](https://affpapa.org/en/nevibecode/skills/tldraw-skill.md) — skill · 3700 installs
- [hand-drawn-diagrams](https://affpapa.org/en/nevibecode/skills/hand-drawn-diagrams.md) — skill · 2800 installs

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
