‹ 首页

writing-statuslines

@lexler · 收录于 昨天 · 上游提交 1 周前

Writes Claude Code status line scripts. Use when creating, customizing, or debugging statusline configurations.

适合你,如果你想要定制 Claude Code 的状态行显示。

/ 通过 npx 安装 校验哈希
npx oh-my-skill add lexler/skill-factory/writing-statuslines
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- lexler/skill-factory/writing-statuslines
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify lexler/skill-factory/writing-statuslines
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
223GitHub stars
~672最小装载
~2.4K含声明引用
~2.6K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 2eae60e · 表述以原文为准
它做什么

装上此技能后,Claude 能编写 Claude Code 状态行脚本,在界面底部显示模型、成本、上下文窗口等实时信息,每次对话消息变化时更新(最多每300毫秒一次),脚本只输出一行到标准输出。

什么时候触发

当用户需要创建、自定义或调试 Claude Code 的状态行配置时触发,如在 settings.json 中设置并编写脚本。

装好后可以这样说
Claude 会生成一个可执行的状态行脚本。
Claude 会检查脚本并按 JSON 输入修正。
Claude 会输出一个 Python 脚本作为状态行。
技能原文 SKILL.md作者撰写 · Apache-2.0 · 2eae60e

STARTER_CHARACTER = 📊

Setup

Update the reference docs to get the latest from Anthropic:

python ~/.claude/skills/writing-statuslines/scripts/update-docs.py
What Status Lines Are

Custom scripts that display contextual information at the bottom of Claude Code's interface. Updated when conversation messages change, at most every 300ms.

Configuration

Add to ~/.claude/settings.json (user-level) or .claude/settings.json (project-level):

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh",
    "padding": 0
  }
}

padding is optional. Set to 0 to let the status line reach the terminal edge.

How It Works
  • Claude Code passes session context as JSON via stdin to the script
  • First line of stdout becomes the status line text
  • ANSI color codes supported
  • Script must be executable (chmod +x)
  • Only stdout is used (not stderr)
JSON Input Schema

The script receives this via stdin:

{
  "hook_event_name": "Status",
  "session_id": "abc123...",
  "transcript_path": "/path/to/transcript.json",
  "cwd": "/current/working/directory",
  "model": {
    "id": "claude-opus-4-1",
    "display_name": "Opus"
  },
  "workspace": {
    "current_dir": "/current/working/directory",
    "project_dir": "/original/project/directory"
  },
  "version": "1.0.80",
  "output_style": {
    "name": "default"
  },
  "cost": {
    "total_cost_usd": 0.01234,
    "total_duration_ms": 45000,
    "total_api_duration_ms": 2300,
    "total_lines_added": 156,
    "total_lines_removed": 23
  },
  "context_window": {
    "total_input_tokens": 15234,
    "total_output_tokens": 4521,
    "context_window_size": 200000,
    "used_percentage": 42.5,
    "remaining_percentage": 57.5,
    "current_usage": {
      "input_tokens": 8500,
      "output_tokens": 1200,
      "cache_creation_input_tokens": 5000,
      "cache_read_input_tokens": 2000
    }
  }
}

context_window.current_usage may be null if no messages have been sent yet.

Key Fields
  • model.display_name — short model name ("Opus", "Sonnet")
  • workspace.current_dir / workspace.project_dir — may differ when working in subdirectories
  • cost.total_cost_usd — cumulative session cost
  • context_window.used_percentage / remaining_percentage — pre-calculated, ready to display
  • context_window.current_usage — raw token counts from the last API call
Constraints
  • Output exactly one line
  • Runs every 300ms at most — expensive operations must be cached
  • Keep it scannable: glanceable in under a second
  • Script must exit cleanly and quickly
Anti-Patterns
  • Cramming too much info — pick 3-4 data points max
  • Not consuming stdin (script must read it even if it doesn't use all fields)
  • Expensive uncached operations (git commands, API calls) on every invocation
  • Multiple output lines (only first line is used)
  • Forgetting chmod +x
  • Writing to stderr instead of stdout
Testing

Test scripts manually with mock JSON:

echo '{"model":{"display_name":"Sonnet"},"workspace":{"current_dir":"/test"},"cost":{"total_cost_usd":0.05},"context_window":{"used_percentage":42.5}}' | ./statusline.sh
Reference
  • [references/anthropic-statusline.md](references/anthropic-statusline.md) - Complete reference with examples in bash, python, and node
按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。