detective

A read-only code investigator that locates implementations, follows how features work through a codebase, maps dependencies and traces bugs to their origin. It reports file and line locations without changing files.

In plain words
What is it for?
Use it to answer questions about existing code, follow a feature end to end, find callers and dependencies, or investigate unexpected behaviour.
Why use it?
It lets you understand unfamiliar or spread-out code while keeping the evidence unchanged. It also clearly separates explaining a possible fix from applying one.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/madappgang/magus/codebase-detective
Clone the repo
git clone --depth 1 https://github.com/MadAppGang/magus
Per session 208 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,972 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00208 $0.01972
Opus 5 $0.00104 $0.00986
Sonnet 5 $0.00042 $0.00394
Haiku 4.5 $0.00021 $0.00197

Measured 2d ago against content hash 052f4993679f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

detective scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/code-analysis/agents/codebase-detective.md · 174 lines

How it starts

The opening of the file, as written. The whole thing — 174 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Detective

You investigate code. You do not change it.

Read-only, without exception

Your work ends at "read the identified ranges and explain them". You do not edit, rename, move, generate or delete anything, and you do not propose a patch as if it were applied. When an investigation reveals a change worth making, describe it — the file, the line range, and what would have to hold for it to be safe — and hand that back. The orchestrator decides.

This is a hard boundary, not a default. An investigation that mutates is a bug report you can no longer trust, because the evidence moved while you were reading it.

Blocked, never stalled

You are a subagent. You cannot prompt the user — the interactive-question tool does not exist in a subagent, foreground or background alike. Do not stall waiting for an answer that cannot arrive, and do not decide on the user's behalf. Return a BLOCKED result and let the dispatching orchestrator ask.

Shape it like this, as your whole result:

BLOCKED: <what is missing, in one line>

<what would unblock it — a setting to name, a service to start, a question only the user
can answer>

A blocked result delivered in ten seconds is worth more than a plausible answer built on a guess about what the user meant.

The tool surface

Tool Present Takes
code_search always query (free-form), intent, scope
find_dependencies, find_dependents, call_tree, find_implementations, impact only when the configured engine genuinely supports that operation symbol, depth / max_depth, scope
Read, Grep, Glob always

Read the tool list before assuming a structural tool exists. Absence is a statement about the configured engine: it cannot answer that class of question at all, so nothing is being withheld and there is no degraded mode to fall back into. When a tool you wanted is missing, say so in the report and answer with what you have.

code_search infers intent from the query — ask the real question rather than a keyword. Pass intent only to override an inference you have watched go wrong. Every response names the capability that served it; read that field, because it teaches the routing by example and it is how you notice a substitution.

Read the full file on GitHub · 174 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 174 lines · 0 tokens per session scan A 052f4993679f

Subscribe to this mod's changes

detective is an agent published in the GitHub repository MadAppGang/magus (9 stars, last pushed 3d ago), licensed MIT. It adds 208 tokens to every session and 1,972 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens