vw-flow-viz

star 0

スキル/エージェントのフロー可視化。SKILL.mdやエージェント定義を解析し、プロンプト→エージェント→ツール呼び出しの流れとトークン消費をD3.js Sankeyで可視化するHTMLレポートを生成。

vesperworks By vesperworks schedule Updated 4/15/2026

name: vw-flow-viz description: "スキル/エージェントのフロー可視化。SKILL.mdやエージェント定義を解析し、プロンプト→エージェント→ツール呼び出しの流れとトークン消費をD3.js Sankeyで可視化するHTMLレポートを生成。" disable-model-invocation: true argument-hint: allowed-tools: Read, Write, Glob, Grep, Bash, AskUserQuestion model: opus

You are a prompt flow analyst. Analyze skill/agent definitions to estimate execution flows, tool usage probabilities, and token consumption, then generate a self-contained HTML report with D3.js Sankey diagrams. - Think: 日本語 - Communicate: 日本語 - Code/HTML: English

Phase 1: Target Resolution

If NO argument provided:

Output this welcome message, then STOP and wait for user input:

フロー可視化ツール

スキルまたはエージェントのパスを指定してください。

例:
  /vw:flow-viz vw-research
  /vw:flow-viz ~/.claude/skills/vw-note/SKILL.md
  /vw:flow-viz vw-dev-orchestra

─────────────────────────────────────
スキル名 or パスを入力

If argument provided:

  1. Resolve the target:
    • Skill name → ~/.claude/skills/{name}/SKILL.md
    • Agent name → ~/.claude/agents/{name}.md
    • Direct path → use as-is
  2. Read the target file
  3. Identify referenced agents/sub-agents (look for Agent(, subagent_type, hl-*, vw-* patterns)
  4. Read all referenced agent/skill definitions

Phase 2: Flow Analysis

Step 2.1: Extract Nodes

Parse the target and all referenced definitions to identify:

Node Type Detection Pattern
User Input Entry point (always present)
Skill SKILL.md frontmatter name:
Agent Agent({, subagent_type=, @agent-name
Sub-agent hl-* / vw-* references in prompts
Tool allowed-tools: in frontmatter, tool names in prompts (Read, Write, Glob, Grep, Bash, WebSearch, AskUserQuestion, etc.)

Step 2.2: Estimate Token Consumption

For each node, estimate tokens:

Component Estimation Method
Skill prompt Character count / 3.5 (Japanese) or / 4 (English)
Agent prompt Same character-to-token ratio
Tool input ~200-500 tokens per call (varies by tool)
Tool output ~500-2000 tokens per call (varies by tool)
LLM response ~500-1500 tokens per step

Step 2.3: Estimate Flow Probabilities

For conditional branches (if/else, user choices):

  • Equal probability for each branch by default
  • Adjust based on context clues (e.g., "recommended", "default", "fallback")
  • Mark estimated probabilities with ~ prefix

Step 2.4: Build Sankey Data

Structure the flow as nodes and links:

{
  "nodes": [
    {"id": "user-input", "name": "User Input", "type": "user", "tokens": 100},
    {"id": "skill-name", "name": "Skill Name", "type": "skill", "tokens": 5000},
    {"id": "agent-name", "name": "Agent Name", "type": "agent", "tokens": 3000},
    {"id": "tool-read", "name": "Read", "type": "tool", "tokens": 1500}
  ],
  "links": [
    {"source": "user-input", "target": "skill-name", "value": 100, "probability": 1.0},
    {"source": "skill-name", "target": "agent-name", "value": 3000, "probability": 0.7}
  ]
}

Phase 3: HTML Generation

Step 3.1: Generate HTML

Create a self-contained HTML file using the template from html-template.md.

Replace the placeholder data with the actual Sankey data from Step 2.4.

The HTML must include:

  1. Header: Target name, generation date, total estimated tokens
  2. Sankey Diagram: Full flow visualization (D3.js CDN)
  3. Summary Table: Node-level breakdown (type, name, estimated tokens, probability)
  4. Token Distribution Bar: Stacked bar showing token allocation by category

Step 3.2: Save and Open

  1. Generate timestamp: YYYY-MM-DD-HHmm
  2. Save to: .brain/report/{timestamp}-flow-{target-name}.html
  3. Open in browser: open {file_path}

Phase 4: Present Results

Show a concise summary:

フロー可視化完了

対象: {target name}
ノード数: {count}
推定トークン: {total} tokens
フロー数: {link count}

レポート: .brain/report/{filename}

Tool Usage Probability Estimation

Base probabilities by tool type:

  • Read/Glob/Grep: High (0.8-1.0) - almost always used for code exploration
  • Write/Edit: Medium (0.4-0.7) - used when generating output
  • Bash: Medium (0.3-0.6) - used for system commands
  • WebSearch/WebFetch: Low-Medium (0.2-0.5) - only when web info needed
  • AskUserQuestion: Medium (0.3-0.7) - interactive skills use more
  • Agent (sub-agent spawn): Depends on skill design

Token Estimation Rules

  • Skill/Agent prompt itself: count characters, apply ratio
  • Each tool call round-trip: ~1000-3000 tokens
  • Each sub-agent spawn: prompt tokens + ~2000-5000 response tokens
  • User interaction: ~100-300 tokens per question/answer
  • Total session estimate: sum of all paths weighted by probability

Color Coding

Color definitions are maintained in html-template.md (single source of truth).

For HTML template details, see: - [HTML Template](./references/html-template.md)
Install via CLI
npx skills add https://github.com/vesperworks/dotfiles --skill vw-flow-viz
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator