ByteByteGo Architect & Diagram Skill (bbg-diagram)
Draws high-signal engineering diagrams grounded in an empirical crawl of all 415 unique pages on bytebytego.com/guides/ (15 categories, 400 child guide pages, 400 measured diagrams) and 6 course tracks (System Design, GenAI, ML, OOD/UML, Mobile, Coding Patterns), reinforced by a visual audit of 254 category diagrams across Cloud, DevOps/CI/CD, Git Flow, Security, AI/ML, Databases, Software Architecture, and Case Studies.
Hard Rules
- Render deterministic SVGs with bbg_svg_kit.py and rasterize 2x Retina PNGs with render_bbg.py. Never use
mermaidorarchify. - Follow the ByteByteGo 60/40 Icon-First Rule: draw standalone infrastructure/actors with
add_actor_node(...)(~40%–60% unboxed glyphs) and reserveadd_node(...)boxes for compute clusters (replicas > 1), nested in-process boundaries (inner_box), or multi-icon service trays. - Show concrete technical mechanics on every canvas: wire payloads, memory/struct strips, SQL/ACL tables, scoring formulas, packet drops, CIDR/HPA bounds, or state guards. Never draw generic rectangles stuffed with framework names.
- Never label components
Layer 1,Layer 2,D1,R1,Y1,V1, or[NO-LLM]. Use real service names, true process/VPC boundaries, pure integer step circles (1..N), and a compactLegendwhen multiple arrow styles appear.
Step 0: Auto-Select Architecture Pattern, Archetype, Icons & Colors
When the user asks what architecture or diagram fits a requirement (in English or Vietnamese), or before drawing an unfamiliar system, run bbg_advisor.py:
python3 ./scripts/bbg_advisor.py recommend "<requirement or prompt>"
python3 ./scripts/bbg_advisor.py resolve-components "Browser, Kong, FastAPI, Redis, PostgreSQL, Kafka"
python3 ./scripts/bbg_advisor.py search-guides "<keyword>" --limit 5
python3 ./scripts/bbg_advisor.py stats
python3 ./scripts/bbg_advisor.py scaffold --archetype D01 --theme course --out diagram.py
Read architect_decision_playbook.md for the decision matrix across 60 Architecture Patterns (P01–P60 across 12 Domains) and icon_and_color_catalog.md for all 94 vector icons and 13 semantic color roles.
Step 1: Pick Surface Theme (T1–T5) and Diagram Type (D01–D18)
Consult archetypes_and_themes.md for exact hex palettes and category_style_matrix.md for empirical counts across the 400 guides and 6 course tracks.
| Diagram Type | Share (n=400) | Default Theme | Concrete Mechanics & Working Example |
|---|---|---|---|
D01 (A1) Numbered Topology | 23.8% (95) | T2 / T5 | Icon-first actors, replicas=3 clusters, 1..N steps, Legend -> ex01_a1_production_web_topology.py |
D02 (A1+Inset) Topology + Zoom | 2.0% (8) | T1 / T5 | Macro path + add_zoom_inset SQL/RRF/DNS details -> demo_light_blueprint_and_inset.py |
D03 (A2) Sequence Lifeline | 2.2% (9) | T1 | add_lifeline_actor, activation bars, self-calls, alt frames, lost=True -> demo_sequence_oauth_and_selfcall.py |
D04 (A3) Memory & OS Anatomy | 6.2% (25) | T1 | add_struct_strip (vertical/horizontal), Application vs Kernel Context, lock table -> ex04_a3_kernel_zerocopy_and_memory.py |
D05 (A4) Split Comparison (VS) | 9.5% (38) | T4 / T1 | Symmetric columns + add_vs_badge + tradeoff matrix -> ex05_a4_split_comparison_btree_vs_lsm.py |
D06 (A5-Radial) Radial Donut Hub | 4.5% (18) | T2 / T3 | Central add_radial_wheel + colored dashed spokes to cards -> demo_dark_topology_and_radial.py |
D07 (A5-Grid) Multi-Card Grid | 29.0% (116) | T3 / T2 | 2x3 / 3x3 neo_header=True cards, micro-diagram + checkmark takeaway -> ex07_a5_grid_database_scaling_cheatsheet.py |
D08 (A6) Swimlane & Chevrons | 2.5% (10) | T4 | add_chevron_rail + colored add_swimlane rails + Action Legend -> ex08_a6_swimlane_gitops_and_data_pipeline.py |
D09 (A7) Ecosystem Stack | 2.8% (11) | T2 | Left icon stems -> stepped trays + add_bracket (never for runtime flow) -> ex09_a7_ecosystem_modern_ai_data_stack.py |
D10 (A8) Two-Phase / Evolution | 3.2% (13) | T1 / T2 | add_split_divider separating Sync Auth vs Async Clearing or Before vs After -> ex10_a8_twophase_visa_payment_settlement.py |
D11 (A9) UML Class & State FSM | 0.5% (2 + OOD) | T5 | add_uml_class ((I)/(C)), add_uml_relation, add_state_node -> demo_ood_uml_and_state_machine.py |
D12 (A10) Cloud / K8s Multi-AZ | 0.2% (1 + Infra) | T5 / T2 | add_boundary_frame (Region -> VPC -> AZ), HPA pods, WAL sync -> demo_icon_first_cloud_architecture.py |
D13 (A11) GenAI / ML / Agent Loop | 0.8% (3 + GenAI) | T5 / T2 | ReAct loop, hybrid memory, guardrails, offline chunk/embed -> ex13_a11_genai_agentic_rag_pipeline.py |
D14 (A12) Git Flow & Merge/Rebase | 2.0% (8) | T1 / T2 | add_git_branch_lane, add_git_commit, Merge vs Rebase, 4-Zone transport -> ex14_a12_gitflow_and_merge_vs_rebase.py |
D15 (A13) Cloud Network & DR | 4.5% (18) | T2 / T5 | add_cloud_service_tile (IGW/NAT/TGW/DX/VPN), add_rpo_rto_timeline -> ex15_a13_aws_hybrid_cloud_vpc_and_dr.py |
D16 (A14) Deployment Rollouts | 0.8% (3) | T4 / T1 | add_traffic_weight_pill, add_toggle_switch, Blue/Green, Canary, Shadow -> ex16_a14_deployment_strategies_matrix.py |
D17 (A15) DevSecOps & IaC Rail | 2.8% (11) | T1 | add_devops_infinity_loop, add_stage_rail_card (Terraform HCL/Plan/Apply) -> ex17_a15_devsecops_infinity_and_terraform_iac.py |
D18 (A16) K8s Internals & Trees | 2.8% (11) | T5 | Control Plane/Worker pods + Service tiles + add_decision_diamond tree -> ex18_a16_k8s_internals_and_architect_decision_tree.py |
Step 2: Budget & Multi-Agent Decomposition
Review anti_patterns_and_qa_checklist.md before writing coordinates:
- Keep
<= 14primary macro nodes per canvas and35%–45%open whitespace (44pxouter margins,>= 24pxgutter between panels). - Keep node titles to
1–4words and takeaway lines<= 16words. - For enterprise platforms spanning multiple concerns (such as Payment + OAuth + Ledger, or Cloud K8s + RAG + CDC), split into 2–3 focused diagrams. Use parallel delegation when available:
- Antigravity: launch parallel subagents (
invoke_subagent), one per diagram in the suite. - Claude Code: delegate each diagram concurrently to the
bbg-architectsubagent (Agenttool). - GitHub Copilot: generate each diagram sequentially via
@bbg-diagramcustom agent or/bbg-diagramprompt.
- Antigravity: launch parallel subagents (
Step 3: Build SVG Using BBGCanvas (scripts/bbg_svg_kit.py)
Resolve the scripts directory dynamically without hardcoding user-specific paths:
import os
from pathlib import Path
import sys
_CANDIDATES = []
if os.environ.get("CLAUDE_PLUGIN_ROOT"):
_CANDIDATES.append(Path(os.environ["CLAUDE_PLUGIN_ROOT"]) / "scripts")
_CANDIDATES.extend([
Path.cwd() / ".agents" / "skills" / "bbg-diagram" / "scripts",
Path.cwd() / ".claude" / "skills" / "bbg-diagram" / "scripts",
Path.cwd() / ".github" / "skills" / "bbg-diagram" / "scripts",
Path.home() / ".gemini" / "config" / "skills" / "bbg-diagram" / "scripts",
Path.home() / ".claude" / "skills" / "bbg-diagram" / "scripts",
Path.home() / ".copilot" / "skills" / "bbg-diagram" / "scripts",
])
_SKILL_SCRIPTS = next(p for p in _CANDIDATES if (p / "bbg_svg_kit.py").exists())
sys.path.insert(0, str(_SKILL_SCRIPTS))
from bbg_svg_kit import BBGCanvas
c = BBGCanvas(1600, 1080, theme="course") # "light" | "dark" | "cheatsheet" | "swimlane" | "course"
y0 = c.add_header("Title with Highlighted Concept", subtitle="Concise mechanism summary", highlight="Highlighted Concept", right_badge="Archetype A1")
client = c.add_actor_node(140, y0 + 220, "browser", "Web Client", "HTTPS / TLS 1.3")
gw = c.add_actor_node(400, y0 + 220, "api_gateway", "API Gateway", "OIDC + Rate Limit")
svc = c.add_node(610, y0 + 165, 250, 110, "Order Service", "FastAPI (:8000)", role="yellow", icon_kind="microservice_hex", replicas=3, badge="x3")
c.add_arrow(client.right, gw.left, step=1, label="POST /v1/orders")
c.add_arrow(gw.right, svc.left, step=2, label="Verified JWT")
c.save("diagram.svg")
Inspect working compositions across all 18 Diagram Types (D01–D18) in examples/:
D01(A1): ex01_a1_production_web_topology.pyD02(A1+Inset): demo_light_blueprint_and_inset.pyD03(A2): demo_sequence_oauth_and_selfcall.pyD04(A3): ex04_a3_kernel_zerocopy_and_memory.pyD05(A4): ex05_a4_split_comparison_btree_vs_lsm.pyD06(A5-Radial): demo_dark_topology_and_radial.pyD07(A5-Grid): ex07_a5_grid_database_scaling_cheatsheet.pyD08(A6): ex08_a6_swimlane_gitops_and_data_pipeline.pyD09(A7): ex09_a7_ecosystem_modern_ai_data_stack.pyD10(A8): ex10_a8_twophase_visa_payment_settlement.pyD11(A9): demo_ood_uml_and_state_machine.pyD12(A10): demo_icon_first_cloud_architecture.pyD13(A11): ex13_a11_genai_agentic_rag_pipeline.pyD14(A12): ex14_a12_gitflow_and_merge_vs_rebase.pyD15(A13): ex15_a13_aws_hybrid_cloud_vpc_and_dr.pyD16(A14): ex16_a14_deployment_strategies_matrix.pyD17(A15): ex17_a15_devsecops_infinity_and_terraform_iac.pyD18(A16): ex18_a16_k8s_internals_and_architect_decision_tree.py
Step 4: Strict Lint & Rasterize 2x Retina PNG
Run render_bbg.py with --strict:
python3 ./scripts/render_bbg.py diagram.svg diagram.png --strict
This checks valid XML, explicit viewBox, zero forbidden anti-pattern labels, wall-of-boxes density (<= 18 boxed nodes), text clipping, text overlaps (with NFC-normalized English and Vietnamese width math), and 2x Retina dimensions via headless Chrome + sips. Fix every reported error or warning before proceeding.
Step 5: Mandatory Visual Inspection
Verify the rendered 2x Retina .png directly before presenting results:
- Antigravity: call
read_fileon the rendered.png. - Claude Code: call
Readon the rendered.png. - GitHub Copilot: enforce
render_bbg.py --strict(0 errors, 0 warnings) in headless/CLI runs and preview the.pngdirectly inside VS Code.
Check all 12 items in the Post-Render Visual QA Checklist. If any label touches a border, a pill crowds a title, or an arrow crosses text, adjust coordinates and re-run Step 4.
For installing or adapting this skill across Antigravity, Claude Code, and GitHub Copilot, see cross_agent_adapters.md and install_skill.py.