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

slash-coverage

一款 Claude Code 模組,顯示每個代理的上下文中有哪些檔案,以及各佔多少比例。

已翻譯

關於這個 mod

slash-coverage 讓子代理的上下文保持可見。對主工作階段與每個子代理,它會顯示:哪些檔案完整放在上下文中,哪些只有部分(以及是哪些行),哪些檔案本身沒讀過、但由它產生的子代理讀過,哪些副本在編輯後已經過時,以及每一項佔用多少 tokens。

每個數值都取自 Claude Code 已經進行的工具呼叫(Read、Edit、Write、Grep、Glob,以及解析後的 shell 讀取)。每個代理的紀錄會儲存在聊天逐字稿旁邊,因此重新啟動後,網格仍會保留。

安裝方式:/plugin install slash-coverage --marketplace Davron2004/slash-coverage

安裝

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

claude plugin marketplace add Davron2004/slash-coverage
claude plugin install slash-coverage
原文 / README

slash-coverage

A Claude Code mod that shows which files each agent has in its context, and how much of each.

When Claude spawns subagents, the files they read go into their contexts, not the main session's. slash-coverage keeps that visible: for the main session and every subagent, which files it holds in full, which only in part (and which lines), which it never read itself but a subagent it spawned did, which copies went stale after an edit, and what each one costs in tokens.

Coverage, one agent

Install

In a Claude Code terminal session:

/plugin install slash-coverage --marketplace Davron2004/slash-coverage

Answer y to add the marketplace, then pick a scope. In a fullscreen terminal at least 144 columns wide the pane opens on the right when a session starts; in a narrower one, /coverage opens it. /coverage also hides it. Ctrl+X then Tab gives the pane the keyboard, so its keys below work.

slash-coverage is built on Claude Code's mod API (function hooks), which is early access and changes between versions. It was built against Claude Code 2.1.292.

Reading it

Pick an agent in the row at the top, and every column describes that agent:

| Column | Shows | | --- | --- | | held | What's in its context: ● all, the line ranges it read (◉ 1–180/1323), ● stale ✎main when another agent edited the file after it read it, ◌ via ex1 when only a subagent it spawned read it, ○ grep hit, or ✕ compacted | | tokens | What the file's tool results cost its context | | last | Time since it last read, searched or edited the file | | reads | Read calls, with ↩n for reads of lines it already held | | edits | Lines it added and removed |

| Glyph | Means | | --- | --- | | ● | The whole file, current | | ◉ | Some of its lines | | ● (orange) | Read before another agent edited it | | ◌ | This agent never read it, but a subagent it spawned did | | ○ | Named in a search, listing or line count, never opened | | ✕ | Read, then dropped by compaction | | ◆ | The file an agent is working on right now |

Rows are the files the picked agent knows: its own, and those a subagent it spawned read. So main lists everything, and a subagent lists only what it touched. In all, rows are every file any agent touched. Untouched files fold into one "N untouched" line per folder. A folder's row sums what's inside it, strongest first: short runs as glyphs, longer ones counted, ●● ◉ ◌14 ○○○ 20/31. Click a file for what every agent knows of it, and a folder to fold it.

| Key | Does | | --- | --- | | h / l | Step to the previous or next agent, in the order they were spawned. The row scrolls; ‹ 3 and 5 › count the agents off screen | | m | Main session | | a | All agents side by side |

All agents side by side

Coverage, all agents

a puts one narrow column per agent next to the file tree, then the team's tokens and last touch. It shows what no single agent's view can: two subagents paying for the same file, and folders no agent covered.

Each agent's header is a numbered toggle. Press its number (2 for 2: ex1) to leave that agent out of the view, as if it never ran. Its column goes and the others close up. It waits under the grid in a "left out" line, as ⊘ex1: click it to bring it back, or press 0 to bring back every agent left out. So you can see what your backend agents know without the UI agent's reads mixed in.

How it works

Every value comes from tool calls Claude Code already makes, and nothing asks an agent to report anything:

  • Read results give the exact line ranges and the file's length.
  • Edit and Write patches give lines added and removed. They also shift the editor's own line ranges, and they mark every other agent's copy of the file stale.
  • Grep and Glob results, and shell commands that search or count (grep, rg, wc), give search hits. A path only counts when it starts a line of the output, so a file merely mentioned inside another file's content doesn't.
  • Shell reads are parsed as shell: quotes, heredocs, redirects, pipes and for loops, with cds followed and globs expanded. Only commands that print file content count as reads, so python3 x.py or a heredoc's code never does, and output sent to a file doesn't either. cat, nl, head, tail, sed -n 'A,Bp' and awk 'NR>=A && NR<=B' give exact lines, through pipes too (cat -n f | sed -n 10,20p is lines 10–20). When Claude Code kept only a preview of a long output, only the lines in the preview count. git status after each command catches files a command changed.
  • Worktrees of the repo (git worktree list) map onto the repo's own paths, so a subagent working in ../app-feature or .claude/worktrees/x fills in the same rows as main.
  • Spawns give each subagent's parent, and a subagent counts as done when its turn ends.
  • Secondhand (◌) is structural: a subagent you spawned read the file. What its report said about the file isn't tracked.

It survives a restart

slash-coverage keeps a log per agent of what it read, searched and edited, and saves it in the chat's own folder next to the transcript: ~/.claude/projects/<project>/<chat id>/slash-coverage/main.json, plus one file per subagent. Resuming the chat (--resume, --continue) replays the logs in time order and the grid comes back as it was, stale copies included. Claude Code deletes a chat's folder along with its transcript, so the logs go with it. /coverage clear empties them.

Limits

  • Files Claude Code loads on its own, like CLAUDE.md, never pass through a tool call, so they don't show.
  • Token counts are estimates (characters ÷ 4).
  • A shell read through something the parser can't follow (sed '/re/,/re/p', a script, xargs) holds unknown lines, so it shows as partial.
  • A forked chat starts empty: the fork gets a new folder, and the logs aren't copied into it.
  • Only the terminal has been checked visually. The desktop app draws the same elements, untested.
  • The glyphs are chosen to sit in one cell of JetBrains Mono (Ghostty's default font). A font that lacks them can draw them wider.

Develop

git clone https://github.com/Davron2004/slash-coverage
claude --plugin-dir ./slash-coverage   # run a session with it; saving a file reloads it
cd slash-coverage
claude plugin validate .
claude plugin test .
tsc -p .                               # after the first load, which lays the API's types in .claude-plugin/types

hooks/knowledge.ts turns tool events into levels, hooks/events.ts holds the event log and its replay, hooks/paths.ts reads shell commands and their output, and hooks/register.tsx wires them to Claude Code and draws the pane.

License

MIT

取得徽章

這是你的專案嗎?把這個徽章放進 README 或網站,連回本頁。

Featured on ClaudeMods
尺寸
配色
Markdown
HTML

更多類似作品