improve

A tool for examining command-use logs and finding possible improvements to an AI coding agent's instructions, settings, hooks, and scripts.

In plain words
What is it for?
Use it to investigate denied or repeated commands, risky command handling, unnecessary one-line shell commands, and missing guidance in CLAUDE.md.
Why use it?
It helps distinguish repeated problems from intentional permission prompts or one-off noise before changing the agent setup.

Command 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 commands/mh4gf/claude-code/improve
Clone the repo
git clone --depth 1 https://github.com/MH4GF/claude-code

Made for: Claude Code.

Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,760 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 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 $0.00033 $0.01760
Opus 5 $0.00016 $0.00880
Sonnet 5 $0.00007 $0.00352
Haiku 4.5 $0.00003 $0.00176

Measured yesterday against content hash 12206f347bed, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

improve scanned grade B 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 yesterday.

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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

- **グローバル** (`~/.claude/settings.json`, `~/.claude/CLAUDE.md`): cwds のユニークなリポジトリルートが 3 以上 or 非リポジトリパス (/tmp 等)
.claude-plugins/tool-use-steering/commands/improve.md · 118 lines

How it starts

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

ref: https://martinfowler.com/articles/harness-engineering.html

Step 1: データ取得

bash "${CLAUDE_PLUGIN_ROOT}/scripts/aggregate-hook-logs.sh" --since ${ARGUMENTS:-14} --format json

Step 2: スキップ判定

以下は改善不要。件数のみカウントして先頭で報告:

  • ask_flowuser_allowed / user_denied のみで、current_settings.ask_bash_prefixes にマッチ → 意図的 ask
  • permission_modes == ["plan"] のみ → plan mode 仕様
  • count < 3 → ノイズ(ただし危険パターンや error は低頻度でも拾う)

Step 3: 根本原因の分析

IMPORTANT: シグナルから直接アクションに飛ばない。まず「なぜこのパターンが発生しているか」を分析する。

各グループについて、以下を問う:

  • なぜ user_allowed が多いのか? — 本当に allow すべきか、それともそもそも Claude がそのコマンドを使う必要がないのでは?代替ツール(Read, Grep 等)で済むなら CLAUDE.md でガイドする方が正しい
  • なぜ denied が繰り返されるのか? — CLAUDE.md にルールがないのか、あるのに守れていないのか。後者なら表現を変える必要がある
  • なぜ複雑な one-liner が生まれるのか? — 既存のツールやスキルで代替できないか。スクリプト抽出は最終手段
  • なぜ危険コマンドが通過しているのか? — permission mode が bypassPermissions だったのか、prefix マッチの抜け穴か

各グループについて根本原因を1行で要約してから Step 4 の分類に進む。

Step 4: 分類

各グループを以下のカテゴリに分類する(複数該当可 — 例: deny 追加 + CLAUDE.md ルール追加のように、センサーとガイドの二重防御が適切な場合がある)。

IMPORTANT: プロジェクト対応は案内のみ。Claude 自身は cd しない。

(1) フィードフォワード改善 — ガイドの追加・修正

Claude の行動を事前に操舵するガイドを改善する。

CLAUDE.md ルール追加:

  • シグナル: 同一 cmd_prefix で auto_denied または user_denied が繰り返される → Claude が禁止行動を学習できていない
  • 例: git add -A denied ×5 → 「ファイルを個別に add」/ cat 頻発 → 「Read ツールを使え」

(2) フィードバック改善 — 権限・センサーの調整

権限ルールと hook バリデータを調整する。

allow 追加 (摩擦削減):

  • シグナル: user_allowed が多い + current_settings.allow_bash_prefixes に該当なし
  • pattern が近い既存 allow があれば拡張を提案

スクリプト抽出 → allow (摩擦削減):

  • シグナル: example_commands に 200+ char の one-liner や複合シェル構文 (&&, |, for, $(...)) で user_allowed が繰り返される
  • .claude/scripts/<name>.sh に抽出し Bash(bash ~/.claude/scripts/<name>.sh*) で allow

Read the full file on GitHub · 118 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. yesterday First seen · 118 lines · 33 tokens per session scan B 12206f347bed

Subscribe to this mod's changes

improve is a command published in the GitHub repository MH4GF/claude-code (2 stars, last pushed 2d ago), licensed MIT. It adds 33 tokens to every session and 1,760 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.