stribus/pygerengastos / .agents/skills/reversa-arquitetura-3d
reversa-arquitetura-3d
VerifiedCria visualizações 3D interativas de arquitetura de software usando Three.js, gerando HTML standalone com cenas navegáveis por câmera livre. Use esta skill sempre que o usuário pedir para visualizar arquitetura, módulos, dependências, camadas ou hierarquia de chamadas em 3D. Deve ser ativada quando o usuário mencionar termos como "code city", "cidade de código", "arquitetura 3D", "dependency graph 3D", "module map 3D", "layer stack 3D", "call graph 3D", "architecture tour", "tour pela arquitetura", "visualizar software em 3D", "Three.js" no contexto de software, ou pedir para explorar a estrutura de um sistema com câmera 3D. Funciona com JSON de módulos (nome, pasta, LOC, complexidade) e dependências (grafo orientado). Sempre gera HTML standalone completo. Quando rodada pelo Time Reversa Docs, usa Three.js servido localmente em assets/vendor/ (offline-first).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.8 KB |
| references/ARCH_TOUR.md | markdown | 7.6 KB |
| references/CALL_GRAPH_3D.md | markdown | 6.8 KB |
| references/CODE_CITY.md | markdown | 7.1 KB |
| references/DEPENDENCY_GRAPH_3D.md | markdown | 7.7 KB |
| references/ERRORS.md | markdown | 8.2 KB |
| references/LAYER_STACK.md | markdown | 6.9 KB |
| references/THREE_PATTERNS.md | markdown | 6.6 KB |
references/LAYER_STACK.md
View on GitHub# Layer Stack 3D
Visualização de **camadas arquiteturais** empilhadas verticalmente, cada camada como um plano com seus módulos, conectadas por setas verticais que mostram o fluxo de dependências entre camadas.
## Mapeamento
| Conceito arquitetural | Visual |
|---|---|
| Camada (UI, Domain, Infra, etc) | Plano horizontal em altura distinta |
| Módulo dentro da camada | Caixa/disco posicionado no plano da camada |
| Dependência inter-camada | Linha vertical orientada conectando módulos |
| Direção do fluxo | Seta na ponta da linha |
| Violação de camada (camada de baixo importando de cima) | Linha vermelha pulsante |
## Quando usar
- Validar que a arquitetura segue Clean Architecture, Hexagonal, ou Onion.
- Detectar **violações de camada** (UI importando direto de Infra, por exemplo).
- Apresentar o sistema para stakeholders que pensam em camadas.
- Comparar com o diagrama arquitetural esperado lado a lado.
**Quando evitar**: sistemas sem separação clara de camadas (monolitos planos). Use Code City.
## Detecção de camadas
A skill aceita o mapeamento de camadas vindo do usuário (via JSON) ou tenta inferir de padrões de pasta.
**Mapeamento explícito**:
```json
{
"layers": [
{ "name": "UI", "order": 0, "folders": ["src/components", "src/pages"] },
{ "name": "Application", "order": 1, "folders": ["src/services", "src/use-cases"] },
{ "name": "Domain", "order": 2, "folders": ["src/domain", "src/entities"] },
{ "name": "Infrastructure", "order": 3, "folders": ["src/db", "src/external"] }
]
}
```
**Inferência heurística** (quando não fornecido): regex sobre nomes de pasta.
```javascript
const LAYER_PATTERNS = [
{ name: "UI", regex: /(components|pages|views|screens|ui)/i, order: 0 },
{ name: "Application", regex: /(services|use-cases|application|handlers)/i, order: 1 },
{ name: "Domain", regex: /(domain|entities|models|business)/i, order: 2 },
{ name: "Infrastructure", regex: /(db|database|repositories|external|infra|adapters)/i, order: 3 }
];
function inferLayer(folder) {
for (const p of LAYER_PATTERNS) {
if (p.regex.test(folder)) return p;
}
return { name: "Outros", order: 999 };
}
```
## Algoritmo de layout
### 1. Empilhar camadas verticalmente
```javascript
const LAYER_GAP = 80;
const LAYER_SIZE = 400; // plano 400x400
const layerPlanes = layers.map((layer, i) => ({
name: layer.name,
y: i * LAYER_GAP,
modules: modules.filter((m) => belongsToLayer(m, layer))
}));
```
### 2. Posicionar módulos dentro da camada
Empacotamento simples em grid 2D no plano da camada.
```javascript
layerPlanes.forEach((layer) => {
const cols = Math.ceil(Math.sqrt(layer.modules.length));
const cellSize = LAYER_SIZE / cols;
layer.modules.forEach((m, idx) => {
const col = idx % cols;
const row = Math.floor(idx / cols);
m.x = (col - cols / 2) * cellSize;
m.y = layer.y;
m.z = (row - cols / 2) * cellSize;
});
});
```
### 3. Renderizar planos de camada
```javascript
layerPlanes.forEach((layer, i) => {
const planeGeo = new THREE.PlaneGeometry(LAYER_SIZE, LAYER_SIZE);
const planeMat = new THREE.MeshStandardMaterial({
color: LAYER_COLORS[i % LAYER_COLORS.length],
transparent: true,
opacity: 0.15,
side: THREE.DoubleSide
});
const plane = new THREE.Mesh(planeGeo, planeMat);
plane.rotation.x = Math.PI / 2;
plane.position.y = layer.y;
scene.add(plane);
// Label da camada lateral
const label = addLabel(layer.name, new THREE.Vector3(LAYER_SIZE / 2 + 20, layer.y, 0));
scene.add(label);
});
const LAYER_COLORS = [0x4a9eff, 0x6cc46c, 0xffc857, 0xb39ddb, 0xff9aa2];
```
### 4. Renderizar módulos como discos
```javascript
const moduleGeo = new THREE.CylinderGeometry(1, 1, 0.5, 16);
const moduleMat = new THREE.MeshStandardMaterial({ roughness: 0.5 });
const modulesMesh = new THREE.InstancedMesh(moduleGeo, moduleMat, modules.length);
modules.forEach((m, i) => {
const dummy = new THREE.Object3D();
const size = 1 + Math.sqrt(m.loc / 100);
dummy.position.set(m.x, m.y, m.z);
dummy.scale.set(size, 1, size);
dummy.updateMatrix();
modulesMesh.setMatrixAt(i, dummy.matrix);
});
modulesMesh.instanceMatrix.needsUpdate = true;
scene.add(modulesMesh);
```
### 5. Renderizar dependências como linhas verticais
```javascript
edges.forEach((e) => {
const src = modules.find((m) => m.name === e.from);
const dst = modules.find((m) => m.name === e.to);
if (!src || !dst) return;
const isViolation = isLayerViolation(src, dst);
const color = isViolation ? 0xff5a4f : 0x6c8eb0;
const points = [
new THREE.Vector3(src.x, src.y, src.z),
new THREE.Vector3(dst.x, dst.y, dst.z)
];
const geo = new THREE.BufferGeometry().setFromPoints(points);
const mat = new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: isViolation ? 1.0 : 0.4
});
const line = new THREE.Line(geo, mat);
if (isViolation) line.userData.pulse = true; // anima opacidade
scene.add(line);
});
```
### 6. Detecção de violação de camada
A regra padrão (Clean Architecture): camadas só dependem de camadas com `order` maior (mais para "dentro").
```javascript
function isLayerViolation(src, dst) {
return src.layerOrder > dst.layerOrder;
}
```
Pode haver exceções configuráveis (ex: ports/adapters em hexagonal).
## Animação de violações
Linhas vermelhas pulsam (opacity oscilando) para chamar atenção.
```javascript
function pulseViolations(time) {
scene.traverse((obj) => {
if (obj.userData?.pulse) {
obj.material.opacity = 0.5 + 0.5 * Math.sin(time * 0.003);
}
});
}
```
## Sidebar de controles
```html
<aside id="sidebar">
<h3>Layer Stack</h3>
<label>Espaçamento entre camadas
<input type="range" min="40" max="200" value="80" data-param="layerGap">
</label>
<label>
<input type="checkbox" data-param="showViolations" checked> Destacar violações
</label>
<label>
<input type="checkbox" data-param="showLabels" checked> Labels de módulo
</label>
<label>Mostrar apenas
<select data-param="layerFilter">
<option value="all">Todas as camadas</option>
<!-- POPULATED -->
</select>
</label>
<div id="violations-count"></div>
<button id="reset">Reset</button>
<button id="export-png">Exportar PNG</button>
</aside>
```
O contador `#violations-count` mostra em tempo real "X violações detectadas".
## Interação
- **Hover em módulo**: tooltip com nome, camada, dependências.
- **Clique em violação**: foca câmera nos dois módulos envolvidos e mostra detalhes da relação no painel.
- **Filtro de camada**: oculta camadas não selecionadas.
## Performance
Camadas tipicamente têm dezenas a poucas centenas de módulos cada. Limite total de ~2.000 módulos. Acima disso, agrupar por pasta dentro de cada camada.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |