ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 bennewton999

session-activity

副作用帳本(/ledger),可攔截正式環境 SQL 寫入;以及用於背景工作的 waiting-on 追蹤器。

bennewton999@bennewton999

bennewton999/claude-code-mods/tree/main/session-activity

原貼文圖片1
已翻譯

關於這個 mod

session-activity 是 claude-code-mods 組合中的 Claude Code mod,提供三個能力:/ledger 列出所有離開本機的動作(MCP 寫入、git push、gh pr、gh api 寫入、Vercel 部署、curl 寫入、SQL 寫入等),可切換檢視最近 24 小時的所有 session;資料庫寫入攔截會在任何寫入型 execute_sql(INSERT/UPDATE/DELETE/DDL/GRANT 等)執行前跳出版確認;waiting-on 則在提示上方列出 Claude 停止後仍在執行的背景指令、agent、workflow 與 monitor,並可用 /waiting 查詢、/waiting clear 重設。安裝方式可透過 marketplace(/plugin install session-activity@bennewton-mods)或 clone 後以 CLAUDE_CODE_PLUGIN_DIRS 載入。所有紀錄僅存放於本機 per-plugin store,唯一的網路請求是 ship-tracker 相關的 gh 查詢。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add bennewton999/claude-code-mods
claude plugin install session-activity
原文 / README

Claude Code mods for running a lot of sessions at once

Five Claude Code mods built from how I actually use Claude Code: four to six sessions at a time, mostly in one repo, a lot of PRs going to production, and a pile of rules I keep forgetting to check.

Claude built all five. The full story, with screenshots, videos and the bugs a real run caught, is on my site: I asked Claude to read 30 of my Claude Code sessions and build the mods I needed

The session-fleet pane listing two live sessions, one waiting on a permission prompt

The prompt

This is what I gave Claude Code. It read my last 30 sessions, came back with ten ideas, and built all ten as these five mods.

look at the last 30 sessions and see how we use claude to work - then look at https://code.claude.com/docs/en/plugins/mods/overview and suggest 10 possible mods for our workflow that would help me be better informed as to what each session is doing.

Run it on your own sessions. Your ten ideas will probably come out different from mine, and I'd like to see them.

The five mods

| Mod | What it gives you | Commands | |---|---|---| | session-fleet | A board of every live session, a "needs you" row when another session is blocked on you, and a guard when two sessions write to the same worktree | /fleet | | ship-tracker | A row per PR: CI → merged → production deployment → live, a warning when a merge never deploys, and a receipt line after every answer | /ship-track <pr> | | session-hygiene | Tripwires for your own rules (typecheck before push, review before push, mutation-check new tests and more), plus a handoff card of loose ends from earlier sessions | /handoff, /handoff clear | | session-activity | A ledger of everything that left the machine, a hold on database writes, and what each session is waiting on | /ledger, /waiting | | context-gauge | Context fill in the status line, warnings before compaction, and a snapshot of in-flight work that survives compaction | /context-log |

They work on their own. Install any one, or all five.

Install

You need a Claude Code version with mods (see the mods docs), git, and for ship-tracker and the handoff card, the GitHub CLI signed in.

A mod is code that runs with your permissions inside Claude Code. Read it before you install it. Each one is a single hooks/register.tsx file, and claude plugin validate <folder> lists exactly which events it hooks and what it calls.

From the marketplace

In a Claude Code session:

/plugin marketplace add bennewton999/claude-code-mods
/plugin install session-fleet@bennewton-mods
/plugin install ship-tracker@bennewton-mods
/plugin install session-hygiene@bennewton-mods
/plugin install session-activity@bennewton-mods
/plugin install context-gauge@bennewton-mods

Then /reload-plugins, or start a new session.

From a clone

git clone https://github.com/bennewton999/claude-code-mods ~/claude-code-mods

Load them in every session by adding the folders to env in ~/.claude/settings.json (colon-separated):

{
  "env": {
    "CLAUDE_CODE_PLUGIN_DIRS": "/Users/you/claude-code-mods/session-fleet:/Users/you/claude-code-mods/ship-tracker:/Users/you/claude-code-mods/session-hygiene:/Users/you/claude-code-mods/session-activity:/Users/you/claude-code-mods/context-gauge",
    "CLAUDE_CODE_PLUGIN_DIR_WATCH": "1"
  }
}

Or try one for a single session:

claude --plugin-dir ~/claude-code-mods/session-fleet

CLAUDE_CODE_PLUGIN_DIR_WATCH makes desktop app sessions hot-reload a mod when its files change (an interactive terminal session already does). A session reads it at startup, so sessions that were already open pick up the mods, and the watch, after one restart.

What each one does

session-fleet

Every session writes one record to a key-value store that all sessions on the machine share ($.store), with a heartbeat every 30 seconds. Three minutes without a heartbeat and the session counts as gone.

  • /fleet opens a pane with every live session: a status dot, its first prompt (there's no session title API), the worktrees it's touching, branch, PR, last action and how long ago. Waiting sessions sort to the top, and a worktree two live sessions share gets a ⚠.

  • Switch by clicking. In the desktop app, click another session's title in the pane to jump to it, the same as clicking it in the sidebar. Terminal sessions show their title as plain text.

  • Project pills. Each session gets a pill naming its repo. To name and color your own projects, set projectPills to Label:regex:color entries separated by ;, the regex tested against the repo folder name:

    "pluginConfigs": {
      "session-fleet": {
        "options": { "projectPills": "Work:acme|billing:#2563eb; Blog:blog:#059669" }
      }
    }
    
  • Needs-you row. When another session is blocked on you, a row shows above your prompt with the reason and how long it has waited, plus a toast. "Blocked" means a permission prompt, a question dialog, or a turn that ended with a question mark. That last one is a guess.

  • Worktree guard. The first session to edit a file or run a mutating git command (commit, checkout, rebase, push…) in a worktree claims it. A second live session that tries gets a Proceed or Stop question naming the other session, its branch and last action. Claims let go after 30 minutes idle.

The needs-you row above the prompt The worktree guard question

ship-tracker

  • Picks up PRs from gh pr output, or add one with /ship-track 1107 or /ship-track owner/repo#1107.
  • Every 45 seconds it reads the PR state and checks from GitHub. After the merge, it finds the GitHub deployment for the merge commit in the Production environment. Live means that deployment succeeded.
  • Merged for 15 minutes with no production deployment? The row says no prod deploy!. That's the silent Vercel git-trigger failure that got me before.
  • A receipt line after every answer: duration, tool calls, files edited, shell commands, outward actions (push, PR, MCP writes) and context fill.

Two PRs in the ship band

session-hygiene

Tripwires for rules you keep forgetting. When one trips you get a transcript line and a toast, and Claude gets a reminder with the tool result so it can act on it. Out of the box these are my rules. Edit the RULES_CONFIG block at the top of session-hygiene/hooks/register.tsx to make them yours.

  • Pushing or opening a PR after TypeScript edits with no npm run typecheck since (scoped to STRICT_REPO)
  • Pushing with edits made since the last local /code-review
  • Writing a new test file: mutation-check it
  • A new top-level src/app/<x>/page.tsx in STRICT_REPO: add the route to the middleware passthrough
  • apply_migration: run NOTIFY pgrst, 'reload schema', and revoke default grants on new tables
  • Merging after package.json or next.config changes with no local npm run build
  • Banned strings in written files (BANNED)

Two rules hold the command with a Run it or Stop question instead: sourcing an env file into the shell, and using a Supabase service-role key.

The handoff card: after each turn a session saves its open loops (open PRs, uncommitted or unpushed worktrees, a question it left you). A new session lists loops from sessions that ended or went quiet, re-checked live first. /handoff shows them again, /handoff clear dismisses them.

A tripwire, and Claude responding to it The handoff card in a new session

session-activity

  • /ledger lists everything that left the machine: MCP write tools, git push, gh pr create and merge, gh api writes, Vercel deploys, curl writes, publishes, SQL writes. A button switches to all sessions in the last 24 hours. Reads stay out of it.
  • Database write hold. Any execute_sql that writes (INSERT, UPDATE, DELETE, DDL, GRANT…) stops for a Run it or Stop question. SELECTs and NOTIFY pass. Words inside comments and quoted strings don't count.
  • Waiting-on. The spinner shows pending background work (Thinking · 2 bg · agent 3m…), and a row above the prompt lists background commands, agents, workflows and monitors still running after Claude stops. /waiting lists them, /waiting clear resets.

The ledger pane

context-gauge

  • The status line shows ctx 62% · 124k/200k · compacted 1×.
  • Toasts at 70% and 85%, and from 80% a row above the prompt with a Compact now button.
  • Before any compaction it snapshots what's in flight (task, latest request, files edited, PR links, last actions), asks the summarizer to keep it, logs it, and hands it back to Claude with your next prompt.
  • /context-log lists every compaction this session with its snapshot.

The context log after a compaction

Privacy

Everything these mods record stays on your machine in Claude Code's per-plugin store. The only network calls are gh requests to GitHub for PR and deployment state (ship-tracker, and the handoff card's re-check).

Known issues

  • Tested in the terminal. The desktop app's Code tab should draw the same panes and rows, but I haven't seen it yet.
  • In one long session, /ledger reported the pane as opened but it never drew. It works in fresh sessions; the built-in diff pane seemed to be in front of it.
  • The mods API is still early access, so an update to Claude Code can break things here.
  • The needs-you "ended with a question" check is a heuristic and will be wrong sometimes.

Who made this

I'm Ben Newton. I write about building with AI at benenewton.com, and I'm building BlackOps Center, the platform that runs my site, my posts and the notes these Claude sessions write into. If you want to see it, start at blackopscenter.com/start.

Claude Code wrote the mods with its built-in plugin-authoring skill. Issues and PRs are welcome.

MIT licensed.

更多類似作品