{
"event": "PreToolUse",
"tool_name": "mcp__mcp-docs__docs_get",
"tool_input": {
"id": 90,
"include_breadcrumb": true
}
}
{
"tool_response": [
{
"type": "text",
"text": "{\n \"success\": true,\n \"doc\": {\n \"id\": 90,\n \"parent_id\": 55,\n \"slug\": \"enforcement-system\",\n \"path\": \"\/betrieb\/enforcement-system\",\n \"title\": \"Enforcement-System\",\n \"description\": \"Dokumentation des Contract-Enforcement-Systems\",\n \"content\": \"<h1>Contract-Enforcement-System<\/h1>\\n<p class=\\\"doc-meta\\\"><strong>Erstellt:<\/strong> 2025-12-22 | <strong>Aktualisiert:<\/strong> 2025-12-27<\/p>\\n\\n\\n<p>Das Enforcement-System stellt sicher, dass alle Code-Qualitätsstandards und Architektur-Regeln automatisch durchgesetzt werden.<\/p>\\n\\n<h2>Architektur-Übersicht<\/h2>\\n\\n<pre><code>\\n┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐\\n│ Contracts │────▶│ Validator │────▶│ Hooks │\\n│ (YAML in DB) │ │ (contract-check)│ │ (Python Scripts)│\\n└─────────────────┘ └─────────────────┘ └─────────────────┘\\n │ │ │\\n ▼ ▼ ▼\\n┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐\\n│ MCP-Contracts │ │ sync-dev-prod │ │ Claude Code │\\n│ (API) │ │ (Workflow) │ │ (PreToolUse) │\\n└─────────────────┘ └─────────────────┘ └─────────────────┘\\n<\/code><\/pre>\\n\\n<h2>Komponenten<\/h2>\\n\\n<h3>1. Contracts (Datenbank)<\/h3>\\n<p>Contracts sind in <code>ki_protokoll.contracts<\/code> gespeichert und definieren Regeln im YAML-Format.<\/p>\\n\\n<table>\\n<tr><th>Contract<\/th><th>Zweck<\/th><th>Severity<\/th><\/tr>\\n<tr><td>code-quality-standards<\/td><td>LOC-Limits, PDO-Verbot in Controllern<\/td><td>critical\/major<\/td><\/tr>\\n<tr><td>layered-architecture<\/td><td>Schichtenarchitektur (MVC\/MVP)<\/td><td>critical<\/td><\/tr>\\n<tr><td>db-access-security<\/td><td>Keine direkten DB-Befehle<\/td><td>critical<\/td><\/tr>\\n<tr><td>python-pipeline<\/td><td>Python-Qualitätsstandards<\/td><td>critical\/major<\/td><\/tr>\\n<tr><td>view-structure<\/td><td>CRUD-View-Standards<\/td><td>critical\/major<\/td><\/tr>\\n<tr><td>css-standards<\/td><td>Accessibility (WCAG 2.1)<\/td><td>critical\/major<\/td><\/tr>\\n<tr><td>critic-workflow<\/td><td>Review-Prozess Definition<\/td><td>critical<\/td><\/tr>\\n<\/table>\\n\\n<h3>2. Validator (contract-check.sh)<\/h3>\\n<p>Führt Contract-Validierungen aus:<\/p>\\n<pre><code>\/opt\/scripts\/contract-check.sh \/var\/www\/dev.campus.systemische-tools.de<\/code><\/pre>\\n\\n<h3>3. Hooks (PreToolUse)<\/h3>\\n<p>Blockieren Architektur-Verletzungen BEVOR Code geschrieben wird:<\/p>\\n\\n<table>\\n<tr><th>Hook<\/th><th>Trigger<\/th><th>Prüfung<\/th><\/tr>\\n<tr><td>block_direct_db.py<\/td><td>Bash<\/td><td>mysql\/mariadb-Befehle<\/td><\/tr>\\n<tr><td>architecture_guard.py<\/td><td>Write\/Edit<\/td><td>Controller LOC > 500, PDO in Controller<\/td><\/tr>\\n<\/table>\\n\\n<h2>Workflow<\/h2>\\n\\n<h3>Pre-Sync Validierung<\/h3>\\n<ol>\\n<li><strong>Contract-Check<\/strong>: Alle Contracts werden validiert<\/li>\\n<li><strong>PHP Quality<\/strong>: PHPStan, PHP-CS-Fixer, Semgrep<\/li>\\n<li><strong>Unit Tests<\/strong>: PHPUnit ausführen<\/li>\\n<li><strong>Entscheidung<\/strong>: Critical=Block, Major=Warn, Minor=Log<\/li>\\n<\/ol>\\n\\n<h3>PreToolUse Hooks<\/h3>\\n<ol>\\n<li>Claude Code ruft Write\/Edit\/Bash auf<\/li>\\n<li>Hook prüft Content\/Command<\/li>\\n<li>Bei Violation: Exit 2 → Block + Fehlermeldung<\/li>\\n<li>Bei OK: Exit 0 → Durchlassen<\/li>\\n<\/ol>\\n\\n<h2>MCP-Tools<\/h2>\\n\\n<h3>contracts_list<\/h3>\\n<pre><code>contracts_list(compact=True)<\/code><\/pre>\\n<p>Listet alle Contracts auf.<\/p>\\n\\n<h3>contracts_validate<\/h3>\\n<pre><code>contracts_validate(name=\\\"code-quality-standards\\\")<\/code><\/pre>\\n<p>Validiert einen Contract gegen die Codebase.<\/p>\\n\\n<h3>contracts_create\/update<\/h3>\\n<pre><code>contracts_create(name=\\\"...\\\", yaml_content=\\\"...\\\", version=\\\"1.0\\\")<\/code><\/pre>\\n<p>Erstellt oder aktualisiert einen Contract.<\/p>\\n\\n<h2>Troubleshooting<\/h2>\\n\\n<h3>\\\"Mein Code wird blockiert\\\"<\/h3>\\n<ol>\\n<li>Prüfe welcher Hook blockiert (Fehlermeldung)<\/li>\\n<li>Prüfe welche Regel verletzt wird<\/li>\\n<li>Behebe das Problem (z.B. Service extrahieren statt PDO in Controller)<\/li>\\n<\/ol>\\n\\n<h3>\\\"Contract-Validierung findet nichts\\\"<\/h3>\\n<ol>\\n<li>Prüfe ob Contract aktiv ist: <code>contracts_get(name=\\\"...\\\")<\/code><\/li>\\n<li>Prüfe Scope-Pfade im Contract<\/li>\\n<li>Prüfe ob Dateien existieren<\/li>\\n<\/ol>\\n\\n<h3>\\\"Sync wird blockiert\\\"<\/h3>\\n<ol>\\n<li>Führe <code>\/opt\/scripts\/contract-check.sh<\/code> aus<\/li>\\n<li>Prüfe Critical\/Major Violations<\/li>\\n<li>Behebe alle Critical-Violations<\/li>\\n<li>Major-Violations können als Baseline akzeptiert werden<\/li>\\n<\/ol>\\n\\n<h2>Baseline für Legacy-Code<\/h2>\\n\\n<p>Aktuell akzeptierte Legacy-Violations (nicht für neue Code):<\/p>\\n<ul>\\n<li>SemanticExplorerRepository.php: 797 LOC<\/li>\\n<li>SystemExplorerRepository.php: 709 LOC<\/li>\\n<li>ChunkSyncService.php: 551 LOC<\/li>\\n<\/ul>\\n\\n<p>Neue Violations in diesen Dateien werden trotzdem blockiert.<\/p>\\n\",\n \"status\": \"published\",\n \"sort_order\": 8,\n \"depth\": 1,\n \"created_at\": \"2025-12-22T22:24:08\",\n \"updated_at\": \"2025-12-29T14:53:21\"\n },\n \"breadcrumb\": [\n {\n \"id\": 55,\n \"path\": \"\/betrieb\",\n \"title\": \"Betrieb\"\n },\n {\n \"id\": 90,\n \"path\": \"\/betrieb\/enforcement-system\",\n \"title\": \"Enforcement-System\"\n }\n ]\n}"
}
]
}