This skill is used to initialize, update, or fully overwrite the Claude Code status bar configuration in any project. Through preset template files, it helps users quickly set up a feature-rich status bar display.
Status Bar Feature Description
After configuration is complete, the Claude Code status bar will display the following information:
| Display Item | Icon | Description |
|---|---|---|
| Current Directory | None | Display the working directory path (~ replaces the user home directory) |
| Git Branch | 🌿 | Display the current Git branch name |
| Model Name | 🤖 | Display the Claude model currently in use |
| Version Number | v | Display the Claude Code version |
| Context Window | 🧠 | Display the remaining context window percentage (color-coded) |
Context Window Color Description
- Green: remaining > 40%, sufficient context
- Yellow: remaining 20% - 40%, moderate context
- Red: remaining < 20%, insufficient context
Skill Directory Structure
init-claude-code-statusline/
├── SKILL.md # 技能说明文件
└── templates/ # 模板文件目录
├── settings.json # Claude Code 设置文件模板
└── statusline.sh # 状态栏脚本模板
1. Configuration files that must be created/modified
1.1. Create .claude/settings.json
Copy from template: see templates/settings.json
Template content:
{
"statusLine": {
"type": "command",
"command": "bash .claude/statusline.sh",
"padding": 0
}
}
1.2. Create .claude/statusline.sh
Copy from template: see templates/statusline.sh
Template feature description:
- Color support: use ANSI color codes to beautify output
- jq compatible: automatically detect jq availability, gracefully degrade
- Git integration: display the current branch or commit hash
- Context calculation: calculate and display the remaining context window percentage
- Color coding: dynamically adjust colors based on the remaining context amount
2. Execution flow
Step 1: Check the target directory
- Check whether the project root directory has a
.claude/directory - If it does not exist, create the
.claude/directory
Step 2: Handle settings.json
- Check whether the
.claude/settings.jsonfile exists - If it exists:
- Use the
AskUserQuestiontool to ask the user to choose an operation method:- Merge configuration: keep the existing configuration and only add/update the
statusLineconfiguration item - Full overwrite: completely replace the existing file with the template
- Skip: do not modify this file
- Merge configuration: keep the existing configuration and only add/update the
- Use the
- If it does not exist:
- Directly use the template to create the file
Step 3: Handle statusline.sh
- Check whether the
.claude/statusline.shfile exists - If it exists:
- Use the
AskUserQuestiontool to ask the user whether to overwrite
- Use the
- If it does not exist:
- Create the file directly using the template
Step 4: Verify the configuration
- Confirm that
.claude/settings.jsonfile format is correct (valid JSON) - Confirm that
.claude/statusline.shfile exists and has the correct shebang
3. Self-check list
After completing initialization, check the following items one by one:
- 1. Directory exists:
.claude/directory has been created - 2. Configuration file exists:
-
.claude/settings.jsonexists -
.claude/statusline.shexists
-
- 3. JSON format is correct:
settings.jsoncan be parsed correctly - 4. Script is executable:
statusline.shcontains the correct shebang (#!/bin/bash) - 5. Function verification: After restarting Claude Code, the status line displays normally
4. Notes
Execution requirements
- Directory creation: If the
.claude/directory does not exist, it must be created first - Ask for confirmation: You must ask the user before overwriting existing files
- JSON format: Ensure that
settings.jsonis in valid JSON format - Script format: Ensure that
statusline.shretains the correct shebang (#!/bin/bash)
Dependency notes
The status line script has optional dependencies on the following tools:
| Tool | Required | Description |
|---|---|---|
| bash | Yes | Script runtime environment |
| git | No | Used to display Git branch information |
| jq | No | Used to parse JSON input; degrades gracefully if absent |
Compatibility notes
- Windows users: You need to ensure that bash is installed on the system (Git Bash, WSL, or another)
- Color support: If the terminal does not support color, you can set the
NO_COLORenvironment variable to disable color - jq missing: The script automatically detects jq availability and uses default values when it is missing
5. Trigger scenarios
This skill should be used in the following scenariosactively invoked:
Explicit triggers
- The user mentions "init-claude-code-statusline"
- The user mentions "initialize status line"
- The user mentions "configure Claude Code status line"
- The user mentions "update status line configuration"
Context triggers
- The user asks how to customize the Claude Code status line
- The user complains that the status line is not displaying properly
- The user wants to use a custom status line in a new project
Reference resources
- Claude Code documentation: https://code.claude.com/docs/zh-CN/skills
- Skill best practices: https://platform.claude.com/docs/zh-CN/agents-and-tools/agent-skills/best-practices