KilimcininKorOglu/claude-code-mods/tree/main/plugins/pin-note
pin-note
Claude Code 插件会在整个会话中保留你用 `/pin-note` 固定的笔记,并在每次压缩和 `/clear` 后通过 SessionStart hook 将它们逐字重新注入模型上下文;它按会话在 `$.store` 中持久化,且默认关闭。
关于这个 mod
pin-note 是一个 Claude Code 插件(已验证 manifest 和 hooks 模块,L0 reach,不访问网络、文件或进程),用于解决你在会话早期给出的指令在压缩或 /clear 后被削弱或丢失的问题。命令:/pin-note(切换并列出固定笔记)、/pin-note on | off、/pin-note <note> 用于固定笔记、/pin-note drop <n> 用于删除笔记。固定笔记按会话存储在 $.store 的会话 ID 下,因此恢复的会话可以找回它们;/clear 会开启一个继承这些笔记的新会话。压缩或 /clear 后,SessionStart hook 会以编号列表重新发送所有固定笔记,每条内容都与输入完全一致;开头会有三行说明笔记的来源,以减少模型把它们误认为注入的指令。通过 claude plugin marketplace add KilimcininKorOglu/claude-code-mods 安装,然后执行 claude plugin install pin-note@kilimcininkoroglu-mods,重启并运行 /pin-note on。限制:笔记只会在压缩和 /clear 时重新发送;旧会话的笔记永远不会进行垃圾回收;笔记数量和长度都没有上限。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add KilimcininKorOglu/claude-code-mods claude plugin install pin-note
原文 / README
pin-note
You tell the model early on "ask before every push", and after a compaction the summary has dropped the sentence or reworded it into something weaker; after /clear it is gone for good. This mod keeps the notes you pin with /pin-note for the whole session, and sends them to the model again, word for word, after each compaction and /clear.
What it does
-
/pin-note <note>pins a note. The model reads it at once, in the command's answer:pin-note: pinned note 1, kept for this session and sent to you again after each compaction and /clear: ask before every push -
After a compaction, and after
/clear, the notes go into the model's new context through aSessionStarthook, as one numbered list, each note as you typed it. Three lines above the list tell the model where the notes come from: you pinned them yourself with/pin-note, then the conversation was compacted or you ran/clear, and the pin-note plugin you turned on hands them back. Without those lines the model at times took a note for an injected instruction and did not follow it. One line tells you:pin-note: sent 1 pinned note(s) again after the compaction -
The notes belong to the session. They are kept in
$.storeunder the session's id, so a reloaded module and a resumed session find them again./clearstarts a new session, and the notes go with it. -
Nothing is sent at a session's start or at a resume, because the conversation there still holds the notes as you pinned them.
Measured on Claude Code 2.1.283 in live sessions with the sonnet model: after /compact the note reached the model's context, and after /clear the model, asked whether a note was pinned, wrote it word for word. A note that asked for one word at the end of every reply was pinned, then /clear and a new question followed, 20 times for each text: with the earlier one-line text the model refused the note 4 times, calling it injected; with the current text it followed the note all 20 times.
Command
/pin-note on or off, and the pinned notes, numbered
/pin-note on | off off by default; off keeps the notes and sends none
/pin-note <note> pins a note; the text is kept as typed, several lines too
/pin-note drop <n> takes note n out
While the mod is off, /pin-note <note> and drop are refused. on, off and drop <n> are the only command words, so a note may start with drop when no number alone follows it.
Install
claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install pin-note@kilimcininkoroglu-mods
Function hooks are early access. Claude Code 2.1.288 and later load them by default, so there is nothing to switch on.
After installing
- Restart Claude Code.
- Run
/pin-note on.
What it can reach
Validated with claude plugin validate on Claude Code 2.1.283:
❯ ./register.ts hooks: session.start, command.run{command=pin-note}, classic.SessionStart
❯ ./register.ts calls: $.command.register, $.session.id, $.store.get (via loadPins, readSettings), $.store.set (via runCommand, savePins), $.ui.log
Reach L0, no network, no files, no processes.
1. Reads: the notes you pin, and the session's id
2. Runs: nothing
3. Sends: nothing off the machine; the notes go into the model's context as you typed them
4. Persists: the on/off setting and each session's notes in $.store
5. Hostile input: a note is your own text and the model reads it as your instruction; nothing else is read
Limits
- The notes are sent again only at a compaction and at
/clear. A note you want gone from the context must be dropped and the context compacted, because a note the model already read stays in the conversation. - Every session's notes stay in
$.storeunder its id; nothing deletes the notes of an old session. - There is no limit on the number or length of notes, and every note goes into the context after each compaction.
Development
make install # eslint, typescript-eslint, typescript
make lint # complexity limit 10, the build fails above it
make typecheck # needs the /plugin-types output in .claude/types/
make validate
make test # claude plugin test
