/linux-plugin:linux-battery-drainfrom linux-plugin
Measures and diagnoses laptop battery drain on Linux in off (S5), suspend (S3/s2idle), and idle states. Runs gauge-aware tests and analyzes journal logs to identify causes like s2idle without S0ix, wake sources, or stuck daemons.
Ships in linux-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
"The battery is always empty" covers three different states with different causes and fixes:
| State | Healthy draw (order of magnitude) | Typical causes of excess |
|---|---|---|
| Off (S5) | tens of mW | EC staying powered, USB/PD power in off state, chipset deep-off mode disabled |
| Suspend (S3 / s2idle) | ~100–500 mW, model-dependent | s2idle without S0ix residency, devices not entering D3, wake sources |
| Running idle, screen off | ~0.5–3 W | a device kept awake by a failing driver, a stuck daemon, no package C-states |
Work out which state the complaint is about before measuring. The journal usually tells you (Step 1).
| Use this skill when... | Use something else when... |
|---|---|
| A laptop is empty after days or weeks unused | Disk is full: linux-plugin:linux-disk-usage |
| Suspend lasts far shorter than expected | The cause turns out to be EC firmware: bios-plugin's ec-firmware-analysis skill |
| Idle draw is high and fans run with nothing open | Thermal or performance tuning beyond drain |
journalctl --list-boots
journalctl -b -1 --no-pager -n 20 # how the previous boot ended
journalctl --no-pager -q | grep -E 'PM: suspend (entry|exit)|System is powering down|Power key'
systemd-shutdown lines was a real poweroff.PM: suspend entry/exit pairs mean the machine was
suspended, not off. Lid close usually defaults to suspend; check
gsettings get org.gnome.settings-daemon.plugins.power lid-close-battery-action
and logind.conf.If it was really suspend, the fix may be a setting (hibernate, or suspend-then-hibernate) rather than a firmware problem.
High idle draw also empties a battery left on, and it confounds every other test:
cat /sys/class/power_supply/BAT*/power_now # µW, on battery
ps -eo pcpu,etime,time,comm --sort=-pcpu | head
cat /sys/bus/pci/devices/*/power_state 2>/dev/null | sort | uniq -c
Two causes observed in practice:
modprobe
continuously, systemd-udevd workers burn CPU, and the GPU stays in D0.
journalctl -k | grep -c "probe with driver" and the GPU's power_state
show it. With a driver that runtime-suspends it (nouveau, or the
supported proprietary branch), the GPU drops to D3cold.The only instrument most laptops offer is the battery's fuel gauge
(energy_now, µWh). Four things make it lie:
energy_full) and rescale energy_now. A test
started right after unplugging from 100% can show energy rising on
battery. Start at 40–80%. Both scripts log energy_full with every
reading so a recalibration is visible.off-test.sh and power on as
soon as the machine is off. That pair is the overhead to subtract./var/lib/upower/history-{charge,rate}-<model>-<…>.dat. The model string
can change after a BIOS/EC update, and then the history continues in a new
file. upower's percentage history is integer-rounded.The charger must stay unplugged for the whole test. The scripts refuse to start with it connected and log the adapter state in every row.
bash "${CLAUDE_SKILL_DIR}/scripts/off-test.sh" 7200 # or --no-rtc
It records energy, installs a one-shot unit that records it at the next boot, and powers off with an RTC alarm. Whether RTC wake from S5 works is firmware-specific: on some laptops it wakes from suspend but not from poweroff. Test it once with a short off period. If it doesn't wake, power on by hand; the unit logs at whatever boot comes next.
For a firmware-versus-OS split, repeat the same off period after a shutdown
from the BIOS setup screen (systemctl reboot --firmware-setup, then power
off from there). If that drains as much, the Linux shutdown path is not the
cause.
bash "${CLAUDE_SKILL_DIR}/scripts/s3-test.sh" 7200
Runs unattended: records, suspends with an RTC alarm, records again 20 s
after resume. It measures whatever /sys/power/mem_sleep selects (deep =
S3; s2idle needs S0ix residency to be efficient).
The laptop's IP address may change across a suspend. Reach it by hostname or mDNS, not by a remembered IP, before concluding it has not woken.
python3 -I "${CLAUDE_SKILL_DIR}/scripts/drain-calc.py" /var/log/offdrain.csv --overhead-wh 0.1
The output gives period, energy drop, average draw, and the draw net of the
measured overhead. It flags rows with the charger connected, a changed
energy_full, or energy that rose. For a recalibrated pair it prints a
state-of-charge estimate, which assumes the gauge kept the percentage. That
assumption is unverified, so report the figure as an estimate.
ec-firmware-analysis skill).bios-setup-variables skill.cat /proc/acpi/wakeup. Linux arms only
devices whose deepest wake state covers the target.Huawei MateBook X Pro 2020, Pop!_OS, 2026-11:
nouveau runtime-suspended the
GPU to D3cold, idle draw was 3.8 W. With the screen off overnight it
averaged 0.62 W.energy_full
from 53.5 to 55.6 Wh mid-test, one minute after the end of a charge.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
battery-drain, power-management, linux-laptop, suspend-debugging, s0ix
npx claudepluginhub laurigates/claude-plugins --plugin linux-plugin2 skills in this plugin
Other plugins' skills for the same job