Create a benchmark to measure CODEBASE.md effectiveness. Sets up hooks to run two parallel agents (one with guide, one without) and compare their efficiency. Requires /agentifind to be run first.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Create a benchmark to measure CODEBASE.md effectiveness. Sets up hooks to run two parallel agents (one with guide, one without) and compare their efficiency. Requires /agentifind to be run first.
Agentifind Benchmark Setup
This skill creates a benchmark infrastructure to measure how effectively CODEBASE.md helps AI agents navigate your codebase.
Prerequisites
.claude/CODEBASE.md must exist (run /agentifind first)
.claude/codebase.json must exist
Procedure
Step 1: Verify Prerequisites
Check that required files exist:
test -f .claude/CODEBASE.md && test -f .claude/codebase.json && echo"Ready" || echo"Missing"
If files don't exist:
CODEBASE.md not found. Please run /agentifind first to generate the codebase guide, then run /agentifind-benchmark again.
Exit the skill if prerequisites are not met.
Step 2: Detect Repo Type and Tech Stack
Read .claude/codebase.json and check the repo_type field:
If repo_type is "terraform" (or other IaC types):
This is an infrastructure repository
Use the Infrastructure Benchmark Template (Step 6B)
Focus on resource navigation, blast radius, dependency tracing
If repo_type is missing or not an IaC type:
This is an application code repository
Use the Application Benchmark Template (Step 6A)
Identify:
Primary language (Python, TypeScript, JavaScript, Go)
Based on the repo type detected in Step 2, use the appropriate template.
Step 6A: Application Benchmark Template
Use this template when repo_type is NOT "terraform" or similar IaC types.
Create .claude/BENCHMARK_ENGINEERING.md with 7 tasks tailored to the detected tech stack.
Task Categories:
TASK-1 (⭐ Fundamental): Find a configuration value
TASK-2 (⭐ Fundamental): Locate a specific function/class
TASK-3 (⭐⭐ Intermediate): Trace a data flow
TASK-4 (⭐⭐⭐ Advanced): Add a new feature following existing patterns
TASK-5 (⭐⭐⭐ Advanced): Fix a bug with provided symptoms
TASK-6 (⭐⭐⭐⭐ Expert): Debug a race condition or performance issue
TASK-7 (⭐⭐⭐⭐⭐ Expert): Design a cross-cutting feature
Template:
# {Project Name} Engineering Benchmark**Purpose:** Measure CODEBASE.md effectiveness on real engineering tasks.
---
## Orchestrator Instructions
You are running a benchmark to compare agent efficiency WITH vs WITHOUT the CODEBASE.md guide.
**IMPORTANT RULES:**1. Run agents in FOREGROUND (do NOT use run_in_background)
2. Run both agents IN PARALLEL for the same task (single message, two Task calls)
3. Wait for both to complete before reporting results
4. Report token usage from the Task tool response if available
5. Track metrics from agent self-reports
---
## How to Run### 1. Reset Logs
\`\`\`bash
.claude/hooks/reset-benchmark.sh
\`\`\`
### 2. Run Both Agents in Parallel (Foreground)
For each task, spawn BOTH subagents in a SINGLE message using two Task tool calls.
Do NOT use run_in_background - we need the full response including token usage.
\`\`\`
Task 1 (WITH_GUIDE):
- subagent_type: "general-purpose"
- run_in_background: false # IMPORTANT: foreground for token tracking
- prompt: |
AGENT_WITH_GUIDE: BENCHMARK
You have access to .claude/CODEBASE.md - a navigation guide for this codebase.
WORKFLOW:
1. Read .claude/CODEBASE.md FIRST
2. Use "Key Files" and "Architecture" sections to identify exactly where to look
3. Go DIRECTLY to relevant files - don't search broadly
4. Minimize tool calls - the guide tells you where things are
TASK: [task description]
DELIVERABLES:
- Answer with specific file paths and line numbers
- Confidence: HIGH/MEDIUM/LOW
- METRICS: Read=[n] Grep=[n] Glob=[n] Total=[n] | Files: [list]
Task 2 (WITHOUT_GUIDE):
- subagent_type: "general-purpose"
- run_in_background: false # IMPORTANT: foreground for token tracking
- prompt: |
After both agents complete, fill in this comparison table:
| Metric | WITHGUIDE |
|--------|------------|---------------|
| Tool calls | | |
| Read | | |
| Grep | | |
| Glob | | |
| Confidence | | |
| Correct? | | |
| Tokens (if available) | | |
\\`bash
.claude/hooks/analyze-benchmark.sh
\\`
Note: The analysis script captures main agent tool calls. Subagent metrics come from self-reporting.
---
⭐
[Create task based on project's config patterns]
⭐
[Create task to find a specific class/function]
⭐⭐
[Create task tracing request through system]
⭐⭐⭐
[Create task adding feature following existing patterns]
⭐⭐⭐
[Create task with bug symptoms to diagnose]
⭐⭐⭐⭐
[Create task with race condition or performance issue]
⭐⭐⭐⭐⭐
[Create cross-cutting feature design task]
---
| Criteria | 0 | 1 | 2 | 3 |
|----------|---|---|---|---|
| Completion | Failed | Partial | Minor issues | Correct |
| Efficiency | >50 calls | 30-50 | 15-30 | <15 |
| Quality | Wrong patterns | Partial | Minor deviations | Matches style |
Important: Each task must be specific to the actual codebase. Use information from:
codebase.json stats (files, functions, classes)
codebase.json modules (real file paths)
codebase.json call_graph (real function relationships)
CODEBASE.md architecture section
Step 6B: Infrastructure Benchmark Template
Use this template when repo_type is "terraform", "kubernetes", "ansible", or "cloudformation".
Create .claude/BENCHMARK_INFRASTRUCTURE.md with 7 tasks tailored to IaC navigation.
Infrastructure Task Categories:
TASK-1 (⭐ Fundamental): Find a resource by type
TASK-2 (⭐ Fundamental): Locate a variable definition
TASK-4 (⭐⭐⭐ Advanced): Assess blast radius of a change
TASK-5 (⭐⭐⭐ Advanced): Add a new resource following patterns
TASK-6 (⭐⭐⭐⭐ Expert): Debug a dependency cycle
TASK-7 (⭐⭐⭐⭐⭐ Expert): Design module refactoring
Template:
# {Project Name} Infrastructure Benchmark**Purpose:** Measure CODEBASE.md effectiveness on infrastructure navigation tasks.
---
## Orchestrator Instructions
You are running a benchmark to compare agent efficiency WITH vs WITHOUT the CODEBASE.md guide.
**IMPORTANT RULES:**1. Run agents in FOREGROUND (do NOT use run_in_background)
2. Run both agents IN PARALLEL for the same task (single message, two Task calls)
3. Wait for both to complete before reporting results
4. Report token usage from the Task tool response if available
5. Track metrics from agent self-reports
---
## How to Run### 1. Reset Logs
\`\`\`bash
.claude/hooks/reset-benchmark.sh
\`\`\`
### 2. Run Both Agents in Parallel (Foreground)
For each task, spawn BOTH subagents in a SINGLE message using two Task tool calls.
Do NOT use run_in_background - we need the full response including token usage.
\`\`\`
Task 1 (WITH_GUIDE):
- subagent_type: "general-purpose"
- run_in_background: false # IMPORTANT: foreground for token tracking
- prompt: |
AGENT_WITH_GUIDE: BENCHMARK
You have access to .claude/CODEBASE.md - an infrastructure navigation guide.
WORKFLOW:
1. Read .claude/CODEBASE.md FIRST
2. Use "Resource Inventory" and "Blast Radius" sections to identify targets
3. Go DIRECTLY to relevant .tf files - don't search broadly
4. Minimize tool calls - the guide tells you where things are
TASK: [task description]
DELIVERABLES:
- Answer with specific file paths and line numbers
- List affected resources if applicable
- Confidence: HIGH/MEDIUM/LOW
- METRICS: Read=[n] Grep=[n] Glob=[n] Total=[n] | Files: [list]
Task 2 (WITHOUT_GUIDE):
- subagent_type: "general-purpose"
- run_in_background: false # IMPORTANT: foreground for token tracking
prompt: |
After both agents complete, fill in this comparison table:
| Metric | WITHGUIDE |
|--------|------------|---------------|
| Tool calls | | |
| Read | | |
| Grep | | |
| Glob | | |
| Confidence | | |
| Correct? | | |
| Tokens (if available) | | |
\\`bash
.claude/hooks/analyze-benchmark.sh
\\`
---
⭐
Find all resources of type (e.g., awsgroup, awsrole).
List all instances with file paths and line numbers.
[Use resources from codebase.json stats.providers to pick a common type]
⭐
Find where variable is defined and list all resources that use it.
Variable definition location + list of usages.
[Pick a variable with usedgraph]
⭐⭐⭐
If we modify , what resources would be affected?
Complete blast radius analysis with severity assessment.
[Pick from blasttype}` resource following the existing naming and tagging patterns.
Code snippet following project conventions.
[Analyze existing resources to determine patterns]
⭐⭐⭐⭐
Resource fails to create with "dependency not ready" error. Find the root cause.
Identify missing explicit dependsgraph]
⭐⭐⭐⭐⭐
Refactor into a reusable module. What inputs/outputs are needed?
Module interface design with variable list and output values.
[Pick related resources that could be modularized]
---
| Criteria | 0 | 1 | 2 | 3 |
|----------|---|---|---|---|
| Completion | Failed | Partial | Minor issues | Correct |
| Efficiency | >50 calls | 30-50 | 15-30 | <15 |
| Blast Radius | Missed deps | Partial | Minor misses | Complete |
Important: Each task must be specific to the actual infrastructure. Use information from:
Tasks must reference real files and patterns from this specific codebase
Do not create generic tasks - analyze codebase.json to find actual components
Each task should have a clear expected answer based on the codebase
The benchmark measures navigation efficiency, not code quality
For IaC repos: Focus on resource discovery, dependency tracing, and blast radius assessment
Technical Limitations
Hooks don't run inside subagents: Claude Code hooks only execute in the main conversation context. Subagent tool calls are not captured by PreToolUse/PostToolUse hooks.
Workaround: Agents self-report their metrics at the end of each task. The prompt includes a METRICS template they must fill out.
What the hooks DO capture:
Main agent spawning subagents (Task tool calls)
Violations if WITHOUT_GUIDE tries to read .claude/ files (blocked by hook)
Token usage: Not directly available via hooks. To estimate:
Tool calls correlate with input/output tokens
Check API billing dashboard for actual usage
Or parse conversation transcripts in ~/.claude/projects/
RESTRICTION: Do NOT read .claude/CODEBASE.md or any .claude/ files.
You must explore the codebase using only Grep, Glob, and Read on source files.
TASK: [task description]
DELIVERABLES:
- Answer with specific file paths and line numbers
- Confidence: HIGH/MEDIUM/LOW
- METRICS: Read=[n] Grep=[n] Glob=[n] Total=[n] | Files: [list]
\`\`\`
### 3. Record Results
_GUIDE | WITHOUT_
### 4. (Optional) Analyze Main Agent Activity
`\`
`\`
## Tasks
### TASK-1: Fundamental - Find Configuration
**Difficulty:**
### TASK-2: Fundamental - Locate Component
**Difficulty:**
### TASK-3: Intermediate - Trace Data Flow
**Difficulty:**
### TASK-4: Advanced - Add Feature
**Difficulty:**
### TASK-5: Advanced - Fix Bug
**Difficulty:**
### TASK-6: Expert - Debug Issue
**Difficulty:**
### TASK-7: Expert - Design Feature
**Difficulty:**
## Scoring
**Total: /9 per task, /63 overall**
-
AGENT_WITHOUT_GUIDE: BENCHMARK
RESTRICTION: Do NOT read .claude/CODEBASE.md or any .claude/ files.
You must explore the infrastructure using only Grep, Glob, and Read on .tf files.
TASK: [task description]
DELIVERABLES:
- Answer with specific file paths and line numbers
- List affected resources if applicable
- Confidence: HIGH/MEDIUM/LOW
- METRICS: Read=[n] Grep=[n] Glob=[n] Total=[n] | Files: [list]
\`\`\`
### 3. Record Results
_GUIDE | WITHOUT_
### 4. (Optional) Analyze Main Agent Activity
`\`
`\`
## Tasks
### TASK-1: Fundamental - Find Resource
**Difficulty:**
**Task:**
`{resource_type}`
_security_
_iam_
**Expected:**
### TASK-2: Fundamental - Locate Variable
**Difficulty:**
**Task:**
`{variable_name}`
**Expected:**
_by.length > 3 from codebase.json]
### TASK-3: Intermediate - Trace Dependencies
**Difficulty:** ⭐⭐
**Task:** Trace all resources that depend on `{resource.type}.{resource.name}`.
**Expected:** Complete dependency chain (direct and transitive).
[Pick a resource with multiple dependents from dependency_
### TASK-4: Advanced - Blast Radius Assessment
**Difficulty:**
**Task:**
`{high_risk_resource}`
**Expected:**
_radius where severity is "high"]
### TASK-5: Advanced - Add Resource
**Difficulty:** ⭐⭐⭐
**Task:** Add a new `{resource_
**Expected:**
### TASK-6: Expert - Debug Dependency Issue
**Difficulty:**
**Task:**
`{resource}`
**Expected:**
_on or circular dependency.
[Create realistic scenario from dependency_