diagnose

diagnose is a command for Claude Code from cameronfreer/lean4-skills. It costs 10 tokens per session (3,123 once invoked), scanned C, original, MIT.

A diagnostic command for the Lean4 plugin and its workspace. Lean4 is a programming language and proof assistant used to write programs and formally check mathematical proofs.

In plain words
What is it for?
Use it for a full diagnostic, environment checks, detecting older installations, finding cleanup targets, or analyzing pasted error text.
Why use it?
It helps identify plugin, environment, migration, cleanup, and error-related problems. It can show stale files and suggest removal commands, with cleanup changes requiring an explicit option.

Command for Claude Code

Written for Claude Code: user-invocable in frontmatter. Also seen: reads .claude/ paths; mentions subagents; mentions Claude Code.

Part of the lean4 plugin — 1 skill, 12 commands, 4 agents, 3 hooks shipped together

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 commands/cameronfreer/lean4-skills/diagnose
Clone the repo
git clone --depth 1 https://github.com/cameronfreer/lean4-skills

Made for: Claude Code.

Or install lean4, the plugin that ships this one along with the rest of its 1 skill, 12 commands, 4 agents, 3 hooks.

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 diagnose

README.md
[![agentmods](https://agentmods.dev/badge/commands/cameronfreer/lean4-skills/diagnose.svg)](https://agentmods.dev/commands/cameronfreer/lean4-skills/diagnose)
Your own site
<a href="https://agentmods.dev/commands/cameronfreer/lean4-skills/diagnose"><img src="https://agentmods.dev/badge/commands/cameronfreer/lean4-skills/diagnose.svg" alt="Measured on agentmods" height="20"></a>
Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,123 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.1 $0.00010 $0.03123
Opus 5 $0.00005 $0.01562
Sonnet 5 $0.00002 $0.00625
Haiku 4.5 $0.00001 $0.00312

Measured 6d ago against content hash 363b5aa15877, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade C, and why

diagnose scanned grade C 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 6d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- Default: Report findings, show `rm -rf` commands, do NOT execute
plugins/lean4/commands/diagnose.md · 289 lines

How it starts

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

Lean4 Diagnostics

Diagnostics, troubleshooting, and migration assistance for the Lean4 plugin.

Usage

/lean4:diagnose                    # Full diagnostic (plugin + workspace)
/lean4:diagnose env                # Environment only
/lean4:diagnose migrate            # Detect legacy installs (read-only)
/lean4:diagnose migrate --global   # Include user-level ~/.claude scan
/lean4:diagnose cleanup            # Show stale files + removal commands
/lean4:diagnose cleanup --apply    # Actually remove stale files
/lean4:diagnose <pasted error>     # Error triage: match against known patterns

Inputs

Arg Required Description
mode No env, migrate, cleanup, or full (default)
--global No Include user-level paths (~/); migrate only
--apply No Execute removals; cleanup only
error text No Positional text whose first token is not a recognized mode is treated as pasted diagnostic text for error triage

Dispatch is decided by the first positional token only:

  • a recognized mode (env, migrate, cleanup) or no positional token → existing mode behavior (default full diagnostic when absent);
  • otherwise → treat the positional text as pasted diagnostic input for error triage.

Mode-specific flags (--global, --apply) remain flags in every case — they are never treated as error text.

Error triage precedence: pasted text is matched against the specific patterns in compilation-errors.md (Quick Reference Table first), including the module-system patterns below, before falling back to the generic Build fails → lake update && lake clean && lake build row. A specific match wins over the generic remediation.

Actions

1. Environment Check

Tool Check Required
lean lean --version Yes
lake lake --version Yes
python3 python3 --version For scripts
git git --version For commits
rg rg --version Optional (faster search)

Read the full file on GitHub · 289 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. 6d ago First seen · 289 lines · 10 tokens per session scan C 363b5aa15877

Subscribe to this mod's changes

diagnose is a command published in the GitHub repository cameronfreer/lean4-skills (430 stars, last pushed yesterday), licensed MIT. It adds 10 tokens to every session and 3,123 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.