mcpField
S
self-improving-agent

self-improving-agent

github.com/kimasplundエージェントワークフロー0212 回インストール40 週間前に更新
リポジトリ

self-improving-agent について

self-improving-agent は、エージェント向けに訂正、失敗、能力の不足、改善策をセッションをまたいで記録するスキルです。フックによる記録や開始時の振り返りに加え、QAVR と連携します。

主な機能

  1. 01フックによる失敗と訂正の記録
  2. 02能力不足の追跡
  3. 03セッション開始時の学習内容確認
  4. 04QAVR のメモリーランキング連携

活用シーン

  1. 01繰り返すコマンドや API の失敗確認
  2. 02セッションをまたぐユーザー訂正の追跡
  3. 03頻繁に求められる未対応機能の特定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/kimasplund/clawdbot-skills-pack --skill self-improving-agent

インストール後、Claude Code で/self-improving-agentを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

capability-tracker.js
correction-detector.js
enhanced-failure-logger.js

詳細

自己改善エージェント

学び、エラー、修正を記録し、セッションをまたいだ継続的な改善を可能にします。

有効化のトリガー

このスキルは、次の場合に自動的に有効になります。

トリガー記録される内容場所
コマンドの失敗エラーの種類、コンテキスト、復旧の提案logs/failures_detailed.jsonl
ユーザーによる修正「いいえ、それは違います……」、「実際は……」logs/corrections.jsonl
機能の不足利用できない機能についての「Xできますか?」logs/missing_capabilities.jsonl
API/ツールの失敗失敗のパターン、修正案logs/failures_detailed.jsonl
より良い方法の発見学習した最適化logs/learnings.jsonl

仕組み

1. 自動記録(フック経由)
PostToolUse → enhanced-failure-logger.js → logs failures with context
UserMessage → correction-detector.js → detects "wrong/actually/try again"
Response → capability-tracker.js → detects unfulfilled requests
2. 学びの集約

すべての学びは logs/learnings.jsonl に記録されます。

{
  "timestamp": "2026-01-26T12:00:00Z",
  "type": "user_correction|tool_failure|missing_capability",
  "category": "factual_error|command_failed|web_browsing",
  "description": "what was learned",
  "source": "which detector"
}
3. セッション開始時の確認

各セッションの開始時に、最近の学びが表示されます。

=== Learning Review ===
[Learnings] 47 total entries
[Recent]
  • [tool_failure] Bash failed: timeout - WebFetch to external API...
  • [user_correction] User corrected: "No, use the other file..."
[Corrections] 12 user corrections logged
[Capability Gaps] Top requested:
  • send emails (5x)
  • browse web (3x)
4. QAVR との統合

成功した学びによって、関連する記憶の Q 値が向上し、将来の検索精度が改善されます。

手動コマンド

学びを確認
# Show all learnings
cat ~/.claude/logs/learnings.jsonl | tail -20

# Show corrections only
cat ~/.claude/logs/corrections.jsonl | jq -s 'group_by(.correction_type) | map({type: .[0].correction_type, count: length})'

# Show capability gaps report
node ~/.claude/scripts/hooks/capability-tracker.js --report
検出をテスト
# Test correction detector
node ~/.claude/scripts/hooks/correction-detector.js

# Test failure logger
node ~/.claude/scripts/hooks/enhanced-failure-logger.js

# Test capability tracker
node ~/.claude/scripts/hooks/capability-tracker.js

学習カテゴリ

修正の種類
  • factual_error - 誤った情報を提供
  • retry_request - ユーザーが再試行を依頼
  • misunderstanding - 依頼を誤って解釈
  • failed_solution - 解決策が機能しなかった
失敗の種類
  • permission_error - アクセスを拒否
  • not_found - ファイル/リソースが見つからない
  • timeout - 操作がタイムアウト
  • network_error - 接続の問題
  • syntax_error - 無効な構文
  • api_error - 外部 API の失敗
  • command_failed - シェルコマンドの失敗
  • agent_failed - サブエージェントの失敗
機能カテゴリ
  • web_browsing - インターネットアクセスのリクエスト
  • image_processing - 画像/写真の処理
  • communication - メール/メッセージング
  • database_access - SQL/データベースクエリ
  • external_api - サードパーティサービス
  • memory_persistence - 長期記憶

設定

settings.json で、次のフックを有効にすると自己改善が可能になります。

{
  "hooks": {
    "SessionStart": [...],  // Reviews learnings
    "PostToolUse": [
      {"matcher": "Bash", "hooks": [{"command": "enhanced-failure-logger.js"}]},
      {"matcher": "Task", "hooks": [{"command": "enhanced-failure-logger.js"}]}
    ]
  }
}

利点

  1. 失敗から学ぶ - 同じエラーを繰り返さない
  2. ユーザーの好みを把握する - 修正が意味する内容を記録
  3. スキルの不足を特定する - 追加すべき機能を把握
  4. 時間とともに改善する - フィードバックによって QAVR のランキングが向上
  5. コンテキストを保持する - 学びはセッションの再起動後も維持される

他のスキルとの統合

スキル統合内容
QAVR成功した学びによって、記憶の Q 値が向上
Memory Consolidation古い学びを定期的に整理
Confidence Check重要なタスクの前に学びを確認
IR-v2学びをパターン選択に活用

ファイル

~/.claude/
├── logs/
│   ├── learnings.jsonl           # All learnings
│   ├── corrections.jsonl         # User corrections
│   ├── failures_detailed.jsonl   # Enhanced failure logs
│   ├── missing_capabilities.jsonl # Capability requests
│   └── capability_gaps.json      # Aggregated gaps
└── scripts/hooks/
    ├── correction-detector.js
    ├── enhanced-failure-logger.js
    ├── capability-tracker.js
    └── session-start.js (reviews learnings)

コメント