diagramming-code
Qué hace
Esta skill crea diagramas de cómo está construido un proyecto de software, usando un grafo de código generado por la herramienta Trailmark. Es para desarrolladores y revisores que quieren entender una base de código desconocida.
Cuándo usarla
- ✓Cuando quieres un gráfico de qué funciones llaman a otras funciones.
- ✓Cuando necesitas un mapa de cómo dependen entre sí los módulos o clases de un proyecto.
- ✓Cuando quieres detectar puntos calientes de complejidad o rastrear el flujo de datos hacia funciones sensibles con diagramas codificados por color.
Link de la skill
https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/diagramming-code/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“¿Puedes dibujar un diagrama de qué funciones llaman a cuáles en este proyecto?”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
Construye un grafo del código con Trailmark, y luego usa un script para producir texto de diagrama Mermaid a partir de ese grafo. El texto Mermaid se puede mostrar en muchas herramientas.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Diagramming Code
Generates Mermaid diagrams from Trailmark's code graph. A pre-made script
handles Mermaid syntax generation; Claude selects the diagram type and
parameters. Trailmark 0.4.0 includes a native trailmark diagram command; use
it only after a version/command check, otherwise use this skill's bundled
script.
When to Use
- Visualizing call paths between functions
- Drawing class inheritance hierarchies
- Mapping module import dependencies
- Showing class structure with members
- Highlighting complexity hotspots with color coding
- Tracing data flow from entrypoints to sensitive functions
When NOT to Use
- Querying the graph without visualization (use the
trailmarkskill) - Mutation testing triage (use the
genotoxicskill) - Architecture diagrams not derived from code (draw by hand)
Prerequisites
trailmark must be installed. If uv run trailmark fails, run:
uv tool install trailmark
# Python snippets: uv run --with trailmark python - (a tool env is not importable)
DO NOT fall back to hand-writing Mermaid from source code reading. The script uses Trailmark's parsed graph for accuracy. If installation fails, report the error to the user.
Version Gate
Check whether native v0.4 diagram support exists:
trailmark diagram --help 2>/dev/null || uv run trailmark diagram --help 2>/dev/null
If this succeeds, you may use trailmark diagram. If it fails, use
uv run {baseDir}/scripts/diagram.py, which keeps the older skill workflow
intact. Do not assume the native CLI exists on Trailmark 0.2.x.
Quick Start
uv run {baseDir}/scripts/diagram.py \
--target {targetDir} --language auto --type call-graph \
--focus <function> --depth 2
# Trailmark 0.4.0+ equivalent after the Version Gate succeeds
uv run trailmark diagram \
--target {targetDir} --language auto --type call-graph \
--focus <function> --depth 2
Output is raw Mermaid text. Wrap in a fenced code block:
```mermaid
flowchart TB
...
```
Diagram Types
├─ "Who calls what?" → --type call-graph
├─ "Class inheritance?" → --type class-hierarchy
├─ "Module dependencies?" → --type module-deps
├─ "Class members and structure?" → --type containment
├─ "Where is complexity highest?" → --type complexity
└─ "Path from input to function?" → --type data-flow
For detailed examples of each type, see references/diagram-types.md.
Workflow
Diagram Progress:
- [ ] Step 1: Verify trailmark is installed
- [ ] Step 2: Identify diagram type from user request
- [ ] Step 3: Determine focus node and parameters
- [ ] Step 4: Run diagram.py script (or native trailmark diagram on v0.4+)
- [ ] Step 5: Verify output is non-empty and well-formed
- [ ] Step 6: Embed diagram in response
Step 1: Run uv run trailmark analyze --language auto --summary {targetDir}. Install
if it fails. Do not run engine.preanalysis() for a diagram: the diagram
command builds its own graph and does not use pre-analysis data, so every
diagram type is identical with or without it. data-flow uses the
entrypoints Trailmark records while parsing.
If auto-detection is wrong for the target, rerun with an explicit language or
comma-separated list such as python,rust.
Step 2: Match the user's request to a --type using the decision tree
above.
Step 3: For call-graph and data-flow, identify the focus function.
Default --depth 2. Use --direction LR for dependency flows.
Step 4: Run the script and capture stdout. If the native v0.4 CLI is available, either command is acceptable; prefer the bundled script when you need behavior consistent with this skill's references.
Step 5: Check: output starts with flowchart or classDiagram,
contains at least one node. If empty or malformed, consult
references/mermaid-syntax.md.
Step 6: Wrap output in ```mermaid ``` code fence.
Script Reference
uv run {baseDir}/scripts/diagram.py [OPTIONS]
# or, on Trailmark 0.4.0+:
uv run trailmark diagram [OPTIONS]
| Argument | Short | Default | Description |
|---|---|---|---|
--target |
-t |
required | Directory to analyze |
--language |
-l |
python |
Source language |
--type |
-T |
required | Diagram type (see above) |
--focus |
-f |
none | Center diagram on this node |
--depth |
-d |
2 |
B |
Preguntas frecuentes
¿Tengo que instalar algo?
Sí. La herramienta Trailmark debe estar instalada. Si la instalación falla, la skill informa del error en lugar de dibujar el diagrama a mano.
¿Puede dibujar la arquitectura de mi sistema desde cero?
No. Solo dibuja diagramas a partir del código que existe. Las ideas de arquitectura que no están en el código deben dibujarse a mano.
¿Qué formato de salida produce?
Produce texto de diagrama Mermaid, que se puede pegar en herramientas que soporten Mermaid.
Detalles
Descripción original del autor
Generates Mermaid diagrams from Trailmark code graphs. Produces call graphs, class hierarchies, module dependency maps, containment diagrams, complexity heatmaps, and attack surface data flow visualizations. Use when visualizing code architecture, drawing call graphs, generating class diagrams, creating dependency maps, producing complexity heatmaps, or visualizing data flow and attack surface paths as Mermaid diagrams.
repo: trailofbits/skills
Popularidad
- Estrellas en GitHub
- 8,0 mil
- Posición en el ranking
- #12727
- Licencia
- CC-BY-SA-4.0
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
audit-context-building
8,0 milAyuda a tu agente a conocer un código desconocido antes de una revisión de seguridad, mapeando qué supone, garantiza y necesita cada función.
algorand-vulnerability-scanner
8,0 milAyuda a tu agente a revisar contratos de Algorand en TEAL o PyTeal en busca de 11 problemas de seguridad comunes, como el rekeying o las tarifas sin control.
audit-prep-assistant
8,0 milAyuda a tu agente a preparar tu código para una auditoría de seguridad externa, con análisis estático, pruebas, limpieza de código muerto y buena documentación.
cairo-vulnerability-scanner
8,0 milAyuda a tu agente a revisar contratos de Cairo en StarkNet en busca de 6 problemas graves, como desbordamientos, mensajes arriesgados entre capas y firmas repetidas.
Skills parecidas
diffs
394 milPermite que tu agente genere un diff real y compartible de los cambios, como enlace de visualización o archivo de imagen, en lugar de un resumen escrito a mano.
coding-agent
394 milAyuda a tu agente a pasar un trabajo de programación grande a Codex, Claude Code u OpenCode como trabajador en segundo plano, y después revisar su progreso.
gh-issues
394 milAyuda a tu agente a encontrar incidencias de GitHub, elegir cuáles trabajar y abrir pull requests con correcciones, incluido el seguimiento de los comentarios de revisión.