Skip to content

Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.

Add ContextBricks - Custom Status Line for Claude Code CLI

Jezc4351a7267fe
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 378c6414..8b01a28f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added - ContextBricks NPM Package 🎨🧱
+
+**Date**: 2025-11-10
+
+**New Tool**: `contextbricks` - Custom status line for Claude Code CLI
+
+**NPM Package**: https://www.npmjs.com/package/contextbricks
+**Version**: 1.0.0
+**Install**: `npx contextbricks init`
+
+**Features**:
+- **Real-time context tracking** from Claude Code transcript files
+- **Brick visualization** showing token usage breakdown
+- **Git integration**: repo:branch [commit] message | github-repo *↑↓
+- **Session metrics**: model name, lines changed, free space
+- **Model-aware**: Automatic context limits (200k Sonnet, 1M Opus)
+
+**Distribution Methods**:
+1. **NPM** (recommended): `npx contextbricks init`
+2. **From source**: `cd tools/statusline && ./install.sh`
+
+**Files Added**:
+- `tools/statusline-npm/` - NPM package structure
+ - `package.json` - NPM configuration
+ - `bin/cli.js` - Node wrapper (dependency checking, commands)
+ - `scripts/` - Bash scripts (statusline, install, uninstall)
+ - `README.md` - NPM-specific documentation
+- `tools/statusline/` - Source implementation
+ - `statusline.sh` - Main status line script (198 lines)
+ - `install.sh` - Automated installer with backups
+ - `uninstall.sh` - Clean uninstaller
+ - `README.md` - Full documentation
+
+**Installation**:
+```bash
+# Quick install via npm
+npx contextbricks init
+
+# Or from source
+cd tools/statusline
+./install.sh
+```
+
+**Token Accuracy**: Matches /context command output (parses same JSONL transcript files)
+
+**Community References**:
+- Implementation approach: [codelynx.dev](https://codelynx.dev/posts/calculate-claude-code-context)
+- Inspired by: [ccstatusline](https://github.com/sirmalloc/ccstatusline)
+
+**Documentation**:
+- NPM: [npmjs.com/package/contextbricks](https://www.npmjs.com/package/contextbricks)
+- Full docs: [tools/statusline/README.md](tools/statusline/README.md)
+
### Removed - auth-js skill (deprecated) ❌
**Date**: 2025-11-08
diff --git a/README.md b/README.md
index f850fd33..5e847ee7 100644
--- a/README.md
+++ b/README.md
@@ -632,6 +632,36 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
---
+## 🧰 Tools & Utilities
+
+### ContextBricks - Custom Status Line
+
+Enhanced status line for Claude Code with **real-time context tracking** and git integration.
+
+[![npm version](https://img.shields.io/npm/v/contextbricks.svg)](https://www.npmjs.com/package/contextbricks)
+
+**Features:**
+- Real token usage from transcript files (matches /context command)
+- Brick visualization showing context breakdown
+- Git info: repo:branch [commit] message | github-repo *↑↓
+- Model name, lines changed, free space
+
+**Installation:**
+```bash
+# Quick install via npm
+npx contextbricks init
+
+# Or from source
+cd tools/statusline
+./install.sh
+```
+
+**NPM Package**: [contextbricks](https://www.npmjs.com/package/contextbricks)
+
+See [tools/statusline/README.md](tools/statusline/README.md) for full documentation.
+
+---
+
## πŸ“‹ Skill Categories
All 60 skills are production-ready and organized by domain:
diff --git a/tools/statusline-npm/LICENSE b/tools/statusline-npm/LICENSE
new file mode 100644
index 00000000..6ea2e76c
--- /dev/null
+++ b/tools/statusline-npm/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Jeremy Dawes (Jezweb)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/tools/statusline-npm/README.md b/tools/statusline-npm/README.md
new file mode 100644
index 00000000..9fa4a31a
--- /dev/null
+++ b/tools/statusline-npm/README.md
@@ -0,0 +1,171 @@
+# 🧱 ContextBricks
+
+**Real-time context tracking with brick visualization for Claude Code CLI**
+
+[![npm version](https://img.shields.io/npm/v/contextbricks.svg)](https://www.npmjs.com/package/contextbricks)
+[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
+
+A custom status line for Claude Code that displays accurate token usage with a beautiful brick visualization, plus git integration and session metrics.
+
+![Status Line Example](https://via.placeholder.com/800x80/1a1a1a/00ff00?text=Screenshot+Coming+Soon)
+
+## ✨ Features
+
+- 🎯 **Real-time context tracking** from Claude Code transcript files
+- 🧱 **Brick visualization** showing token breakdown by category
+- πŸ”§ **Git integration**: repo:branch [commit] message | github-repo *↑↓
+- πŸ“Š **Session metrics**: model name, lines changed, free space
+- 🎨 **Model-aware**: Automatic context limits (200k Sonnet, 1M Opus)
+- ⚑ **Zero config**: Auto-detects everything, just install and go
+
+## πŸš€ Quick Start
+
+```bash
+# Install and configure (one command!)
+npx contextbricks init
+
+# Restart Claude Code to see your new status line
+```
+
+That's it! Your status line now shows real-time context tracking.
+
+## πŸ“¦ Installation Options
+
+### Option 1: npx (Recommended - No Install)
+
+```bash
+npx contextbricks init
+```
+
+### Option 2: Global Install
+
+```bash
+npm install -g contextbricks
+contextbricks init
+```
+
+### Option 3: From Source
+
+```bash
+git clone https://github.com/jezweb/claude-skills
+cd claude-skills/tools/statusline
+./install.sh
+```
+
+## 🎨 What It Looks Like
+
+**Line 1: Git + Model + Changes**
+```
+[Sonnet 4.5] claude-skills:main [5f2ce67] Remove auth-js skill | jezweb/claude-skills *↑2 | +145/-23
+```
+
+**Line 2: Context Bricks + Breakdown**
+```
+ctx [β– β– β– β– β– β– β– β– β– β– β– β– β– β– β– β– β– β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 43% (86k/200k tokens) | sys:4k tools:16k mcp:2k mem:10k msg:54k | 113k free
+```
+
+**Color Legend:**
+- πŸ”² Dim white = System prompt
+- 🟨 Yellow = Tools
+- πŸŸͺ Magenta = MCP servers
+- 🟦 Blue = Memory/files
+- 🟦 Cyan = Messages
+- ⬜ Dim hollow = Free space
+
+## πŸ”§ Requirements
+
+- **Node.js** β‰₯14 (you already have this for Claude Code)
+- **jq** - JSON processor
+ ```bash
+ sudo apt install jq # Ubuntu/Debian
+ brew install jq # macOS
+ ```
+- **git** (optional) - For git info display
+
+## πŸ“š Commands
+
+```bash
+contextbricks init # Interactive install (recommended)
+contextbricks install # Install status line
+contextbricks uninstall # Uninstall status line
+contextbricks --help # Show help
+contextbricks --version # Show version
+```
+
+## 🎯 How It Works
+
+ContextBricks reads Claude Code's session transcript files (JSONL format) to get **real token usage** - the same data that the `/context` command shows.
+
+Each assistant message includes cumulative token counts:
+- `input_tokens` - New input
+- `cache_read_input_tokens` - Cached tokens reused
+- `cache_creation_input_tokens` - New cache entries
+- `output_tokens` - Claude's response
+
+The brick visualization shows proportional usage across categories, and git info is queried from your workspace.
+
+## πŸ”„ Updates
+
+```bash
+# If installed globally
+npm update -g contextbricks
+
+# If using npx
+npx contextbricks@latest init
+```
+
+## πŸ› Troubleshooting
+
+### Status line shows 0% (0k/200k tokens)
+
+**Cause**: jq not installed or transcript file not found
+
+**Fix**:
+```bash
+# Check jq
+which jq || sudo apt install jq
+
+# Test manually
+contextbricks install
+```
+
+### Git info not showing
+
+**Cause**: Not in a git repository
+
+**Fix**: Initialize git or cd into a git repo
+
+### Brick visualization looks wrong
+
+**Cause**: Terminal color support
+
+**Fix**: Ensure your terminal supports 256 colors
+```bash
+export TERM=xterm-256color
+```
+
+## 🀝 Contributing
+
+Found a bug or have a feature request?
+
+- GitHub: https://github.com/jezweb/claude-skills
+- Issues: https://github.com/jezweb/claude-skills/issues
+
+## πŸ“„ License
+
+MIT License - See [LICENSE](./LICENSE)
+
+## πŸ™ Credits
+
+- Part of the [claude-skills](https://github.com/jezweb/claude-skills) collection
+- Inspired by [ccstatusline](https://github.com/sirmalloc/ccstatusline)
+- Token parsing approach from [codelynx.dev](https://codelynx.dev/posts/calculate-claude-code-context)
+
+## πŸ“– Full Documentation
+
+For complete documentation, customization options, and advanced usage, see:
+[Full Documentation](https://github.com/jezweb/claude-skills/tree/main/tools/statusline)
+
+---
+
+**Made with ❀️ for the Claude Code community**
diff --git a/tools/statusline-npm/bin/cli.js b/tools/statusline-npm/bin/cli.js
new file mode 100755
index 00000000..1ef5c3b4
--- /dev/null
+++ b/tools/statusline-npm/bin/cli.js
@@ -0,0 +1,107 @@
+#!/usr/bin/env node
+
+const { spawnSync } = require('child_process');
+const path = require('path');
+const fs = require('fs');
+
+const command = process.argv[2];
+const scriptsDir = path.join(__dirname, '../scripts');
+
+// Colors for terminal output
+const colors = {
+ reset: '\x1b[0m',
+ red: '\x1b[31m',
+ green: '\x1b[32m',
+ yellow: '\x1b[33m',
+ cyan: '\x1b[36m',
+};
+
+// Check for jq dependency
+function checkDependencies() {
+ const jqCheck = spawnSync('which', ['jq'], { encoding: 'utf-8' });
+ if (jqCheck.status !== 0) {
+ console.error(`${colors.red}❌ Error: jq is required but not installed.${colors.reset}`);
+ console.error(` ${colors.cyan}Install with:${colors.reset}`);
+ console.error(` sudo apt install jq ${colors.yellow}# Ubuntu/Debian${colors.reset}`);
+ console.error(` brew install jq ${colors.yellow}# macOS${colors.reset}`);
+ console.error(` yum install jq ${colors.yellow}# RHEL/CentOS${colors.reset}`);
+ process.exit(1);
+ }
+
+ const gitCheck = spawnSync('which', ['git'], { encoding: 'utf-8' });
+ if (gitCheck.status !== 0) {
+ console.warn(`${colors.yellow}⚠️ Warning: git not found. Git info will not be available.${colors.reset}`);
+ }
+}
+
+// Display help
+function showHelp() {
+ console.log(`
+${colors.cyan}🧱 ContextBricks${colors.reset} - Claude Code Status Line
+
+${colors.green}Usage:${colors.reset}
+ contextbricks init Interactive install
+ contextbricks install Install status line
+ contextbricks uninstall Uninstall status line
+ contextbricks --help Show this help
+ contextbricks --version Show version
+
+${colors.green}Quick Start:${colors.reset}
+ npx contextbricks init
+
+${colors.green}Features:${colors.reset}
+ β€’ Real-time context tracking from transcript files
+ β€’ Brick visualization showing token breakdown
+ β€’ Git integration (repo, branch, commit, status)
+ β€’ Model-aware context limits (200k Sonnet, 1M Opus)
+ β€’ Session metrics (lines changed, free space)
+
+${colors.green}More Info:${colors.reset}
+ GitHub: https://github.com/jezweb/claude-skills/tree/main/tools/statusline
+ Issues: https://github.com/jezweb/claude-skills/issues
+`);
+}
+
+// Main command handler
+function main() {
+ switch (command) {
+ case 'install':
+ case 'init':
+ checkDependencies();
+ const installResult = spawnSync('bash', [path.join(scriptsDir, 'install.sh')], {
+ stdio: 'inherit',
+ env: { ...process.env, NPM_INSTALL: '1' }
+ });
+ process.exit(installResult.status || 0);
+ break;
+
+ case 'uninstall':
+ const uninstallResult = spawnSync('bash', [path.join(scriptsDir, 'uninstall.sh')], {
+ stdio: 'inherit',
+ env: { ...process.env, NPM_INSTALL: '1' }
+ });
+ process.exit(uninstallResult.status || 0);
+ break;
+
+ case '--version':
+ case '-v':
+ const packageJson = require('../package.json');
+ console.log(`contextbricks v${packageJson.version}`);
+ break;
+
+ case '--help':
+ case '-h':
+ case 'help':
+ showHelp();
+ break;
+
+ default:
+ if (command) {
+ console.error(`${colors.red}❌ Unknown command: ${command}${colors.reset}\n`);
+ }
+ showHelp();
+ process.exit(command ? 1 : 0);
+ }
+}
+
+main();
diff --git a/tools/statusline-npm/package.json b/tools/statusline-npm/package.json
new file mode 100644
index 00000000..8c394544
--- /dev/null
+++ b/tools/statusline-npm/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "contextbricks",
+ "version": "1.0.0",
+ "description": "Real-time context tracking with brick visualization for Claude Code CLI",
+ "keywords": [
+ "claude",
+ "claude-code",
+ "statusline",
+ "cli",
+ "context",
+ "bricks",
+ "git",
+ "tokens",
+ "terminal",
+ "visualization"
+ ],
+ "bin": {
+ "contextbricks": "./bin/cli.js"
+ },
+ "scripts": {
+ "postinstall": "echo '\n🧱 ContextBricks installed! Run: contextbricks init\n'"
+ },
+ "files": [
+ "bin/",
+ "scripts/",
+ "README.md",
+ "LICENSE"
+ ],
+ "engines": {
+ "node": ">=14"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/jezweb/claude-skills.git",
+ "directory": "tools/statusline-npm"
+ },
+ "bugs": {
+ "url": "https://github.com/jezweb/claude-skills/issues"
+ },
+ "author": "Jeremy Dawes <[email protected]> (https://jezweb.com.au)",
+ "license": "MIT",
+ "homepage": "https://github.com/jezweb/claude-skills/tree/main/tools/statusline"
+}
diff --git a/tools/statusline-npm/scripts/install.sh b/tools/statusline-npm/scripts/install.sh
new file mode 100755
index 00000000..3735613c
--- /dev/null
+++ b/tools/statusline-npm/scripts/install.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+# Claude Code Status Line - Installation Script
+# Installs custom status line with real-time context tracking and git info
+
+set -e
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+STATUSLINE_SCRIPT="$SCRIPT_DIR/statusline.sh"
+INSTALL_PATH="$HOME/.claude/statusline.sh"
+SETTINGS_FILE="$HOME/.claude/settings.json"
+BACKUP_SUFFIX=".backup-$(date +%Y%m%d-%H%M%S)"
+
+echo "πŸš€ Installing Claude Code Custom Status Line..."
+echo ""
+
+# Check dependencies
+echo "Checking dependencies..."
+if ! command -v jq &> /dev/null; then
+ echo "❌ Error: jq is required but not installed."
+ echo " Install with: sudo apt install jq"
+ exit 1
+fi
+
+if ! command -v git &> /dev/null; then
+ echo "⚠️ Warning: git not found. Git info will not be available."
+fi
+
+echo "βœ… Dependencies OK"
+echo ""
+
+# Backup existing statusline script if it exists
+if [[ -f "$INSTALL_PATH" ]]; then
+ echo "πŸ“¦ Backing up existing status line script..."
+ cp "$INSTALL_PATH" "${INSTALL_PATH}${BACKUP_SUFFIX}"
+ echo " Backup saved: ${INSTALL_PATH}${BACKUP_SUFFIX}"
+fi
+
+# Copy statusline script
+echo "πŸ“ Installing status line script..."
+cp "$STATUSLINE_SCRIPT" "$INSTALL_PATH"
+chmod +x "$INSTALL_PATH"
+echo " Installed: $INSTALL_PATH"
+echo ""
+
+# Update settings.json
+if [[ -f "$SETTINGS_FILE" ]]; then
+ echo "βš™οΈ Updating settings.json..."
+
+ # Backup settings
+ cp "$SETTINGS_FILE" "${SETTINGS_FILE}${BACKUP_SUFFIX}"
+ echo " Backup saved: ${SETTINGS_FILE}${BACKUP_SUFFIX}"
+
+ # Update statusLine config using jq
+ jq '.statusLine = {
+ "type": "command",
+ "command": "'"$INSTALL_PATH"'",
+ "padding": 0
+ }' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
+
+ echo " Settings updated"
+else
+ echo "βš™οΈ Creating settings.json..."
+ mkdir -p "$HOME/.claude"
+ cat > "$SETTINGS_FILE" <<EOF
+{
+ "statusLine": {
+ "type": "command",
+ "command": "$INSTALL_PATH",
+ "padding": 0
+ }
+}
+EOF
+ echo " Settings created: $SETTINGS_FILE"
+fi
+
+echo ""
+echo "βœ… Installation complete!"
+echo ""
+echo "πŸ“Š Your status line will show:"
+echo " β€’ Model name (Sonnet 4.5, Opus 4, etc.)"
+echo " β€’ Git repo:branch [commit] message"
+echo " β€’ GitHub repo name"
+echo " β€’ Git status indicators (*uncommitted, ↑ahead, ↓behind)"
+echo " β€’ Lines changed this session (+added/-removed)"
+echo " β€’ Real-time context usage with brick visualization"
+echo " β€’ Token breakdown (system, tools, MCP, memory, messages)"
+echo ""
+echo "πŸ”„ Restart Claude Code to see your new status line!"
+echo ""
+echo "ℹ️ To uninstall: ./uninstall.sh"
+echo "ℹ️ To restore backup: cp ${INSTALL_PATH}${BACKUP_SUFFIX} $INSTALL_PATH"
diff --git a/tools/statusline-npm/scripts/statusline.sh b/tools/statusline-npm/scripts/statusline.sh
new file mode 100755
index 00000000..d6b28019
--- /dev/null
+++ b/tools/statusline-npm/scripts/statusline.sh
@@ -0,0 +1,237 @@
+#!/bin/bash
+
+# Claude Code Custom Status Line with Context Brick Visualization
+# Shows: Model | Repo:Branch [commit] message | GitHub | git status | lines changed
+# Context usage as horizontal brick visualization (like /context)
+
+# Read JSON from stdin
+input=$(cat)
+
+# Parse Claude data
+model=$(echo "$input" | jq -r '.model.display_name // "Claude"' | sed 's/Claude //')
+current_dir=$(echo "$input" | jq -r '.workspace.current_dir // env.PWD')
+lines_added=$(echo "$input" | jq -r '.cost.total_lines_added // 0')
+lines_removed=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')
+
+# Get git information (change to workspace directory)
+cd "$current_dir" 2>/dev/null || cd "$HOME"
+
+# Check if we're in a git repo
+if git rev-parse --git-dir > /dev/null 2>&1; then
+ repo_name=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" || echo "")
+ branch=$(git branch --show-current 2>/dev/null || echo "detached")
+ commit_short=$(git rev-parse --short HEAD 2>/dev/null || echo "")
+ commit_msg=$(git log -1 --pretty=%s 2>/dev/null | cut -c1-40 || echo "")
+
+ # Get GitHub repo (if remote exists)
+ github_url=$(git config --get remote.origin.url 2>/dev/null)
+ if [[ $github_url =~ github.com[:/](.+/.+)(\.git)?$ ]]; then
+ github_repo="${BASH_REMATCH[1]%.git}"
+ else
+ github_repo=""
+ fi
+
+ # Git status indicators
+ git_status=""
+ if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
+ git_status="*"
+ fi
+
+ # Check ahead/behind remote
+ upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
+ if [[ -n "$upstream" ]]; then
+ ahead=$(git rev-list --count "$upstream"..HEAD 2>/dev/null || echo "0")
+ behind=$(git rev-list --count HEAD.."$upstream" 2>/dev/null || echo "0")
+ [[ "$ahead" -gt 0 ]] && git_status="${git_status}↑${ahead}"
+ [[ "$behind" -gt 0 ]] && git_status="${git_status}↓${behind}"
+ fi
+else
+ repo_name="no-repo"
+ branch=""
+ commit_short=""
+ commit_msg=""
+ github_repo=""
+ git_status=""
+fi
+
+# Build Line 1: Git + Model + Changes
+line1=""
+
+# Model in brackets
+line1+="\033[1;36m[$model]\033[0m "
+
+# Repo:Branch
+if [[ -n "$repo_name" && "$repo_name" != "no-repo" ]]; then
+ line1+="\033[1;32m$repo_name\033[0m"
+ if [[ -n "$branch" ]]; then
+ line1+=":\033[1;34m$branch\033[0m"
+ fi
+fi
+
+# Commit info
+if [[ -n "$commit_short" ]]; then
+ line1+=" [\033[1;33m$commit_short\033[0m]"
+ if [[ -n "$commit_msg" ]]; then
+ line1+=" $commit_msg"
+ fi
+fi
+
+# GitHub repo
+if [[ -n "$github_repo" ]]; then
+ line1+=" | \033[0;35m$github_repo\033[0m"
+fi
+
+# Git status indicators
+if [[ -n "$git_status" ]]; then
+ line1+=" \033[1;31m$git_status\033[0m"
+fi
+
+# Lines changed
+if [[ "$lines_added" -gt 0 || "$lines_removed" -gt 0 ]]; then
+ line1+=" | \033[0;32m+$lines_added\033[0m/\033[0;31m-$lines_removed\033[0m"
+fi
+
+# Build Line 2: Context Brick Visualization
+# Parse REAL context data from transcript file
+
+# Extract transcript path from JSON
+transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')
+
+# Get model ID for context limit detection
+model_id=$(echo "$input" | jq -r '.model.id // ""')
+
+# Determine context limit based on model
+case "$model_id" in
+ *"opus-4"*) total_tokens=1000000 ;;
+ *"sonnet-4"*|*"sonnet-3-7"*) total_tokens=200000 ;;
+ *"haiku"*) total_tokens=200000 ;;
+ *) total_tokens=200000 ;; # Default
+esac
+
+# Parse transcript for token usage (if available)
+if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then
+ # Parse JSONL transcript - get the LAST assistant message's token usage
+ # (Each message contains cumulative context, so we only need the most recent)
+ last_usage=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \
+ tail -1 | \
+ jq -r '.message.usage // null' 2>/dev/null)
+
+ if [[ -n "$last_usage" && "$last_usage" != "null" ]]; then
+ # Sum all token types from the last message
+ used_tokens=$(echo "$last_usage" | jq '
+ (.input_tokens // 0) +
+ (.cache_read_input_tokens // 0) +
+ (.cache_creation_input_tokens // 0) +
+ (.output_tokens // 0)
+ ')
+ else
+ used_tokens=0
+ fi
+
+ # Ensure we have a valid number
+ if [[ ! "$used_tokens" =~ ^[0-9]+$ ]]; then
+ used_tokens=0
+ fi
+else
+ # No transcript available (new session)
+ used_tokens=0
+fi
+
+# Estimate breakdown (rough approximation based on typical usage)
+# In future: could parse tool definitions, CLAUDE.md, etc. for accuracy
+system_tokens=$((total_tokens * 2 / 100)) # ~2% system prompt
+tools_tokens=$((total_tokens * 8 / 100)) # ~8% tools
+mcp_tokens=$((total_tokens * 1 / 100)) # ~1% MCP
+memory_tokens=$((total_tokens * 5 / 100)) # ~5% memory/files
+message_tokens=$((used_tokens - system_tokens - tools_tokens - mcp_tokens - memory_tokens))
+if [[ $message_tokens -lt 0 ]]; then
+ message_tokens=0
+fi
+
+free_tokens=$((total_tokens - used_tokens))
+
+usage_pct=$(( (used_tokens * 100) / total_tokens ))
+
+# Convert to 'k' format for display
+used_k=$(( used_tokens / 1000 ))
+total_k=$(( total_tokens / 1000 ))
+free_k=$(( free_tokens / 1000 ))
+system_k=$(( system_tokens / 1000 ))
+tools_k=$(( tools_tokens / 1000 ))
+mcp_k=$(( mcp_tokens / 1000 ))
+memory_k=$(( memory_tokens / 1000 ))
+message_k=$(( message_tokens / 1000 ))
+
+# Generate brick visualization (40 bricks total for more granularity)
+total_bricks=40
+used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))
+free_bricks=$((total_bricks - used_bricks))
+
+# Color codes for different types (matching /context)
+# System: dim (gray), Tools: yellow, MCP: magenta, Memory: blue, Messages: cyan, Free: dim white
+brick_line="ctx ["
+
+# Calculate bricks per category (proportional to actual usage)
+system_bricks=$(( (system_tokens * total_bricks) / total_tokens ))
+tools_bricks=$(( (tools_tokens * total_bricks) / total_tokens ))
+mcp_bricks=$(( (mcp_tokens * total_bricks) / total_tokens ))
+memory_bricks=$(( (memory_tokens * total_bricks) / total_tokens ))
+message_bricks=$(( (message_tokens * total_bricks) / total_tokens ))
+
+# Draw bricks by category
+brick_count=0
+
+# System bricks (dim white)
+for ((i=0; i<system_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[2;37mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Tools bricks (yellow)
+for ((i=0; i<tools_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;33mβ– \033[0m"
+ ((brick_count++))
+done
+
+# MCP bricks (magenta/pink)
+for ((i=0; i<mcp_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;35mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Memory bricks (blue)
+for ((i=0; i<memory_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;34mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Message bricks (cyan)
+for ((i=0; i<message_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;36mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Fill any remaining used bricks (in case of rounding)
+while ((brick_count < used_bricks)); do
+ brick_line+="\033[0;36mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Free bricks (dim/gray hollow squares)
+for ((i=0; i<free_bricks; i++)); do
+ brick_line+="\033[2;37mβ–‘\033[0m"
+done
+
+brick_line+="] \033[1m${usage_pct}%\033[0m (${used_k}k/${total_k}k tokens)"
+
+# Add breakdown (simplified)
+brick_line+=" | \033[2;37msys:${system_k}k\033[0m"
+brick_line+=" \033[0;33mtools:${tools_k}k\033[0m"
+brick_line+=" \033[0;35mmcp:${mcp_k}k\033[0m"
+brick_line+=" \033[0;34mmem:${memory_k}k\033[0m"
+brick_line+=" \033[0;36mmsg:${message_k}k\033[0m"
+brick_line+=" | \033[1;32m${free_k}k free\033[0m"
+
+# Output both lines
+echo -e "$line1"
+echo -e "$brick_line"
diff --git a/tools/statusline-npm/scripts/uninstall.sh b/tools/statusline-npm/scripts/uninstall.sh
new file mode 100755
index 00000000..6db23dbe
--- /dev/null
+++ b/tools/statusline-npm/scripts/uninstall.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# Claude Code Status Line - Uninstallation Script
+# Removes custom status line and optionally restores previous configuration
+
+set -e
+
+INSTALL_PATH="$HOME/.claude/statusline.sh"
+SETTINGS_FILE="$HOME/.claude/settings.json"
+
+echo "πŸ—‘οΈ Uninstalling Claude Code Custom Status Line..."
+echo ""
+
+# Find most recent backup
+LATEST_BACKUP=$(ls -t "${INSTALL_PATH}.backup-"* 2>/dev/null | head -1 || echo "")
+LATEST_SETTINGS_BACKUP=$(ls -t "${SETTINGS_FILE}.backup-"* 2>/dev/null | head -1 || echo "")
+
+# Remove statusline script
+if [[ -f "$INSTALL_PATH" ]]; then
+ echo "πŸ“ Removing status line script..."
+ rm "$INSTALL_PATH"
+ echo " Removed: $INSTALL_PATH"
+else
+ echo "⚠️ Status line script not found (already removed?)"
+fi
+
+echo ""
+
+# Ask about settings.json
+if [[ -f "$SETTINGS_FILE" ]]; then
+ echo "βš™οΈ Settings.json options:"
+ echo " 1) Remove statusLine configuration (keep other settings)"
+ echo " 2) Restore from backup (if available)"
+ echo " 3) Leave settings.json unchanged"
+ echo ""
+ read -p "Choose option [1-3]: " choice
+
+ case $choice in
+ 1)
+ echo "Removing statusLine from settings.json..."
+ jq 'del(.statusLine)' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
+ echo " StatusLine configuration removed"
+ ;;
+ 2)
+ if [[ -n "$LATEST_SETTINGS_BACKUP" ]]; then
+ echo "Restoring from backup: $LATEST_SETTINGS_BACKUP"
+ cp "$LATEST_SETTINGS_BACKUP" "$SETTINGS_FILE"
+ echo " Settings restored"
+ else
+ echo "❌ No backup found. Removing statusLine configuration instead..."
+ jq 'del(.statusLine)' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
+ fi
+ ;;
+ 3)
+ echo "Leaving settings.json unchanged"
+ ;;
+ *)
+ echo "Invalid option. Leaving settings.json unchanged"
+ ;;
+ esac
+fi
+
+echo ""
+
+# Ask about backups
+if [[ -n "$LATEST_BACKUP" ]] || [[ -n "$LATEST_SETTINGS_BACKUP" ]]; then
+ echo "πŸ“¦ Backup files found:"
+ [[ -n "$LATEST_BACKUP" ]] && echo " β€’ $LATEST_BACKUP"
+ [[ -n "$LATEST_SETTINGS_BACKUP" ]] && echo " β€’ $LATEST_SETTINGS_BACKUP"
+ echo ""
+ read -p "Delete backup files? [y/N]: " delete_backups
+
+ if [[ "$delete_backups" =~ ^[Yy]$ ]]; then
+ [[ -n "$LATEST_BACKUP" ]] && rm "${INSTALL_PATH}.backup-"* 2>/dev/null && echo " Removed script backups"
+ [[ -n "$LATEST_SETTINGS_BACKUP" ]] && rm "${SETTINGS_FILE}.backup-"* 2>/dev/null && echo " Removed settings backups"
+ else
+ echo " Backups preserved"
+ fi
+fi
+
+echo ""
+echo "βœ… Uninstallation complete!"
+echo ""
+echo "πŸ”„ Restart Claude Code for changes to take effect"
+echo ""
+echo "ℹ️ To reinstall: ./install.sh"
diff --git a/tools/statusline/README.md b/tools/statusline/README.md
new file mode 100644
index 00000000..ba515e8f
--- /dev/null
+++ b/tools/statusline/README.md
@@ -0,0 +1,274 @@
+# Claude Code Custom Status Line
+
+A custom status line for Claude Code CLI that displays real-time context tracking, git information, and session metrics with a beautiful brick visualization.
+
+![Status Line Example](https://via.placeholder.com/800x100/1a1a1a/00ff00?text=Screenshot+Coming+Soon)
+
+## ✨ Features
+
+### Real-Time Context Tracking
+- **Accurate token usage** from Claude Code's transcript files
+- **Brick visualization** showing context breakdown by category
+- **Model-aware limits** (200k for Sonnet, 1M for Opus)
+- **Token breakdown**: System, Tools, MCP, Memory, Messages
+
+### Git Integration
+- Current **repo name and branch**
+- Latest **commit hash and message**
+- **GitHub repo** name (if remote exists)
+- **Status indicators**:
+ - `*` = uncommitted changes
+ - `↑3` = ahead of remote by 3 commits
+ - `↓2` = behind remote by 2 commits
+
+### Session Metrics
+- **Model name** (Sonnet 4.5, Opus 4, Haiku, etc.)
+- **Lines changed** this session (+added/-removed)
+- **Free space** remaining in context
+
+## πŸ“¦ Installation
+
+### Quick Install (Recommended)
+
+**Via npm** (easiest):
+```bash
+npx contextbricks init
+```
+
+**Or from source**:
+```bash
+cd tools/statusline
+./install.sh
+```
+
+The installer will:
+1. Check dependencies (jq, git)
+2. Back up existing status line configuration
+3. Install the script to `~/.claude/statusline.sh`
+4. Update `~/.claude/settings.json`
+
+**NPM Package**: [contextbricks](https://www.npmjs.com/package/contextbricks) - Install with one command!
+
+### Manual Install
+
+1. Copy the script:
+ ```bash
+ cp statusline.sh ~/.claude/statusline.sh
+ chmod +x ~/.claude/statusline.sh
+ ```
+
+2. Update `~/.claude/settings.json`:
+ ```json
+ {
+ "statusLine": {
+ "type": "command",
+ "command": "/home/YOUR_USERNAME/.claude/statusline.sh",
+ "padding": 0
+ }
+ }
+ ```
+
+3. Restart Claude Code
+
+## 🎨 What It Looks Like
+
+### Line 1: Git + Model + Changes
+```
+[Sonnet 4.5] claude-skills:main [5f2ce67] Remove auth-js skill | jezweb/claude-skills *↑2 | +145/-23
+```
+
+### Line 2: Context Bricks + Breakdown
+```
+ctx [β– β– β– β– β– β– β– β– β– β– β– β– β– β– β– β– β– β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 43% (86k/200k tokens) | sys:4k tools:16k mcp:2k mem:10k msg:54k | 113k free
+```
+
+**Color Legend:**
+- πŸ”² Dim white = System prompt
+- 🟨 Yellow = Tools
+- πŸŸͺ Magenta = MCP servers
+- 🟦 Blue = Memory/files
+- 🟦 Cyan = Messages
+- ⬜ Dim hollow = Free space
+
+## πŸ”§ Requirements
+
+- **jq** - JSON processor
+ ```bash
+ sudo apt install jq # Ubuntu/Debian
+ brew install jq # macOS
+ ```
+
+- **git** (optional) - For git info display
+ ```bash
+ sudo apt install git
+ ```
+
+## πŸ“– How It Works
+
+### Context Tracking
+
+Claude Code stores session transcripts in JSONL format at:
+```
+~/.claude/projects/{project-dir}/{session-id}.jsonl
+```
+
+Each assistant message includes cumulative token usage:
+```json
+{
+ "type": "assistant",
+ "message": {
+ "usage": {
+ "input_tokens": 3,
+ "cache_read_input_tokens": 93279,
+ "cache_creation_input_tokens": 2822,
+ "output_tokens": 467
+ }
+ }
+}
+```
+
+The status line:
+1. Receives `transcript_path` from Claude Code via JSON stdin
+2. Parses the **last assistant message** (cumulative counts)
+3. Sums all token types
+4. Calculates percentage against model's context limit
+5. Generates brick visualization proportional to usage
+
+### Git Information
+
+Queries git commands in the current workspace:
+- `git rev-parse --show-toplevel` - Repo name
+- `git branch --show-current` - Current branch
+- `git rev-parse --short HEAD` - Commit hash
+- `git log -1 --pretty=%s` - Commit message
+- `git status --porcelain` - Uncommitted changes
+- `git rev-list --count` - Ahead/behind tracking
+
+## πŸ› Troubleshooting
+
+### Status line shows 0% (0k/200k tokens)
+
+**Cause**: Transcript file not found or parsing failed
+
+**Debug**:
+```bash
+# Check if jq is installed
+which jq
+
+# Test the script manually
+echo '{"transcript_path":"~/.claude/projects/test.jsonl","model":{"id":"claude-sonnet-4-5"}}' | ~/.claude/statusline.sh
+
+# Check Claude Code logs
+tail -f ~/.claude/logs/claude-code.log
+```
+
+### Brick visualization looks wrong
+
+**Cause**: Terminal color support or ANSI escape codes
+
+**Fix**:
+- Ensure your terminal supports 256 colors
+- Check `$TERM` environment variable
+- Try: `export TERM=xterm-256color`
+
+### Git info not showing
+
+**Cause**: Not in a git repository or git not installed
+
+**Fix**:
+```bash
+# Check if in git repo
+git rev-parse --git-dir
+
+# Install git
+sudo apt install git
+```
+
+### Script runs slowly
+
+**Cause**: Large transcript files (>10MB)
+
+**Optimization**: The script uses `grep | tail -1` which is fast for most cases. For very large files, consider:
+- Clearing old sessions: `rm ~/.claude/projects/*/old-session-*.jsonl`
+- Using `tail -1000` to limit parsing
+
+## πŸŽ›οΈ Customization
+
+### Change Brick Count
+
+Edit `statusline.sh` line 166:
+```bash
+total_bricks=40 # Increase for more granular visualization
+```
+
+### Adjust Token Breakdown Estimates
+
+Edit lines 140-147:
+```bash
+system_tokens=$((total_tokens * 2 / 100)) # Adjust percentages
+tools_tokens=$((total_tokens * 8 / 100))
+# ...
+```
+
+### Hide Git Status
+
+Comment out lines 84-87:
+```bash
+# if [[ -n "$git_status" ]]; then
+# line1+=" \033[1;31m$git_status\033[0m"
+# fi
+```
+
+### Compact Mode (Single Line)
+
+Comment out line 197:
+```bash
+echo -e "$line1"
+# echo -e "$brick_line" # Disable context line
+```
+
+## πŸ—‘οΈ Uninstallation
+
+```bash
+cd tools/statusline
+./uninstall.sh
+```
+
+The uninstaller will:
+1. Remove the status line script
+2. Offer to restore settings.json from backup
+3. Optionally delete backup files
+
+Manual uninstall:
+```bash
+rm ~/.claude/statusline.sh
+# Edit ~/.claude/settings.json and remove the "statusLine" section
+```
+
+## 🀝 Contributing
+
+Found a bug or have a feature request?
+
+1. Open an issue: [github.com/jezweb/claude-skills/issues](https://github.com/jezweb/claude-skills/issues)
+2. Submit a PR with improvements
+3. Share your customizations!
+
+## πŸ“„ License
+
+MIT License - See [LICENSE](../../LICENSE) file
+
+## πŸ™ Credits
+
+- Inspired by [ccstatusline](https://github.com/sirmalloc/ccstatusline)
+- Token parsing approach from [codelynx.dev](https://codelynx.dev/posts/calculate-claude-code-context)
+- Built for the [claude-skills](https://github.com/jezweb/claude-skills) repository
+
+## πŸ“š Related Resources
+
+- [Claude Code Documentation](https://code.claude.com/docs)
+- [Status Line API](https://code.claude.com/docs/en/statusline)
+- [Claude Code GitHub](https://github.com/anthropics/claude-code)
+
+---
+
+**Made with ❀️ for the Claude Code community**
diff --git a/tools/statusline/install.sh b/tools/statusline/install.sh
new file mode 100755
index 00000000..3735613c
--- /dev/null
+++ b/tools/statusline/install.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+# Claude Code Status Line - Installation Script
+# Installs custom status line with real-time context tracking and git info
+
+set -e
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+STATUSLINE_SCRIPT="$SCRIPT_DIR/statusline.sh"
+INSTALL_PATH="$HOME/.claude/statusline.sh"
+SETTINGS_FILE="$HOME/.claude/settings.json"
+BACKUP_SUFFIX=".backup-$(date +%Y%m%d-%H%M%S)"
+
+echo "πŸš€ Installing Claude Code Custom Status Line..."
+echo ""
+
+# Check dependencies
+echo "Checking dependencies..."
+if ! command -v jq &> /dev/null; then
+ echo "❌ Error: jq is required but not installed."
+ echo " Install with: sudo apt install jq"
+ exit 1
+fi
+
+if ! command -v git &> /dev/null; then
+ echo "⚠️ Warning: git not found. Git info will not be available."
+fi
+
+echo "βœ… Dependencies OK"
+echo ""
+
+# Backup existing statusline script if it exists
+if [[ -f "$INSTALL_PATH" ]]; then
+ echo "πŸ“¦ Backing up existing status line script..."
+ cp "$INSTALL_PATH" "${INSTALL_PATH}${BACKUP_SUFFIX}"
+ echo " Backup saved: ${INSTALL_PATH}${BACKUP_SUFFIX}"
+fi
+
+# Copy statusline script
+echo "πŸ“ Installing status line script..."
+cp "$STATUSLINE_SCRIPT" "$INSTALL_PATH"
+chmod +x "$INSTALL_PATH"
+echo " Installed: $INSTALL_PATH"
+echo ""
+
+# Update settings.json
+if [[ -f "$SETTINGS_FILE" ]]; then
+ echo "βš™οΈ Updating settings.json..."
+
+ # Backup settings
+ cp "$SETTINGS_FILE" "${SETTINGS_FILE}${BACKUP_SUFFIX}"
+ echo " Backup saved: ${SETTINGS_FILE}${BACKUP_SUFFIX}"
+
+ # Update statusLine config using jq
+ jq '.statusLine = {
+ "type": "command",
+ "command": "'"$INSTALL_PATH"'",
+ "padding": 0
+ }' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
+
+ echo " Settings updated"
+else
+ echo "βš™οΈ Creating settings.json..."
+ mkdir -p "$HOME/.claude"
+ cat > "$SETTINGS_FILE" <<EOF
+{
+ "statusLine": {
+ "type": "command",
+ "command": "$INSTALL_PATH",
+ "padding": 0
+ }
+}
+EOF
+ echo " Settings created: $SETTINGS_FILE"
+fi
+
+echo ""
+echo "βœ… Installation complete!"
+echo ""
+echo "πŸ“Š Your status line will show:"
+echo " β€’ Model name (Sonnet 4.5, Opus 4, etc.)"
+echo " β€’ Git repo:branch [commit] message"
+echo " β€’ GitHub repo name"
+echo " β€’ Git status indicators (*uncommitted, ↑ahead, ↓behind)"
+echo " β€’ Lines changed this session (+added/-removed)"
+echo " β€’ Real-time context usage with brick visualization"
+echo " β€’ Token breakdown (system, tools, MCP, memory, messages)"
+echo ""
+echo "πŸ”„ Restart Claude Code to see your new status line!"
+echo ""
+echo "ℹ️ To uninstall: ./uninstall.sh"
+echo "ℹ️ To restore backup: cp ${INSTALL_PATH}${BACKUP_SUFFIX} $INSTALL_PATH"
diff --git a/tools/statusline/statusline.sh b/tools/statusline/statusline.sh
new file mode 100755
index 00000000..d6b28019
--- /dev/null
+++ b/tools/statusline/statusline.sh
@@ -0,0 +1,237 @@
+#!/bin/bash
+
+# Claude Code Custom Status Line with Context Brick Visualization
+# Shows: Model | Repo:Branch [commit] message | GitHub | git status | lines changed
+# Context usage as horizontal brick visualization (like /context)
+
+# Read JSON from stdin
+input=$(cat)
+
+# Parse Claude data
+model=$(echo "$input" | jq -r '.model.display_name // "Claude"' | sed 's/Claude //')
+current_dir=$(echo "$input" | jq -r '.workspace.current_dir // env.PWD')
+lines_added=$(echo "$input" | jq -r '.cost.total_lines_added // 0')
+lines_removed=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')
+
+# Get git information (change to workspace directory)
+cd "$current_dir" 2>/dev/null || cd "$HOME"
+
+# Check if we're in a git repo
+if git rev-parse --git-dir > /dev/null 2>&1; then
+ repo_name=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" || echo "")
+ branch=$(git branch --show-current 2>/dev/null || echo "detached")
+ commit_short=$(git rev-parse --short HEAD 2>/dev/null || echo "")
+ commit_msg=$(git log -1 --pretty=%s 2>/dev/null | cut -c1-40 || echo "")
+
+ # Get GitHub repo (if remote exists)
+ github_url=$(git config --get remote.origin.url 2>/dev/null)
+ if [[ $github_url =~ github.com[:/](.+/.+)(\.git)?$ ]]; then
+ github_repo="${BASH_REMATCH[1]%.git}"
+ else
+ github_repo=""
+ fi
+
+ # Git status indicators
+ git_status=""
+ if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
+ git_status="*"
+ fi
+
+ # Check ahead/behind remote
+ upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
+ if [[ -n "$upstream" ]]; then
+ ahead=$(git rev-list --count "$upstream"..HEAD 2>/dev/null || echo "0")
+ behind=$(git rev-list --count HEAD.."$upstream" 2>/dev/null || echo "0")
+ [[ "$ahead" -gt 0 ]] && git_status="${git_status}↑${ahead}"
+ [[ "$behind" -gt 0 ]] && git_status="${git_status}↓${behind}"
+ fi
+else
+ repo_name="no-repo"
+ branch=""
+ commit_short=""
+ commit_msg=""
+ github_repo=""
+ git_status=""
+fi
+
+# Build Line 1: Git + Model + Changes
+line1=""
+
+# Model in brackets
+line1+="\033[1;36m[$model]\033[0m "
+
+# Repo:Branch
+if [[ -n "$repo_name" && "$repo_name" != "no-repo" ]]; then
+ line1+="\033[1;32m$repo_name\033[0m"
+ if [[ -n "$branch" ]]; then
+ line1+=":\033[1;34m$branch\033[0m"
+ fi
+fi
+
+# Commit info
+if [[ -n "$commit_short" ]]; then
+ line1+=" [\033[1;33m$commit_short\033[0m]"
+ if [[ -n "$commit_msg" ]]; then
+ line1+=" $commit_msg"
+ fi
+fi
+
+# GitHub repo
+if [[ -n "$github_repo" ]]; then
+ line1+=" | \033[0;35m$github_repo\033[0m"
+fi
+
+# Git status indicators
+if [[ -n "$git_status" ]]; then
+ line1+=" \033[1;31m$git_status\033[0m"
+fi
+
+# Lines changed
+if [[ "$lines_added" -gt 0 || "$lines_removed" -gt 0 ]]; then
+ line1+=" | \033[0;32m+$lines_added\033[0m/\033[0;31m-$lines_removed\033[0m"
+fi
+
+# Build Line 2: Context Brick Visualization
+# Parse REAL context data from transcript file
+
+# Extract transcript path from JSON
+transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')
+
+# Get model ID for context limit detection
+model_id=$(echo "$input" | jq -r '.model.id // ""')
+
+# Determine context limit based on model
+case "$model_id" in
+ *"opus-4"*) total_tokens=1000000 ;;
+ *"sonnet-4"*|*"sonnet-3-7"*) total_tokens=200000 ;;
+ *"haiku"*) total_tokens=200000 ;;
+ *) total_tokens=200000 ;; # Default
+esac
+
+# Parse transcript for token usage (if available)
+if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then
+ # Parse JSONL transcript - get the LAST assistant message's token usage
+ # (Each message contains cumulative context, so we only need the most recent)
+ last_usage=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \
+ tail -1 | \
+ jq -r '.message.usage // null' 2>/dev/null)
+
+ if [[ -n "$last_usage" && "$last_usage" != "null" ]]; then
+ # Sum all token types from the last message
+ used_tokens=$(echo "$last_usage" | jq '
+ (.input_tokens // 0) +
+ (.cache_read_input_tokens // 0) +
+ (.cache_creation_input_tokens // 0) +
+ (.output_tokens // 0)
+ ')
+ else
+ used_tokens=0
+ fi
+
+ # Ensure we have a valid number
+ if [[ ! "$used_tokens" =~ ^[0-9]+$ ]]; then
+ used_tokens=0
+ fi
+else
+ # No transcript available (new session)
+ used_tokens=0
+fi
+
+# Estimate breakdown (rough approximation based on typical usage)
+# In future: could parse tool definitions, CLAUDE.md, etc. for accuracy
+system_tokens=$((total_tokens * 2 / 100)) # ~2% system prompt
+tools_tokens=$((total_tokens * 8 / 100)) # ~8% tools
+mcp_tokens=$((total_tokens * 1 / 100)) # ~1% MCP
+memory_tokens=$((total_tokens * 5 / 100)) # ~5% memory/files
+message_tokens=$((used_tokens - system_tokens - tools_tokens - mcp_tokens - memory_tokens))
+if [[ $message_tokens -lt 0 ]]; then
+ message_tokens=0
+fi
+
+free_tokens=$((total_tokens - used_tokens))
+
+usage_pct=$(( (used_tokens * 100) / total_tokens ))
+
+# Convert to 'k' format for display
+used_k=$(( used_tokens / 1000 ))
+total_k=$(( total_tokens / 1000 ))
+free_k=$(( free_tokens / 1000 ))
+system_k=$(( system_tokens / 1000 ))
+tools_k=$(( tools_tokens / 1000 ))
+mcp_k=$(( mcp_tokens / 1000 ))
+memory_k=$(( memory_tokens / 1000 ))
+message_k=$(( message_tokens / 1000 ))
+
+# Generate brick visualization (40 bricks total for more granularity)
+total_bricks=40
+used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))
+free_bricks=$((total_bricks - used_bricks))
+
+# Color codes for different types (matching /context)
+# System: dim (gray), Tools: yellow, MCP: magenta, Memory: blue, Messages: cyan, Free: dim white
+brick_line="ctx ["
+
+# Calculate bricks per category (proportional to actual usage)
+system_bricks=$(( (system_tokens * total_bricks) / total_tokens ))
+tools_bricks=$(( (tools_tokens * total_bricks) / total_tokens ))
+mcp_bricks=$(( (mcp_tokens * total_bricks) / total_tokens ))
+memory_bricks=$(( (memory_tokens * total_bricks) / total_tokens ))
+message_bricks=$(( (message_tokens * total_bricks) / total_tokens ))
+
+# Draw bricks by category
+brick_count=0
+
+# System bricks (dim white)
+for ((i=0; i<system_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[2;37mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Tools bricks (yellow)
+for ((i=0; i<tools_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;33mβ– \033[0m"
+ ((brick_count++))
+done
+
+# MCP bricks (magenta/pink)
+for ((i=0; i<mcp_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;35mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Memory bricks (blue)
+for ((i=0; i<memory_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;34mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Message bricks (cyan)
+for ((i=0; i<message_bricks && brick_count<used_bricks; i++)); do
+ brick_line+="\033[0;36mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Fill any remaining used bricks (in case of rounding)
+while ((brick_count < used_bricks)); do
+ brick_line+="\033[0;36mβ– \033[0m"
+ ((brick_count++))
+done
+
+# Free bricks (dim/gray hollow squares)
+for ((i=0; i<free_bricks; i++)); do
+ brick_line+="\033[2;37mβ–‘\033[0m"
+done
+
+brick_line+="] \033[1m${usage_pct}%\033[0m (${used_k}k/${total_k}k tokens)"
+
+# Add breakdown (simplified)
+brick_line+=" | \033[2;37msys:${system_k}k\033[0m"
+brick_line+=" \033[0;33mtools:${tools_k}k\033[0m"
+brick_line+=" \033[0;35mmcp:${mcp_k}k\033[0m"
+brick_line+=" \033[0;34mmem:${memory_k}k\033[0m"
+brick_line+=" \033[0;36mmsg:${message_k}k\033[0m"
+brick_line+=" | \033[1;32m${free_k}k free\033[0m"
+
+# Output both lines
+echo -e "$line1"
+echo -e "$brick_line"
diff --git a/tools/statusline/uninstall.sh b/tools/statusline/uninstall.sh
new file mode 100755
index 00000000..6db23dbe
--- /dev/null
+++ b/tools/statusline/uninstall.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# Claude Code Status Line - Uninstallation Script
+# Removes custom status line and optionally restores previous configuration
+
+set -e
+
+INSTALL_PATH="$HOME/.claude/statusline.sh"
+SETTINGS_FILE="$HOME/.claude/settings.json"
+
+echo "πŸ—‘οΈ Uninstalling Claude Code Custom Status Line..."
+echo ""
+
+# Find most recent backup
+LATEST_BACKUP=$(ls -t "${INSTALL_PATH}.backup-"* 2>/dev/null | head -1 || echo "")
+LATEST_SETTINGS_BACKUP=$(ls -t "${SETTINGS_FILE}.backup-"* 2>/dev/null | head -1 || echo "")
+
+# Remove statusline script
+if [[ -f "$INSTALL_PATH" ]]; then
+ echo "πŸ“ Removing status line script..."
+ rm "$INSTALL_PATH"
+ echo " Removed: $INSTALL_PATH"
+else
+ echo "⚠️ Status line script not found (already removed?)"
+fi
+
+echo ""
+
+# Ask about settings.json
+if [[ -f "$SETTINGS_FILE" ]]; then
+ echo "βš™οΈ Settings.json options:"
+ echo " 1) Remove statusLine configuration (keep other settings)"
+ echo " 2) Restore from backup (if available)"
+ echo " 3) Leave settings.json unchanged"
+ echo ""
+ read -p "Choose option [1-3]: " choice
+
+ case $choice in
+ 1)
+ echo "Removing statusLine from settings.json..."
+ jq 'del(.statusLine)' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
+ echo " StatusLine configuration removed"
+ ;;
+ 2)
+ if [[ -n "$LATEST_SETTINGS_BACKUP" ]]; then
+ echo "Restoring from backup: $LATEST_SETTINGS_BACKUP"
+ cp "$LATEST_SETTINGS_BACKUP" "$SETTINGS_FILE"
+ echo " Settings restored"
+ else
+ echo "❌ No backup found. Removing statusLine configuration instead..."
+ jq 'del(.statusLine)' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
+ fi
+ ;;
+ 3)
+ echo "Leaving settings.json unchanged"
+ ;;
+ *)
+ echo "Invalid option. Leaving settings.json unchanged"
+ ;;
+ esac
+fi
+
+echo ""
+
+# Ask about backups
+if [[ -n "$LATEST_BACKUP" ]] || [[ -n "$LATEST_SETTINGS_BACKUP" ]]; then
+ echo "πŸ“¦ Backup files found:"
+ [[ -n "$LATEST_BACKUP" ]] && echo " β€’ $LATEST_BACKUP"
+ [[ -n "$LATEST_SETTINGS_BACKUP" ]] && echo " β€’ $LATEST_SETTINGS_BACKUP"
+ echo ""
+ read -p "Delete backup files? [y/N]: " delete_backups
+
+ if [[ "$delete_backups" =~ ^[Yy]$ ]]; then
+ [[ -n "$LATEST_BACKUP" ]] && rm "${INSTALL_PATH}.backup-"* 2>/dev/null && echo " Removed script backups"
+ [[ -n "$LATEST_SETTINGS_BACKUP" ]] && rm "${SETTINGS_FILE}.backup-"* 2>/dev/null && echo " Removed settings backups"
+ else
+ echo " Backups preserved"
+ fi
+fi
+
+echo ""
+echo "βœ… Uninstallation complete!"
+echo ""
+echo "πŸ”„ Restart Claude Code for changes to take effect"
+echo ""
+echo "ℹ️ To reinstall: ./install.sh"