Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By u-ichiMITIn 1 marketplace
Restores claude.ai project instructions and plugin Markdown lost after a Claude Code compact. A prompt hook saves project-instruction text from your messages to a state file. Claims no setup; project instructions return only in sessions run from a claude.ai project.
Trending plugins
7-day copy clicks
Run automatically on Claude Code events. Claude doesn't decide.
1 critical · 2 cautions to review before installing
A hook runs before every tool call and can block or approve it
A hook runs when Claude uses the Bash tool
A hook runs when Claude writes or edits files
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
Of the plugin's README
Japanese
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Claude Code の compact で起きる、原因の違う2つの問題に対処する plugin である。設定は無く、plugin を入れて有効にするだけで動く。hook だけで成り立ち、skill は持たない。hook に対応するのは Claude Code である。
この plugin が対処するのは次の2つである。
Python 3.9 以上で動作し、標準ライブラリだけを使う。hook は失敗しても会話を止めず、読めない物があれば何もしない。サブエージェントのイベントでは何もしない。
検証の詳しい方法と結果は プロジェクト指示の入れ直しの検証結果 にある。
claude.ai のプロジェクト(Claude Projects)だけにある「プロジェクト指示」は、compact が起きると全文が会話から無くなり、書き方などのルールが落ちる。不具合ではなく compact の仕様(要約の性質)によるものである。compact は会話全体を要約に置き換え、プロジェクト指示は会話の最初のメッセージにしか入らないため、要約の中の言い換えだけが残る。プロセスの再開が無くても compact のたびに起きる。
会話の途中で読んだ plugin の Markdown(skill の references や playbook など、手順を書いた物)も compact で要約に置き換わる。Claude Code は compact の直後に、読んだか編集したファイルのうち最近更新された5つまでを読み直し、5,000 トークンを超えるファイルはパスだけになる(Claude Code 公式文書(Context window))。それ以外は要約の言い換えだけが残る。
CLAUDE.md は Claude Code が compact の後に自分で入れ直すため、この plugin の対象外である。
Claude Code の compact では PreCompact、要約の作成、SessionStart(source が compact)、PostCompact の順に処理が進む。利用者がファイルを用意してパスを設定する必要は無い。
SessionStart(source が compact)の hook が、transcript の最初の user の行にある <project-instructions nonce="..."> から同じ nonce の閉じタグ </project-instructions nonce="..."> までの中身(タグと前後の空白を除く)を取り出し、前置きを付けて additionalContext で出力する。nonce が違う閉じタグでは切らない。UserPromptSubmit の hook が prompt に同じ形のブロックがあれば中身を状態ファイルに保存する(新しい物で上書きする)。transcript から取れないときはこの保存内容を使う。どちらも無ければ何もしない。<session_id>-instructions.md に書き、そのファイルを Read で読み直すよう求める文だけを出す。プロジェクト指示のブロックが無い会話(claude.ai のプロジェクトを使わない Claude Code)では何もしない。CLAUDE.md は対象外である。
PostToolUse の hook が全文を読んだ Markdown を状態ファイルに記録する。全文を読んだと数えるのは、offset・limit なしの Read ツールと、Bash の cat などで出力にファイルの全文がそのまま出た読み取りである。出力が切り詰められた物や一部だけの読み取りは数えない。~/.claude/plugins の下にある Markdown と、Skill ツールの結果の Base directory for this skill: の行が示すフォルダの下にある Markdown である。Read ツールや Bash の cat で全文を読んだ SKILL.md もほかの Markdown と同じ条件で記録する(Skill ツールでは呼べず、SKILL.md を Read で読む skill があるため)。Skill ツールで呼んだだけの skill の SKILL.md は2つ目の問題の対処で戻すため、記録しない。SessionStart(compact)で、記録した Markdown を全部「戻す対象」にする。PreToolUse の hook が戻す対象から次の3つを除き、残りのファイルの今の本文を additionalContext で差し込む。1回に 9,000 UTF-16 単位まで差し込み、入らない分は次の tool の呼び出しで続ける。差し込みの途中でファイルの内容が変わったときは、今の本文の最初から差し込み直す。
compact_boundary の行の後に、attachment.type が file でそのパスの attachment がある物(Claude Code が全文を付け直した物)。パスだけの compact_file_reference は付け直されていない物として扱う。Skill ツールで本文が戻った skill の SKILL.md(同じ本文が2回入らないようにするため)。最後の compact_boundary の行の後の invoked_skills の attachment で付け直された skill については skills[].content の1行目の Base directory for this skill: の行が示すフォルダの SKILL.md を、compact の後に Skill ツールで呼び直した skill についてはその SKILL.md を除く。mcp__hearthbot__message_coordinator、mcp__hearthbot__message_thread、mcp__hearthbot__edit_message、mcp__hearthbot__request_decision、mcp__hearthbot__no_reply_needed、mcp__hearthbot__start_thread)と Agent の呼び出しを止め、差し込んだ内容に従って見直してからもう一度呼ぶよう求める。mcp__hearthbot__post_message と mcp__hearthbot__post_widget は止めず、差し込みだけを行う(呼び出し中に本文が画面に出る tool で、止めると本文が消えるため)。それ以外の tool も止めない。合成の場面での測定(169 回)では、プロジェクト指示の全文を入れ直すことで、compact の後のルール違反が平均 13.7 件から 1.5 件に減った。同じ測定では手順書ファイルを読み直させる案は差が出なかった(何もしない実行でもモデルが自分で読み直していた)。この plugin は、モデルが自分で読み直さなかった場合にも今の本文が会話に入るように、読んだ plugin の Markdown を戻す。
検証の詳しい方法と結果は skill の付け直しと呼び直しの検証結果 にある。
Claude Code 2.1.328、2.1.330、2.1.331 で確認した Claude Code の不具合である。プロセスの再開をはさんだ compact で、Skill ツールで呼んだ skill の本文が付け直されない。
Claude Code の compact は、プロセスが持つ「呼んだ skill の一覧」にある skill の本文を compact の後に付け直す。プロセスを終了して同じ会話を再開(resume)すると、この一覧は直前の compact で付け直した内容(それまで compact が無ければ空)に戻る。そのため、再開より前に呼んだ skill が一覧から落ち、次の compact で付け直されない。

図は横が時間の順(skill を呼ぶ、プロセスの終了、再開、compact)、縦が「会話の中の skill の本文」「Claude Code が持つ呼んだ skill の一覧」「モデルから skill が見えるか」の3段である。
Claude Code の中のどの処理を直すべきかは外からは分からない。再開時に一覧を会話の記録から作り直すのか、compact の処理が会話の記録を見るのかは判断できない。
この不具合は次の順に起きたときに発生する。
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub u-ichi/agent-plugins --plugin claude-compact-restorePlugins from other owners that cover similar ground