# crypto-protocol-diagram

Reads protocol code or a spec and writes a Mermaid sequenceDiagram with crypto annotations, plus an ASCII diagram in the reply.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3900 installs · ★ 7805
- Author: trailofbits
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills/tree/HEAD/plugins/trailmark/skills/crypto-protocol-diagram/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/crypto-protocol-diagram

## What it does

Point it at a crypto protocol and it maps the message flow: who sends what, which operation runs at each step, what phases the handshake has. The Mermaid `sequenceDiagram` is written to a file, and an ASCII version lands inline in the answer.

Input can be implementation code (`.py`, `.rs`, `.go`, `.ts`, `.js`, `.cpp`, `.c`) or a specification: an RFC, a paper, pseudocode, plain prose, a ProVerif `.pv` model, a Tamarin `.spthy` one. The work follows a checklist — classify the input, find protocol entry points with `rg` searches over names like `handshake` and `keygen`, list the parties, then annotate each cryptographic step and show error paths as `alt` blocks. Specs behind a URL arrive through WebFetch; Read, Write, Grep, Glob and Bash handle local files.

When both code and a spec exist, it starts from the spec and then checks the implementation against it, flagging divergences. That is why it does not sketch from memory. Call graphs and class hierarchies are the job of the neighbouring `diagramming-code` skill, since this one extracts protocol semantics rather than code structure.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill crypto-protocol-diagram -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill crypto-protocol-diagram -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill crypto-protocol-diagram -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install trailofbits/skills crypto-protocol-diagram
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill crypto-protocol-diagram -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/trailofbits/skills --path plugins/trailmark/skills/crypto-protocol-diagram
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill crypto-protocol-diagram -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/trailofbits/skills/tree/HEAD/plugins/trailmark/skills/crypto-protocol-diagram/SKILL.md

## When to use it
- trace a TLS handshake through library source
- pull message flow out of an RFC and draw it
- see where the code drifted from the spec
- visualise a ProVerif model before checking it
- sketch the X3DH key exchange phases

## Example prompts
- Diagram the handshake in `src/handshake.rs` as a Mermaid sequenceDiagram
- Extract the message flow from this RFC and annotate the crypto steps
- Compare `noise/` against the `noise.spthy` model and mark the differences

## Similar
- [mcp-protocol-specialist](https://affpapa.org/en/nevibecode/agents/mcp-protocol-specialist.md) — subagent · 781 installs
- [diagram-design](https://affpapa.org/en/nevibecode/skills/diagram-design.md) — skill · 19600 installs
- [diagram-creator](https://affpapa.org/en/nevibecode/skills/diagram-creator.md) — skill · 5000 installs
- [follow-the-crypto](https://affpapa.org/en/nevibecode/skills/follow-the-crypto.md) — skill · 1800 installs
- [crypto-report](https://affpapa.org/en/nevibecode/skills/crypto-report.md) — skill · 4700 installs
- [diagram-generator](https://affpapa.org/en/nevibecode/skills/diagram-generator.md) — skill · 1300 installs

From the same set: [trailofbits/skills](https://affpapa.org/en/nevibecode/by/trailofbits/skills.md) — 77 cards

---
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
