返回技能列表

generate-workflow-diagram

pjt222
更新于 2 days ago
3 次查看
17
2
17
在 GitHub 上查看
aiautomationdesigndata

关于

This skill generates themed Mermaid flowchart diagrams from `putior` workflow data. It offers multiple themes, output formats, and interactive features for embedding in documentation. Use it to visualize workflows after annotating source files or when you need to update diagrams for different audiences.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/generate-workflow-diagram

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Generate Workflow Diagram

Make themed Mermaid flowchart diagram from putior workflow data. Embed in docs.

When Use

  • After annotating source files, ready to make visual diagram
  • Regenerate diagram after workflow changes
  • Switch themes or output formats for different audiences
  • Embed workflow diagrams in README, Quarto, R Markdown docs

Inputs

  • Required: Workflow data from put(), put_auto(), or put_merge()
  • Optional: Theme name (default: "light"; options: light, dark, auto, minimal, github, viridis, magma, plasma, cividis)
  • Optional: Output target: console, file path, clipboard, raw string
  • Optional: Interactive features: show_source_info, enable_clicks

Steps

Step 1: Extract Workflow Data

Get workflow data from one of three sources.

library(putior)

# From manual annotations
workflow <- put("./src/")

# From manual annotations, excluding specific files
workflow <- put("./src/", exclude = c("build-workflow\\.R$", "test_"))

# From auto-detection only
workflow <- put_auto("./src/")

# From merged (manual + auto)
workflow <- put_merge("./src/", merge_strategy = "supplement")

Workflow data frame may include node_type column from annotations. Node types control Mermaid shapes:

node_typeMermaid ShapeUse Case
"input"Stadium ([...])Data sources, configuration files
"output"Subroutine [[...]]Generated artifacts, reports
"process"Rectangle [...]Processing steps (default)
"decision"Diamond {...}Conditional logic, branching
"start" / "end"Stadium ([...])Entry/terminal nodes

Each node_type also gets CSS class (class nodeId input;) for theme-based styling.

Got: Data frame with at least one row, has id, label, optionally input, output, source_file, node_type columns.

If fail: Data frame empty? No annotations or patterns found. Run analyze-codebase-workflow first, or check annotations syntactically valid with put("./src/", validate = TRUE).

Step 2: Pick Theme + Options

Pick theme for target audience.

# List all available themes
get_diagram_themes()

# Standard themes
# "light"   — Default, bright colors
# "dark"    — For dark mode environments
# "auto"    — GitHub-adaptive with solid colors
# "minimal" — Grayscale, print-friendly
# "github"  — Optimized for GitHub README files

# Colorblind-safe themes (viridis family)
# "viridis" — Purple→Blue→Green→Yellow, general accessibility
# "magma"   — Purple→Red→Yellow, high contrast for print
# "plasma"  — Purple→Pink→Orange→Yellow, presentations
# "cividis" — Blue→Gray→Yellow, maximum accessibility (no red-green)

Additional parameters:

  • direction: Diagram flow direction — "TD" (top-down, default), "LR" (left-right), "RL", "BT"
  • show_artifacts: TRUE/FALSE — show artifact nodes (files, data); noisy for large workflows (16+ extra nodes)
  • show_workflow_boundaries: TRUE/FALSE — wrap each source file nodes in Mermaid subgraph
  • source_info_style: How source file info displayed on nodes (subtitle)
  • node_labels: Format for node label text

Got: Theme names printed. Pick one by context.

If fail: Theme name not recognized? put_diagram() falls back to "light". Check spelling.

Step 3: Custom Palette with put_theme() (Optional)

9 built-in themes don't match project palette? Make custom theme with put_theme().

# Create custom palette — unspecified types inherit from base theme
cyberpunk <- put_theme(
  base = "dark",
  input    = c(fill = "#1a1a2e", stroke = "#00ff88", color = "#00ff88"),
  process  = c(fill = "#16213e", stroke = "#44ddff", color = "#44ddff"),
  output   = c(fill = "#0f3460", stroke = "#ff3366", color = "#ff3366"),
  decision = c(fill = "#1a1a2e", stroke = "#ffaa33", color = "#ffaa33")
)

# Use the palette parameter (overrides theme when provided)
mermaid_content <- put_diagram(workflow, palette = cyberpunk, output = "raw")
writeLines(mermaid_content, "workflow.mmd")

put_theme() takes input, process, output, decision, artifact, start, end node types. Each takes named vector c(fill = "#hex", stroke = "#hex", color = "#hex"). Unset types inherit from base theme.

Got: Mermaid output with custom classDef lines. Node shapes from node_type preserved; only colors change. All node types use stroke-width:2px — override not supported via put_theme().

If fail: Palette object not putior_theme class? put_diagram() raises descriptive error. Pass return value of put_theme(), not raw list.

Fallback — manual classDef replacement: Fine-grained control beyond put_theme() (per-type stroke widths)? Generate with base theme + replace classDef lines manually:

mermaid_content <- put_diagram(workflow, theme = "dark", output = "raw")
lines <- strsplit(mermaid_content, "\n")[[1]]
lines <- lines[!grepl("^\\s*classDef ", lines)]
custom_defs <- c("  classDef input fill:#1a1a2e,stroke:#00ff88,stroke-width:3px,color:#00ff88")
mermaid_content <- paste(c(lines, custom_defs), collapse = "\n")

Step 4: Generate Mermaid Output

Make diagram in desired output mode.

# Print to console (default)
cat(put_diagram(workflow, theme = "github"))

# Save to file
writeLines(put_diagram(workflow, theme = "github"), "docs/workflow.md")

# Get raw string for embedding
mermaid_code <- put_diagram(workflow, output = "raw", theme = "github")

# With source file info (shows which file each node comes from)
cat(put_diagram(workflow, theme = "github", show_source_info = TRUE))

# With clickable nodes (for VS Code, RStudio, or file:// protocol)
cat(put_diagram(workflow,
  theme = "github",
  enable_clicks = TRUE,
  click_protocol = "vscode"  # or "rstudio", "file"
))

# Full-featured
cat(put_diagram(workflow,
  theme = "viridis",
  show_source_info = TRUE,
  enable_clicks = TRUE,
  click_protocol = "vscode"
))

Got: Valid Mermaid code starts with flowchart TD (or LR by direction). Nodes connected by arrows showing data flow.

If fail: Output is flowchart TD with no nodes? Workflow data frame empty. Connections missing? Check output filenames match input filenames across nodes.

Step 5: Embed in Target Document

Insert diagram into appropriate docs format.

GitHub README (```mermaid code fence):

## Workflow

```mermaid
flowchart TD
  A["Extract Data"] --> B["Transform"]
  B --> C["Load"]
```

Quarto document (native mermaid chunk via knit_child):

# Chunk 1: Generate code (visible, foldable)
workflow <- put("./src/")
mermaid_code <- put_diagram(workflow, output = "raw", theme = "github")
# Chunk 2: Output as native mermaid chunk (hidden)
#| output: asis
#| echo: false
mermaid_chunk <- paste0("```{mermaid}\n", mermaid_code, "\n```")
cat(knitr::knit_child(text = mermaid_chunk, quiet = TRUE))

R Markdown (with mermaid.js CDN or DiagrammeR):

DiagrammeR::mermaid(put_diagram(workflow, output = "raw"))

Got: Diagram renders correct in target format. GitHub renders mermaid code fences native.

If fail: GitHub won't render diagram? Code fence must use exactly ```mermaid (no extra attributes). Quarto → use knit_child() approach since direct variable interpolation in {mermaid} chunks not supported.

Checks

  • put_diagram() produces valid Mermaid code (starts with flowchart)
  • All expected nodes appear in diagram
  • Data flow connections (arrows) present between connected nodes
  • Selected theme applied (check init block in output for theme-specific colors)
  • Diagram renders correct in target format (GitHub, Quarto)

Pitfalls

  • Empty diagrams: Usually put() returned no rows. Check annotations exist + syntactically valid.
  • All nodes disconnected: Output filenames must exactly match input filenames (including extension) for putior to draw connections. data.csv + Data.csv are different.
  • Theme not visible on GitHub: GitHub mermaid renderer has limited theme support. "github" theme designed for GitHub. %%{init:...}%% theme block may be ignored by some renderers.
  • Quarto mermaid variable interpolation: Quarto {mermaid} chunks don't support R variables direct. Use knit_child() from Step 5.
  • Clickable nodes not working: Click directives need renderer supporting Mermaid interaction events. GitHub static renderer no click support. Use local Mermaid renderer or putior Shiny sandbox.
  • Self-referential meta-pipeline files: Scanning directory including build script generating diagram → duplicate subgraph IDs + Mermaid errors. Use exclude parameter:
    workflow <- put("./src/", exclude = c("build-workflow\\.R$", "build-workflow\\.js$"))
    
  • show_artifacts = TRUE too noisy: Large projects generate many artifact nodes (10–20+), clutter diagram. Use show_artifacts = FALSE + rely on node_type annotations to mark key inputs/outputs explicit.

See Also

  • annotate-source-files — prerequisite: files annotated before diagram generation
  • analyze-codebase-workflow — auto-detection supplements manual annotations
  • setup-putior-ci — automate diagram regeneration in CI/CD
  • create-quarto-report — embed diagrams in Quarto reports
  • build-pkgdown-site — embed diagrams in pkgdown docs sites

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman/skills/generate-workflow-diagram
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能

creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能

sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能