Skip to content

feat: add PostToolUseFailure/PreCompact hooks and memory separation#62

Merged
snkrheadz merged 2 commits intomainfrom
feat/claude-hooks-v2-memory-separation
Mar 1, 2026
Merged

feat: add PostToolUseFailure/PreCompact hooks and memory separation#62
snkrheadz merged 2 commits intomainfrom
feat/claude-hooks-v2-memory-separation

Conversation

@snkrheadz
Copy link
Owner

Summary

  • PostToolUseFailure移行: governance failure captureをPostToolUse→PostToolUseFailureに移行。失敗時のみ発火するため成功時のオーバーヘッドを排除。Bash/Write/Editの失敗をキャプチャ可能に拡張
  • PreCompact hook追加: コンテキスト圧縮前に作業状態を~/.claude/pre-compact-context.mdに保存。SessionStartで1回限り復元して削除
  • Memory Separation文書化: Auto-Memory(ツールパターン/環境情報)とtasks/lessons.md(ユーザー訂正/間違いパターン)の棲み分けルールを明確化

Test plan

  • shellcheck: 新規作成の3ファイルすべて通過
  • JSON構文: jq . claude/settings.json 通過
  • post-failure-proposal.sh: Bash test失敗→proposal生成、Edit失敗→proposal生成、interrupt→スキップ
  • pre-compact-save.sh: コンテキスト保存確認
  • session-context.sh: pre-compact復元→ファイル削除の1回限り動作確認

🤖 Generated with Claude Code

snkrheadz and others added 2 commits March 1, 2026 14:46
…aration

- Migrate governance failure capture from PostToolUse to PostToolUseFailure
  (fires only on failure, eliminates per-success overhead)
- Extend failure capture to Write/Edit tools in addition to Bash
- Add PreCompact hook to preserve working state before context compaction
- Add one-shot context restore in SessionStart via session-context.sh
- Document Auto-Memory vs tasks/lessons.md separation rules
- Update hook count (4 → 5) and descriptions in project CLAUDE.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Existing environments retain the old hook symlink after re-running
install.sh. Explicitly remove it during the hooks setup phase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@snkrheadz snkrheadz merged commit 611db75 into main Mar 1, 2026
1 check passed
@snkrheadz snkrheadz deleted the feat/claude-hooks-v2-memory-separation branch March 1, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant