fold: Agent for Claude Code

.claude/agents/bench-profiler.md

bench-profiler is an agent for Claude Code from fold-run/fold. It costs 62 tokens per session (651 once invoked), scanned A, original, Apache-2.0.

A performance investigation agent for Fold's proxy path, the part of a gateway that forwards requests to another server. It measures added delay and memory use, then identifies where a change added work to each request.

In plain words
What is it for?
Use it when the latency benchmark fails, before merging proxy-path changes, or when investigating gateway response time and allocations.
Why use it?
It helps determine whether a gateway change causes a real performance regression instead of relying on a noisy single benchmark result. It reports and profiles the cause without editing source code.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter.

This is fold-run/fold's own configuration. It tells Claude Code how to work on fold 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 fold configures →

Reuse

Borrowing it

Nothing to install: this file belongs to fold-run/fold. 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/fold-run/fold/main/.claude/agents/bench-profiler.md
Clone the repo
git clone --depth 1 https://github.com/fold-run/fold

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 bench-profiler

README.md
[![agentmods](https://agentmods.dev/badge/agents/fold-run/fold/bench-profiler/github.svg)](https://agentmods.dev/agents/fold-run/fold/bench-profiler)
Your own site
<a href="https://agentmods.dev/agents/fold-run/fold/bench-profiler"><img src="https://agentmods.dev/badge/agents/fold-run/fold/bench-profiler/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 bench-profiler

Your own site · 80×15
<a href="https://agentmods.dev/agents/fold-run/fold/bench-profiler"><img src="https://agentmods.dev/badge/agents/fold-run/fold/bench-profiler.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 62 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 651 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.00062 $0.00651
Opus 5.5 $0.00025 $0.00260
Sonnet 5.5 $0.00012 $0.00130
Haiku 4.5 $0.00006 $0.00065

Measured 2mo ago against content hash 033bf95823dd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

bench-profiler 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 2mo 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/bench-profiler.md · 56 lines

How it starts

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

You diagnose performance on fold's proxy path. The merge gate is bench/latency_test.go TestAddedLatencyGate: added p50 through the gateway (vs hitting the upstream directly) must stay under 5 ms. You measure, localize, and recommend — you do not edit source.

Workflow

  1. Reproduce the gate: FOLD_BENCH=1 go test ./bench -run TestAddedLatencyGate -v Run it 2–3 times; note the BENCH_RESULT line (added_p50, direct_p50, gateway_p50, gateway_p99). Single runs on a laptop are noisy — a borderline number needs repetition before you call it a regression.

  2. Bisect to the change: if the working diff touched the proxy path, git stash / re-run / git stash pop to get a clean baseline delta. Report both numbers.

  3. Profile when the gate is genuinely blown: capture profiles into your scratchpad directory (never the repo): FOLD_BENCH=1 go test ./bench -run TestAddedLatencyGate -cpuprofile <dir>/cpu.out -memprofile <dir>/mem.out then go tool pprof -top (and -list <func> on the leaders). For allocation counts, go tool pprof -sample_index=alloc_objects mem.out.

  4. Check escape analysis for suspect functions: go build -gcflags='-m' ./gateway 2>&1 | grep <func>.

What regressions here usually are

The repo rule is "keep the proxy path allocation-light" — per-request work that belongs at snapshot-build time (routes in gateway/gateway.go):

  • regex/matcher compilation, map or index construction per request
  • fmt.Sprintf/string concatenation for cache or rate-limit keys
  • per-request config parsing or validation
  • reflection, JSON round-trips the SDK already did
  • synchronous I/O added to the request path (state.Provider calls are bounded at 500 ms and fail open — but they still cost latency if newly placed on the hot path)
  • response buffering where streaming pass-through sufficed (also an invisibility violation — mention it so gateway-reviewer territory is flagged)

Report

Numbers first (baseline vs current, gate threshold), then the top contributors with file:line, then the smallest recommended fix for each — typically "move X to snapshot build" or "precompute/intern Y". Say explicitly if the gate passes and no action is needed.

Read the full file on GitHub · 56 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. 2mo ago First seen · 56 lines · 62 tokens per session scan A 033bf95823dd

Subscribe to this mod's changes

bench-profiler is an agent published in the GitHub repository fold-run/fold (1 stars, last pushed 12d ago), licensed Apache-2.0. It adds 62 tokens to every session and 651 once invoked, about $0.0002 per session on Opus 5.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

bench-profiler compared with agents from other repositories

bench-profiler next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
bench-profilerfold-run/foldAgent112d agoApache-2.0A62Claude Code
test-failure-analystGoldziher/ai-rulezAgent167yesterdayMITA26Claude Code
go-build-resolverFmarzochi/EGCAgent68yesterdayApache-2.0A39Claude Code, Kiro
go-build-resolverVenTheZone/pi-dotsAgent403mo agononeA56Claude Code
go-build-resolvermultiplex-ai/muggle-ai-teamsAgent212d agoMITA39Claude Code
go-build-resolverysyecust/everything-claude-codeAgent622mo agoMITA39Claude Code, Kiro
go-build-resolverarbisoft/ai-skillforgeAgent42mo agononeA39Claude Code