編集部セレクト
Claude Codeの文脈が圧縮されたあと、CLAUDE.mdの決まりが抜け落ちていませんか。
公式のhooksドキュメントは、圧縮の直後に始まる回をcompactとして区別しています。
SessionStartのフックをcompactで動かすと、返した文字列が会話の冒頭に差し込まれます。
守らせたい決まりだけを返すようにすれば、圧縮のたびに読み直させられます。
今日は設定にSessionStartのフックを足し、compactで動くよう指定してください。
出典の原文(引用)
| `compact` | When you start Claude Code after context compaction | / Plain-text stdout from your hook becomes context that Claude sees. Claude Code adds it as a system reminder at the start of the conversation, before the first prompt.— code.claude.com
この話題のきっかけ
https://qiita.com/DevMasatoman/items/1076e65af05afa0cdff2
題材を見つけた場所です。記事の根拠は上の出典です。
