Read ~/.claude/settings.json and check the statusLine field. Three cases:
a. Already references statusline.py from this plugin (in the command itself or inside the script the command runs): report that it is already configured and stop.
b. No statusLine configured: create ~/.claude/frugal-statusline.sh with the content below, make it executable, and set "statusLine": {"type": "command", "command": "bash \"$HOME/.claude/frugal-statusline.sh\""} in settings.json (ask the user before writing settings.json).
#!/bin/bash
INPUT=$(cat)
MODEL=$(echo "$INPUT" | jq -r '.model.display_name // empty' 2>/dev/null)
DIR=$(basename "$(echo "$INPUT" | jq -r '.cwd // "~"' 2>/dev/null)")
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
FRUGAL=""
FRUGAL_SCRIPT=$(ls -d "$HOME"/.claude/plugins/cache/*/frugal/*/scripts/statusline.py 2>/dev/null | head -1)
if [ -n "$FRUGAL_SCRIPT" ]; then
TXT=$(python3 "$FRUGAL_SCRIPT" ${SESSION_ID:+--session "$SESSION_ID"} 2>/dev/null)
[ -n "$TXT" ] && FRUGAL=" \033[38;5;114m[${TXT}]\033[0m"
fi
printf '%b\n' "[${MODEL:-claude}] [${DIR}]${FRUGAL}"
c. An existing statusline is configured: read the script or command it points at, then merge the segment into it. Preferred merge: compute the badge early and append it to the script's assembled output, following this shape:
FRUGAL=""
FRUGAL_SCRIPT=$(ls -d "$HOME"/.claude/plugins/cache/*/frugal/*/scripts/statusline.py 2>/dev/null | head -1)
if [ -n "$FRUGAL_SCRIPT" ]; then
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
TXT=$(python3 "$FRUGAL_SCRIPT" ${SESSION_ID:+--session "$SESSION_ID"} 2>/dev/null)
[ -n "$TXT" ] && FRUGAL="\033[38;5;114m[${TXT}]\033[0m"
fi
Adapt to the script's own conventions (variable names, how it reads stdin, how it assembles the final line). If the statusline is an inline command rather than a script, wrap it: create ~/.claude/frugal-statusline.sh that pipes $INPUT to the original command and appends the badge to its output, then point statusLine.command at the wrapper. Show the user the proposed edit and get consent before modifying their statusline or settings.json.