ClaudeMods
☰
ZH-CN
● 0 人在线 · 浏览 0 次
赞助提交作品
GitHub 仓库 · 发布者 AsyrafHussin

statusline-band

Claude Code 提示符上方的面板,显示速率限制及其消耗速度、上下文、费用和令牌、Git 状态与开关、操作,以及带有 Clawd 和 Beatbot 的 Spotify 卡片

AsyrafHussin@AsyrafHussin

AsyrafHussin/claude-code-statusline/tree/main/mod/statusline-band

已翻译

关于这个 mod

statusline-band

Claude Code 提示符上方的面板,旁边站着 Claude Code 吉祥物 Clawd,下方还有一张带有 Spotify 吉祥物 Beatbot 的 Spotify 卡片。

  • 顶部: 仓库名称、分支、模型及其 effort,还有你的 Claude 方案(Max 5x、Pro...)。右侧是本次会话的费用和令牌,接着是今天和最近 30 天的费用与令牌。
  • 中部: 以填充环显示 5 小时和 7 天速率限制,同时显示重置倒计时和本地重置时间。当当前速度会在重置前耗尽某个限制时,会显示 ▲ out ~7h。下方是上下文使用量条。
  • 底部: 正在运行的子代理、未提交的文件和行数、未推送的提交及其行数、落后提交、贮藏,以及距离上次提交的时间。右侧是上一条回复的输入令牌(含缓存占比)和输出令牌、会话长度与时间。
  • Clawd: Claude 工作时会奔跑。其他时候,如果速率限制达到 95% 或更高,它会流汗;安静 10 分钟后会睡着;你的提交推送完成时会欢呼。
  • 操作: 卡片下方的一行按钮会像你输入一样发送提示:push(提交并推送)、find bugs、run tests 和 summarize。quick commit 会让 Haiku 根据差异写出提交消息,并让你选择:提交、提交并推送,或自己输入;然后它会自行提交,不占用主模型的一轮。点击一个按钮,或按 ctrl+x tab 聚焦面板,移动到按钮后按 Enter。
  • Git 开关: 每个仓库分别保存 commit auto · push ask。设为 ask 时,Claude 的 git add、commit 或 push 都会等待你的确认。设为 auto 时,Claude 还会自行执行:每次改动完成就提交,随后立即推送。无提示执行只适用于指定仓库的简单形式:使用 -C 命名仓库,例如 git -C '/abs/path' add <files>、git -C '/abs/path' commit -m '…' 和 git -C '/abs/path' push [remote] [branch],并以 && 连接。其他形式都会按照开关设置询问,包括不带 -C 的步骤(Bash 工具会在调用之间保留自己的目录)、强制推送、heredoc、$(…)、cd、管道、env 或 xargs 之类的包装器,或会提交、推送的别名。计划模式下不允许任何操作。只读步骤(status、log、diff、show,以及只调整输出形式的参数)可以随同执行。某一步需要确认时,对话框下方会说明它会连带哪些内容。系统提示会告诉 Claude 这种简单形式以及每个开关的状态。点击 commit 或 push 即可切换。
  • Spotify(macOS): 在你点击 Git 开关旁的 spotify 之前它处于关闭状态(spotify off,之后是 on,并跨会话保留)。关闭时不会向 Spotify 查询任何内容。开启且 Spotify 正在运行时,面板下方会显示一张以 Spotify 绿色为边框的卡片,包含状态和曲目、◀◀ ❚❚ ▶▶、带时间的进度、随机播放、循环和音量 − +,以及之前听过的曲目(跨会话保留)。开启 lyrics on(位于 spotify 旁,默认开启)后,卡片还会随歌曲显示正在唱的歌词行(明亮)和下一行(变暗);歌词来自 LRCLIB(lrclib.net),没有同步歌词的曲目不会显示歌词。search(或 /spotify-search)会打开搜索 Spotify 的面板并播放你选中的曲目;设置好 spotifyClientId 和客户端密钥后,终端仍会保持在前台。像素绘制的 Spotify 小吉祥物 Beatbot 会在播放时跳舞在 Clawd 下方;曲目暂停 10 分钟后,它会伴着 Z 字睡着。它每 5 秒通过 AppleScript 向 Spotify 查询一次,从不启动 Spotify。当前播放列表不会显示:Spotify 只通过需要登录的 Web API 提供它。
  • 最小化: 任一卡片底部边缘的 minimize 会把它从面板左边缘缩成一行。主卡片保留仓库和分支、模型、以百分比显示的限制和上下文、第一个 Git 信息以及会话费用;Spotify 卡片保留控件、曲目和时间。expand 会恢复卡片。每张卡片都会跨会话记住选择。
  • 其他: 将鼠标悬停在速率限制上可查看其速度。点击 30d 或运行 /usage-history,可打开显示每天费用和令牌的面板。当限制超过 80% 和 95% 时,以及当前速度会在重置前耗尽限制时,会弹出通知。

需要 Claude Code v2.1.287 或更高版本。

安装

/plugin marketplace add AsyrafHussin/claude-code-statusline
/plugin install statusline-band@claude-code-statusline

设置

每项都是 /config 中的一行,也可以运行 /plugin configure statusline-band@claude-code-statusline。

| 设置 | 默认值 | 作用 | |---------|---------|--------------| | initials | empty | Clawd 衣服上显示最多两个字母 | | cardColor | #0a0a0a | 面板背景;留空("")表示不设置,让终端使用自己的背景 | | padRows | 1 | 统计信息上下方的空行数,范围为 0 到 2 | | historyDays | 30 | 滚动费用和历史面板覆盖的天数,范围为 7 到 62 | | noAttribution | false | 从提交和拉取请求中去掉 Co-Authored-By、Claude-Session 以及 Claude Code 页脚 | | gitStrict | true | 开启时:Git 开关设为 auto 后,只有使用 -C 命名仓库的简单命令会免提示运行。关闭时:仓库开关设为 auto 后,任何 Git 命令都会免提示运行 | | spotify | true | Spotify 运行时,在面板下显示它正在播放的内容,并显示跳舞的 Beatbot、进度条和控件(macOS) | | plan | empty | 按显示结果显示你的 Claude 方案,例如 Max 20x;留空则从 Claude Code 自己的 ~/.claude.json 读取(Claude Code 启动或登录时更新) | | spotifyClientId | empty | 你在 developer.spotify.com/dashboard 的应用客户端 ID,用于搜索 Spotify | | spotifyClientSecret | empty | 该应用的客户端密钥。/config 不会显示密钥设置,因此请将它保存在 macOS 钥匙串中:security add-generic-password -U -s statusline-band-spotify -a client-secret -w(它会隐藏输入并要求你提供密钥) |

它运行、读取、保存和发送的内容

它运行的程序

它运行以下程序,从不通过 shell。参数都是固定的,例外是目录(每条 git 命令都在仓库目录中运行,即 git -C <folder>)、你批准的快速提交消息,以及所搜索曲目的 Spotify URI(会检查其格式为 spotify:track: 且只含字母和数字)。

  • git,只读,用于显示分支及其改动(每次都在仓库目录中运行,即 git -C <folder>)。它会运行:

    • rev-parse --show-toplevel 获取仓库根目录,每个目录执行一次
    • status --porcelain=v2 --branch --show-stash 获取分支、上游、领先和落后提交、未提交文件与贮藏
    • diff --shortstat HEAD 和 diff --shortstat @{upstream}...HEAD 获取未提交和未推送的行数
    • log -1 --format=%ct 获取上次提交的时间

    这些命令每 30 秒运行一次,并在每次工具调用后运行。

  • Claude 的 Git 步骤需要确认时运行的 git: 在对话框下方说明它会连带哪些内容:同样的只读命令,以及 config --get alias.<name>,用来查看 Git 别名代表什么。

  • 你按下快速提交时运行的 git: 先运行 status --porcelain、diff HEAD 和 log -5 --format=%s 来写出消息;你批准后再运行 add -A、commit -q -m <message>,以及在你选择时运行 push。这些是它唯一会改变内容的 Git 命令。

  • Spotify 使用的 osascript: 仅在 spotify 开关开启且 Spotify 正在运行时每 5 秒读取曲目;按下控件时读取或执行播放、暂停、跳过、随机播放、循环和音量操作;你选中搜索结果后播放曲目,并将你原先使用的应用带回前台。

  • 搜索使用的 security find-generic-password -s statusline-band-spotify -w: 当你打开或使用搜索且设置为空时,读取 macOS 钥匙串中的 Spotify 客户端密钥;找到后一直保存到外掛重新加载。

  • date,读取本地日期和时间(+%Y-%m-%d,以及 +%Y-%m-%d|%I:%M %p|%H|%M|%S)。它也会格式化时区中的速率限制重置时刻(date -r <epoch>)。

它读取的内容

  • 来自会话: Claude Code 报告的用量(费用、上下文、速率限制及其重置时间)、模型名称、会话 ID 和工作目录、正在运行的子代理,以及每轮结束时的令牌数量。
  • 来自 Claude Code 自己的 ~/.claude.json: 仅在每次加载时读取你账户的方案类型和速率限制等级,用于显示方案。
  • 来自运行中的 Spotify: 正在播放的曲目名称、艺术家、专辑、长度、位置和 ID,以及随机播放、循环和音量设置。
  • 来自 macOS 钥匙串: 仅在你搜索时读取 statusline-band-spotify 项目和 Spotify 客户端密钥。
  • 它从不读取的内容: 你的提示或 Claude 回复的文本。它只从工具调用中读取 Bash 命令,用于找出开关覆盖的 Git 步骤。

它保存的内容

所有内容都留在插件自己的本机存储中,不会去别处:

  • 每个仓库根目录对应的 Git 开关
  • 最近听过的 3 首 Spotify 曲目
  • spotify 和 lyrics 开关的开启或关闭状态
  • 每张卡片是否最小化
  • 最近 62 天每天的费用和令牌
  • 最近 100 个会话的每次会话最后一次读取结果
  • 最近 3 小时的速率限制读数,用于计算近期速度
  • 已经显示过的通知

它发送的内容

  • 只在你按下操作按钮时发送给 Claude 的提示。 每条都是 Actions 下列出的固定文本,会像你输入一样发送到本次会话。推送仍会经过你自己的权限规则。
  • 只在你按下快速提交时发送给 Haiku 的差异。 最多 24k 个差异字符、新文件名称和最近 5 条提交主题会通过 Claude Code 自己的模型调用发送给 Claude 的小模型,方式与 Claude Code 自己和模型通信相同,用来写出消息。
  • 只在你在快速提交中选择「Commit and push」时执行的推送。 它会用你已有的 Git 凭据,将 git push 自行运行到分支的上游。
  • 只在你搜索时执行的 Spotify 搜索。 使用你自己的应用客户端 ID 和密钥,插件会向 accounts.spotify.com 请求应用令牌,向 api.spotify.com 请求最多 10 首符合输入的曲目;选择一首后,会通过 AppleScript 在 Spotify 应用中播放。
  • 当 spotify 和 lyrics 开启时发送给 LRCLIB 的当前曲目。 每首新曲目一次,将其名称、艺术家、专辑和长度发送到 lrclib.net 这个免费开放歌词服务,以获取同步歌词。不需要账户或密钥。关闭 lyrics 后不会发送任何内容。
  • 其他都不会发送。 它从不从 Git 获取内容,不会进行其他网络调用,没有遥测,也不会发送到任何其他服务。落后提交数以你上次 fetch 或 pull 时远端的状态为准。

钩子

  • tool.call: 只记录时间并在调用后刷新面板。它让每次调用原样运行,从不阻止或重写调用。
  • prompt.submit: 启动 Clawd 的奔跑动画。提示会原样传递。
  • turn.complete: 停止动画,并把本轮令牌数量加入总数。
  • session.start: 启动面板计时器,并注册 /usage-history;开启 spotify 时也注册 /spotify-search。
  • command.run: 只处理自己的 /usage-history 和 /spotify-search 命令,通过打开面板来响应。
  • attribution.text: 开启 noAttribution 后,返回空的提交尾注和 PR 页脚。
  • prompt.compose: 在系统提示中加入一节,说明 Git 简单形式、每个开关的状态,以及(开启 noAttribution 时)不添加署名行。
  • 操作按钮: 按下按钮会用固定提示调用 $.prompt.submit;没有按下按钮就不会发送任何内容。quick commit 则会通过 Claude Code 自己的模型调用,把差异(最多 24k 个字符)和最近 5 条提交主题发送给 Haiku,然后自行运行 git add -A、git commit -m,以及在你选择时运行 git push。
  • classic.UserPromptSubmit、classic.PostToolUse: 读取权限模式和 effort;它们不会改变任何内容。
  • **classic.PreToolUse

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add AsyrafHussin/claude-code-statusline
claude plugin install statusline-band
原文 / README

statusline-band

A panel above the Claude Code prompt, with Clawd, the Claude Code mascot, standing beside it, and a Spotify card under it with Beatbot, a Spotify mascot.

  • Top edge: the repo name, branch, and the model with its effort and your Claude plan (Max 5x, Pro...). On the right: the session's cost and tokens, then today's and the last 30 days'.
  • Middle: the 5-hour and 7-day rate limits as filling rings, with the reset countdown and the local reset time. ▲ out ~7h appears when the pace would use a limit up before it resets. Then context usage as a bar.
  • Bottom edge: running subagents, uncommitted files and lines, unpushed commits and their lines, commits behind, stashes and the time since the last commit. On the right: the last reply's input (with its cached share) and output tokens, the session length and the time.
  • Clawd: runs while Claude works. Otherwise it sweats while a rate limit is at 95% or more, falls asleep after 10 quiet minutes, and cheers when your commits are pushed.
  • Actions: a row under the card sends a prompt as if you typed it: push (commit and push), find bugs, run tests and summarize. quick commit has Haiku write a message from the diff and shows it: commit, commit and push, or type your own; it then commits itself, without a turn of the main model. Click one, or focus the band with ctrl+x tab, move to it and press Enter.
  • Git switches: commit auto · push ask, kept per repo. On ask, Claude's git add or commit, or push, waits for your OK. On auto Claude also does it on its own: it commits each finished change, and pushes right after. It runs without a prompt, but only in its plain form, naming its repo with -C: git -C '/abs/path' add <files>, git -C '/abs/path' commit -m '…' and git -C '/abs/path' push [remote] [branch], joined by &&. Any other shape asks whatever the switch says: a step without -C (the Bash tool keeps its own folder between calls), a force push, a heredoc, $(…), a cd, a pipe, a wrapper such as env or xargs, or an alias that commits or pushes. Nothing is allowed in plan mode. Steps that only read (status, log, diff, show, with flags that only shape their output) may ride along. When a step asks, a line under the dialog says what it takes with it. The system prompt tells Claude the plain form and where each switch stands. Click commit or push to flip it.
  • Spotify (macOS): off until you click spotify beside the git switches (spotify off, then on, kept across sessions). While it is off, nothing asks Spotify anything. When it is on and Spotify runs, a card framed in Spotify green under the band shows the state and the track, ◀◀ ❚❚ ▶▶, progress with the time, shuffle, repeat and volume − +, and the track heard before it (kept across sessions). With lyrics on (beside spotify, on by default), the card also shows the line being sung, bright, and the next one dim, in time with the song; they come from LRCLIB (lrclib.net), and a track it has no synced lyrics for shows none. search (or /spotify-search) opens a pane that searches Spotify and plays the track you pick, keeping the terminal in front, once spotifyClientId and the client secret are set. Beatbot, a little Spotify mascot drawn in pixels, dances under Clawd while a track plays, and falls asleep with Z's once a track has been paused 10 minutes. It asks Spotify through AppleScript every 5 seconds and never launches it. The playing playlist is not shown: Spotify gives it only through its Web API, which needs a sign-in.
  • Minimize: minimize on the bottom edge of either card shrinks it to one line from the band's left edge. The main card keeps the repo and branch, model, limits and context as percents, the first git fact and the session cost; the Spotify card keeps the controls, the track and the time. expand brings it back. Each card remembers its choice across sessions.
  • Extras: hover a rate limit for its pace. Click 30d, or run /usage-history, for a pane with each day's cost and tokens. Toasts fire when a limit passes 80% and 95%, and when its pace would run it out before the reset.

Needs Claude Code v2.1.287 or later.

Install

/plugin marketplace add AsyrafHussin/claude-code-statusline
/plugin install statusline-band@claude-code-statusline

Settings

Each is a row in /config, or run /plugin configure statusline-band@claude-code-statusline.

| Setting | Default | What it does | |---------|---------|--------------| | initials | empty | Up to two letters on Clawd's shirt | | cardColor | #0a0a0a | Background of the band; empty ("") for none, so it takes the terminal's own | | padRows | 1 | Empty rows above and below the stats, 0 to 2 | | historyDays | 30 | Days the rolling cost and the history pane cover, 7 to 62 | | noAttribution | false | Leave Co-Authored-By, Claude-Session and the Claude Code footer out of commits and pull requests | | gitStrict | true | On: with a git switch on auto, only plain commands naming their repo with -C run without a prompt. Off: any git command runs without a prompt while the repo's switch is on auto | | spotify | true | While Spotify runs, show what it plays under the band, with Beatbot dancing, a progress bar and controls (macOS) | | plan | empty | Your Claude plan as shown, such as Max 20x; empty reads it from Claude Code's own ~/.claude.json (updated when Claude Code starts or signs in) | | spotifyClientId | empty | Client ID of your own app at developer.spotify.com/dashboard, for searching Spotify | | spotifyClientSecret | empty | Client secret of that app. /config leaves secret settings out, so keep it in the macOS Keychain instead: security add-generic-password -U -s statusline-band-spotify -a client-secret -w (it asks for the secret, hidden) |

What it runs, reads, keeps and sends

Programs it runs

It runs these programs, never through a shell. The arguments are fixed except the folder (each git command runs in the repo's folder, git -C <folder>), for quick commit the commit message you approved, and for a searched track its Spotify URI (checked to be spotify:track: and letters and digits only).

  • git, read-only, to show the branch and its changes (each in the repo's folder, git -C <folder>). It runs:

    • rev-parse --show-toplevel for the repo's root, once per folder
    • status --porcelain=v2 --branch --show-stash for the branch, its upstream, commits ahead and behind, uncommitted files and stashes
    • diff --shortstat HEAD and diff --shortstat @{upstream}...HEAD for the lines uncommitted and unpushed
    • log -1 --format=%ct for the time of the last commit

    These run every 30 seconds and after each tool call.

  • git, when a git step of Claude's asks, to say under the dialog what it takes with it: the same read-only commands, and config --get alias.<name> to see what a git alias in the command stands for.

  • git, when you press quick commit: status --porcelain, diff HEAD and log -5 --format=%s to write the message; then, once you approve it, add -A, commit -q -m <message> and, if you chose it, push. These are the only git commands it runs that change anything.

  • osascript, for Spotify: every 5 seconds, only while the spotify switch is on and Spotify runs, to read the track; on a press of a control (play, pause, skip, shuffle, repeat, volume); and when you pick a searched track, to play it and bring the app you were in back to the front.

  • security find-generic-password -s statusline-band-spotify -w, for search: when you open or use the search and the setting is empty, to read the Spotify client secret from your macOS Keychain; once it is found, it is kept until the mod reloads.

  • date, to read the local date and time (+%Y-%m-%d, and +%Y-%m-%d|%I:%M %p|%H|%M|%S). It also formats a rate limit's reset moment in your timezone (date -r <epoch>).

What it reads

  • From the session: the usage Claude Code reports (cost, context, rate limits and when they reset), the model's name, the session id and working folder, the subagents that are running, and the token counts at the end of each turn.
  • From Claude Code's own ~/.claude.json: only your account's plan type and rate-limit tier, once per load, to show the plan.
  • From Spotify, while it runs: the playing track's name, artist, album, length, position and id, and the shuffle, repeat and volume settings.
  • From your macOS Keychain: only the item statusline-band-spotify, the Spotify client secret, when you search.
  • What it never reads: the text of your prompts or Claude's replies. Of tool calls it reads only Bash commands, to find the git steps the switches cover.

What it keeps

All of it stays in the plugin's own store on your machine, nothing else:

  • each repo's git switches, by the repo's root
  • the last three Spotify tracks heard
  • the spotify and lyrics switches, on or off
  • whether each card is minimized
  • each day's cost and tokens, for the last 62 days
  • each session's last reading, for the last 100 sessions
  • rate-limit readings from the last 3 hours, used for the recent pace
  • which toasts it has already shown

What it sends

  • Prompts to Claude, only when you press an action. Each is the fixed text listed under Actions, sent to this session as if you typed it. A push still goes through your own permission rules.
  • The diff to Haiku, only when you press quick commit. Up to 24k characters of the diff, the names of new files and the last five commit subjects go to Claude's small model through Claude Code's own model call, the same way Claude Code itself talks to the model, to write the message.
  • A push, only when you choose "Commit and push" in quick commit. It runs git push itself, to the branch's upstream, with the git credentials you already have.
  • A Spotify search, only when you search. With your own app's client ID and secret, the mod asks accounts.spotify.com for an app token and api.spotify.com for up to 10 tracks matching what you typed; picking one plays it in the Spotify app through AppleScript.
  • The playing track to LRCLIB, while spotify and lyrics are on. Once per new track, its name, artist, album and length go to lrclib.net, a free open lyrics service, to get its synced lyrics. No account or key is involved. Turn lyrics off and nothing is sent.
  • Nothing else. It never fetches from git, makes no other network calls, has no telemetry, and sends nothing to any other service. Commits behind are counted against the remote as of your own last fetch or pull.

Hooks

  • tool.call: only notes the time and refreshes the panel after the call. It lets every call run unchanged and never blocks or rewrites one.
  • prompt.submit: starts Clawd's running animation. The prompt passes through unchanged.
  • turn.complete: stops the animation and adds the turn's token counts to the totals.
  • session.start: starts the panel's timers and registers /usage-history and, with spotify on, /spotify-search.
  • command.run: answers only its own /usage-history and /spotify-search commands, by opening their panes.
  • attribution.text: with noAttribution on, answers an empty commit trailer and PR footer.
  • prompt.compose: adds one section to the system prompt: the git plain form, where each switch stands, and (with noAttribution) no credit lines.
  • Action buttons: pressing one calls $.prompt.submit with its fixed prompt; nothing is sent without a press. quick commit instead sends the diff (up to 24k characters) and the last five commit subjects to Haiku through Claude Code's own model call, then runs git add -A, git commit -m and, if you choose it, git push itself.
  • classic.UserPromptSubmit, classic.PostToolUse: read the permission mode and effort; they change nothing.
  • classic.PreToolUse (Bash only): runs the hooks beneath it first (your own settings hooks among them; their ask or deny stands), then reads the command as it will run for git add, commit and push, and answers ask or allow by the repo's switches. Any other command passes on to your usual permissions untouched.
  • ui.render: draws the panel above the prompt (AbovePrompt), and the history and Spotify search panes (Pane).

其他同名作品

更多类似作品