Index of every page on this site: llms.txt
All skills
xenodium avatar
by xenodiumxenodium/emacs-skills151 stars
19
Run it yourself

This skill should be used when the user invokes "/d2" to create a diagram from the current context using D2 and output the resulting image path.

Use this Skill: https://skilld.dev/gh/xenodium/emacs-skills/d2

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈37 tokens for metadata: the name and description. ≈638 when used: this file.

How this Skill uses context

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

This Skill turns off automatic use in Claude Code. Its description stays out of the automatic Skill list by default.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Create diagrams with D2

Create a diagram from the most recent interaction context using D2. Generate a PNG image and output it as a markdown image so it renders inline.

How to create a diagram

  1. Extract or derive diagrammable data from the current context.
  2. If the Emacs foreground color and background mode are not already known from a previous diagram in this session, query them:
    emacsclient --eval '(face-foreground (quote default))'
    emacsclient --eval '(frame-parameter nil (quote background-mode))'
    The first returns a hex color like "#eeffff". The second returns dark or light. Reuse both for all subsequent diagrams.
  3. Write a D2 file to a temporary file using the foreground color.
  4. Run D2 with --theme 200 if background mode is dark, or --theme 0 if light.
  5. Output the result as a markdown image on its own line:
    ![description](/tmp/agent-diagram-XXXX.png)
# Use --theme 200 for dark, --theme 0 for light
d2 --theme 200 --pad 40 /tmp/agent-diagram-XXXX.d2 /tmp/agent-diagram-XXXX.png

D2 template

Use --theme 200 for dark or --theme 0 for light, based on the Emacs background mode. Apply the queried foreground color to style.font-color and style.stroke on nodes and edges.

direction: right

node1: Label {
  style.font-color: "#eeffff"
  style.fill: "#2d3748"
  style.stroke: "#eeffff"
}

node2: Label {
  style.font-color: "#eeffff"
  style.fill: "#2d3748"
  style.stroke: "#eeffff"
}

node1 -> node2: label {style.stroke: "#eeffff"; style.font-color: "#eeffff"}

Rules

  • Query the Emacs foreground color once per session and reuse it for all subsequent diagrams. Only query again if the color is not already known.
  • Query the Emacs background mode once per session via (frame-parameter nil 'background-mode). Use --theme 200 for dark or --theme 0 for light. Always use --pad 40.
  • Always use a timestamp in the filename (e.g., /tmp/agent-diagram-$(date +%s).png). Never use descriptive names.
  • Set the queried foreground color on style.font-color and style.stroke for all nodes and edges so the diagram is readable on the user's Emacs background.
  • Use meaningful fill colors to distinguish different types of elements.
  • After D2 runs successfully, output a markdown image (![description](path)) on its own line.
  • Choose an appropriate layout direction and structure for the data.
  • Include labels on edges when they add clarity.
  • If no diagrammable data exists in the recent context, inform the user.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo4 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The analyzed content consists of a comprehensive instruction set for an AI agent performing security audits. It defines threat categories, detection rules, and trust scopes but does not contain any executable code, malicious payloads, or security vulnerabilities. It is purely instructional and serves as a defensive framework for auditing other skills.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer8mo

    1/1 file flagged

Signed by skilld at a158238. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 9 months ago
tools
Bash
disable-model-invocation
true

README badge

README badge for xenodium/emacs-skills/d2