Langsung ke konten
Skillpedia
Pemrograman umum8.0k Β· #12727

diagramming-code

Fungsinya

Skill ini membuat diagram tentang bagaimana sebuah proyek perangkat lunak dibangun, memakai graf kode yang dibuat oleh alat Trailmark. Skill ini untuk developer dan peninjau yang ingin memahami basis kode yang belum dikenal.

Kapan dipakai

  • βœ“Saat Anda ingin bagan tentang fungsi mana yang memanggil fungsi lain.
  • βœ“Saat Anda membutuhkan peta bagaimana modul atau kelas dalam proyek saling bergantung.
  • βœ“Saat Anda ingin menemukan titik panas kompleksitas atau melacak alur data menuju fungsi sensitif dengan diagram berwarna.

Link skill

https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/diagramming-code/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/diagramming-code/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBisakah Anda menggambar diagram fungsi mana yang memanggil fungsi mana dalam proyek ini?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini membangun graf kode dengan Trailmark, lalu memakai skrip untuk menghasilkan teks diagram Mermaid dari graf itu. Teks Mermaid bisa ditampilkan di banyak alat.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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 trailmark skill)
  • Mutation testing triage (use the genotoxic skill)
  • 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
Pertanyaan umum

Apakah saya perlu memasang sesuatu?

Ya. Alat Trailmark harus terpasang. Jika pemasangan gagal, skill ini melaporkan kesalahannya alih-alih menggambar diagram dengan tangan.

Bisakah skill ini menggambar arsitektur sistem saya dari nol?

Tidak. Skill ini hanya menggambar diagram dari kode yang sudah ada. Ide arsitektur yang tidak ada di kode perlu digambar dengan tangan.

Format output apa yang dihasilkan?

Skill ini menghasilkan teks diagram Mermaid, yang bisa ditempel ke alat yang mendukung Mermaid.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
8.0k
Peringkat
#12727
Lisensi
CC-BY-SA-4.0
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa