Pinned rules: one instruction for every agent session

in Agent-to-agent communication

A rule you give one AI chat, like "only chat A pushes today", never reaches the chats you open after it, so you end up repeating it by hand.

  1. What is CAM?
  2. What do you need?
  3. How does a fact move through CAM?
  4. Why didn't the pusher rule reach new chats?
  5. What does a pin change?
  6. How did we test it?
  7. Where does it still fall short?
  8. Summary

On 17 October more than a dozen Claude Code chats were working in one repo. I told one of them, chat A, that it was the only chat allowed to push that day. Chat A passed the rule on to every chat that was open. The chats I opened after that never heard it, and I found myself repeating the rule by hand. This post follows that one rule through CAM, the journal our chats share, and shows the piece we added so the next rule reaches every chat. Times are UTC. Chats are lettered.

What is CAM?

CAM (Central Agentic Memory) is a small store that every chat in a repo writes to and reads from. It lives in .git/cam, so it is never committed or pushed. Three files matter:

  • journal.jsonl: one line per git write (commit, push, reset…) and per note, with the chat that made it.
  • an inbox per chat: messages one chat leaves for another.
  • pins.json: rules that every new chat must see. This is the new piece.
a chatgit, note, tell, pin inbox1 per chat journalper git write pins.jsonevery new chat open chateach prompt new chatsession start
Figure 1. The three CAM stores, what writes them and who reads them.

What do you need?

Claude Code with hooks enabled, and git. Everything is files under .git/cam; nothing runs in the background. The idea works for any tool that can run a script when a session starts and when a prompt arrives.

How does a fact move through CAM?

A fact gets in four ways and gets out at two moments, and the figure shows which way reaches which moment. Dashed arrows are messages into and out of the store in .git/cam.

Chat A New chat cam pina rule for today git commita hook journals it cam notethe why cam tell Bone chat pins.jsonmax 5 live journal.jsonlrotates past 1 MB inboxper chat .git/cam session startsnapshot each promptwhat's new every live pin latest line per peer unread lines once, if addressed 1 1 1 1 2 3
  1. Chat A writes: a git command (a hook journals it), cam note (the why, into the same journal), cam tell B (one chat's inbox) or cam pin (pins.json).
  2. A new chat starts and gets a snapshot: every live pin, and only the latest journal line of each peer.
  3. On each prompt it gets the journal lines it has not read, and any message addressed to it, once.
Figure 2. Four ways a fact gets into CAM, and two ways out.

The four ways in:

  • A git command. A hook reads every shell call. When one writes to git, it adds a journal line on its own. Nobody has to ask.
  • cam note "<why>" adds the reason. The hook knows who committed what; only the chat knows why.
  • cam tell N "<text>" leaves chat N a message. It is delivered once, on that chat's next prompt or session start.
  • cam pin "<text>" writes a rule to pins.json.

The two ways out:

  • Session start (also on resume, compact and clear) shows a snapshot: who is live, and the latest journal line of each peer chat.
  • Each prompt shows the journal lines this chat has not read yet, and any message addressed to it.

The journal part of each block is capped at 8 lines and 1,500 characters, so a busy repo can't flood a chat's context. When nothing is new, CAM says nothing and costs no tokens.

What to notice: the snapshot keeps only the newest line per peer. That keeps it short, and it is why notes failed for the pusher rule.

Why didn't the pusher rule reach new chats?

A note is only in the snapshot while it is its author's newest line, and a tell only reaches chats that exist when it is sent. The journal shows what chat A did:

Time What chat A did
14:54 Sent the rule to 14 open chats with cam tell, then noted "told 14 peer chats"
15:16 Sent it again to the 2 chats opened since

Seven of those chats logged reading the message that day, between 1 and 85 minutes after it was sent, each on its next prompt. Chat A sent no more tells until 20:44, when it told two more chats. At least seven chats that started after 15:16 show up in the same journal and were never told. I noticed the new chats didn't know the rule, and that is where this fix started.

What happened: the rule reached the chats that were open, one message each, and none that came later.

Warning: a rule that only reaches the chats open right now has to be resent every time a chat opens. In practice that is a person relaying it.

What does a pin change?

A pin sits at the top of every new chat's CAM block until it is used or stale, whatever its author does next:

bin/cam pin "chat A is today's only pusher"
Pinned (1) — remove with `cam unpin <id>` once used or stale:
- chat A [3fa9c1]: "chat A is today's only pusher" (until 23:59)

The id here is an example; cam pin makes a new one each time.

  • Where it lives: pins.json, outside the journal. The journal rotates past 1 MB, and the snapshot reads only its tail, so a pin kept there would be lost again.
  • How it ends: any chat runs cam unpin <id> when the rule is used or stale. The chat that pinned it ending also removes it, and /clear counts as ending. Midnight local time is the backstop.
  • Limits: 5 live pins and 200 characters each. A sixth pin or a longer one is refused, and nothing is written.
  • Open chats see a new pin once, as a pinned line on their next prompt. It isn't repeated every turn.

What happened: the rule costs one command and two lines in each new chat's context.

Warning: anyone can pin. The cap of 5 and the midnight backstop are what keep pins from piling up.

How did we test it?

We wrote the tests first, and they failed on the old code. Then we broke the code on purpose to check that the tests noticed. The work ran as one lane: one subagent building in its own git worktree, with two review rounds.

  • Red first: 31 new checks failed on the unchanged code, including "a chat sees the pin after its author wrote 70 more journal lines".
  • Mutants: the builder broke the code on purpose 3 times: no pins read at start, expiry ignored, and session end removing every chat's pins. The suite caught each one (9, 4 and 1 failing checks).
  • Review round 1: no critical findings, 3 warnings. A stuck lock could have hung every chat's exit. Pins skipped /clear, but /clear most likely starts a new session id (the reviewer's reading; we haven't measured it), which would leave the old chat's pins until midnight. We removed the skip. And two checks could not fail.
  • Fix round: 5 new failing checks, then the fixes, then 3 more mutants, each caught. The second review ran the new checks against the old code, and all 5 failed there.

The whole run took 31 minutes of wall time, from the first agent's start to the re-review's end. The ship check found no critical issues.

Warning: the /clear bug was in a default I picked myself while planning. The review caught it, the tests didn't.

Where does it still fall short?

  • Archiving a chat may not end it. Pins go when their chat ends. We have not checked whether archiving a chat in the desktop app counts as ending it. If it doesn't, an archived chat's pins stay until midnight.
  • A pin is text, not a lock. It tells every chat the rule; it can't stop one from breaking it. For pushing, the hard stop is a lock, as in One push at a time.
  • Messages still wait. A tell is read on the receiver's next prompt. Here that took up to 85 minutes, and one chat read it two days later.
  • One repo only. The store is inside .git, so a chat in another repo can't see the pin.

Summary

  • A shared journal tells parallel chats what changed, but its start-up snapshot keeps only each chat's newest line.
  • A message only reaches chats that already exist.
  • A rule for the whole day needs its own place, read by every chat that starts, with a clear way to end.
  • That's a pin: one command, one line per new chat, gone when it's used, when its chat ends, or at midnight.
  1. Give day-wide rules their own store, apart from the journal and the inbox. Don't rely on a note staying the newest line.
  2. Make the single-pusher step pin itself, so the rule no longer depends on a chat remembering to.