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.
npx agentmods add commands/themoah/klag/diagnosegit clone --depth 1 https://github.com/themoah/klagWrote 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.
[](https://agentmods.dev/commands/themoah/klag/diagnose)<a href="https://agentmods.dev/commands/themoah/klag/diagnose"><img src="https://agentmods.dev/badge/commands/themoah/klag/diagnose.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00025 | $0.00868 |
| Opus 5 | $0.00013 | $0.00434 |
| Sonnet 5 | $0.00005 | $0.00174 |
| Haiku 4.5 | $0.00003 | $0.00087 |
Grade A, and why
diagnose scanned grade A with 1 finding 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 4d 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.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
curl -s <klag>/metrics | grep -E '^klag_consumer_lag(_sum)?\{|^klag_consumer_commit_staleness_seconds|^klag_consumer_lag_retention_percent|^klag_consumer_group_state|^klag_consumer_lag_velocity' How it starts
The opening of the file, as written. The whole thing — 62 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Triage consumer lag with the user's running Klag. Group: $ARGUMENTS (empty = whole cluster).
Prefer the MCP tools. If the klag MCP server is not registered in this session, say so, fall
back to scraping /metrics, and point at /klag:connect.
Path A — MCP (preferred)
find_lagging_groups(sortBy:lag|velocity|retention,limit) for the cluster view, or go straight to the named group.diagnose <group>— returnsseverity(OK|INFO|WARNING|CRITICAL), asummary, andfindings[]of{severity, title, detail}.get_consumer_group_lag <group>when you need per-partition detail. Response keys:partitions[](lag,committedOffset,logEndOffset,logStartOffset),velocity,lagMs,timeToClose,retentionRisk,trends,overallTrend,recentTransitions,commitStalenessSeconds. Read the keys off the response rather than assuming — this list is a convenience, the server is the authority.
Check snapshotAgeMs in the response. Anything much older than METRICS_INTERVAL_MS means you
are reading a stale picture — say so rather than diagnosing confidently off it.
Path B — no MCP
curl -s <klag>/metrics | grep -E '^klag_consumer_lag(_sum)?\{|^klag_consumer_commit_staleness_seconds|^klag_consumer_lag_retention_percent|^klag_consumer_group_state|^klag_consumer_lag_velocity'
Same reasoning, less structure. Note in your answer that MCP would give a better one.
Reading the result
Map findings to causes, worst first:
| Signal | Reading |
|---|---|
state dead |
group gone — consumers crashed or never restarted. Look at the app, not Kafka. |
state empty + lag |
nobody consuming; work is piling up. |
commitStalenessSeconds high while lag > 0 |
stuck consumer: alive but not advancing — poison message, wedged handler, or a blocked downstream. Lag alone misses this. |
many recentTransitions |
rebalance storm / flapping: max.poll.interval.ms too low, slow processing, or unstable pods. |
retention_percent climbing toward 100 |
data loss risk — messages will expire unread. This outranks raw lag size. |
| lag growing, velocity positive | producers outpace consumers: scale out, or the partition count caps parallelism. |
| hot partition | skewed keys, not a consumer problem — repartition or change the key. |
| under-replicated partitions | broker-side fault tolerance loss, unrelated to the consumer. |
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.
- 4d ago First seen · 62 lines · 25 tokens per session scan A ff3017d55b4f
diagnose is a command published in the GitHub repository themoah/klag (82 stars, last pushed 3d ago), licensed Apache-2.0. It adds 25 tokens to every session and 868 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
migration-observability
Migration monitoring, CDC, and observability infrastructure.
migration-observability
Migration monitoring, CDC, and observability infrastructure.
migration-observability
Migration monitoring, CDC, and observability infrastructure.
migration-observability
Migration monitoring, CDC, and observability infrastructure.
migration-observability
Migration monitoring, CDC, and observability infrastructure.
migration-observability
Migration monitoring, CDC, and observability infrastructure.