名称:状态行自定义 描述:Claude Code 状态行配置的中心权威。涵盖自定义状态行创建、/statusline 命令、状态行设置(settings.json 中的 statusLine)、JSON 输入结构(模型、工作空间、成本、会话信息)、状态行脚本(Bash、Python、Node.js)、终端颜色代码、Git 感知状态行、辅助函数和状态行故障排除。支持创建自定义状态行、配置状态行行为和显示上下文会话信息。100% 委托给 docs-management 技能以获取官方文档。 用户可调用:false 允许工具:Read, Glob, Grep, Skill
状态行元技能
🚨 强制:首先调用 docs-management
停止 - 在提供任何关于状态行配置的响应之前:
- 调用
docs-management技能- 查询 用户的特定主题
- 基于 所有响应 EXCLUSIVELY 在加载的官方文档上
跳过此步骤会导致过时或错误的信息。
验证检查点
在响应之前,验证:
- [ ] 我是否调用了 docs-management 技能?
- [ ] 官方文档是否加载?
- [ ] 我的响应是否基于 EXCLUSIVELY 官方文档?
如果 ANY 复选框未选中,停止并首先调用 docs-management。
概述
Claude Code 状态行配置的中心权威。此技能使用 100% 委托给 docs-management - 它不包含重复的官方文档。
架构: 纯委托与关键词注册表。所有官方文档通过 docs-management 技能查询访问。
何时使用此技能
关键词: 状态行、statusline、/statusline 命令、自定义状态行、状态行配置、statusLine 设置、状态行脚本、状态行 JSON 输入、模型显示、工作空间信息、成本跟踪显示、会话信息显示、ANSI 颜色状态行、Git 感知状态行、PS1 样式提示
在以下情况下使用此技能:
- 创建自定义状态行
- 配置状态行设置
- 理解状态行 JSON 输入结构
- 编写状态行脚本(Bash、Python、Node.js)
- 添加 Git 信息到状态行
- 使用 ANSI 颜色样式化状态行
- 故障排除状态行问题
- 显示模型、成本或工作空间信息
用于 docs-management 查询的关键词注册表
查询 docs-management 技能以获取官方文档时使用这些关键词:
状态行基础
| 主题 | 关键词 |
|---|---|
| 概述 | “status line”, “statusline”, “custom status line” |
| 目的 | “status line purpose”, “contextual information display” |
| 行为 | “status line update”, “status line refresh rate” |
配置方法
| 主题 | 关键词 |
|---|---|
| 斜杠命令 | “/statusline command”, “statusline setup” |
| 设置 | “statusLine setting”, “settings.json statusLine” |
| 命令类型 | “statusLine type command”, “status line command config” |
| 填充 | “statusLine padding”, “status line edge” |
JSON 输入结构
| 主题 | 关键词 |
|---|---|
| 输入格式 | “status line JSON input”, “statusline stdin JSON” |
| 模型信息 | “status line model”, “model display_name”, “model id” |
| 工作空间信息 | “status line workspace”, “current_dir”, “project_dir” |
| 会话信息 | “status line session_id”, “transcript_path” |
| 成本信息 | “status line cost”, “total_cost_usd”, “lines_added” |
| 版本信息 | “status line version”, “output_style” |
| 上下文使用 | “used_percentage”, “remaining_percentage”, “context window usage”, “context capacity” |
脚本示例
| 主题 | 关键词 |
|---|---|
| Bash 脚本 | “status line bash script”, “statusline.sh” |
| Python 脚本 | “status line python”, “statusline python example” |
| Node.js 脚本 | “status line nodejs”, “statusline javascript” |
| 辅助函数 | “status line helper functions”, “statusline helpers” |
Git 集成
| 主题 | 关键词 |
|---|---|
| Git 感知状态 | “git-aware status line”, “git branch status line” |
| Git 分支显示 | “status line git branch”, “show git branch” |
样式和显示
| 主题 | 关键词 |
|---|---|
| ANSI 颜色 | “status line ANSI”, “status line colors”, “styling status line” |
| 表情符号 | “status line emojis”, “status line icons” |
| 简洁显示 | “status line concise”, “fit on one line” |
故障排除
| 主题 | 关键词 |
|---|---|
| 不出现 | “status line not appearing”, “statusline troubleshooting” |
| 可执行问题 | “status line chmod”, “script not executable” |
| 输出问题 | “status line stdout”, “first line output” |
| JSON 解析错误 | “status line JSON input”, “jq parsing” |
| 颜色不工作 | “status line ANSI”, “terminal colors” |
| Git 分支不显示 | “git-aware status line”, “git branch display” |
| 更新慢 | “status line update”, “rate limiting” |
| 设置未应用 | “statusLine setting”, “settings.json” |
快速决策树
你想做什么?
- 快速创建状态行 -> 查询 docs-management:“/statusline command”, “statusline setup”
- 在设置中配置状态行 -> 查询 docs-management:“statusLine setting”, “settings.json statusLine”
- 理解 JSON 输入 -> 查询 docs-management:“status line JSON input”, “statusline stdin JSON”
- 显示模型信息 -> 查询 docs-management:“status line model”, “model display_name”
- 显示成本/使用情况 -> 查询 docs-management:“status line cost”, “total_cost_usd”
- 添加 Git 分支 -> 查询 docs-management:“git-aware status line”, “git branch status line”
- 编写 Bash 脚本 -> 查询 docs-management:“status line bash script”, “statusline.sh”
- 编写 Python 脚本 -> 查询 docs-management:“status line python”, “statusline python example”
- 添加颜色 -> 查询 docs-management:“status line ANSI”, “status line colors”
- 修复状态行问题 -> 查询 docs-management:“statusline troubleshooting”, “status line not appearing”
主题覆盖
状态行配置
- 用于快速设置的 /statusline 斜杠命令
- settings.json 中的 statusLine 设置
- 命令类型配置
- 填充配置(边缘对齐)
- 脚本路径指定
JSON 输入数据
- hook_event_name(始终为 “Status”)
- session_id(当前会话标识符)
- transcript_path(转录文件路径)
- cwd(当前工作目录)
- 模型对象(id 和 display_name)
- 工作空间对象(current_dir 和 project_dir)
- 版本(Claude Code 版本)
- output_style 对象(当前样式名称)
- 成本对象(使用指标)
成本跟踪字段
- total_cost_usd(会话成本)
- total_duration_ms(会话持续时间)
- total_api_duration_ms(API 调用时间)
- total_lines_added(添加的行数)
- total_lines_removed(删除的行数)
脚本实现模式
- 使用 jq 进行 JSON 解析的 Bash
- 使用 json 模块的 Python
- 使用 JSON.parse 的 Node.js
- 复杂脚本的辅助函数模式
- 从 stdin 读取
- 输出到 stdout(仅第一行)
Git 集成模式
- 检测 Git 仓库
- 读取当前分支
- 分支显示格式化
- 非 Git 目录的错误处理
样式化方法
- ANSI 颜色代码支持
- 用于视觉指示器的表情符号使用
- 简洁格式化(一行)
- 信息密度考虑
更新行为
- 在对话消息更改时更新
- 300ms 速率限制
- stdout 的第一行成为状态文本
- ANSI 颜色代码保留
委托模式
标准查询模式
用户问:"如何创建自定义状态行?"
1. 调用 docs-management 技能
2. 使用关键词:"/statusline command", "custom status line"
3. 加载官方文档
4. 基于 EXCLUSIVELY 官方文档提供指导
多主题查询模式
用户问:"我想要一个显示 Git 分支和成本的状态行"
1. 使用多个查询调用 docs-management 技能:
- "git-aware status line", "git branch status line"
- "status line cost", "total_cost_usd"
2. 从官方文档综合指导
故障排除模式
用户报告:"我的状态行脚本不显示"
1. 调用 docs-management 技能
2. 使用关键词:"statusline troubleshooting", "status line not appearing"
3. 检查官方文档中的常见问题
4. 指导用户完成故障排除步骤
故障排除快速参考
| 问题 | 用于 docs-management 的关键词 |
|---|---|
| 状态行不出现 | “statusline troubleshooting”, “status line not appearing” |
| 脚本不可执行 | “status line chmod”, “script not executable” |
| 错误输出 | “status line stdout”, “first line output” |
| JSON 解析错误 | “status line JSON input”, “jq parsing” |
| 颜色不工作 | “status line ANSI”, “terminal colors” |
| Git 分支不显示 | “git-aware status line”, “git branch display” |
| 更新慢 | “status line update”, “rate limiting” |
| 设置未应用 | “statusLine setting”, “settings.json” |
仓库特定说明
此仓库当前不使用自定义状态行。状态行文档相关用于:
- 理解状态行自定义选项
- 为开发工作流创建潜在自定义状态行
- 理解通过 JSON 输入可用的会话信息
在处理状态行主题时,始终使用 docs-management 技能访问官方文档。
审计状态行
此技能提供由 statusline-auditor 代理用于正式审计的验证标准。
审计资源
| 资源 | 位置 | 目的 |
|---|---|---|
| 审计框架 | references/audit-framework.md |
查询指南和评分标准 |
评分类别
| 类别 | 分数 | 关键标准 |
|---|---|---|
| 脚本结构 | 25 | 有效脚本、shebang、可执行 |
| JSON 处理 | 25 | 正确 JSON 输入解析 |
| 输出格式 | 25 | 适当终端格式化、颜色 |
| 跨平台 | 25 | 在 Windows、macOS、Linux 上工作 |
阈值: 85+ = 通过,70-84 = 通过带警告,<70 = 失败
相关代理
statusline-auditor 代理(Haiku 模型)使用此技能执行正式审计:
- 通过
skills: status-line-customization自动加载此技能 - 使用审计框架和 docs-management 获取规则
- 生成结构化审计报告
- 通过
/audit-statuslines命令调用
外部技术验证
当审计使用外部技术(脚本、包、运行时)的状态行脚本时,审计员必须在标记发现之前使用 MCP 服务器验证声明。
需要 MCP 验证的技术:
- .NET/C# 脚本:使用 microsoft-learn + perplexity 验证
- Node.js/npm 包:使用 context7 + perplexity 验证
- Python 脚本/包:使用 context7 + perplexity 验证
- Shell 脚本:使用 perplexity 验证
- 任何版本特定声明:始终使用 perplexity 验证
验证规则:
在没有首先的情况下,永远不要将技术使用标记为不正确:
- 查询适当的 MCP 服务器以获取当前文档
- 使用 perplexity 验证最近更改(尤其是 .NET 10+)
- 在发现中记录 MCP 来源
过时数据警告:
- microsoft-learn 可能返回缓存/过时的文档
- 始终将 microsoft-learn 与 perplexity 配对进行版本验证
- 信任 perplexity 获取版本号和最近发布的功能
参考文献
官方文档(通过 docs-management 技能):
- 主要:“statusline” 文档
- 相关:“settings”, “terminal-config”, “output-styles”
仓库特定:
- 状态行设置:
.claude/settings.json(statusLine 设置) - 自定义脚本:
~/.claude/statusline.sh(用户级)
版本历史
-
v1.1.0(2026-01-16):添加了 v2.1.6+ 关键词注册表条目
- 添加上下文使用字段(used_percentage, remaining_percentage)
-
v1.0.0(2025-11-26):初始发布
- 纯委托架构
- 全面关键词注册表
- 快速决策树
- 所有状态行功能的主题覆盖
- 故障排除快速参考
最后更新
日期: 2026-01-16 模型: claude-opus-4-5-20251101