graphql-performance-optimizer — Claude Code subagent for GraphQL speed
A subagent that digs into slow GraphQL queries: finds N+1 patterns, wires up DataLoader, sets caching. Useful when a user list page drags for seconds.
npx claude-code-templates@latest --agent api-graphql/graphql-performance-optimizerWhat graphql-performance-optimizer does
The subagent works on existing code. It reads resolver files, spots per-record database calls and rewrites them to batched loading with DataLoader. The schema stays untouched. It can also turn on Automatic Persisted Queries in Apollo Server, point APQ at a Redis store and add field-level cache-control so a CDN serves the short GET responses.
Federated graphs get a different set of moves: query plan caching at the router, DataLoader instances scoped to each request context, and batch loading through __resolveReference for entities. That collapses the cross-subgraph fetches behind high p95 latency.
Its tools are Read, Grep, Glob, Edit, Write, Bash, the model is sonnet, and the permission mode is acceptEdits. It edits files on its own, so keep the project under git before you run it. One caveat: security work — query allowlisting, authorization caching, introspection control — is out of scope, that belongs to graphql-security-specialist.
What it helps with
- find an N+1 in a resolver and rewrite it with DataLoader
- cut origin hits on a public API
- cache the query plan in a federated graph
- drop the extra
SELECT COUNT(*)behind connection fields - compare query counts before and after a fix
Example prompts for the agent
- Find the N+1 in our user list resolvers and rewrite them with DataLoader
- Set up APQ and CDN caching for our Apollo Server
- Add router query plan caching and batch entity loading
How to install graphql-performance-optimizer
1claude-code-templates
npx claude-code-templates@latest --agent api-graphql/graphql-performance-optimizer2Manually: put the files in place
.claude/agents/graphql-performance-optimizer.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/graphql-performance-optimizer.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/graphql-performance-optimizer.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about graphql-performance-optimizer
How do I install graphql-performance-optimizer in Claude?
Through the templates CLI: npx claude-code-templates@latest --agent api-graphql/graphql-performance-optimizer. The agent file lands at .claude/agents/graphql-performance-optimizer.md.
What does graphql-performance-optimizer do?
It analyzes GraphQL API performance and edits the code: N+1 in resolvers, caching strategies, batched entity loading. It leaves the schema alone.
Does it handle security topics?
No. Query allowlisting, authorization caching and introspection control are left to the graphql-security-specialist agent.