惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家
V
V2EX
Jina AI
Jina AI
V
Visual Studio Blog
有赞技术团队
有赞技术团队
博客园 - 司徒正美
博客园 - 叶小钗
The Cloudflare Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
Google Online Security Blog
Google Online Security Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic
N
News and Events Feed by Topic
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
SecWiki News
SecWiki News
博客园_首页
罗磊的独立博客
量子位
Latest news
Latest news
I
Intezer
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Last Week in AI
Last Week in AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
SegmentFault 最新的问题
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News | PayPal Newsroom

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work Top 15 Reinforcement Learning Questions That Will Appear in Exams The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I Replaced /usage and /context in Claude Code With a Single Statusline
Vientapps · 2026-04-18 · via DEV Community

You already run /usage and /context all day. This bash statusline puts both, plus your 5h reset time and working directory, at the bottom of every Claude Code prompt as colored progress bars. Exact script inside.

I'm on Claude Code Max 5x. It's a generous plan. It is also not infinite.

Three things kept catching me off guard. The 5-hour session window would fill up in the middle of a long chain of edits and suddenly I was on a cooldown I hadn't seen coming. The 7-day rolling limit was a slower version of the same problem. And the context window would creep toward full during a deep session and I'd only notice when the responses got weirdly slow.

I knew all three numbers existed somewhere. You can already get the rate limits by running /usage in Claude Code, and the context window by running /context. I was running both commands several times an hour, which is exactly the friction I was trying to avoid in the first place.

It turns out Claude Code has a statusline feature that very few people seem to know about. It runs a shell command before every prompt and prints whatever that command returns at the bottom of your terminal. That's the whole primitive. You get to decide what goes in it. So instead of typing /usage and /context on demand, I put both of them plus my working directory and my 5h reset time in the statusline and never have to ask again.

I asked Claude to build mine. It took four rounds of back-and-forth to land it where I wanted. Here's what I ended up with and why.

What the statusline actually is

A statusLine entry in your ~/.claude/settings.json that points at a script. Every time you hit enter on a Claude Code prompt, the harness pipes a JSON blob to that script over stdin and prints whatever your script writes to stdout.

The JSON blob contains useful fields. For my purposes:

  • cwd, the current working directory
  • rate_limits.five_hour.used_percentage and resets_at
  • rate_limits.seven_day.used_percentage
  • context_window.used_percentage

That is all I needed.

How I worked with Claude on this one

This was the statusline-setup agent end to end. I'd tell the agent what I wanted, it would write the script, I'd look at the output in my terminal, then come back and say "now change this." Four rounds total:

  1. First pass: show 5h, 7d, context, cwd as percentages.
  2. "Shorter. Show just the folder, not the full path. Can we use bars instead of percentages?"
  3. "Move the folder to the front. Color the bars by severity."
  4. "Add the reset time for the 5-hour bar."

I didn't hand-edit the script at any point. Every change went through the agent. Not because I was trying to be pure about it, just because the iterations were fast enough that writing prose was quicker than diffing bash.

The stack

bash + jq + ANSI escape codes. That's it.

The script lives at ~/.claude/statusline-command.sh. The settings.json entry points at it:

"statusLine": {
  "type": "command",
  "command": "bash /Users/YOURNAME/.claude/statusline-command.sh"
}

No install step, no build, no dependencies beyond jq (which most dev machines already have).

The bars

I wanted the progress bars to be visually distinct from each other so I could spot trouble at a glance. Claude's first pass had them all in the same dim color, which was technically working but useless for scanning. That was round three of corrections.

The fix was severity coloring. The filled portion of each bar gets green, yellow, or red depending on how full it is. The empty portion stays dim gray.

bar_color() {
  pct="$1"
  int_pct=$(printf '%.0f' "$pct" 2>/dev/null || echo 0)
  if [ "$int_pct" -ge 81 ] 2>/dev/null; then
    printf '\033[0;31m'   # red
  elif [ "$int_pct" -ge 50 ] 2>/dev/null; then
    printf '\033[0;33m'   # yellow
  else
    printf '\033[0;32m'   # green
  fi
}

Green below 50, yellow 50 to 80, red above 80. So when I glance down and see two greens and a yellow, I'm fine. Two yellows and a red, I wrap up the current task before I lose the session.

Drawing a 10-slot bar in pure shell

The bar itself is 10 Unicode blocks, some filled, some empty. This function computes how many slots to fill, then paints them with ANSI colors:

make_bar() {
  pct="$1"
  filled=$(printf '%.0f' "$(echo "$pct * 10 / 100" | bc -l 2>/dev/null || echo 0)")
  [ "$filled" -gt 10 ] 2>/dev/null && filled=10
  [ "$filled" -lt 0 ] 2>/dev/null && filled=0
  color=$(bar_color "$pct")
  reset='\033[0m'
  dim='\033[2;37m'
  bar=""
  i=0
  while [ "$i" -lt "$filled" ]; do
    bar="${bar}${color}\xe2\x96\x88${reset}"
    i=$((i + 1))
  done
  while [ "$i" -lt 10 ]; do
    bar="${bar}${dim}\xe2\x96\x91${reset}"
    i=$((i + 1))
  done
  printf '['; printf "$bar"; printf ']'
}

\xe2\x96\x88 is the full block character, \xe2\x96\x91 is the light shade. Escape color, character, reset, repeat. The trailing reset on every character matters. If you skip them, a tmux resize or scrollback can bleed color into adjacent text.

The reset timestamp

The nice detail I didn't realize I wanted until I saw the finished version: the 5-hour bar shows when it resets, not just how full it is.

The JSON gives you resets_at as a Unix timestamp. On macOS, date -r takes a timestamp directly:

five_reset_str=$(date -r "$five_resets" "+%-I:%M%p" 2>/dev/null \
  | tr '[:upper:]' '[:lower:]')
[ -n "$five_reset_str" ] && five_reset_str=" rst:${five_reset_str}"

%-I strips the leading zero so 03:45pm renders as 3:45pm. tr lowercases it so it reads closer to how I'd write the time in a note: 3:45pm rather than 3:45PM.

Now the 5h segment looks like 5h:[████████░░]82% rst:3:45pm. I can see both the cost and the clock.

Where Claude surprised me

The severity coloring was me saying "make the bars not all gray, use any colors that make sense" and the agent came back with the green/yellow/red thresholds on its own. I was expecting I'd have to define the ranges. Not complicated logic, but it picked reasonable cutoffs without me specifying them and I didn't need to adjust after.

Where Claude fell short

The first version wrote out full paths for the working directory. I told it I wanted just the folder name. That was a one-line basename fix. Easy, but it's the kind of thing "good default" might have caught without me asking.

The first version also had ASCII bars all in the same dim gray. Functional but not useful. I had to explicitly ask for color differentiation. On re-read, my original prompt did ask for visual bars but didn't say anything about severity, so that's fair. Still, "make the bars informative" would have been my one-shot prompt if I were writing it now.

It also wrote the code to extract rate_limits.five_hour.resets_at before confirming the field actually existed in the JSON payload. It was a plausible path, and it happened to be correct, but it was a guess. For a less obvious field I'd have wasted a round on a hallucinated schema.

The fastest way to get this setup

If you want the exact statusline I have without hand-editing bash, paste this into any Claude Code session and let it do the work:

Set up my Claude Code statusline to show my working directory folder name, my 5-hour usage as a severity-colored progress bar with the reset time next to it, my 7-day usage as a severity-colored progress bar, and my context window as a severity-colored progress bar. Green under 50%, yellow 50 to 80%, red above 80%. Write a bash script at ~/.claude/statusline-command.sh and register it in ~/.claude/settings.json.

Claude Code ships with a statusline-setup agent that's purpose-built for this. That prompt will trigger it and you'll have the same setup in a minute or two. If it picks defaults you don't like, say "now change this" and iterate.

The whole script, if you want mine

If you'd rather read the bash yourself, save this as ~/.claude/statusline-command.sh:

#!/bin/sh
input=$(cat)

cwd=$(echo "$input" | jq -r '.cwd // .workspace.current_dir // empty')
ctx_used=$(echo "$input" | jq -r '.context_window.used_percentage // empty')
five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
five_resets=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')

bar_color() {
  pct="$1"
  int_pct=$(printf '%.0f' "$pct" 2>/dev/null || echo 0)
  if [ "$int_pct" -ge 81 ] 2>/dev/null; then
    printf '\033[0;31m'
  elif [ "$int_pct" -ge 50 ] 2>/dev/null; then
    printf '\033[0;33m'
  else
    printf '\033[0;32m'
  fi
}

make_bar() {
  pct="$1"
  filled=$(printf '%.0f' "$(echo "$pct * 10 / 100" | bc -l 2>/dev/null || echo 0)")
  [ "$filled" -gt 10 ] 2>/dev/null && filled=10
  [ "$filled" -lt 0 ] 2>/dev/null && filled=0
  color=$(bar_color "$pct")
  reset='\033[0m'
  dim='\033[2;37m'
  bar=""
  i=0
  while [ "$i" -lt "$filled" ]; do
    bar="${bar}${color}\xe2\x96\x88${reset}"
    i=$((i + 1))
  done
  while [ "$i" -lt 10 ]; do
    bar="${bar}${dim}\xe2\x96\x91${reset}"
    i=$((i + 1))
  done
  printf '['; printf "$bar"; printf ']'
}

parts=""

if [ -n "$cwd" ]; then
  folder=$(basename "$cwd")
  parts="${parts}$(printf '\033[0;36m%s\033[0m ' "$folder")"
fi

if [ -n "$five_pct" ]; then
  bar=$(make_bar "$five_pct")
  five_reset_str=""
  if [ -n "$five_resets" ]; then
    five_reset_str=$(date -r "$five_resets" "+%-I:%M%p" 2>/dev/null \
      | tr '[:upper:]' '[:lower:]')
    [ -n "$five_reset_str" ] && five_reset_str=" rst:${five_reset_str}"
  fi
  parts="${parts}$(printf '\033[0;33m5h:\033[0m%s%.0f%%%s ' "$bar" "$five_pct" "$five_reset_str")"
fi

if [ -n "$week_pct" ]; then
  bar=$(make_bar "$week_pct")
  parts="${parts}$(printf '\033[0;33m7d:\033[0m%s%.0f%% ' "$bar" "$week_pct")"
fi

if [ -n "$ctx_used" ]; then
  bar=$(make_bar "$ctx_used")
  parts="${parts}$(printf '\033[0;35mctx:\033[0m%s%.0f%%' "$bar" "$ctx_used")"
fi

printf '%s' "$parts"

Make it executable (chmod +x ~/.claude/statusline-command.sh), then add this to ~/.claude/settings.json:

"statusLine": {
  "type": "command",
  "command": "bash /Users/YOURNAME/.claude/statusline-command.sh"
}

Replace YOURNAME with your actual home directory. Restart Claude Code. Run a prompt. The statusline shows up after the first response, which is when the JSON starts carrying real usage numbers.

The output looks like this on my machine:

Folder first, then 5h with its reset time, then 7d, then context. The bars shift from green to yellow to red as the meters fill up, so I can scan the line without reading numbers.

Styling tips

A few things I learned by iterating on this:

Label colors matter more than bar colors. I used cyan for the cwd, yellow for 5h and 7d labels, purple for ctx. When I glance down, the label colors are what tell me which segment I'm looking at. The bar colors just tell me severity.

Keep segments narrow. Ten-slot bars are small enough to fit four segments on one line in a typical terminal. I tried 20-slot bars at one point and they wrapped on my laptop screen.

Always reset after every ANSI escape. I've been burned by color bleeding into the rest of the terminal after a process crashes mid-write. The ${reset} after every character is paranoid but cheap.

Hide segments when the data isn't there yet. The rate-limit numbers aren't populated until Claude Code has made at least one API call in the session. If you print them unconditionally you get an ugly 5h:[░░░░░░░░░░] on a fresh start. The if [ -n ... ] guards handle that.

Where it is now

Running on my machine. I see it every prompt. It has already saved me from one 5h wall I didn't notice coming. Low stakes, nice feature, took about an hour of back-and-forth to land.

What I'd do differently

Tell Claude the severity thresholds up front. I let the agent pick them and it happened to get it right, but on a different day I might have wanted different cutoffs and wasted a round correcting. Specifying "green under 50, yellow 50-80, red over 80" in the first prompt costs nothing.

Ask the agent to verify fields in the JSON before writing code. The resets_at field happened to exist. For a feature you're actually shipping, the "does this field exist" check should happen before the "format it as a time" code. A one-line jq against a sample payload would have caught it.

Don't wait to try it. I almost didn't build this because it felt like yak-shaving. It took under an hour and changed how I pace work inside Claude Code. If you've never opened the statusLine key in your settings.json, that's where to start.