Skip to content
Agentmart
Submit a tool

ir-analysis

Compute information retrieval quality metrics (precision, recall, MRR, nDCG, MAP) comparing file retrieval across baseline and MCP configs against ground truth.

Skill by sourcegraph

IndexedApache-2.0★ 37
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/sourcegraph-ir-analysis

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Compute information retrieval quality metrics (precision, recall, MRR, nDCG, MAP) comparing file retrieval across baseline and MCP configs against ground truth. Triggers on ir analysis, retrieval metrics, file recall, ground truth, search quality.

Use cases: agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/ir-analysis

What's inside

Skill name
ir-analysis
Description
Compute information retrieval quality metrics (precision, recall, MRR, nDCG, MAP) comparing file retrieval across baseline and MCP configs against ground truth. Triggers on ir analysis, retrieval metrics, file recall, ground truth, search quality.
License
Apache-2.0
Instructions
126 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • files: referenced but missing: scripts/ir_analysis.py

Files (1)

  • SKILL.md

SKILL.md (first lines)

# IR Analysis

Measure how well agents find the right files, comparing baseline (local tools) vs MCP (Sourcegraph) retrieval against per-task ground truth.

## What This Does

Runs `scripts/ir_analysis.py` which:
1. Loads ground truth files per task from `configs/ground_truth_files.json` (or builds it from benchmark task dirs)
2. Parses agent transcripts (`agent/claude-code.txt`) to extract which files were accessed via tool calls
3. Computes IR metrics: Precision@K, Recall@K, F1@K, MRR, nDCG@K, MAP, file-level recall, context efficiency
4. Aggregates by benchmark and config, with statistical significance tests

## Steps

### 1. Ensure ground truth is built

If `configs/ground_truth_files.json` doesn't exist or needs refreshing:

```bash
cd ~/CodeScaleBench && python3 scripts/ir_analysis.py --build-ground-truth
```

This extracts ground truth files from each benchmark's task structure (patches, diffs, ground_truth dirs, test scripts, instructions). Reports per-benchmark counts and confidence levels.

### 2. Run the IR analysis

```bash
cd ~/CodeScaleBench && python3 scripts/ir_analysis.py --json 2>/dev/null
```

Or for human-readable table output:

```bash
cd ~/CodeScaleBench && python3 scripts/ir_analysis.py 2>/dev/null
```

### 3. Parse and present key findings

**Per-benchmark IR scores:**

| Benchmark | Config | N | File Recall | MRR | P@5 | R@5 | nDCG@5 | MAP | Ctx Eff |
|-----------|--------|--:|------------:|----:|----:|----:|-------:|----:|--------:|

**Overall aggregates:**

| Config | File Recall | MRR | MAP | Context Efficiency |
|--------|------------:|----:|----:|-------------------:|
| baseline | X | X | X | X |
| sourcegraph_full | X | X | X | X |

**Statistical tests (baseline vs SG_full):**

| Metric | Welch's t | p-value | Cohen's d | Bootstrap 95% CI |
|--------|----------:|--------:|----------:|-----------------:|

### 4. Interpret results

Key metrics to focus on:
- **File recall**: Fraction of ground truth files the agent accessed (most important)
- **MRR**: How quickly the agent found the first relevant file (1.0 = first file accessed was relevant)
- **Context efficiency**: Relevant files / total files accessed (higher = less noise)
- **P@K**: Precision at top-K accessed files (were early accesses relevant?)

### 5. Per-task drill-down (optional)

For detailed per-task scores:

```bash
python3 scripts/ir_analysis.py --per-task --json 2>/dev/null
```

Filter to a specific benchmark:

```bash
python3 scripts/ir_analysis.py --suite csb_sdlc_swebenchpro 2>/dev/null
```

## Variants

### Build/refresh ground truth only
```bash
python3 scripts/ir_analysis.py --build-ground-truth
```

### JSON output for programmatic use
```bash
python3 scripts/ir_analysis.py --json > /tmp/ir_results.json
```

### Filter to one benchmark
```bash
python3 scripts/ir_analysis.py --suite csb_sdlc_pytorch
```

### Per-task detail
```bash
python3 scripts/ir_analysis.py --per-task
```

## Key Technical Notes

- **Ground truth confidence levels**: "high" (from patches/diffs — SWE-bench Pro, PyTorch, K8s Docs), "medium" (from test scripts), "low" (regex from instructions). High-confidence tasks give the most reliable IR metrics.
- **Transcript parsing**: Reads Harbor's nested JSONL format from `agent/claude-code.txt`. Extracts file paths from Read, Grep, Glob, Write, Edit tool inputs and MCP tool results.
- **Path normalization**: Strips `/workspace/` prefix, `a/`/`b/` diff notation, lowercases for comparison.
- **Baseline retrieval**: For runs without MCP, "retrieved files" come from local Read/Grep/Glob calls. This measures manual navigation quality vs MCP search quality.
- **Deduplication**: When multiple batches exist for the same task+config, the latest (by `started_at` timestamp) wins.
- **Statistical tests**: Uses pure-stdlib implementations from `csb_metrics/statistics.py` — Welch's t-test, Cohen's d, bootstrap CI. No scipy dependency.

## Ground Truth Sources

| Benchmark | Strategy | Source File | Confidence |
|-----------|----------|-------------|:----------:|
| SWE-bench Pro | Patch headers | `solve.sh` / `solution/solve.sh` | high |
| PyTorch | Diff headers | `tests/expected.diff` / `instruction.md` | high |
| K8s Docs | Directory listing | `ground_truth/` | high |
| Governance | Test script paths | `tests/test.sh` | medium |
| Enterprise | Test script paths | `tests/test.sh` | medium |
| Others | Instruction regex | `instruction.md` | low |

From sourcegraph/CodeScaleBench, Apache-2.0.

More from sourcegraph/CodeScaleBench

Signals

Stars
37
Forks
5
Open issues
0
Last commit (this folder)
Mar 17, 2026 (7 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from sourcegraph

Cite this page

ir-analysis skill. Agent Mart. https://agentmart.dev/skills/sourcegraph-ir-analysis (last updated 2026-10-24)