Skip to content
Shell
3.8 KB
Raw Blame

Claude Code Helper Scripts

These helper scripts enhance your Claude Code workflow with additional functionality.

Status Line System

Main Script

statusline.sh - Main status line display script

  • Shows: hostname, timestamp, directory, git branch, model, Comet status, test results, costs
  • Called automatically by Claude Code every 300ms when conversation updates
  • Configured in .claude/settings.json

Helper Scripts

Comet Browser Management

check-comet.sh - Check if Comet is running

~/.claude/helpers/check-comet.sh
# Returns: "running" or "stopped"

comet-quick.sh - Manage Comet browser quickly

# Check status
~/.claude/helpers/comet-quick.sh status

# Start Comet with debug port
~/.claude/helpers/comet-quick.sh start

# Stop Comet
~/.claude/helpers/comet-quick.sh stop

# Restart Comet
~/.claude/helpers/comet-quick.sh restart

Test Status Tracking

get-test-status.sh - Get test status for display

~/.claude/helpers/get-test-status.sh /path/to/project
# Returns: ✅ (pass) or ❌(count) (fail)
# Status expires after 5 minutes

set-test-status.sh - Set test status after running tests

# Mark tests as passing
~/.claude/helpers/set-test-status.sh pass

# Mark tests as failing with count
~/.claude/helpers/set-test-status.sh fail:3

# Set for specific project
~/.claude/helpers/set-test-status.sh pass /path/to/project

Integration with Hooks

You can integrate these helpers with Claude Code hooks to automatically update status:

Example: Update test status after running tests

In your .claude/settings.json, add a hook:

{
  "hooks": {
    "tool-calls-succeeded": [
      {
        "pattern": "npm test",
        "command": "if grep -q 'Tests:.*passed' <<< \"$TOOL_OUTPUT\"; then ~/.claude/helpers/set-test-status.sh pass; else ~/.claude/helpers/set-test-status.sh fail; fi"
      }
    ]
  }
}

Example: Auto-check Comet status before browser automation

{
  "hooks": {
    "tool-calls-pre": [
      {
        "pattern": "mcp__playwright-server__browser_navigate",
        "command": "if [ \"$(~/.claude/helpers/check-comet.sh)\" == \"stopped\" ]; then echo 'WARNING: Comet not running with debug port. Run: ~/.claude/helpers/comet-quick.sh start'; exit 1; fi"
      }
    ]
  }
}

Status Line Features

The status line displays:

  1. Hostname & Time - Eddies-Mac-Studio@11:49:41
  2. Current Directory - ~/Development/id8 (with ~ expansion)
  3. Git Branch - (main) in salmon color, with * if uncommitted changes
  4. Model Name - Sonnet 4.5 (shortened for space)
  5. Comet Status - 🌐 (green) when running with debug port
  6. Test Status - ✅ or ❌(3) based on last test run
  7. Costs - 💰$0.0523 (+245/-67) showing USD cost and lines changed

Customization

Edit ~/.claude/statusline.sh to:

  • Change colors (ANSI escape codes)
  • Add/remove components
  • Change formatting
  • Add custom indicators

Color Reference

salmon=$(printf '\033[38;5;210m')
green=$(printf '\033[38;5;34m')
yellow=$(printf '\033[38;5;220m')
red=$(printf '\033[38;5;196m')
reset=$(printf '\033[0m')

Troubleshooting

Status line not appearing?

  1. Check script is executable: chmod +x ~/.claude/statusline.sh
  2. Test manually: echo '{"model":{"display_name":"Test"},"workspace":{"current_dir":"'$(pwd)'"}}' | ~/.claude/statusline.sh
  3. Check for errors in the script

Comet status not showing?

  1. Verify Comet is running: ~/.claude/helpers/comet-quick.sh status
  2. Check port 9222: lsof -i :9222
  3. Start Comet: ~/.claude/helpers/comet-quick.sh start

Test status not updating?

  1. Manually set status: ~/.claude/helpers/set-test-status.sh pass
  2. Check if .test-status file exists in project root
  3. Status expires after 5 minutes (by design)