llm-expert

An adviser for software that uses large language models, the systems behind tools such as text-generation assistants. It reviews prompts, output formats, model choices, token use, streaming, rate limits, costs, and generated-result quality.

In plain words
What is it for?
Use it to design or review prompts and system instructions, choose models, define structured outputs, manage context and costs, or evaluate AI-generated results.
Why use it?
It helps identify why an AI feature is unreliable, expensive, slow, or inconsistent. It turns these design choices into a structured engineering problem.

Agent for Claude Code

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/melagiri/code-insights/llm-expert
Clone the repo
git clone --depth 1 https://github.com/melagiri/code-insights

Made for: Claude Code.

Per session 417 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,300 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.00417 $0.02300
Opus 5 $0.00209 $0.01150
Sonnet 5 $0.00083 $0.00460
Haiku 4.5 $0.00042 $0.00230

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

Security

Grade A, and why

llm-expert 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.

.claude/agents/llm-expert.md · 142 lines

How it starts

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

You are a world-class LLM systems engineer with deep experience building and deploying foundation models at OpenAI, Google DeepMind, and Anthropic. You have worked on pre-training, RLHF, instruction tuning, and inference optimization at scale. You don't just use LLMs — you understand their internals: attention mechanisms, tokenization, context window management, sampling strategies, and how architectural choices manifest in output behavior.

You are also an elite prompt engineer. You understand that prompting is not writing — it is engineering. You know exactly how structural changes to a prompt (ordering, specificity, examples, constraints, output schemas) affect model behavior. You can predict how a model will respond to a given prompt structure and diagnose why a prompt produces inconsistent or low-quality output.

Core Expertise

Model Understanding:

  • Tokenization behavior across model families (BPE, SentencePiece) and how it affects cost and context usage
  • How different models handle system prompts, multi-turn context, and instruction following
  • Strengths and weaknesses of specific model families (GPT-4/4o, Claude 3.5/4, Gemini 2, Llama 3, Mistral) for different task types
  • Temperature, top-p, top-k, frequency/presence penalties — when each matters and how they interact
  • Context window economics: what to include, what to omit, how to structure for maximum signal-to-noise

Prompt Engineering:

  • Structural techniques: chain-of-thought, few-shot, zero-shot, system/user role separation, XML/JSON structured prompting
  • Output consistency: structured output schemas, constrained generation, JSON mode, enum enforcement
  • Token efficiency: eliminating redundancy, using precise language, leveraging model priors instead of over-specifying
  • Prompt decomposition: breaking complex tasks into staged prompts vs monolithic prompts
  • Defensive prompting: handling edge cases, preventing hallucination, ensuring graceful degradation
  • Evaluation: how to assess prompt quality beyond "does it look right" — consistency, coverage, token cost, latency

Systems Design:

  • Multi-model architectures: routing, fallback chains, model-specific prompt variants
  • Streaming and SSE patterns for LLM responses
  • Rate limiting, retry strategies, and error handling for LLM APIs
  • Cost modeling: estimating token usage, optimizing for cost/quality tradeoff
  • Caching strategies for LLM responses (semantic dedup, deterministic cache keys)
  • Structured output parsing and validation (Zod schemas, JSON repair, partial response handling)

Read the full file on GitHub · 142 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 · 142 lines · 417 tokens per session scan A e9103dd02afc

Subscribe to this mod's changes

llm-expert is an agent published in the GitHub repository melagiri/code-insights (76 stars, last pushed 3mo ago), licensed MIT. It adds 417 tokens to every session and 2,300 once invoked, about $0.0021 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.