Snipgrapher

作者 mcollina72b727514771無授權條款收錄於 2026年10月8日更新於 2026年10月8日

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.

AI 產生的概覽

設定並使用 snipgrapher 命令列工具,把程式碼算繪成帶語法突顯的 PNG、SVG 或 WebP 程式碼片段圖片。

功能
此技能引導代理使用 snipgrapher 命令列工具,將原始檔轉成精美的程式碼片段圖片。內容涵蓋初始化專案設定、定義可重複使用的具名設定檔,以及以單檔、批次或監看模式算繪 PNG、SVG 或 WebP,並支援自訂主題與樣式。它也列出常見算繪失敗的排查方式,例如缺少字型、語法不受支援、輸出為空以及找不到設定檔。
適用情境
當使用者需要程式碼截圖或可分享的程式碼圖片時使用,例如為文件、更新日誌或社群貼文製作精美程式碼片段。也適合批次產生程式碼片段素材、建立可重複使用的算繪預設值,或使用者明確提到 snipgrapher 時。
執行需求
需要 Node.js 與 npm/npx,並需要網路連線以從 npm 取得已發佈的 snipgrapher 套件,或使用本機已安裝的 snipgrapher 執行檔。使用自訂主題時,相關字型須已安裝於系統中。此技能未附帶指令碼,僅為說明文件。

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.jsonnpx 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 [blocked] - Install, select executable, initialize config, and define profiles
  • rules/rendering-workflows.md [blocked] - 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

來源與署名

來源:mcollina/skills位於skills/snipgrapher提交72b7275

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架