Install command
Not provided
A Claude Code statusline that reads the session JSON on stdin and splits total_duration_ms into API processing time versus network/waiting time (total minus API).
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Not provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
6 to clear
Platforms
1 listed
Difficulty
100/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Prerequisite readiness
6 prerequisites to line up before setup.
Safety & privacy surface
2 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens.
#!/usr/bin/env bash
# API Latency Breakdown Monitor for Claude Code
# Shows network/waiting time vs actual API processing time
# Read JSON from stdin
read -r input
# Extract values
total_duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
api_duration_ms=$(echo "$input" | jq -r '.cost.total_api_duration_ms // 0')
# Calculate network/waiting time (total - API)
network_time=$((total_duration_ms - api_duration_ms))
# Avoid negative values
if [ $network_time -lt 0 ]; then
network_time=0
fi
# Convert to seconds for display
api_seconds=$(echo "scale=2; $api_duration_ms / 1000" | bc)
network_seconds=$(echo "scale=2; $network_time / 1000" | bc)
total_seconds=$(echo "scale=2; $total_duration_ms / 1000" | bc)
# Calculate percentage split
if [ $total_duration_ms -gt 0 ]; then
api_percentage=$(( (api_duration_ms * 100) / total_duration_ms ))
network_percentage=$(( 100 - api_percentage ))
else
api_percentage=0
network_percentage=0
fi
# Performance assessment (network time should be minimal)
if [ $network_time -lt 1000 ]; then # < 1 second network time
PERF_COLOR="\033[38;5;46m" # Green: Excellent
PERF_STATUS="✓ FAST"
elif [ $network_time -lt 5000 ]; then # < 5 seconds
PERF_COLOR="\033[38;5;226m" # Yellow: Moderate
PERF_STATUS="⚠ SLOW"
else
PERF_COLOR="\033[38;5;196m" # Red: Poor performance
PERF_STATUS="✗ BOTTLENECK"
fi
RESET="\033[0m"
# Build ratio bar (API vs Network)
API_BAR="\033[48;5;75m" # Blue background for API time
NET_BAR="\033[48;5;214m" # Orange background for network time
# Create 20-char bar showing split
api_chars=$((api_percentage / 5)) # Each char = 5%
net_chars=$((network_percentage / 5))
if [ $api_chars -gt 0 ]; then
api_bar=$(printf "${API_BAR} %.0s" $(seq 1 $api_chars))${RESET}
else
api_bar=""
fi
if [ $net_chars -gt 0 ]; then
net_bar=$(printf "${NET_BAR} %.0s" $(seq 1 $net_chars))${RESET}
else
net_bar=""
fi
# Output statusline
echo -e "${PERF_COLOR}${PERF_STATUS}${RESET} | API: ${api_seconds}s (${api_percentage}%) | Network: ${network_seconds}s (${network_percentage}%) | ${api_bar}${net_bar}"{
"statusLine": {
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/statuslines/api-latency-breakdown.sh"
}
}{
"statusLine": {
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/statuslines/api-latency-breakdown.sh"
}
}
Extended version with percentile latency tracking and historical comparison
#!/usr/bin/env bash
# Enhanced API Latency Breakdown with P95 Tracking
input=$(cat)
total_duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
api_duration_ms=$(echo "$input" | jq -r '.cost.total_api_duration_ms // 0')
network_time=$((total_duration_ms - api_duration_ms))
if [ $network_time -lt 0 ]; then
network_time=0
fi
# Store latency history in /tmp
HIST_FILE="/tmp/claude_latency_history.txt"
echo "$network_time" >> "$HIST_FILE"
# Calculate P95 if we have enough samples (last 20 measurements)
if [ -f "$HIST_FILE" ] && [ $(wc -l < "$HIST_FILE") -ge 20 ]; then
p95_network=$(sort -n "$HIST_FILE" | tail -n 20 | awk 'BEGIN{c=0} {a[c++]=$1} END{print a[int(c*0.95)]}')
p95_display=$(echo "scale=2; $p95_network / 1000" | bc 2>/dev/null || echo "$((p95_network / 1000))")
p95_info=" | P95: ${p95_display}s"
else
p95_info=""
fi
api_seconds=$(echo "scale=2; $api_duration_ms / 1000" | bc 2>/dev/null || echo "$((api_duration_ms / 1000))")
network_seconds=$(echo "scale=2; $network_time / 1000" | bc 2>/dev/null || echo "$((network_time / 1000))")
if [ $total_duration_ms -gt 0 ]; then
api_percentage=$(( (api_duration_ms * 100) / total_duration_ms ))
network_percentage=$(( 100 - api_percentage ))
else
api_percentage=0
network_percentage=0
fi
if [ $network_time -lt 1000 ]; then
PERF_COLOR="\033[38;5;46m"
PERF_STATUS="✓ FAST"
elif [ $network_time -lt 5000 ]; then
PERF_COLOR="\033[38;5;226m"
PERF_STATUS="⚠ SLOW"
else
PERF_COLOR="\033[38;5;196m"
PERF_STATUS="✗ BOTTLENECK"
fi
RESET="\033[0m"
API_BAR="\033[48;5;75m"
NET_BAR="\033[48;5;214m"
api_chars=$((api_percentage / 5))
net_chars=$((network_percentage / 5))
api_bar=$(printf "${API_BAR} %.0s" $(seq 1 $api_chars))${RESET}
net_bar=$(printf "${NET_BAR} %.0s" $(seq 1 $net_chars))${RESET}
echo -e "${PERF_COLOR}${PERF_STATUS}${RESET} | API: ${api_seconds}s (${api_percentage}%) | Network: ${network_seconds}s (${network_percentage}%)${p95_info} | ${api_bar}${net_bar}"
Configurable performance thresholds for different network environments
#!/usr/bin/env bash
# API Latency Breakdown with Custom Thresholds
# Configure via environment variables
FAST_THRESHOLD=${LATENCY_FAST_THRESHOLD:-1000} # Default: 1 second
SLOW_THRESHOLD=${LATENCY_SLOW_THRESHOLD:-5000} # Default: 5 seconds
input=$(cat)
total_duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
api_duration_ms=$(echo "$input" | jq -r '.cost.total_api_duration_ms // 0')
network_time=$((total_duration_ms - api_duration_ms))
if [ $network_time -lt 0 ]; then
network_time=0
fi
api_seconds=$(echo "scale=2; $api_duration_ms / 1000" | bc 2>/dev/null || echo "$((api_duration_ms / 1000))")
network_seconds=$(echo "scale=2; $network_time / 1000" | bc 2>/dev/null || echo "$((network_time / 1000))")
if [ $total_duration_ms -gt 0 ]; then
api_percentage=$(( (api_duration_ms * 100) / total_duration_ms ))
network_percentage=$(( 100 - api_percentage ))
else
api_percentage=0
network_percentage=0
fi
# Custom thresholds
if [ $network_time -lt $FAST_THRESHOLD ]; then
PERF_COLOR="\033[38;5;46m"
PERF_STATUS="✓ FAST"
elif [ $network_time -lt $SLOW_THRESHOLD ]; then
PERF_COLOR="\033[38;5;226m"
PERF_STATUS="⚠ SLOW"
else
PERF_COLOR="\033[38;5;196m"
PERF_STATUS="✗ BOTTLENECK"
fi
RESET="\033[0m"
API_BAR="\033[48;5;75m"
NET_BAR="\033[48;5;214m"
api_chars=$((api_percentage / 5))
net_chars=$((network_percentage / 5))
api_bar=$(printf "${API_BAR} %.0s" $(seq 1 $api_chars))${RESET}
net_bar=$(printf "${NET_BAR} %.0s" $(seq 1 $net_chars))${RESET}
echo -e "${PERF_COLOR}${PERF_STATUS}${RESET} | API: ${api_seconds}s (${api_percentage}%) | Network: ${network_seconds}s (${network_percentage}%) | ${api_bar}${net_bar}"
Complete setup script with bc installation check
#!/bin/bash
# Installation script for API Latency Breakdown
mkdir -p .claude/statuslines
# Check for bc (required for floating point calculations)
if ! command -v bc &> /dev/null; then
echo "Installing bc for floating point calculations..."
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install bc
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -y bc || sudo yum install -y bc
else
echo "Please install bc manually: https://www.gnu.org/software/bc/"
fi
fi
cat > .claude/statuslines/api-latency-breakdown.sh << 'SCRIPT_EOF'
#!/usr/bin/env bash
# Paste the full statusline script from the primary example above before running this installer.
SCRIPT_EOF
chmod +x .claude/statuslines/api-latency-breakdown.sh
# Add to settings.json
if [ ! -f .claude/settings.json ]; then
echo '{"statusLine":{"type":"command","command":"$CLAUDE_PROJECT_DIR/.claude/statuslines/api-latency-breakdown.sh"}}' > .claude/settings.json
else
jq '.statusLine = {"type":"command","command":"$CLAUDE_PROJECT_DIR/.claude/statuslines/api-latency-breakdown.sh"}' .claude/settings.json > .claude/settings.json.tmp
mv .claude/settings.json.tmp .claude/settings.json
fi
echo "API Latency Breakdown installed successfully!"
echo "Note: bc is required for floating point calculations. If not installed, script will use integer math."
Verify both cost.total_duration_ms and cost.total_api_duration_ms fields exist: echo '$input' | jq .cost. Negative protection caps network_time at 0. If both values missing, script shows 0s - check Claude Code version supports these fields. Verify JSON structure: jq '.cost | keys' to see available fields.
This indicates total_duration_ms equals total_api_duration_ms (no measurable network overhead). Verify calculations: network_time = total - API. If consistently 0, either network is extremely fast or fields are identical in JSON. Check actual JSON values: echo '$input' | jq '.cost.total_duration_ms, .cost.total_api_duration_ms'. Test with known slow network to verify detection works.
Thresholds: <1s green (FAST), 1-5s yellow (SLOW), >5s red (BOTTLENECK). Adjust thresholds in script if your network baseline differs. VPN users may see higher normal latency. Modify: network_time -lt 5000 to higher value for VPN environments. Use custom thresholds version: export LATENCY_FAST_THRESHOLD=2000 LATENCY_SLOW_THRESHOLD=10000.
Bar uses ANSI background colors (\033[48;5;Xm). Ensure terminal supports 256-color mode: tput colors (should return 256). If bars show as spaces only, verify ANSI escape codes working: echo -e '\033[48;5;75m BLUE \033[0m'. Check terminal emulator color support settings. Verify echo -e flag is used for escape sequence interpretation.
Install bc: brew install bc (macOS), apt install bc (Linux), or download from https://www.gnu.org/software/bc/. Alternative: use integer math only: api_percentage=$((api_duration_ms * 100 / total_duration_ms)) - removes decimal precision but works without bc. Script includes fallback to integer math if bc unavailable. Verify bc installation: which bc.
This indicates bc is not working or fallback to integer math is active. Check bc installation: bc --version. Verify bc command in script: echo 'scale=2; 1234 / 1000' | bc (should return 1.34). If bc fails, script uses integer division: $((api_duration_ms / 1000)) which truncates decimals. Install bc for decimal precision.
Verify integer division is working correctly: echo $((100 * 50 / 100)) (should be 50). Check total_duration_ms > 0 before division. Test calculation: api_percentage=$((api_duration_ms * 100 / total_duration_ms)). Ensure values are numeric: echo "$api_duration_ms" | grep -E '^[0-9]+$'. Check for integer overflow if values are very large.
Verify echo -e flag is used for escape sequence interpretation. Check terminal supports ANSI colors: echo -e '\033[38;5;46mGreen\033[0m'. Some terminals require explicit color support enabled. Check TERM environment variable: echo $TERM (should include 'xterm' or '256color'). Verify terminal emulator settings for color support.
Show that API Latency Breakdown - Statuslines is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/statuslines/api-latency-breakdown)API Latency Breakdown - Statuslines side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | A Claude Code statusline that reads the session JSON on stdin and splits total_duration_ms into API processing time versus network/waiting time (total minus API). Open dossier | A Claude Code statusline command (bash) that detects concurrent Claude Code sessions. Open dossier | Multi-provider AI performance dashboard with context occupancy tracking, truncation warnings, TTFT latency, tokens/min rate, and model comparison metrics. Open dossier | Real-time MCP server monitoring statusline showing connected servers, active tools, and performance metrics for Claude Code MCP integration Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | statuslines | statuslines | statuslines | statuslines |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-10-25 | 2025-10-25 | 2025-10-23 | 2025-10-16 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Configured as a command-type statusline, so the script runs automatically on every status update. The Examples "Installation" script writes .claude/statuslines/api-latency-breakdown.sh and edits .claude/settings.json, and runs brew/apt-get/yum to install bc. | ✓Runs as a shell command on every statusline refresh (configured refreshInterval 2000ms), executing jq, find, grep, date and arithmetic each time. Creates the directory ~/.claude-code-sessions and writes a per-session file there on every refresh. Automatically deletes session files older than 10 minutes (configurable via SESSION_STALE_THRESHOLD in one variant) using rm. The installation-example variant installs jq via brew or apt-get/yum with sudo and rewrites .claude/settings.json; review before running. | ✓Runs as a Claude Code statusline command on every refresh and depends on the local shell environment; a failure only affects status rendering, not your session. | ✓Runs as a Claude Code statusline command on every refresh and depends on the local shell environment; a failure only affects status rendering, not your session. |
| Privacy notes | ✓The Examples "Enhanced P95" variant appends every measured network time to /tmp/claude_latency_history.txt, leaving session timing data on disk until manually cleared. | ✓Stores the current session_id and absolute workspace path in plaintext files under ~/.claude-code-sessions, readable by other local processes. The enhanced variant additionally writes the session_id into the file contents and displays the first 8 characters of each session id in the statusline output. | ✓Reads the Claude Code statusline JSON from stdin (model, token usage, context occupancy) and renders it in the local terminal; it does not send data off-machine. | ✓Reads the Claude Code statusline JSON from stdin (model, workspace path, token usage) and renders it in the local terminal; it does not send data off-machine. |
| Prerequisites |
|
|
|
|
| Install | — | — | — | — |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Control MCP tool output size with env limits, annotations, and tool search to protect Claude Code context.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.