SLOPSHOPPER

pin-everywhere

A pinned session keeps its Remote Control on (reconnected after app restarts) once machine-tag has put the machine icon in the title, so it shows by name and…

guardtoasttimer
A shopper browsing a rack in a slop shop
README

claude-mods

Private Claude Code marketplace for Tuncer's mods: function-hook plugins that run inside every Claude Code session on his machines (MacBook Pro, MacBook Air, therig, the 5090 PC, the 4090 work PC).

PluginWhat it does
memory-guardsRefuses the footgun commands Claude's memory notes warn about (for example impeccable update --help, routing shiftyeyegames.com DNS through cloudflared, /logout before cswap add) and says why, with the safe alternative. It also refuses every copy of the Graves23 and Castaway projects (~370 GB each): worktrees by any route (shell, EnterWorktree, agent or workflow isolation, a session with its own worktree), clones, git archive, --work-tree, robocopy/xcopy/Copy-Item/cp/rsync of the project, MI, MI/Assets or MI/Library, and junctions or links, pointing at ~/.claude/rules/big-project-branches.md.
kb-healthShows KB health in the status line on the machine that runs the KB. It stays quiet on machines without the KB snapshot job.
machine-tagPrefixes session titles with the machine's emoji tag (💻 MBP, 🪶 Air, 🎮 Rig, 🔥 5090, ⚡ 4090), so pinned sessions show which computer they run on. /machine-tag <emoji> <word> overrides it per machine.
pin-everywhereA pinned session keeps its Remote Control on once machine-tag has put the machine icon in the title, so the session shows by name and icon on every other computer and the phone. Every open session checks all of the machine's pinned sessions every 2 minutes and reconnects any that dropped (an app restart drops them), including ones nobody has opened. Unpinning turns Remote Control back off when this mod turned it on; to keep a pinned session off Remote Control, unpin it. A title is published when Remote Control connects, so after renaming a pinned session, unpin and pin it again to publish the new name.

Install on a machine

claude plugin marketplace add Shifty-Eye-Games/claude-mods
claude plugin install memory-guards@claude-mods
claude plugin install kb-health@claude-mods
claude plugin install machine-tag@claude-mods
claude plugin install pin-everywhere@claude-mods

Then turn on auto-update: in /plugin, open Marketplaces, pick claude-mods and enable auto-update, or set it in ~/.claude/settings.json:

"extraKnownMarketplaces": {
  "claude-mods": {
    "source": { "source": "github", "repo": "Shifty-Eye-Games/claude-mods" },
    "autoUpdate": true
  }
}

Each session start then pulls main. No versions are set, so every commit is an update.

The repo is private, so each machine needs GitHub access without a prompt: an SSH key GitHub knows (Claude Code tries ssh -T git@github.com first), or stored HTTPS credentials (gh auth login then gh auth setup-git, or Git Credential Manager on Windows). Without them the clone and the updates fail silently and the machine keeps its last copy.

Machines that loaded these mods from local folders before must drop those folders from CLAUDE_CODE_PLUGIN_DIRS in ~/.claude/settings.json, or each mod loads twice.

Change a mod

  1. Edit it under plugins/<name>/.
  2. Check it: claude plugin validate plugins/<name> and claude plugin test plugins/<name>.
  3. Push to main. Versions are left unset on purpose, so each commit reaches every machine at its next session start.

How mods work, and the engine rules that bite, are in Claude's memory note on Claude Code mods.

Security

Auto-update is on, so whatever lands on main runs in every session on all four machines. Only org admins can push here (the org's default member permission is read). Keep it that way: never give anyone else write access.

Source 1 files
hooks/register.ts 224 lines
1import type { EngineInterface, Hook, Register } from 'claude-code'
2
3// A pinned session keeps its Remote Control on, so it shows on every other computer signed in to the same
4// account (and the phone) with its title, machine icon included. Remote Control fixes the title it publishes when
5// it connects, so the mod waits until machine-tag has put the machine's tag in the title before connecting.
6// Unpinning turns Remote Control off again, but only when this mod turned it on. To keep a pinned session off
7// Remote Control, unpin it; to publish a later rename, unpin and pin again.
8//
9// Remote Control drops when the desktop app restarts, so every running session sweeps all of this machine's
10// pinned sessions every 2 minutes and reconnects any that are off, including ones nobody has opened since.
11const PLUGIN = 'pin-everywhere'
12const GET = 'mcp__ccd_session_mgmt__get_session'
13const LIST = 'mcp__ccd_session_mgmt__list_sessions'
14const SET_RC = 'mcp__ccd_session_mgmt__set_remote_control'
15const LIST_LIMIT = 200
16const TICK_MS = 2 * 60_000
17const CALL_TIMEOUT_MS = 30_000
18const RETRY_MS = 60 * 60_000
19const TAGGED = /^\p{Extended_Pictographic}(?:️|‍\p{Extended_Pictographic}|[\u{1F3FB}-\u{1F3FF}])* \S+ · /u
20
21// pinned: true, false, or undefined when the app has not reported a pin for the session (never read as unpinned).
22type Info = { id: string; title: string; pinned: boolean | undefined; rc: string; fromRemote: boolean; archived: boolean }
23// One store key per pinned app session ("rc:<id>"): whether the mod turned Remote Control on (so an unpin turns it
24// off), and when a refused or failed connect may be tried again (so a declined approval doesn't return every tick).
25type Seen = { pinned: true; owned: boolean; retryAt?: number }
26
27const state = { busy: false, warned: false, timer: undefined as { cancel: () => void } | undefined }
28
29function parse(text: string | undefined): unknown {
30  try {
31    return JSON.parse(text ?? '')
32  } catch {
33    return undefined
34  }
35}
36
37function toInfo(row: unknown): Info | undefined {
38  if (!row || typeof row !== 'object') {
39    return undefined
40  }
41  const r = row as Record<string, unknown>
42  if (typeof r.sessionId !== 'string') {
43    return undefined
44  }
45
46  return {
47    id: r.sessionId,
48    title: typeof r.title === 'string' ? r.title : '',
49    pinned: typeof r.pinned === 'boolean' ? r.pinned : undefined,
50    // get_session reports remoteControlState; list_sessions only a remoteControlActive flag, read as "on" or as
51    // unknown (empty), which a get_session fills in when it matters.
52    rc: typeof r.remoteControlState === 'string' ? r.remoteControlState : r.remoteControlActive === true ? 'on' : '',
53    fromRemote: r.startedViaRemoteControl === true,
54    archived: r.isArchived === true,
55  }
56}
57
58// A tool call that settles within CALL_TIMEOUT_MS, so an approval dialog left open can't wedge the sweep. No
59// $.tool.check first: a plugin's own query skips its own tool.check hook, so it would report the session's
60// rules, not the allow allowMine gives the real call.
61async function call($: EngineInterface, input: Record<string, unknown>) {
62  const done = $.tool.call(input as never).catch(() => undefined)
63  const late = $.clock.sleep(CALL_TIMEOUT_MS).then(() => undefined)
64
65  return Promise.race([done, late])
66}
67
68// The session, 'gone' when the app answered that it can't report it, undefined when the call itself failed.
69async function getSession($: EngineInterface, id: string): Promise<Info | 'gone' | undefined> {
70  const got = await call($, { tool: GET, session_id: id })
71  if (got?.isError) {
72    return 'gone'
73  }
74
75  return toInfo(parse(got?.text))
76}
77
78async function listSessions($: EngineInterface): Promise<Info[]> {
79  const rows = parse((await call($, { tool: LIST, limit: LIST_LIMIT }))?.text)
80
81  return Array.isArray(rows) ? rows.map(toInfo).filter((r): r is Info => r !== undefined) : []
82}
83
84// Resolves to the state the app reports afterwards, or undefined when the call was refused, failed or timed out.
85async function setRemoteControl($: EngineInterface, id: string, enabled: boolean): Promise<string | undefined> {
86  const row = parse((await call($, { tool: SET_RC, session_id: id, enabled }))?.text) as Record<string, unknown> | undefined
87
88  return typeof row?.remoteControlState === 'string' ? row.remoteControlState : undefined
89}
90
91async function readSeen($: EngineInterface, key: string): Promise<Seen | undefined> {
92  const raw = await $.store.get(key)
93
94  return raw && typeof raw === 'object' ? (raw as Seen) : undefined
95}
96
97async function keepOn($: EngineInterface, me: Info): Promise<void> {
98  // 'connecting' means wait; 'unavailable' means this app can't; a phone-started session's switch is locked.
99  if (me.fromRemote || (me.rc !== 'on' && me.rc !== 'off')) {
100    return
101  }
102  const key = `rc:${me.id}`
103  const seen = await readSeen($, key)
104  if (me.rc === 'on') {
105    if (!seen) {
106      await $.store.set(key, { pinned: true, owned: false })
107    }
108    return
109  }
110  // Not tagged yet: wait, so the title Remote Control publishes already carries the machine icon.
111  if (!TAGGED.test(me.title)) {
112    return
113  }
114  const now = await $.clock.now()
115  if (seen?.retryAt && now < seen.retryAt) {
116    return
117  }
118  const after = await setRemoteControl($, me.id, true)
119  if (after === 'on' || after === 'connecting') {
120    await $.store.set(key, { pinned: true, owned: true })
121    return
122  }
123  await $.store.set(key, { pinned: true, owned: seen?.owned === true, retryAt: now + RETRY_MS })
124  if (!state.warned) {
125    state.warned = true
126    $.ui.toast('pin-everywhere: Remote Control could not be turned on for a pinned session; retrying in an hour.')
127  }
128}
129
130async function drop($: EngineInterface, me: Info): Promise<void> {
131  const key = `rc:${me.id}`
132  const seen = await readSeen($, key)
133  if (seen?.owned && me.rc === 'on') {
134    await setRemoteControl($, me.id, false)
135  }
136  await $.store.delete(key)
137}
138
139async function sync($: EngineInterface): Promise<void> {
140  if (state.busy) {
141    return
142  }
143  state.busy = true
144  try {
145    const self = await getSession($, 'self')
146    const listed = await listSessions($)
147    const rows = self && self !== 'gone' ? [self, ...listed.filter(r => r.id !== self.id)] : listed
148    const byId = new Map(rows.map(r => [r.id, r]))
149    const tracked = new Set(await $.store.keys())
150    // Sessions this mod tracks but the list didn't return (archived, deleted, or past the list's limit).
151    for (const key of tracked) {
152      const id = key.startsWith('rc:') ? key.slice(3) : ''
153      if (!id || byId.has(id)) {
154        continue
155      }
156      const me = await getSession($, id)
157      if (me === 'gone' || me?.archived) {
158        await $.store.delete(key)
159      } else if (me) {
160        byId.set(id, me)
161      }
162    }
163
164    for (const row of byId.values()) {
165      if (row.pinned === true) {
166        // A list row only says whether Remote Control is up; ask for the full state when it is not.
167        const me = row.rc === 'on' || row.rc === 'off' ? row : await getSession($, row.id)
168        if (me && me !== 'gone' && me.pinned === true && !me.archived) {
169          await keepOn($, me)
170        }
171      } else if (row.pinned === false && tracked.has(`rc:${row.id}`)) {
172        // Only an explicit unpin counts: a session with no pin recorded is left alone.
173        await drop($, row)
174      }
175    }
176  } finally {
177    state.busy = false
178  }
179}
180
181function startTicking($: EngineInterface) {
182  state.timer?.cancel()
183  state.timer = $.clock.every(TICK_MS, () => void sync($))
184}
185
186// The mod's own calls to the app's session tools need no prompt; anything else (the model's calls) goes to the
187// normal permission decision.
188const allowMine: Hook<'tool.check'> = async ($, e, next) => {
189  const mine = next.origin.plugin === PLUGIN || next.origin.plugin.startsWith(`${PLUGIN}@`)
190  if (mine) {
191    return { decision: 'allow', reason: 'pin-everywhere: Remote Control for pinned sessions' }
192  }
193
194  return next(e)
195}
196
197export const register: Register = on => {
198  state.timer = undefined
199  state.warned = false
200
201  on('tool.check', { tool: GET }, allowMine)
202  on('tool.check', { tool: LIST }, allowMine)
203  on('tool.check', { tool: SET_RC }, allowMine)
204
205  on('session.start', async ($, e, next) => {
206    const ran = await next(e)
207    startTicking($)
208
209    return ran
210  })
211
212  // After each turn, outside the prompt's dispatch. A hot reload cancels the timer without a new session.start,
213  // so the first turn after one starts it again.
214  on('turn.complete', async ($, e, next) => {
215    const ran = await next(e)
216    if (!state.timer) {
217      startTicking($)
218    }
219    $.clock.after(0, () => void sync($))
220
221    return ran
222  })
223}
224