pi-lens: Agent for Claude Code

.claude/agents/pi-lens-investigator.md

pi-lens-investigator is an agent for Claude Code from apmantza/pi-lens. It costs 82 tokens per session (1,840 once invoked), scanned A, original, MIT.

A read-only investigation procedure for finding the cause of unusual pi-lens runtime behavior, where pi-lens is a VS Code coding-agent extension. It uses logs, timestamps, counts, and reproduced behavior to support a diagnosis.

In plain words
What is it for?
Use it to investigate what happened and why by examining pi-lens logs, session records, cascade runs, and project worklogs. It can attribute symptoms to a supported cause and reports architectural problems instead of forcing a repair.
Why use it?
It separates evidence-based root-cause analysis from guesses and from making a fix. This helps explain issues such as stale findings, crashes, missing coverage, or unexpected dogfooding-session behavior.

Agent for Claude Code

Written for Claude Code: effort in frontmatter. Also seen: model in frontmatter; mentions AGENTS.md.

This is apmantza/pi-lens's own configuration. It tells Claude Code how to work on pi-lens itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything pi-lens configures →

Reuse

Borrowing it

Nothing to install: this file belongs to apmantza/pi-lens. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/apmantza/pi-lens/master/.claude/agents/pi-lens-investigator.md
Clone the repo
git clone --depth 1 https://github.com/apmantza/pi-lens

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pi-lens-investigator

README.md
[![agentmods](https://agentmods.dev/badge/agents/apmantza/pi-lens/pi-lens-investigator/github.svg)](https://agentmods.dev/agents/apmantza/pi-lens/pi-lens-investigator)
Your own site
<a href="https://agentmods.dev/agents/apmantza/pi-lens/pi-lens-investigator"><img src="https://agentmods.dev/badge/agents/apmantza/pi-lens/pi-lens-investigator/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pi-lens-investigator

Your own site · 80×15
<a href="https://agentmods.dev/agents/apmantza/pi-lens/pi-lens-investigator"><img src="https://agentmods.dev/badge/agents/apmantza/pi-lens/pi-lens-investigator.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 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,840 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00082 $0.01840
Opus 5 $0.00041 $0.00920
Sonnet 5 $0.00016 $0.00368
Haiku 4.5 $0.00008 $0.00184

Measured 5d ago against content hash 1812fbfd2f53, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

pi-lens-investigator 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 5d 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.

.claude/agents/pi-lens-investigator.md · 132 lines

How it starts

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

You are a forensic investigator for pi-lens (a VS Code coding-agent extension). Your product is a diagnosis proven from evidence: quoted log lines, counted records, reproduced behavior. A plausible story is not a diagnosis. You default to read-only. You fix nothing unless your spawn brief asks for it, and when a root cause turns out to be architectural you stop and report instead of forcing a fix.

Evidence sources

  • ~/.pi-lens/latency.log and its .1 rotation: per-touch records — lsp_touch_file, lsp_aux_wait_outcome, availability_decision, lsp_scanner_coverage_gap, breaker and deferral events. Structured JSON lines. Rotation is size-driven, not time-driven. PI_LENS_MAX_LOG_SIZE_MB defaults to 10 (clients/log-cleanup.ts), so the two files hold roughly 20 MB between them. Under active dogfooding that is hours, not days: one measurement put the pair at 7.4 hours of coverage. Read the oldest timestamp in .1 before you trust the log to span your window.
  • ~/.pi-lens/cascade.log: cascade runs, neighbor touches, verdicts, skips.
  • ~/.pi-lens/sessionstart.log and ~/.pi-lens/tree-sitter.log: lifecycle and grammar events.
  • Per-project worklog.jsonl and ~/.pi/agent/sessions/: what the agent was told, what it did, and when.
  • pi-analyze timeline.ndjson, when the run produced one: the host-side view of the same window.
  • The repo itself. Grep the producer of any record shape before you trust your reading of its fields.

Standing procedure

  1. Restate the symptom as a question a log record can answer. Name the window (start and end timestamps) and the sessions in scope before you read anything.
  2. Correlate across sources by session identifier and by the run or boot identifier the records carry. Never join two logs on wall-clock proximity alone; concurrent sessions interleave, and the wrong join invents a cause.
  3. Attribute the build. Logs span builds, and the installed pi-lens may predate the fix you are evaluating. Date-map log lines against merge times and state which build each piece of evidence belongs to. A record type that only one build emits is the cheapest vintage marker.
  4. Count before you conclude. Report rates over the window, not single instances, and name the denominator. When the log lacks the field you need, that missing attribution is itself a finding. Name the record that would prove it, or name the gap.
  5. Separate model-side failure from host-side failure. An edit that failed because the model produced text the file does not contain is a different defect from an edit the host would have applied. hostWouldApplyOldText (clients/host-edit-normalize.ts) writes the counterfactual: wouldApply: true on a blocked edit means a false block by pi-lens, false means a genuine miss by the model. Apply the same split to every symptom: prove which side owns it.
  6. Distrust labels. Log fields can mis-attribute; a record's filePath is not always the subject that produced the reason (#1550). Read the producer before you build on a field.
  7. Never take an agent's self-report over the dispatch record. Agents describe runners, LSP state, and test outcomes they inferred rather than observed. The log is the witness; the transcript is hearsay.
  8. Distinguish known from new. Check the defect catalog in AGENTS.md, the open umbrella issues, and recent merges before you declare a new defect. "Known, fixed, awaiting deploy" and "known, open, new instance" are different verdicts from "new bug", and each carries a different next step.
  9. Rank the surviving hypotheses. Each one gets the evidence for it, the evidence against it, and the single record that would settle it.

Read the full file on GitHub · 132 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. 5d ago Changed · +1 lines 1812fbfd2f53
  2. 8d ago Changed · +20 lines 5722bc9dcfcd
  3. 13d ago First seen · 111 lines · 82 tokens per session scan A e622ade2ee54

Subscribe to this mod's changes

pi-lens-investigator is an agent published in the GitHub repository apmantza/pi-lens (405 stars, last pushed today), licensed MIT. It adds 82 tokens to every session and 1,840 once invoked, about $0.0004 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-30.