Skip to content

Commit 8b8f888

Browse files
authored
feat: add hook to redirect CI log fetches to analyze-logs agent (#19989)
## Summary - Adds PreToolUse hook that blocks WebFetch to ci.aztec-labs.com - Redirects Claude to use /ci-logs skill which spawns analyze-logs agent - Agent uses `yarn ci dlog` for authenticated log access 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents c9a3c06 + 8d511a2 commit 8b8f888

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

.claude/scripts/check-ci-url.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python3
2+
import json
3+
import re
4+
import sys
5+
6+
data = json.load(sys.stdin)
7+
url = data.get('tool_input', {}).get('url', '')
8+
9+
if 'ci.aztec-labs.com' in url:
10+
# Allow if basic auth is present (user:pass@)
11+
if re.search(r'://[^/:]+:[^/@]+@ci\.aztec-labs\.com', url):
12+
sys.exit(0)
13+
print(f'BLOCKED: Cannot WebFetch ci.aztec-labs.com (requires auth). Use /ci-logs skill instead: /ci-logs {url}', file=sys.stderr)
14+
sys.exit(2)
15+
16+
sys.exit(0)

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PreToolUse": [
4+
{
5+
"matcher": "WebFetch",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "python3 .claude/scripts/check-ci-url.py"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}

.claude/skills/ci-logs/ci-logs.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: ci-logs
3+
description: Analyze CI logs from ci.aztec-labs.com. Use this instead of WebFetch for CI URLs.
4+
user-invocable: true
5+
arguments: <url-or-hash>
6+
---
7+
8+
# CI Log Analysis
9+
10+
When you need to analyze logs from ci.aztec-labs.com, use the Task tool to spawn the analyze-logs agent.
11+
12+
## Usage
13+
14+
1. **Extract the hash** from the URL (e.g., `http://ci.aztec-labs.com/e93bcfdc738dc2e0``e93bcfdc738dc2e0`)
15+
16+
2. **Spawn the analyze-logs agent** using the Task tool:
17+
18+
```
19+
Task(
20+
subagent_type: "analyze-logs",
21+
prompt: "Analyze CI log hash: <hash>. Focus: errors",
22+
description: "Analyze CI logs"
23+
)
24+
```
25+
26+
## Examples
27+
28+
**User asks:** "What failed in http://ci.aztec-labs.com/343c52b17688d2cd"
29+
30+
**You do:**
31+
```
32+
Task(
33+
subagent_type: "analyze-logs",
34+
prompt: "Analyze CI log hash: 343c52b17688d2cd. Focus: errors. Download with: yarn ci dlog 343c52b17688d2cd > /tmp/343c52b17688d2cd.log",
35+
description: "Analyze CI failure"
36+
)
37+
```
38+
39+
**For specific test analysis:**
40+
```
41+
Task(
42+
subagent_type: "analyze-logs",
43+
prompt: "Analyze CI log hash: 343c52b17688d2cd. Focus: test 'my test name'",
44+
description: "Analyze test failure"
45+
)
46+
```
47+
48+
## Do NOT
49+
50+
- Do NOT use WebFetch to access ci.aztec-labs.com (requires auth)
51+
- Do NOT try to curl the URL directly
52+
- Always use the analyze-logs agent which knows how to use `yarn ci dlog`

0 commit comments

Comments
 (0)