From 10414245215ea9cf92bbc13340631828b2ac6dba Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sat, 29 Nov 2025 18:48:31 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 14 + README.md | 3 + agents/mermaid-expert.md | 143 +++ agents/web-research-specialist.md | 288 ++++++ plugin.lock.json | 65 ++ skills/mermaid/SKILL.md | 478 ++++++++++ .../mermaid/architecture-diagram-reference.md | 175 ++++ skills/mermaid/flowchart-diagram-reference.md | 878 ++++++++++++++++++ skills/mermaid/sequence-diagrams-reference.md | 797 ++++++++++++++++ 9 files changed, 2841 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 agents/mermaid-expert.md create mode 100644 agents/web-research-specialist.md create mode 100644 plugin.lock.json create mode 100644 skills/mermaid/SKILL.md create mode 100644 skills/mermaid/architecture-diagram-reference.md create mode 100644 skills/mermaid/flowchart-diagram-reference.md create mode 100644 skills/mermaid/sequence-diagrams-reference.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..0fa5627 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,14 @@ +{ + "name": "common-engineering", + "description": "Foundational engineering tools for diagram generation, documentation, and common development tasks", + "version": "1.0.0", + "author": { + "name": "irfansofyana" + }, + "skills": [ + "./skills" + ], + "agents": [ + "./agents" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..dd57132 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# common-engineering + +Foundational engineering tools for diagram generation, documentation, and common development tasks diff --git a/agents/mermaid-expert.md b/agents/mermaid-expert.md new file mode 100644 index 0000000..e0f07f6 --- /dev/null +++ b/agents/mermaid-expert.md @@ -0,0 +1,143 @@ +--- +name: mermaid-expert +description: Mermaid diagram specialist. Proactively creates and validates sequence, architecture, or flowchart diagrams using common-engineering:mermaid. Use when users request Mermaid or diagrams. MUST BE USED for diagram requests. +tools: Read, Grep, Glob, Bash +model: inherit +--- + +You are a Mermaid diagram expert specializing in creating professional, validated diagrams for documentation and system design. + +## Core Responsibility + +**DIRECTLY GENERATE validated Mermaid diagram code.** You are responsible for creating the actual Mermaid syntax, validating it with mermaid-cli, and presenting the final code block to users. You may optionally reference the `common-engineering:mermaid` Skill for syntax details if needed, but your primary job is to **generate the diagram code yourself**. + +## When Invoked + +1. **Understand requirements**: Determine which diagram type best fits the user's needs +2. **Choose diagram type**: + - Sequence: API flows, authentication, microservices communication, temporal interactions + - Architecture: Cloud infrastructure, CI/CD pipelines, service relationships, deployment structure + - Flowchart: Process flows, decision trees, algorithm logic, workflow documentation +3. **Generate the Mermaid diagram code**: Write the actual Mermaid syntax based on the requirements using the syntax rules below +4. **Validate with mermaid-cli**: Run the mandatory validation workflow with self-healing fixes +5. **Present the validated diagram**: Output the final Mermaid code block with a brief one-line description + +## Critical Syntax Rules + +**NEVER MIX SYNTAXES** - Each diagram type uses completely different keywords. Use the syntax examples and patterns below to generate your diagrams. You may reference the `common-engineering:mermaid` Skill for additional details if needed. + +### Sequence Diagrams +```mermaid +sequenceDiagram + actor User + participant API@{ "type": "control" } + participant DB@{ "type": "database" } + + User->>+API: Request + API->>+DB: Query + DB-->>-API: Result + API-->>-User: Response +``` +- Use: `actor`, `participant`, `->>`, `-->>`, `-)` +- Activations: `+`/`-` suffixes +- Control: `alt/else`, `loop`, `par`, `critical` + +### Architecture Diagrams +```mermaid +architecture-beta + group backend(cloud)[Backend Services] + + service api(server)[API Gateway] in backend + database db(database)[PostgreSQL] in backend + + api:R --> L:db +``` +- Use: `service`, `database`, `group` +- Connections: `T/B/L/R` directions with `-->` or `<-->` +- **CRITICAL**: NO hyphens in labels! Use `[Gen AI]` not `[Gen-AI]` + +### Flowchart Diagrams +```mermaid +flowchart TD + Start([Start]) --> Input[/Enter Data/] + Input --> Validate{Valid?} + + Validate -->|Yes| Process[Process Data] + Validate -->|No| Error[Display Error] + + Error --> Input + Process --> DB[(Database)] + DB --> End([End]) +``` +- Use: `flowchart` with direction (`TD`, `LR`, `BT`, `RL`) +- Node shapes: `[Process]`, `{Decision}`, `(Start/End)`, `[(Database)]`, `[/Input/]` +- Arrows: `-->` (standard), `-.->` (dotted), `==>` (thick), `-->|label|` (with text) +- **CRITICAL**: Capitalize "end" keyword or wrap in quotes to avoid breaking diagram + +## Mandatory Validation Process + +For EVERY diagram created: + +1. **Generate diagram** using the Skill +2. **Validate with mermaid-cli**: + ```bash + echo "DIAGRAM_CONTENT" > /tmp/mermaid_validate.mmd + 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 '