| name | code-screenshot |
| description | Generate beautiful code/text screenshots as PNG images for sharing in chat clients. Use when user asks for "代码截图/代码美化截图/把这段代码做成图片/代码图片", or when assistant is about to present a code block and wants a readable screenshot (especially for long code, multi-client sharing, or when formatting may break). Supports syntax highlighting, **line numbers (default ON)**, title, and theme. |
Code Screenshot (PNG/JPG)
Convert a code snippet or a short text block into an image suitable for Telegram/WeChat/Slack/etc.
Notes:
- JPG is often more likely to display inline as a photo preview in chat clients.
- PNG keeps crisp edges (best quality) but may be shown as a file/document in some clients.
Default behavior
- Default output: JPG (better inline preview in Telegram).
- Use PNG when the user asks for lossless.
- Default look: Carbon-like lavender gradient + dark purple card + window chrome (3 dots).
- Default line numbers: ON.
- Default look: Carbon-like (lavender gradient frame + dark rounded card).
- Default font:
Monaco on macOS, with DejaVuSansMono / LiberationMono fallbacks on Linux.
- If language is unknown, still render as monospace text.
When to use
Use this skill when:
- The user explicitly asks for a code screenshot (代码截图/美化截图/截图形式发我).
- You are about to send a longer code block and want consistent rendering across clients.
- The user wants a “demo snippet” that should look polished.
Do not use by default for very short one-liners unless asked.
How to produce the image
Use the bundled script:
scripts/render_code_image.py
It will auto-bootstrap a local Python venv under the skill folder and install dependencies (Pillow + Pygments) if needed.
Inputs
You can provide code via:
--in <path> (recommended), or
- stdin (use
--stdin).
Specify:
--lang <lexer> (examples: python, js, ts, go, json, yaml, bash, sql)
--title "..." optional
--line-numbers optional (recommended; default in our workflow)
--theme dark|light optional
--frame none|gradient optional (default: gradient)
--bg lavender|sunset|mint optional (default: lavender)
--chrome / --no-chrome optional (default: chrome on when --frame gradient)
Typical workflow
- Extract the code/text from the user message.
- Save it to a temp file in the workspace (e.g.
work/code-screenshot/snippet.txt).
- Run the script to generate a PNG.
- Send the PNG back using the
message tool with media=<png path>.
Example (JPG for better inline preview):
python3 skills/code-screenshot/scripts/render_code_image.py \
--in work/code-screenshot/snippet.py \
--out work/code-screenshot/snippet.jpg \
--format jpg \
--lang python \
--title "Example" \
--line-numbers
Example (PNG lossless):
python3 skills/code-screenshot/scripts/render_code_image.py \
--in work/code-screenshot/snippet.py \
--out work/code-screenshot/snippet.png \
--format png \
--lang python \
--title "Example" \
--line-numbers
Intention detection (important)
Two ways to trigger:
-
Explicit (strong trigger)
- 用户明确说:代码截图/代码图片/把这段代码做成图片/代码美化截图
- 或者说:发群里/发朋友圈/发推/做海报/做封面,并且内容主要是代码
-
Implicit (assistant judgment; recommend trigger)
- 代码块较长(例如 > 25 行 或 > 1200 字符),在聊天里容易折叠/难读
- 需要严格保留格式(对齐、缩进、空格、注释结构),且目标平台容易吞格式
- 讨论场景需要“逐行沟通/审阅”,行号默认开启更利于交流
Do not trigger by default when:
- 只有 1–10 行、且用户需要可复制粘贴
- 用户明确说“不要图片”
When using implicit trigger, briefly mention you’re sending it as an image for readability.