xiaohongshu
xiaohongshu
d2-diagram
Comprehensive tool for creating D2 diagrams based on descriptions and requirements. This skill should be used when creating visual diagrams, system architectures, flowcharts, network topologies, data flows, or any visual representation that can be expressed as a diagram. Triggers include requests...
Full skill instructions
Generate clear, well-structured, and visually appealing D2 diagrams from textual descriptions. D2 is a modern diagram scripting language that transforms text into professional diagrams with support for icons, styling, containers, and multiple layout options.
Use this skill when:
CRITICAL: Before creating any diagram, read the reference files to understand D2 syntax and available icons:
references/d2_syntax_reference.md for syntax patterns and examplesreferences/d2_validated_icons_list.md for available icon URLsCarefully review the provided description to identify:
Example Analysis:
Request: "Create a diagram showing a web application with users connecting to a load balancer, which distributes traffic to multiple app servers. The app servers connect to a database."
Analysis:
Create a mental model of the diagram structure:
Choose appropriate shapes and icons for each element:
Shape Selection Guidelines:
person - Users, people, actorscylinder - Databases, data storagehexagon - Gateways, processors, servicescloud - Cloud services, external systemsrectangle - Default for most components, servers, applicationsdiamond - Decision points, conditionalscircle - Start/end points, eventsqueue - Message queues, buffersstored_data - Data stores, cachesIcon Selection:
references/d2_validated_icons_list.md for available iconsshape: image to display icon without borderCreate consistent visual appearance:
Styling Best Practices:
classes: {
primary_service: {
style.fill: "#4A90E2"
style.stroke: "#2E5C8A"
style.stroke-width: 2
}
database_style: {
shape: cylinder
style.fill: "#48C774"
style.multiple: true
}
}
Build the diagram following D2 syntax:
Before finalizing:
Quality Checklist:
direction: right
classes: {
service: {
style.fill: "#4A90E2"
style.stroke: "#2E5C8A"
}
db: {
shape: cylinder
style.fill: "#48C774"
}
}
users: Users {
shape: person
icon: https://icons.terrastruct.com/essentials/365-user.svg
}
frontend: Frontend {
class: service
icon: https://icons.terrastruct.com/tech/react.svg
}
backend: Backend Services {
api: API Gateway {
class: service
icon: https://icons.terrastruct.com/aws/Networking%20&%20Content%20Delivery/Amazon-API-Gateway.svg
}
auth: Auth Service {
class: service
}
data: Data Service {
class: service
}
}
database: PostgreSQL {
class: db
icon: https://icons.terrastruct.com/tech/postgresql.svg
}
users -> frontend: Access
frontend -> backend.api: REST API
backend.api -> backend.auth: Authenticate
backend.api -> backend.data: Fetch Data
backend.data -> database: Query
direction: right
source: Data Source {
shape: cylinder
style.fill: "#E8F5E9"
style.multiple: true
}
ingestion: Data Ingestion {
shape: hexagon
style.fill: "#FFF9C4"
}
processing: Data Processing {
transform: Transform
validate: Validate
enrich: Enrich
style.fill: "#E3F2FD"
}
storage: Data Warehouse {
shape: stored_data
style.fill: "#F3E5F5"
}
analytics: Analytics Layer {
shape: rectangle
style.fill: "#FCE4EC"
}
viz: Visualization {
shape: page
icon: https://icons.terrastruct.com/essentials/dashboard.svg
}
source -> ingestion: Extract {
style.stroke: "#4CAF50"
style.stroke-width: 2
}
ingestion -> processing.transform: Raw Data {
style.animated: true
}
processing.transform -> processing.validate
processing.validate -> processing.enrich
processing.enrich -> storage: Store {
style.stroke: "#2196F3"
style.stroke-width: 2
}
storage -> analytics: Query
analytics -> viz: Display
direction: down
internet: Internet {
shape: cloud
icon: https://icons.terrastruct.com/essentials/214-worldwide.svg
}
firewall: Firewall {
shape: hexagon
style.fill: "#FF5252"
icon: https://icons.terrastruct.com/infra/firewall.svg
}
dmz: DMZ {
direction: right
lb: Load Balancer {
shape: hexagon
icon: https://icons.terrastruct.com/infra/load-balancer.svg
}
web1: Web Server 1 {
shape: rectangle
}
web2: Web Server 2 {
shape: rectangle
}
style.fill: "#FFF3E0"
}
internal: Internal Network {
direction: right
app1: App Server 1
app2: App Server 2
db: Database Cluster {
shape: cylinder
style.multiple: true
icon: https://icons.terrastruct.com/tech/postgresql.svg
}
style.fill: "#E8F5E9"
}
internet -> firewall
firewall -> dmz.lb
dmz.lb -> dmz.web1
dmz.lb -> dmz.web2
dmz.web1 -> internal.app1
dmz.web2 -> internal.app2
internal.app1 -> internal.db
internal.app2 -> internal.db
direction: right
classes: {
service: {
shape: rectangle
style.fill: "#E3F2FD"
style.stroke: "#1976D2"
}
database: {
shape: cylinder
style.fill: "#C8E6C9"
}
queue: {
shape: queue
style.fill: "#FFF9C4"
}
}
users: Users {
shape: person
}
gateway: API Gateway {
shape: hexagon
style.fill: "#B39DDB"
}
services: Microservices {
user_service: User Service {
class: service
}
order_service: Order Service {
class: service
}
payment_service: Payment Service {
class: service
}
notification_service: Notification Service {
class: service
}
}
queues: Message Queues {
order_queue: Order Queue {
class: queue
}
notification_queue: Notification Queue {
class: queue
}
}
databases: Databases {
user_db: User DB {
class: database
}
order_db: Order DB {
class: database
}
payment_db: Payment DB {
class: database
}
}
users -> gateway
gateway -> services.user_service
gateway -> services.order_service
gateway -> services.payment_service
services.user_service -> databases.user_db
services.order_service -> databases.order_db
services.payment_service -> databases.payment_db
services.order_service -> queues.order_queue: Publish
services.payment_service -> queues.order_queue: Subscribe
services.notification_service -> queues.notification_queue: Subscribe
references/d2_validated_icons_list.mdWrong:
server: {
icon: https://example.com/fake-icon.svg # This will fail
}
Right:
server: {
icon: https://icons.terrastruct.com/tech/docker.svg # Verified URL
shape: image
}
Or use a shape without an icon:
server: {
shape: rectangle
}
Wrong:
# Too many nested levels
system.layer1.layer2.layer3.layer4.component
Right:
# Clear, manageable hierarchy
system: {
frontend
backend
database
}
Wrong:
# No direction specified, layout may be suboptimal
A -> B -> C -> D
Right:
direction: right # Clear flow direction
A -> B -> C -> D
Wrong:
# Inconsistent styling
element1: {
style.fill: "#FF0000"
}
element2: {
style.fill: "#00FF00"
}
element3: {
style.fill: "#0000FF"
}
Right:
# Consistent styling with classes
classes: {
primary: {
style.fill: "#4A90E2"
}
}
element1: { class: primary }
element2: { class: primary }
element3: { class: primary }
vars: {
d2-config: {
layout-engine: elk # Try 'elk' for better hierarchical layouts
pad: 50 # Adjust padding
}
}
# Use direction to control flow
direction: right
# Use grid for structured layouts
grid_container: {
grid-rows: 2
grid-columns: 3
item1; item2; item3
item4; item5; item6
}
classes: {
critical: {
style.fill: "#FF5252"
style.stroke: "#D32F2F"
style.stroke-width: 3
}
normal: {
style.fill: "#4CAF50"
style.stroke: "#388E3C"
}
inactive: {
style.fill: "#BDBDBD"
style.opacity: 0.5
}
}
# Apply classes
prod_server: { class: critical }
dev_server: { class: normal }
old_server: { class: inactive }
component: {
link: https://docs.example.com/component
tooltip: Click to view documentation
}
important_element: Critical Component
important_element.note: |md
This component handles:
- User authentication
- Session management
- Rate limiting
| {
shape: text
near: top-center
}
Always provide:
The output should be a complete .d2 file that can be:
d2 diagram.d2 output.svgreferences/d2_syntax_reference.md: Comprehensive D2 syntax guide with examplesreferences/d2_validated_icons_list.md: Verified icon URLs organized by categoryBasic Shape:
element: Label
Shape with Type:
element: Label {
shape: cylinder
}
Connection:
A -> B: Connection Label
Container:
container: Container Name {
child1
child2
child1 -> child2
}
Styling:
element: {
style.fill: "#4A90E2"
style.stroke: "#2E5C8A"
}
Icon:
element: {
icon: https://icons.terrastruct.com/tech/docker.svg
shape: image
}
Diagram looks cluttered?
Icons not appearing?
shape: image to remove borderLayout not as expected?
direction settingelk vs dagre)Connections crossing awkwardly?
Remember: The goal is to create clear, informative diagrams that effectively communicate system structure and relationships. When in doubt, prioritize clarity over complexity.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience