بنقرة واحدة
c4-diagrams
Create, update, validate, and maintain Ruby Fast LSP C4 architecture diagrams using LikeC4.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Create, update, validate, and maintain Ruby Fast LSP C4 architecture diagrams using LikeC4.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Design Ruby Fast LSP features, understand module responsibilities, apply layer boundaries, and make structural changes.
Implement or review error handling patterns in Ruby Fast LSP, including Result, Option, logging, failures, and exception flows.
Optimize Ruby Fast LSP performance, profile latency and memory, benchmark changes, and make performance-critical decisions.
Refactor Ruby Fast LSP modules, extract abstractions, reduce complexity, and preserve test coverage during structural changes.
Release a new version of ruby-fast-lsp. Bumps version in Cargo.toml, commits, tags, and pushes to trigger CI. Use when the user says /release, 'release', 'publish', 'bump version', 'cut a release', or 'new version'.
Review Ruby Fast LSP code changes and PRs using TigerStyle principles, project standards, and correctness checks.
| name | c4-diagrams |
| description | Create, update, validate, and maintain Ruby Fast LSP C4 architecture diagrams using LikeC4. |
Use this skill when creating, updating, or maintaining C4 architecture diagrams for the Ruby Fast LSP project. Provides guidance on proper layering (L1-L4), file organization, LikeC4 syntax, and validation. Triggers: c4 diagrams, architecture visualization, documentation, system design, component diagrams, dynamic views.
The C4 model provides a hierarchical approach to architecture documentation:
Level 1: System Context
├─ Shows the big picture
├─ Actors and external systems
└─ High-level interactions
Level 2: Container Diagram
├─ Major building blocks
├─ Technology choices
└─ Container relationships
Level 3: Component Diagram
├─ Internal structure of containers
├─ Component responsibilities
└─ Component interactions
Level 4: Code/Dynamic Views
├─ Implementation details
├─ Sequence flows
└─ State machines
Levels 1-2: High-Level Architecture
Levels 3-4: In-Depth Visualizations
All C4 diagrams live in .ai/diagrams/ and follow a structured organization pattern.
.ai/diagrams/
├── README.md # Overview and usage instructions
├── model.c4 # Base model (L1-L2): Specification, actors, containers
├── server.c4 # Server components (L3): Handlers, capabilities, query
├── indexing.c4 # Indexing lifecycle (L3): Indexer, analyzer, visitors
├── requests.c4 # Request flow (L4): Dynamic views for LSP requests
├── notifications.c4 # Notification flow (L4): Dynamic views for LSP notifications
└── [feature].c4 # Feature-specific views (L3-L4)
model.c4 - Always the base file defining specification and L1-L2[domain].c4 - Named after domain/subsystem (e.g., indexing.c4, inferrer.c4)inlay_hints.c4)model.c4 (Base Model)
[domain].c4 (Domain Extensions)
README.md (Documentation)
// Define specification (only in model.c4)
specification {
element person { style { shape person color red } }
element softwareSystem { style { color blue } }
element container { style { color indigo } }
element component { style { color slate } }
}
// Define model elements
model {
// Actors
developer = person 'Ruby Developer' {
description 'Uses IDE to write Ruby code.'
}
// External systems
ide = softwareSystem 'IDE' {
description 'VS Code, Zed, etc.'
}
// Your system with containers
lsp = softwareSystem 'Ruby Fast LSP' {
server = container 'LSP Server' {
technology 'Rust / tower-lsp'
description 'Handles LSP protocol.'
}
}
// Extend existing elements (in other files)
extend lsp.server {
handlers = component 'Handlers' {
technology 'handlers/'
description 'Routes LSP requests.'
}
}
// Relationships
ide -> lsp.server 'LSP requests'
lsp.server.handlers -> lsp.capabilities 'Delegates to'
}
1. System Context View (L1)
views {
view context of lsp {
title 'System Context'
description 'Shows LSP and external dependencies.'
include developer, ide, lsp, prism, filesystem
autoLayout TopBottom
}
}
2. Container View (L2)
views {
view containers of lsp {
title 'Containers'
description 'Major containers within LSP.'
include * // All containers
autoLayout TopBottom
}
}
3. Component View (L3)
views {
view components of lsp.server {
title 'Server Components'
description 'Internal components of LSP Server.'
include *
include lsp.capabilities // Related containers
autoLayout LeftRight
}
}
4. Dynamic View (L4)
views {
dynamic view requestFlow {
title 'LSP Request Flow'
description 'Shows step-by-step request handling.'
ide -> lsp.server 'textDocument/definition'
lsp.server -> lsp.server.handlers 'Route request'
lsp.server.handlers -> lsp.capabilities.definitions 'handle_definition()'
lsp.capabilities.definitions -> lsp.query 'find_definitions()'
lsp.query -> lsp.index 'Lookup symbol'
lsp.index -> lsp.query 'Location'
lsp.query -> lsp.capabilities.definitions 'Location'
lsp.capabilities.definitions -> lsp.server 'Response'
lsp.server -> ide 'Location response'
autoLayout TopBottom
}
}
Rule: Only containers can have components, components cannot have sub-components.
// ✅ CORRECT: Components inside containers
extend lsp.query {
definitionQuery = component 'Definition Query' { ... }
hoverQuery = component 'Hover Query' { ... }
}
// ❌ WRONG: Components inside components
extend lsp.query.definitionQuery {
helper = component 'Helper' { ... } // Invalid!
}
If you need to show internal structure of a component, use:
Model Block Relationships (static structure):
model {
// Simple relationships
ide -> lsp.server 'LSP protocol'
// Component-to-component
lsp.server.handlers -> lsp.capabilities.definitions 'Delegates'
// Container-to-container
lsp.query -> lsp.index 'Queries'
}
Dynamic View Relationships (execution flow):
dynamic view flow {
// Step-by-step interactions
ide -> lsp.server 'Request'
lsp.server -> lsp.capabilities 'Delegate'
lsp.capabilities -> lsp.query 'Query'
lsp.query -> lsp.index 'Lookup'
// Return path
lsp.index -> lsp.query 'Result'
lsp.query -> lsp.capabilities 'Data'
}
Ask yourself:
model.c4indexing.c4, requests.c4)model {
// Only if creating new containers/components
extend lsp.myContainer {
myComponent = component 'My Component' {
technology 'path/to/code.rs'
description 'Brief description of responsibility.'
}
}
// Define relationships
lsp.myContainer.myComponent -> lsp.otherContainer 'Interaction'
}
views {
// For L3: Component view
view components of lsp.myContainer {
title 'My Container Components'
description 'Shows internal structure.'
include *
include lsp.relatedContainer
autoLayout LeftRight
}
// For L4: Dynamic view
dynamic view myFlow {
title 'My Feature Flow'
description 'Shows execution sequence.'
// Step-by-step interactions
autoLayout TopBottom
}
}
Add entry to the file structure table:
| `my_feature.c4` | **My feature.** Description of what this diagram shows. |
Add architecture notes if needed in the relevant section.
Always validate after creating or modifying diagrams:
npx likec4 validate .ai/diagrams
Run validation before committing:
npx likec4 validate .ai/diagrams
Expected output (success):
version 1.x.x
layout wasm
workspace: file:///path/to/.ai/diagrams
workspace: found N source files
Expected output (failure):
Invalid /path/to/file.c4
Line X: Error description
Line Y: Error description
1. Duplicate Element Names
Line X: Duplicate element name 'analyzer'
Fix: Remove duplicate definition, use extend in secondary files
2. Invalid Parent-Child Relationship
Line X: Invalid parent-child relationship
Fix: Only nest components in containers, not in other components
3. Could Not Resolve Reference
Line X: Could not resolve 'lsp.foo.bar'
Fix: Ensure referenced element is defined in model or imported files
4. Missing Element
Line X: Element 'lsp.server.foo' not found
Fix: Define the element in a model block before referencing
Before finalizing diagrams:
npx likec4 validate .ai/diagramsextend usage for cross-file definitionsEach domain file should focus on one subsystem:
indexing.c4 - All indexing-related components and flowsrequests.c4 - All LSP request flowsmisc.c4 - Catch-all for unrelated components// model.c4
lsp = softwareSystem 'Ruby Fast LSP' {
server = container 'LSP Server' { ... }
}
// server.c4 - ✅ CORRECT
extend lsp.server {
handlers = component 'Handlers' { ... }
}
// server.c4 - ❌ WRONG
lsp = softwareSystem 'Ruby Fast LSP' {
server = container 'LSP Server' { ... } // Duplicate!
}
Always link to actual code:
definitionQuery = component 'Definition Query' {
technology 'query/definition.rs' // Actual file path
description 'Finds where symbols are defined.'
}
// ✅ GOOD: Explains what and why
description 'Visitor that traverses AST and collects nodes relevant for hints. Does NOT generate hints.'
// ❌ BAD: Just repeats the name
description 'Inlay node collector.'
Choose based on natural flow:
TopBottom - For sequential processes (request flows, lifecycles)LeftRight - For layered architectures (handlers → capabilities → query)BottomTop - For reverse flows (responses)RightLeft - Rarely usedWhen components have complex internals that can't be nested:
extend lsp.query.inlayHintsQuery {
// Note: The inlayHintsQuery component contains:
// - InlayNodeCollector (collector.rs): Visitor that collects AST nodes
// - InlayNode types (nodes.rs): Data structures for collected nodes
// - Hint Generators (generators.rs): Convert nodes to hints
// - HintContext: Provides access to Index and type inference
}
Use dynamic views to show what can't be shown in static structure:
Install the LikeC4 VS Code extension:
Run local preview server:
npx likec4 serve .ai/diagrams
Opens in browser with:
# Export all views
npx likec4 export png .ai/diagrams -o ./diagrams-export/
# Export specific view
npx likec4 export png .ai/diagrams --view systemContext -o ./context.png
Update C4 diagrams when:
When reviewing diagram changes:
Diagrams should be living documentation:
When adding textDocument/codeActions:
extend lsp.capabilities {
codeActionsCap = component 'Code Actions' {
technology 'capabilities/code_actions.rs'
description 'Provides quick fixes and refactorings.'
}
}
lsp.server.requestHandlers -> lsp.capabilities.codeActionsCap 'Code Actions'
lsp.capabilities.codeActionsCap -> lsp.query 'find_fixable_issues()'
views {
dynamic view codeActionsFlow {
title 'Code Actions Request Flow'
description 'Shows how code actions are generated.'
ide -> lsp.server 'textDocument/codeActions'
lsp.server -> lsp.capabilities.codeActionsCap 'handle_code_actions()'
lsp.capabilities.codeActionsCap -> lsp.query 'find_diagnostics()'
lsp.query -> lsp.index 'Analyze symbols'
lsp.index -> lsp.query 'Issues found'
lsp.query -> lsp.capabilities.codeActionsCap 'Diagnostic[]'
lsp.capabilities.codeActionsCap -> lsp.server 'CodeAction[]'
lsp.server -> ide 'Quick fixes'
autoLayout TopBottom
}
}
| `code_actions.c4` | **Code actions flow.** Dynamic view showing quick fix generation. |
npx likec4 validate .ai/diagrams
For the inlay hints feature:
// inlay_hints.c4
model {
// No additional model elements - inlayHintsQuery already exists
}
views {
dynamic view inlayHintsFlow {
title 'Inlay Hints Request Flow'
// Show the high-level flow
}
dynamic view inlayHintsArchitecture {
title 'Inlay Hints Internal Architecture'
// Show internal steps with comments documenting:
// - Collector phase
// - Node types collected
// - Generator functions
}
}
Problem: Empty or broken diagrams Solution:
Problem: Validation takes too long Solution:
Problem: Defined elements don't show in views Solution:
include statements in view// =============================================================================
// Ruby Fast LSP - [Feature Name] ([Level])
// =============================================================================
// Brief description of what this file documents.
// =============================================================================
model {
// Extend existing elements
extend lsp.containerName {
myComponent = component 'Component Name' {
technology 'path/to/code.rs'
description 'Component responsibility.'
}
}
// Define relationships
lsp.containerName.myComponent -> lsp.otherContainer 'Interaction'
}
// =============================================================================
// VIEWS
// =============================================================================
views {
// Component view
view components of lsp.containerName {
title 'Container Components'
description 'Shows internal structure.'
include *
autoLayout LeftRight
}
// Dynamic view
dynamic view myFlow {
title 'My Feature Flow'
description 'Shows execution sequence.'
// Steps here
autoLayout TopBottom
}
}
# Validate all diagrams
npx likec4 validate .ai/diagrams
# View diagrams locally
npx likec4 serve .ai/diagrams
# Export diagrams
npx likec4 export png .ai/diagrams -o ./output/
person // External users/actors
softwareSystem // External systems or your main system
container // Major deployable units
component // Internal building blocks
source -> target 'Label'
source -> target.component 'Label'
container.component1 -> container.component2 'Label'
model.c4npx likec4 validate .ai/diagrams