Create validated Mermaid diagrams (sequence, architecture, flowchart) with automatic syntax checking and self-healing. Use when users request diagrams, visualizations of API flows, system architecture, or process documentation. All diagrams are validated with mermaid-cli before delivery.
/plugin marketplace add irfansofyana/my-claude-code-marketplace/plugin install common-engineering@my-claude-code-marketplaceThis skill is limited to using the following tools:
references/REFERENCE.mdreferences/architecture-diagrams.mdreferences/flowcharts.mdreferences/sequence-diagrams.mdCreate professional diagrams using Mermaid syntax for documentation, design discussions, and system architecture planning. This skill covers three primary diagram types:
IMPORTANT: All diagrams generated by this skill are automatically validated with mermaid-cli. This ensures error-free diagrams that render correctly every time.
When creating diagrams, ALWAYS follow this exact workflow:
NEVER skip validation or present unvalidated diagrams to users.
Sequence diagrams are interaction diagrams that show how processes operate with one another and in what order. They visualize temporal interactions between participants, making them ideal for documenting API flows, system integrations, user interactions, and distributed system communications.
actor (humans) or participant with type attributes->> (sync), -->> (response), -) (async)+/- to arrows (A->>+B, B-->>-A)alt/else, loop, par, critical for complex flowsβ For detailed syntax, see references/sequence-diagrams.md
After generating any sequence diagram, you MUST:
Create temp files:
echo "YOUR_SEQUENCE_DIAGRAM_HERE" > /tmp/mermaid_validate.mmd
Run enhanced validation (your bash script approach):
mmdc -i /tmp/mermaid_validate.mmd -o /tmp/mermaid_validate.svg 2>/tmp/mermaid_validate.err
rc=$?
if [ $rc -ne 0 ]; then
echo "π mmdc failed (exit code $rc)."; cat /tmp/mermaid_validate.err; exit 1
fi
# Check SVG for error markers that mmdc might miss
if grep -q -i 'Syntax error in graph\|mermaidError\|errorText\|Parse error' /tmp/mermaid_validate.svg; then
echo "π Mermaid syntax error found in output SVG"
exit 1
fi
# Verify SVG actually contains diagram content (not just error text)
if ! grep -q '<svg.*width.*height' /tmp/mermaid_validate.svg; then
echo "π SVG output appears invalid or empty"
exit 1
fi
echo "β
Diagram appears valid"
If validation fails, apply fixes:
participant or actor keywords used correctly->>, -->>, -) patterns are correctalt, loop, par blocks are properly closed/tmp/mermaid_validate.err for specific issuesRe-validate until successful: (repeat step 2)
Cleanup and confirm:
rm -f /tmp/mermaid_validate.mmd /tmp/mermaid_validate.svg /tmp/mermaid_validate.err
VALIDATION MUST PASS BEFORE PRESENTING TO USER!
NEVER MIX THESE SYNTAXES! Each diagram type has completely different keywords. Mixing them will break your diagram.
Sequence Diagrams:
sequenceDiagram
actor User
participant API@{ "type": "control" }
participant DB@{ "type": "database" }
actor for humans (stick figure icon)participant with type attributes for systemsparticipant, actorservice, database, groupArchitecture Diagrams:
architecture-beta
service api(server)[API]
database db(database)[Database]
group backend(cloud)[Backend]
service for componentsdatabase as a keyword (NOT participant!)group for organizing servicesservice, database, groupparticipant, actorsequenceDiagram
actor User
participant API@{ "type": "control" }
participant DB@{ "type": "database" }
User->>+API: Request data
API->>+DB: Query
DB-->>-API: Result
API-->>-User: Response
+/-) to show processing periodsalt, loop, par) for complex flowsβ See references/sequence-diagrams.md for detailed patterns and best practices
Architecture diagrams show relationships between services and resources commonly found within cloud or CI/CD deployments. Services (nodes) are connected by edges, and related services can be placed within groups to illustrate organization.
architecture-beta keywordgroup {id}({icon})[{label}]service {id}({icon})[{label}] in {group}{id}:{T|B|L|R} -- {T|B|L|R}:{id}--> (single) or <--> (bidirectional)CRITICAL Syntax Rules:
api, db1, auth_service) - NO spaces or special charsGen-AI, Cross-Account)AWS Account: prod)[Gen AI] instead of [Gen-AI][Cross Account IAM Role] instead of [Cross-Account IAM Role]Default icons: cloud, database, disk, internet, server
β For extended icons and advanced features, see references/architecture-diagrams.md
After generating any architecture diagram, you MUST:
Create temp files:
echo "YOUR_ARCHITECTURE_DIAGRAM_HERE" > /tmp/mermaid_validate.mmd
Run enhanced validation (your bash script approach):
mmdc -i /tmp/mermaid_validate.mmd -o /tmp/mermaid_validate.svg 2>/tmp/mermaid_validate.err
rc=$?
if [ $rc -ne 0 ]; then
echo "π mmdc failed (exit code $rc)."; cat /tmp/mermaid_validate.err; exit 1
fi
# Check SVG for error markers that mmdc might miss
if grep -q -i 'Syntax error in graph\|mermaidError\|errorText\|Parse error' /tmp/mermaid_validate.svg; then
echo "π Mermaid syntax error found in output SVG"
exit 1
fi
# Verify SVG actually contains diagram content (not just error text)
if ! grep -q '<svg.*width.*height' /tmp/mermaid_validate.svg; then
echo "π SVG output appears invalid or empty"
exit 1
fi
echo "β
Diagram appears valid"
If validation fails, apply automatic fixes:
[Gen-AI] β [Gen AI][API:prod] β [API Prod]/tmp/mermaid_validate.err for specific issuesRe-validate until successful: (repeat step 2)
Cleanup and confirm:
rm -f /tmp/mermaid_validate.mmd /tmp/mermaid_validate.svg /tmp/mermaid_validate.err
VALIDATION MUST PASS BEFORE PRESENTING TO USER!
architecture-beta
group stg_aitools(cloud)[AWS Stg AI Tools]
group stg_genai(cloud)[AWS Stg Gen AI]
service litellm(server)[LiteLLM Service] in stg_aitools
service rds(database)[RDS PostgreSQL] in stg_aitools
service redis(disk)[Redis Cache] in stg_aitools
service bedrock(server)[AWS Bedrock] in stg_genai
service iam_role(server)[Cross Account IAM Role] in stg_genai
litellm:R --> L:rds
litellm:B --> T:redis
litellm:R --> L:iam_role
iam_role:B --> T:bedrock
Note: No hyphens in labels! Use spaces instead (Gen AI not Gen-AI)
group declarations-->)β See references/architecture-diagrams.md for icons, junctions, and complex patterns
Flowchart diagrams visualize processes, decision logic, algorithms, and workflows using nodes (shapes) and edges (arrows). They're ideal for documenting business processes, algorithm logic, decision trees, and step-by-step workflows.
flowchart keyword and direction: flowchart TD (Top Down), LR (Left Right)[Process], {Decision}, (Start/End), [(Database)]--> (standard), -.-> (dotted), ==> (thick)-->|label| or -- label -->subgraph blocksstyle id fill:#color,stroke:#colorβ For detailed syntax, see references/flowcharts.md
After generating any flowchart diagram, you MUST:
Create temp files:
echo "YOUR_FLOWCHART_DIAGRAM_HERE" > /tmp/mermaid_validate.mmd
Run enhanced validation (your bash script approach):
mmdc -i /tmp/mermaid_validate.mmd -o /tmp/mermaid_validate.svg 2>/tmp/mermaid_validate.err
rc=$?
if [ $rc -ne 0 ]; then
echo "π mmdc failed (exit code $rc)."; cat /tmp/mermaid_validate.err; exit 1
fi
# Check SVG for error markers that mmdc might miss
if grep -q -i 'Syntax error in graph\|mermaidError\|errorText\|Parse error' /tmp/mermaid_validate.svg; then
echo "π Mermaid syntax error found in output SVG"
exit 1
fi
# Verify SVG actually contains diagram content (not just error text)
if ! grep -q '<svg.*width.*height' /tmp/mermaid_validate.svg; then
echo "π SVG output appears invalid or empty"
exit 1
fi
echo "β
Diagram appears valid"
If validation fails, apply fixes:
-->, -.->, ==> patterns are correctsubgraph has matching end/tmp/mermaid_validate.err for specific issuesRe-validate until successful: (repeat step 2)
Cleanup and confirm:
rm -f /tmp/mermaid_validate.mmd /tmp/mermaid_validate.svg /tmp/mermaid_validate.err
VALIDATION MUST PASS BEFORE PRESENTING TO USER!
flowchart TD
Start([Start Process]) --> Input[/Enter Data/]
Input --> Validate{Valid Data?}
Validate -->|Yes| Process[Process Data]
Validate -->|No| Error[Display Error]
Error --> Input
Process --> DB[(Save to Database)]
DB --> End([End])
subgraph for organizationβ See references/flowcharts.md for all node shapes, arrow types, subgraphs, and styling options
For Both Diagram Types:
Diagram Size Guidelines:
When Diagrams Conflict:
Architecture diagrams: NEVER use these patterns:
Hyphens in labels (breaks parsing):
[Gen-AI], [Cross-Account], [AI-Tools][Gen AI], [Cross Account], [AI Tools]Special characters in labels:
[AWS Account: prod] (colons)[DB@prod] (at symbols)[AWS Account Prod] (simple words)Invalid keywords in sequence diagrams:
database DB, service APIparticipant DB@{ "type": "database" }Unbalanced brackets in flowchart nodes:
A[Text, B{Decision, C(StartA[Text], B{Decision}, C(Start)Reserved words in flowcharts:
end (breaks diagram)End, END, or "end"β See examples above for correct syntax patterns
π§ Validation Tip: These errors are automatically caught and fixed by the mandatory validation process. See the Automatic Validation Workflow section.
Sequence Diagrams:
"end" or parentheses (end)participant Name before first use->>, -->>, ->, -->, -))Architecture Diagrams:
:) and complex punctuation in labels
[AWS Account: prod api][AWS Account Prod API]group stg ai-tools (space in ID)group stg_aitools or group aitools_stgin {group_id}Flowchart Diagrams:
A[Process, B{DecisionA[Process], B{Decision}flowchart TD\n A --> endflowchart TD\n A --> End-->, -.->, ==>)subgraph has matching endValidation & mmdc Issues:
npm install -g @mermaid-js/mermaid-cli/tmp directory/tmp/mermaid_validate.err for detailed error messages when validation failsEnhanced Validation Features:
For complete syntax, advanced features, and more examples:
This skill enables you to create professional diagrams for documentation, design discussions, API specifications, system architecture planning, and process documentation. Choose the appropriate diagram type based on whether you're documenting temporal interactions (sequence), structural relationships (architecture), or process flows (flowchart).
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.