SuperAPI AI Directory

init-claude-code-statusline

Coding & development

View repository

Updated 10-16 06:52

About this skill

Initialize Claude Code status bar configuration

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:

  1. Color support: use ANSI color codes to beautify output
  2. jq compatible: automatically detect jq availability, gracefully degrade
  3. Git integration: display the current branch or commit hash
  4. Context calculation: calculate and display the remaining context window percentage
  5. Color coding: dynamically adjust colors based on the remaining context amount

2. Execution flow

Step 1: Check the target directory

  1. Check whether the project root directory has a .claude/ directory
  2. If it does not exist, create the .claude/ directory

Step 2: Handle settings.json

  1. Check whether the .claude/settings.json file exists
  2. If it exists:
    • Use the AskUserQuestion tool to ask the user to choose an operation method:
      • Merge configuration: keep the existing configuration and only add/update the statusLine configuration item
      • Full overwrite: completely replace the existing file with the template
      • Skip: do not modify this file
  3. If it does not exist:
    • Directly use the template to create the file

Step 3: Handle statusline.sh

  1. Check whether the .claude/statusline.sh file exists
  2. If it exists:
    • Use the AskUserQuestion tool to ask the user whether to overwrite
  3. If it does not exist:
    • Create the file directly using the template

Step 4: Verify the configuration

  1. Confirm that .claude/settings.json file format is correct (valid JSON)
  2. Confirm that .claude/statusline.sh file 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.json exists
    • .claude/statusline.sh exists
  • 3. JSON format is correct:settings.json can be parsed correctly
  • 4. Script is executable:statusline.sh contains the correct shebang (#!/bin/bash)
  • 5. Function verification: After restarting Claude Code, the status line displays normally

4. Notes

Execution requirements

  1. Directory creation: If the .claude/ directory does not exist, it must be created first
  2. Ask for confirmation: You must ask the user before overwriting existing files
  3. JSON format: Ensure that settings.json is in valid JSON format
  4. Script format: Ensure that statusline.sh retains 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

  1. Windows users: You need to ensure that bash is installed on the system (Git Bash, WSL, or another)
  2. Color support: If the terminal does not support color, you can set the NO_COLOR environment variable to disable color
  3. 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

  1. The user mentions "init-claude-code-statusline"
  2. The user mentions "initialize status line"
  3. The user mentions "configure Claude Code status line"
  4. The user mentions "update status line configuration"

Context triggers

  1. The user asks how to customize the Claude Code status line
  2. The user complains that the status line is not displaying properly
  3. The user wants to use a custom status line in a new project

Reference resources