Protokoll #23877
| ID | 23877 |
|---|---|
| Zeitstempel | 2025-12-27 15:29:07.639075 |
| Client | root |
| IP | Warning: Undefined array key "request_ip" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 |
| Modell | claude-sonnet-4-20250514 |
| Status | completed |
| Tokens | 1,584 (Input: 0, Output: 0) |
| Dauer | 84 ms |
| Request-Zeit | Warning: Undefined array key "request_timestamp" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 18 |
| Response-Zeit | - |
Warning: Undefined array key "error_message" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 22
Request
{
"event": "PreToolUse",
"tool_name": "mcp__mcp-docs__docs_get",
"tool_input": {
"id": 80
}
}
Response
{
"tool_response": [
{
"type": "text",
"text": "{\n \"success\": true,\n \"doc\": {\n \"id\": 80,\n \"parent_id\": 55,\n \"slug\": \"claude-hooks\",\n \"path\": \"\/betrieb\/claude-hooks\",\n \"title\": \"Claude Hooks\",\n \"description\": \"Claude Code Hooks für Logging, Backup und Task-Erstellung\",\n \"content\": \"<nav class=\\\"breadcrumb\\\">\\n <a href=\\\"\/docs\\\">Dokumentation<\/a> » <a href=\\\"\/docs\/betrieb\\\">Betrieb<\/a> » Claude Hooks\\n<\/nav>\\n\\n<h1>Claude Hooks<\/h1>\\n<p>Python-Hooks für Claude Code Integration mit Protokollierung, Backup, Task-Erstellung und Workflow-Validierung.<\/p>\\n\\n<table>\\n <tr><th>Pfad<\/th><td>\/var\/www\/tools\/ki-protokoll\/claude-hook\/<\/td><\/tr>\\n <tr><th>Konfiguration<\/th><td>\/root\/.claude\/settings.json<\/td><\/tr>\\n <tr><th>Datenbank<\/th><td>ki_dev<\/td><\/tr>\\n<\/table>\\n\\n<h2>Übersicht<\/h2>\\n<table>\\n <tr><th>Hook<\/th><th>Trigger<\/th><th>Funktion<\/th><\/tr>\\n <tr><td>log_to_db.py<\/td><td>Alle Events<\/td><td>Protokollierung in DB<\/td><\/tr>\\n <tr><td>file_backup_hook.py<\/td><td>PreToolUse (Edit, Write)<\/td><td>Datei-Backup vor Änderung<\/td><\/tr>\\n <tr><td>task_hook.py<\/td><td>UserPromptSubmit<\/td><td>Auto-Task-Erstellung<\/td><\/tr>\\n <tr><td>task_completion_guard.py<\/td><td>PreToolUse (mcp__mcp-tasks__tasks_status)<\/td><td>Blockiert Task-Completion ohne Result<\/td><\/tr>\\n<\/table>\\n\\n<h2>log_to_db.py<\/h2>\\n<p>Protokolliert alle Claude Code Events in der Datenbank.<\/p>\\n\\n<h3>Features<\/h3>\\n<ul>\\n <li><strong>Request\/Response-Pairing:<\/strong> PreToolUse → PostToolUse werden verknüpft<\/li>\\n <li><strong>Duration-Tracking:<\/strong> Millisekunden-genaue Zeiterfassung<\/li>\\n <li><strong>Token-Schätzung:<\/strong> ~4 Zeichen = 1 Token<\/li>\\n <li><strong>Sensible Daten:<\/strong> Automatische Maskierung (Passwörter, API-Keys, JWTs)<\/li>\\n <li><strong>Session-Tracking:<\/strong> Temporäre Dateien in \/tmp\/claude_hooks\/<\/li>\\n<\/ul>\\n\\n<h3>Verarbeitete Events<\/h3>\\n<table>\\n <tr><th>Event<\/th><th>Verarbeitung<\/th><\/tr>\\n <tr><td>UserPromptSubmit<\/td><td>Prompt speichern<\/td><\/tr>\\n <tr><td>PreToolUse<\/td><td>Tool-Name + Input speichern, pending<\/td><\/tr>\\n <tr><td>PostToolUse<\/td><td>Response zu PreToolUse matchen, completed<\/td><\/tr>\\n <tr><td>SessionStart\/End<\/td><td>Session-Lifecycle loggen<\/td><\/tr>\\n <tr><td>Stop\/SubagentStop<\/td><td>Abschluss loggen<\/td><\/tr>\\n<\/table>\\n\\n<h3>Datenbank-Tabelle<\/h3>\\n<pre><code>ki_dev.protokoll\\n├── id, timestamp\\n├── request_ip, client_name\\n├── request, request_timestamp\\n├── response, response_timestamp\\n├── duration_ms\\n├── tokens_input, tokens_output, tokens_total\\n├── model_name, status<\/code><\/pre>\\n\\n<h2>file_backup_hook.py<\/h2>\\n<p>Sichert Dateien automatisch BEVOR sie geändert werden.<\/p>\\n\\n<h3>Trigger<\/h3>\\n<ul>\\n <li>PreToolUse → Edit<\/li>\\n <li>PreToolUse → Write<\/li>\\n<\/ul>\\n\\n<h3>Backup-Verzeichnisse<\/h3>\\n<pre><code>\/var\/www\/dev.campus.systemische-tools.de\/src\\n\/var\/www\/dev.campus.systemische-tools.de\/public\\n\/var\/www\/dev.campus.systemische-tools.de\/scripts\\n\/var\/www\/dev.campus.systemische-tools.de\/config\\n\/var\/www\/prod.campus.systemische-tools.de\/src\\n...<\/code><\/pre>\\n\\n<h3>Features<\/h3>\\n<ul>\\n <li><strong>Versionierung:<\/strong> Automatische Version pro Datei<\/li>\\n <li><strong>Hash-Prüfung:<\/strong> Skip bei unveränderter Datei<\/li>\\n <li><strong>Größenlimit:<\/strong> Max 10 MB pro Datei<\/li>\\n <li><strong>Non-Blocking:<\/strong> Hook blockiert nie<\/li>\\n<\/ul>\\n\\n<h3>Datenbank-Tabelle<\/h3>\\n<pre><code>ki_dev.file_backup_history\\n├── id, file_path, version\\n├── file_content, content_hash, file_size\\n├── change_type, changed_by, reason\\n├── created_at<\/code><\/pre>\\n\\n<h2>task_hook.py<\/h2>\\n<p>Erstellt automatisch Tasks aus Patterns in User-Prompts.<\/p>\\n\\n<h3>Erkannte Patterns<\/h3>\\n<pre><code>TODO: <text> → Task erstellen\\nTASK: <text> → Task erstellen\\n@task <text> → Task erstellen\\n#task <text> → Task erstellen<\/code><\/pre>\\n\\n<h2>task_completion_guard.py<\/h2>\\n<p>Blockiert <code>tasks_status(completed)<\/code> wenn kein Result existiert. Erzwingt korrekten Workflow.<\/p>\\n\\n<h3>Trigger<\/h3>\\n<ul>\\n <li>PreToolUse → mcp__mcp-tasks__tasks_status<\/li>\\n <li>Nur bei status=\\\"completed\\\"<\/li>\\n<\/ul>\\n\\n<h3>Prüflogik<\/h3>\\n<ol>\\n <li>Prüft ob <code>status == \\\"completed\\\"<\/code><\/li>\\n <li>DB-Query: <code>SELECT COUNT(*) FROM task_results WHERE task_id = ?<\/code><\/li>\\n <li>Wenn count = 0 → Block mit Exit-Code 2<\/li>\\n<\/ol>\\n\\n<h3>Block-Nachricht<\/h3>\\n<pre><code>BLOCKIERT: Task kann nicht als 'completed' markiert werden!\\n\\nLÖSUNG: Vor tasks_status(id, \\\"completed\\\") MUSS tasks_result() aufgerufen werden:\\n\\n tasks_result(\\n id=TASK_ID,\\n response=\\\"Zusammenfassung...\\\",\\n executor=\\\"claude\\\",\\n executor_type=\\\"claude\\\"\\n )<\/code><\/pre>\\n\\n<h3>Fail-Safe<\/h3>\\n<p>Bei DB-Verbindungsfehlern: fail-open (durchlassen). Server-seitige Validierung greift als Backup.<\/p>\\n\\n<h2>Konfiguration<\/h2>\\n<p>Hooks werden in <code>\/root\/.claude\/settings.json<\/code> registriert:<\/p>\\n<pre><code>{\\n \\\"hooks\\\": {\\n \\\"UserPromptSubmit\\\": [...],\\n \\\"PreToolUse\\\": [\\n {\\\"matcher\\\": \\\"Bash\\\", \\\"hooks\\\": [...]},\\n {\\\"matcher\\\": \\\"mcp__mcp-tasks__tasks_status\\\", \\\"hooks\\\": [\\n {\\\"type\\\": \\\"command\\\", \\\"command\\\": \\\"...\/task_completion_guard.py\\\", \\\"timeout\\\": 5}\\n ]},\\n {\\\"matcher\\\": \\\"Edit|Write\\\", \\\"hooks\\\": [...]},\\n {\\\"matcher\\\": \\\"\\\", \\\"hooks\\\": [...]}\\n ],\\n \\\"PostToolUse\\\": [...]\\n }\\n}<\/code><\/pre>\\n\\n<h2>Environment-Variablen<\/h2>\\n<p>In <code>.env<\/code> im Hook-Verzeichnis:<\/p>\\n<pre><code>CLAUDE_DB_HOST=localhost\\nCLAUDE_DB_PORT=3306\\nCLAUDE_DB_USER=root\\nCLAUDE_DB_PASSWORD=***\\nCLAUDE_DB_NAME=ki_dev<\/code><\/pre>\",\n \"status\": \"published\",\n \"sort_order\": 6,\n \"depth\": 1,\n \"created_at\": \"2025-12-20T13:41:35\",\n \"updated_at\": \"2025-12-27T10:28:51\"\n }\n}"
}
]
}