Skip to content

Add visual status line for Claude Code#11

Merged
tyom merged 5 commits intomasterfrom
statusline
Jan 17, 2026
Merged

Add visual status line for Claude Code#11
tyom merged 5 commits intomasterfrom
statusline

Conversation

@tyom
Copy link
Owner

@tyom tyom commented Jan 17, 2026

Added status line bash script and updated the docs on how to install it.

image image

Summary by CodeRabbit

  • New Features

    • Status Line plugin shows model name and context-window usage as a 20-block visual bar (15 active + 5 reserved), with scaled percentage and colour-coded status (Grey <75%, Orange 75–93%, Red ≥94%).
  • Documentation

    • Added README with setup instructions, configuration examples and sample output.

✏️ Tip: You can customize this high-level summary in your review settings.

tyom added 2 commits January 17, 2026 14:10
- Replace token count with ASCII progress bar (■◧□)
- Show model name prefix (e.g., "Opus 4.5 | ctx")
- Color coding: grey (<60%), orange (60-80%), red (>80%)
- Hide status line when context is 0%
- Add README with setup instructions
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Adds a README and a new Bash status line script for the Claude Code Dotfiles Plugin; the README documents enabling and output format, and the script parses JSON from stdin to extract model name and context usage, computes an effective percentage, and renders a 20-character, colour-coded progress bar with percentage.

Changes

Cohort / File(s) Summary
Documentation
claude-plugin/README.md
New README documenting the Status Line feature, how to enable it via ~/<user>/.claude/settings.json (fields: type, command, padding), example output, progress bar logic (usable vs reserved squares, effective usage calculation) and colour thresholds (Grey <75%, Orange 75–93%, Red ≥94%).
Status Line Implementation
claude-plugin/statusline/statusline.sh
New Bash script reading JSON from stdin (requires jq), extracts context_window.used_percentage and model name, exits quietly if used is 0, computes EFFECTIVE_PCT (scaled against 77.5) clamped to 0–100, builds a 20-square bar (15 usable + 5 reserved with optional half-square), applies colours, and prints `

Sequence Diagram(s)

sequenceDiagram
  participant Input as JSON stdin
  participant Script as statusline.sh
  participant Terminal as Output
  Input->>Script: provide JSON (model, context_window.used_percentage)
  Script-->>Script: parse fields (jq), default values if missing
  Script-->>Script: compute EFFECTIVE_PCT (used / 77.5 * 100), clamp, derive full/half/empty squares
  Script-->>Script: assemble coloured BAR + reserved segment
  Script->>Terminal: print "<MODEL> | ctx <BAR> <PERCENT>%"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately reflects the main changes: a new visual status line feature for Claude Code, including both the bash script implementation and README documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98c0c4f and 5e24dd7.

📒 Files selected for processing (2)
  • claude-plugin/README.md
  • claude-plugin/statusline/statusline.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • claude-plugin/README.md
  • claude-plugin/statusline/statusline.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@claude-plugin/README.md`:
- Around line 31-33: Update the README color thresholds to match the
implementation logic: change the "Orange: 60-80%" line to explicitly show the
upper bound is exclusive (for example "Orange: 60-<80% (60–79%)") and clarify
the Red line to indicate it applies to >=80% (e.g., "Red: ≥80%"), so the listed
ranges for "Grey: < 60%", "Orange: 60-<80% (60–79%)", and "Red: ≥80%" accurately
reflect the script's use of `< 80` for the orange cutoff.

In `@claude-plugin/statusline/statusline.sh`:
- Around line 14-28: Clamp USED_PCT and cap computed squares to avoid negative
EMPTY_SQUARES: before calculating FULL_SQUARES/REMAINDER/HAS_HALF, clamp
USED_PCT into 0..100 (replace or assign a sanitized variable, e.g.,
SANITIZED_PCT) and then compute FULL_SQUARES from that; after computing
FULL_SQUARES, ensure FULL_SQUARES is not greater than 20 (cap to 20) and only
set HAS_HALF when FULL_SQUARES < 20 and REMAINDER >= 2.5; finally compute
EMPTY_SQUARES as max(0, 20 - FULL_SQUARES - (HAS_HALF ? 1 : 0)). Apply these
changes around the symbols USED_PCT, FULL_SQUARES, REMAINDER, HAS_HALF, BAR, and
EMPTY_SQUARES.
🧹 Nitpick comments (2)
claude-plugin/README.md (1)

25-27: Add language specifier to fenced code block.

The static analysis tool correctly flags that this code block lacks a language specifier. Since this shows example terminal output, consider using text or plaintext.

-```
+```text
 Opus 4.5 | ctx ■■■■■□□□□□□□□□□□□□□□ 25%

</blockquote></details>
<details>
<summary>claude-plugin/statusline/statusline.sh (1)</summary><blockquote>

`1-7`: **Consider validating dependencies.**

The script relies on `jq` and `bc` which may not be installed on all systems. Consider adding a check or documenting the dependencies.

<details>
<summary>🔧 Optional: Add dependency check</summary>

```diff
 #!/bin/bash
+# Dependencies: jq, bc
+command -v jq >/dev/null 2>&1 || { echo "jq required" >&2; exit 1; }
+command -v bc >/dev/null 2>&1 || { echo "bc required" >&2; exit 1; }
+
 # Read JSON input from stdin
 input=$(cat)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55fc15e and c26ebee.

📒 Files selected for processing (2)
  • claude-plugin/README.md
  • claude-plugin/statusline/statusline.sh
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-01T21:11:09.058Z
Learnt from: tyom
Repo: tyom/dotfiles PR: 6
File: scripts/setup.sh:33-41
Timestamp: 2026-01-01T21:11:09.058Z
Learning: In dotfiles repositories, when running installers during setup (e.g., Volta or similar tools) from shell scripts, pass the appropriate skip/setup flag (such as --skip-setup or an equivalent) to avoid modifying shell profiles. Shell configuration should be managed centrally in the version-controlled dotfiles, so external modifications should be prevented or minimized by default. Ensure setup.sh and related scripts do not alter shell init files outside the repo.

Applied to files:

  • claude-plugin/statusline/statusline.sh
🪛 markdownlint-cli2 (0.18.1)
claude-plugin/README.md

25-25: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (1)
claude-plugin/statusline/statusline.sh (1)

33-44: LGTM!

The colour logic correctly implements the threshold rules, and the printf formatting handles the output well. The use of ANSI escape codes for terminal colours is appropriate.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

- Clamp percentage to 0-100 range to handle overflow
- Cap full squares at 20 to prevent negative empty squares
- Only add half square when room available
- Update README with precise threshold ranges (60–79%, ≥80%)
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@claude-plugin/README.md`:
- Around line 25-27: The fenced code block in README.md lacks a language
specifier which triggers MD040; update the example fence around "Opus 4.5 | ctx
■■■■■□□□□□□□□□□□□□□□ 25%" by adding a language token (e.g., use "text" or
"console") after the opening ``` so the block becomes a fenced code block with a
language and satisfies the linter.

In `@claude-plugin/statusline/statusline.sh`:
- Around line 47-58: The color selection and printed percentage should use the
clamped value instead of the raw USED_PCT: change the comparison logic that sets
COLOR to compare CLAMPED_PCT (not USED_PCT) and update the printf to print
CLAMPED_PCT (not USED_PCT); keep BAR as-is (it’s already from CLAMPED_PCT), and
ensure variables referenced are COLOR, CLAMPED_PCT, USED_PCT, BAR, and the
printf call so the display and colour remain consistent for out-of-range inputs.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c26ebee and 13b9834.

📒 Files selected for processing (2)
  • claude-plugin/README.md
  • claude-plugin/statusline/statusline.sh
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-01T21:11:09.058Z
Learnt from: tyom
Repo: tyom/dotfiles PR: 6
File: scripts/setup.sh:33-41
Timestamp: 2026-01-01T21:11:09.058Z
Learning: In dotfiles repositories, when running installers during setup (e.g., Volta or similar tools) from shell scripts, pass the appropriate skip/setup flag (such as --skip-setup or an equivalent) to avoid modifying shell profiles. Shell configuration should be managed centrally in the version-controlled dotfiles, so external modifications should be prevented or minimized by default. Ensure setup.sh and related scripts do not alter shell init files outside the repo.

Applied to files:

  • claude-plugin/statusline/statusline.sh
🪛 markdownlint-cli2 (0.18.1)
claude-plugin/README.md

25-25: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Display reserved context as shaded blocks (▨) in dark gray to visualize
the 22.5% auto-compact buffer. Percentage now reflects usable context
rather than total, giving accurate warning before auto-compact triggers.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@claude-plugin/statusline/statusline.sh`:
- Around line 1-12: The script uses jq to populate USED_PCT and MODEL (see the
jq calls around those variable assignments) but has no dependency documentation
or runtime check; update the project README to list jq as a required tool and
modify statusline.sh to fail fast if jq is missing (e.g., check via command -v
jq or type jq and print a clear error to stderr and exit non-zero before the
lines that compute USED_PCT and MODEL), so the script does not fail silently
when jq is unavailable.
🧹 Nitpick comments (3)
claude-plugin/statusline/statusline.sh (1)

55-68: Colour thresholds now use EFFECTIVE_PCT consistently.

The colour logic and final printf both use EFFECTIVE_PCT, which resolves the previous review concern about inconsistency. The thresholds (75%, 94%) align with the documented behaviour.

One minor point: the comment on Line 56 states "60%/75%/80% of total context" but should read "~58%/~58-72%/~73%+ of total" to match the README. This is cosmetic but could cause confusion.

📝 Suggested comment clarification
 # Color based on effective usage (grey < 75%, orange 75-94%, red >= 94%)
-# These thresholds correspond to 60%/75%/80% of total context
+# These thresholds correspond to ~58%/~58-72%/~73%+ of total context
claude-plugin/README.md (2)

1-21: Documentation is clear and provides useful setup instructions.

The configuration example is well-structured. However, the hardcoded path ~/Code/dotfiles/claude-plugin/statusline/statusline.sh is user-specific and may not apply to other users of these dotfiles.

Consider using a relative path or a placeholder to make it more generic.

📝 Suggested change for portability
 {
   "statusLine": {
     "type": "command",
-    "command": "~/Code/dotfiles/claude-plugin/statusline/statusline.sh",
+    "command": "<path-to-dotfiles>/claude-plugin/statusline/statusline.sh",
     "padding": 0
   }
 }

23-35: Output example and colour thresholds are well-documented.

The explanation of usable vs reserved squares and the effective usage calculation is helpful. The colour thresholds now correctly reflect the implementation with proper boundary notation (≥ for red).

One minor discrepancy: the script requires jq to parse JSON input, but this dependency is not mentioned in the README. Consider adding a prerequisites section.

📝 Suggested addition for dependencies
 ## Status Line

 A custom status bar showing model name and context usage with a visual progress bar.

+### Prerequisites
+
+- `jq` - JSON processor (install via `brew install jq` or your package manager)
+
 ### Enable
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13b9834 and 98c0c4f.

📒 Files selected for processing (2)
  • claude-plugin/README.md
  • claude-plugin/statusline/statusline.sh
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-01T21:11:09.058Z
Learnt from: tyom
Repo: tyom/dotfiles PR: 6
File: scripts/setup.sh:33-41
Timestamp: 2026-01-01T21:11:09.058Z
Learning: In dotfiles repositories, when running installers during setup (e.g., Volta or similar tools) from shell scripts, pass the appropriate skip/setup flag (such as --skip-setup or an equivalent) to avoid modifying shell profiles. Shell configuration should be managed centrally in the version-controlled dotfiles, so external modifications should be prevented or minimized by default. Ensure setup.sh and related scripts do not alter shell init files outside the repo.

Applied to files:

  • claude-plugin/statusline/statusline.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (3)
claude-plugin/statusline/statusline.sh (3)

14-22: Effective percentage calculation is well-designed.

The logic correctly scales the raw usage against the 77.5% auto-compact threshold and clamps EFFECTIVE_PCT to 100. The separate CLAMPED_PCT for bar calculation (clamped to 0–77.5) is also appropriate.

Minor nit: the scale=2 in Line 16 produces up to 2 decimal places, but Line 22 may produce more precision. This inconsistency is harmless since the final output uses %.0f, but could be tidied for clarity.


24-42: Bar calculation handles edge cases correctly.

The clamping of FULL_SQUARES to 15, the conditional half-square logic, and the safeguard for negative EMPTY_SQUARES are all sensible. This addresses the overflow concern raised in prior reviews.


44-53: Bar construction is clear and functional.

The loop-based approach for building the progress bar string works correctly. The use of Unicode characters (■, ◧, □) provides a clean visual representation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Repository owner deleted a comment from coderabbitai bot Jan 17, 2026
@tyom tyom merged commit 3fe92d2 into master Jan 17, 2026
3 checks passed
@tyom tyom deleted the statusline branch January 17, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant