hexagonal-guard
Abdox-menara/guard-skills/skills/guards/hexagonal-guard/SKILL.md
ULTRA-ADVANCED Hexagonal Guard - Hexagonal/ports-and-adapters architecture validation - clean dependency flow
Skill0 starsChanged 40 days ago
What's in it
- Hexagonal Guard - ULTRA-ADVANCED v1.0
- Overview
- Detection Patterns
- Scoring
- Implementation
---
name: hexagonal-guard
version: 1.0.0
author: Abdox
description: |
ULTRA-ADVANCED Hexagonal Guard - Hexagonal/ports-and-adapters architecture validation - clean dependency flow
CAPABILITIES:
- Anti-pattern detection with severity scoring
- Automated pattern recognition
- Compliance scoring (A-F grade)
- Fix suggestion generation
- Directory scanning and reporting
TRIGGER PHRASES: "hexagonal architecture, ports and adapters, clean architecture"
ENVIRONMENT: Works with any codebase, any language, any framework.
---
# Hexagonal Guard - ULTRA-ADVANCED v1.0
## Overview
Hexagonal/ports-and-adapters architecture validation - clean dependency flow. This skill scans codebases for violations, scores compliance, and generates actionable recommendations.
## Detection Patterns
| Pattern | Description | Severity |
|---|---|---|
| Port interface violation | Domain depends on infrastructure detail | critical |
| Adapter layer leak | Infrastructure detail leaks into application | high |
| Layer violation | Wrong import direction across layers | critical |
| Input port missing | No inbound boundary interface defined | medium |
| Output port missing | No outbound boundary interface defined | medium |
## Scoring
- **A** (90-100): Excellent
- **B** (75-89): Good
- **C** (60-74): Fair
- **D** (40-59): Poor
- **F** (0-39): Failing
## Implementation
```python
import re, os
from typing import Dict, List, Set, Any
from datetime import datetime
class HexagonalGuard:
def __init__(self):
self.file_results = {}
def scan_file(self, file_path: str) -> Dict:
try:
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
return self._analyze(content, file_path)
except Exception as e:
return {'error': str(e), 'file': file_path}
def _analyze(self, content: str, file_path: str) -> Dict:
issues = []
for pid, info in self._patterns().items():
matches = re.findall(info['regex'], content, re.IGNORECASE | re.MULTILINE)
if matches:
issues.append({'id': pid, 'severity': info['severity'],
'count': len(matches), 'message': info['message']})
score = max(0.0, 100.0 - sum(self._weight(i['severity']) * i['count'] for i in issues))
return {'file': file_path, 'issues': issues, 'score': round(score, 1),
'grade': self._grade(score), 'analyzed_at': datetime.now().isoformat()}
def _patterns(self) -> Dict:
return {}
def _weight(self, s: str) -> float:
return {'critical': 10.0, 'high': 7.0, 'medium': 5.0, 'low': 2.0}.get(s, 5.0)
def _grade(self, s: float) -> str:
return 'A' if s >= 90 else 'B' if s >= 75 else 'C' if s >= 60 else 'D' if s >= 40 else 'F'
def scan_directory(self, d: str, exts: Set[str] = None) -> Dict:
results = {}
skip = {'.git', 'node_modules', 'venv', '__pycache__', 'target', 'build', 'dist'}
for root, dirs, files in os.walk(d):
dirs[:] = [dd for dd in dirs if not dd.startswith('.') and dd not in skip]
for f in files:
if exts and not any(f.endswith(e) for e in exts): continue
results[os.path.join(root, f)] = self.scan_file(os.path.join(root, f))
return results
def generate_report(self, results: Dict) -> Dict:
if not results: return {'error': 'No results'}
total_issues = sum(len(r.get('issues', [])) for r in results.values() if 'issues' in r)
scores = [r.get('score', 0) for r in results.values() if 'score' in r]
avg = sum(scores) / len(scores) if scores else 0
return {'files_scanned': len(results), 'total_issues': total_issues,
'avg_score': round(avg, 1), 'grade': self._grade(avg),
'critical': sum(1 for r in results.values() for i in r.get('issues', []) if i.get('severity') == 'critical'),
'recommendations': []}
```
---
**Version**: 1.0.0
**Status**: PRODUCTION READY
**Total Patterns**: 5
More agent context in Abdox-menara/guard-skills
220 other files this repository gives its agents, the first 60 shown.
AGENTS.md
Skill
- desktop-control-mcpskills/desktop-control-mcp/SKILL.md
- force-deleteskills/force-delete/SKILL.md
- analytics-guardskills/guards/analytics-guard/SKILL.md
- api-contract-guardskills/guards/api-contract-guard/SKILL.md
- api-security-guardskills/guards/api-security-guard/SKILL.md
- async-guardskills/guards/async-guard/SKILL.md
- build-guardskills/guards/build-guard/SKILL.md
- changelog-guardskills/guards/changelog-guard/SKILL.md
- ci-guardskills/guards/ci-guard/SKILL.md
- circuit-breaker-guardskills/guards/circuit-breaker-guard/SKILL.md
- clean-arch-guardskills/guards/clean-arch-guard/SKILL.md
- clean-code-guardskills/guards/clean-code-guard/SKILL.md
- comment-guardskills/guards/comment-guard/SKILL.md
- commit-guardskills/guards/commit-guard/SKILL.md
- concurrency-guardskills/guards/concurrency-guard/SKILL.md
- config-guardskills/guards/config-guard/SKILL.md
- cors-guardskills/guards/cors-guard/SKILL.md
- cqrs-guardskills/guards/cqrs-guard/SKILL.md
- csrf-guardskills/guards/csrf-guard/SKILL.md
- css-guardskills/guards/css-guard/SKILL.md
- cyclomatic-guardskills/guards/cyclomatic-guard/SKILL.md
- ddd-guardskills/guards/ddd-guard/SKILL.md
- dead-code-guardskills/guards/dead-code-guard/SKILL.md
- dependency-injection-guardskills/guards/dependency-injection-guard/SKILL.md
- deploy-guardskills/guards/deploy-guard/SKILL.md
- docker-compose-guardskills/guards/docker-compose-guard/SKILL.md
- docker-guardskills/guards/docker-guard/SKILL.md
- docs-guardskills/guards/docs-guard/SKILL.md
- duplicate-code-guardskills/guards/duplicate-code-guard/SKILL.md
- encryption-guardskills/guards/encryption-guard/SKILL.md
- env-check-guardskills/guards/env-check-guard/SKILL.md
- error-handling-guardskills/guards/error-handling-guard/SKILL.md
- event-driven-guardskills/guards/event-driven-guard/SKILL.md
- event-sourcing-guardskills/guards/event-sourcing-guard/SKILL.md
- file-guardskills/guards/file-guard/SKILL.md
- graceful-shutdown-guardskills/guards/graceful-shutdown-guard/SKILL.md
- health-check-guardskills/guards/health-check-guard/SKILL.md
- helm-guardskills/guards/helm-guard/SKILL.md
- html-guardskills/guards/html-guard/SKILL.md
- iam-guardskills/guards/iam-guard/SKILL.md
- idor-guardskills/guards/idor-guard/SKILL.md
- injection-guardskills/guards/injection-guard/SKILL.md
- json-guardskills/guards/json-guard/SKILL.md
- jwt-guardskills/guards/jwt-guard/SKILL.md
- kubernetes-guardskills/guards/kubernetes-guard/SKILL.md
- large-class-guardskills/guards/large-class-guard/SKILL.md
- logging-pattern-guardskills/guards/logging-pattern-guard/SKILL.md
- long-method-guardskills/guards/long-method-guard/SKILL.md
- lsp-guardskills/guards/lsp-guard/SKILL.md
- markdown-guardskills/guards/markdown-guard/SKILL.md
- message-queue-guardskills/guards/message-queue-guard/SKILL.md
- migration-pattern-guardskills/guards/migration-pattern-guard/SKILL.md
- naming-guardskills/guards/naming-guard/SKILL.md
- nested-depth-guardskills/guards/nested-depth-guard/SKILL.md
- observer-pattern-guardskills/guards/observer-pattern-guard/SKILL.md
- pr-guardskills/guards/pr-guard/SKILL.md
- python-guardskills/guards/python-guard/SKILL.md
- react-guardskills/guards/react-guard/SKILL.md
- readme-guardskills/guards/readme-guard/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

