Agent skill

Cpu Reduction

by nubjs in nubjs/nub

Diagnose and clear CPU, memory, and disk contention on the maintainer's dev host.

MITAuto-check passedDevelopment

Install Cpu Reduction

skills CLI
$ npx skills add nubjs/nub --skill cpu-reduction -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install nubjs/nub cpu-reduction --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/nubjs/nub.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/cpu-reduction .claude/skills/cpu-reduction && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cpu-reduction
GitHub stars
4.4k
Token cost
~2.8k tokens
SKILL.md length
1,203 words
Files
2 (incl. scripts)
Skills in repo
31
Repo updated
First seen
Licence
MIT

At a glance

Diagnose and clear CPU, memory, and disk contention on the maintainer's dev host.

  • Works in 8 steps: Measure → Old Rust builds — locks, orphans, disk → Orphaned node test processes (the load… → …
  • Tasks that involve Git worktrees
  • SKILL.md covers 1. Measure, 2. Old Rust builds — locks,…, 3. Orphaned node test… and 4. Capture evidence before you…, plus 4 more sections
  • Runs Python scripts from its folder; calls tsc, git and python3

What it does

Cpu Reduction is an agent skill from nubjs/nub. Diagnose and clear CPU, memory, and disk contention on the maintainer's dev host. Invoke when the machine is slow, load or swap is high, disk is filling, a Rust build hangs on a target lock, a benchmark needs a quiet host, stale worktree targets have accumulated, or orphaned build/test processes are suspected. Covers safe worktree-target cleanup, detached Rust builds, orphaned Node tests and synthetic load generators, the preserve list, and the measure-to-verify loop. For preventing orphan builds, use…

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including scripts (for example `scripts/clean-worktree-targets.py`).

It sits in Development, covering Git worktrees. It works with Rust. The repository describes itself as: The fast all-in-one Node.js toolkit. The licence is MIT.

When your agent uses it

  • Tasks that involve Git worktrees

Example prompts

  • “/cpu-reduction”

Requirements

  • Python 3

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Measure
  2. Old Rust builds — locks, orphans, disk
  3. Orphaned node test processes (the load floor)
  4. Capture evidence before you kill
  5. Preserve list — check before killing
  6. Sweep — four gotchas
  7. Verify
  8. Standing risks

What it can do on your machine

Read from SKILL.md and the folder at commit 568e73a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • tsc
    • git
    • python3
    • tsx
    • node
    • cargo
    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cpu Reduction loads about 2.8k tokens when it runs. Until then it costs about 136 tokens; SKILL.md has 1,203 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~136
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from nubjs/nub at commit 568e73a, republished under its MIT licence (© nubjs). 1,203 words, ~2,838 tokens.

Download SKILL.mdSave it as .claude/skills/cpu-reduction/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
cpu-reduction
description
Diagnose and clear CPU, memory, and disk contention on the maintainer's dev host. Invoke when the machine is slow, load or swap is high, disk is filling, a Rust build hangs on a target lock, a benchmark needs a quiet host, stale worktree targets have accumulated, or orphaned build/test processes are suspected. Covers safe worktree-target cleanup, detached Rust builds, orphaned Node tests and synthetic load generators, the preserve list, and the measure-to-verify loop. For preventing orphan builds, use `rust-build-hygiene`.
metadata.internal
true

CPU / disk reduction — clear build & test residue

The maintainer's Mac is 10 CPUs / 64 GiB. Three residue families need different treatment — diagnose by symptom before sweeping.

FamilySymptomCostCause
Old Rust buildsa build hangs on Blocking waiting for file lock; a few rustc/cargo/lld pegged; disk fillingLOCK contention + CPU + tens of GB of target/detached/orphaned builds that outlived their launcher; abandoned worktree target/ dirs
Orphaned node testsload floor sits ~20 with nothing buildingCPU + swapnode/tsx/esbuild/tsc -w reparented to launchd when their harness died
Orphaned load generatorsload in the hundreds; N identical /bin/zsh at 25–70%, consecutive PIDs, same start secondCPU — starves every builda probe spawned (while :; do :; done) & and died before its cleanup line ran

A high load FLOOR with nothing building is almost never active compilation — it is orphaned node processes (§3). A hung build or filling disk is the Rust family (§2).

Prevention beats cleanup: rust-build-hygiene is how to spin builds up so they die with you.

1. Measure

sh
uptime                                   # load; the 1-min figure LAGS — see §7
sysctl -n hw.ncpu vm.swapusage
memory_pressure | grep -i "free percentage"
df -h ~/.cache                            # disk — worktree target/ dirs live here
ps -Ao pid,ppid,pgid,%cpu,%mem,rss,etime,state,comm -r | head -40

Load well above hw.ncpu with nothing building → §3. A build stuck on a lock, or ~/.cache near full → §2. Start with make build-status: it prints which builds hold the machine-wide compile slots, who is queued behind them and for how long, token occupancy, and any build running outside the cap — a build sitting at Compiling with no CPU is queued behind the governor, not hung.

2. Old Rust builds — locks, orphans, disk

2a. Orphaned builds holding a target lock (the hang)

A build that outlived its launcher still holds a target-dir lock, so a live build blocks behind it — often 30+ minutes, reading as "the build is just slow."

sh
# builds still running, with age + which target dir
ps -Ao pid,ppid,%cpu,etime,command | grep -Ei 'rustc|cargo|ld64|lld|cc1' | grep -v grep
# is a build blocked on a lock right now? (check the build log)
grep -l 'Blocking waiting for file lock on' /tmp/*build*.log 2>/dev/null
pkill -f '<target-dir-path>'              # kill the orphaned builds for that target

Cause is almost always TWO builds on ONE target dir — most often a stopped agent's detached cargo build that TaskStop did not reap (TaskStop kills the agent, not its background bash jobs; setsid/nohup-detached builds reparent to PID 1). Artifacts persist and stay warm — hand the contention-free target to ONE fresh foreground build. Never point two concurrently-building trees at one target dir.

2b. Worktree-owned Rust targets eating disk
sh
# Audit only. This is the default.
python3 .claude/skills/cpu-reduction/scripts/clean-worktree-targets.py

# Repeat every safety check, then delete eligible build output.
python3 .claude/skills/cpu-reduction/scripts/clean-worktree-targets.py --apply

It deletes no worktree, branch, source file, or shared cache. Layouts it covers:

text
~/.cache/nub/worktrees/<slug>/target/
~/.cache/nub/worktrees/<slug>/aube-target/
~/.cache/nub/worktrees/<slug>/target-linux/
~/.cache/nub/worktrees/<slug>-target/
~/.cache/nub/worktrees/<slug>-launcher-target/
~/.cache/nub/worktrees/<slug>-target-native/

Spellings vary; the invariant is a top-level target-named directory inside a registered worktree, or a target-named sibling prefixed by that worktree's full basename.

Safety model: the cleaner protects an owner's entire target set when git status --porcelain reports any staged, unstaged, or untracked work — an uncommitted worktree is active state. It refuses symlinks, unmatched directories, targets owning the installed nub-dev/nubx-dev binary, and apply mode while any Rust build is running. Status and process state are rechecked at the deletion boundary.

Do not remove clean worktree checkouts merely to recover disk. Build output is regenerable; a checkout and branch are not interchangeable with cache. Remove a checkout only via the worktree skill after proving it abandoned and pushed.

Shared targets stay warm — they seed fresh worktrees and may own the installed nub-dev binary. Never include them in a worktree cleanup; prune only with explicit operator approval:

text
~/.cache/nub/shared-target
~/.cache/nub/shared-target-<content-hash>

Judge every reclaim by df, never du. APFS clone/shared-block accounting means summed du sizes need not equal the df delta, and du -sh over the worktree root can take minutes.

sh
df -h /System/Volumes/Data
2c. Orphaned rustc at high CPU

Rare — Rust builds are noisy but they finish. If ps shows a long-etime rustc/cc1plus/lld at high %cpu with no parent cargo, it's an orphan; kill -9 after confirming its ppid chain has no live build.

2d. Orphaned synthetic load generators (load in the hundreds)

A probe that needs contended measurement sometimes manufactures the contention and then dies before cleanup, leaving busy-loops spinning forever under launchd.

Signature — all four together, never /bin/zsh alone:

sh
ps -Ao pid=,ppid=,%cpu=,etime=,comm= | awk '$2==1 && $3>20 && $5=="/bin/zsh"'
ps -o command= -p <pid>          # full argv reveals the `while :; do :; done` and its dead cleanup
pgrep -P <pid>                   # NO children — it is not wrapping a real build

Consecutive PIDs + identical start second + PPID=1 + no children + a spinning loop in the argv = safe to kill -9. Read the full argv first — an agent's own background cargo also runs as /bin/zsh -c source <snapshot> && …, and that one has children and must be left alone.

pgrep -f can return 0 for everything when it cannot read other processes' argv under the sandbox. It reports absence, not an error — cross-check with ps aux | grep before concluding "nothing is running."

Prevention, in the probe itself:

sh
LOADPIDS=$(jobs -p)
trap 'kill $LOADPIDS 2>/dev/null' EXIT INT TERM

3. Orphaned node test processes (the load floor)

Orphans are PPID=1:

sh
# every orphaned dev process, with what it costs
ps -Ao pid=,ppid=,%cpu=,rss=,etime=,command= | awk '$2==1' \
  | grep -Ei 'nvm/versions/node|/bin/tsx|esbuild --service|cache/nub/worktrees|tsc -b -w'
# what it totals
ps -Ao ppid=,user=,rss=,command= | awk '$1==1 && $2=="colinmcd94"' \
  | grep -Ei 'nvm/versions/node|/bin/tsx|esbuild --service|cache/nub/worktrees|tsc -b -w' \
  | awk '{s+=$3; n++} END {printf "count=%d  RSS=%.2f GB\n", n, s/1048576}'

PPID=1 also matches ~445 legitimate macOS agents (/System, /usr/*, /Applications). Always narrow by command pattern; never sweep on PPID=1 alone. Two cost shapes: CPU burners (a handful at 60–90%) and memory ballast (hundreds idle at ~0% CPU, ~52 MB RSS each).

Show full SKILL.md (459 more words)Show less

4. Capture evidence before you kill

A process spinning for days is a reproducible bug; killing it destroys the only live instance.

sh
sample <pid> 3 -mayDie                     # writes /tmp/<comm>_<ts>.sample.txt
ps -Ao pid,ppid,pgid,%cpu,rss,etime,state,lstart,command > ps-snapshot.txt

Known nub fixture-hang signature:

v8::internal::Isolate::StackOverflow
v8::internal::ErrorUtils::Construct
v8::internal::Isolate::CaptureAndSetErrorStack

= infinite recursion → RangeError: Maximum call stack size exceeded → source-mapped over a maximally deep stack (nub passes --enable-source-maps) → something catches the RangeError and retries → never dies. The fix belongs in the recursion guard + catch site, not the sweep.

5. Preserve list — check before killing

Standing instruction: kill anything not doing productive work, but have high confidence it is not in fact productive. Never kill:

  • Anything holding a listening socket — lsof -nP -iTCP -sTCP:LISTEN | awk 'NR>1{print $2}' | sort -u, intersect with candidates (dev servers, the agent harness's own board/UI process, agent-browser).
  • tmux sessions (they host live claude / dispatched workers).
  • claude processes and anything whose PPID chains to one.
  • node --inspect-brk (a debugger may be attached).
  • Any cargo/rustc in a LIVE build tree (check the ppid chain).

Everything else — orphaned tsx runs, node --watch, tsc -b -w, esbuild --service --ping, nub fixture runs from ~/.cache/nub/worktrees, detached cargo/rustc whose launcher is gone — is safe once PPID=1 and more than a few hours old.

6. Sweep — four gotchas

  • kill $PIDS silently no-ops with a large PID list (returns 0, kills nothing). Since SIGKILL can't be ignored, "survived SIGKILL" always means it was never delivered. Use awk '{print $1}' candidates.txt | xargs -n 20 kill -9.
  • Killing parents reparents their children — sweep in passes. Re-run identify until the count hits zero.
  • A %cpu == 0 filter misses near-zero idlers. Filter by PPID=1 + command + age; treat CPU as info, not the predicate.
  • SIGTERM won't be serviced by a process stuck in a JS recursion loop (event loop unreachable). SIGTERM the sleeping Rust parents (temp files to clean); SIGKILL straight to spinning node children.

7. Verify

sh
uptime; sysctl -n vm.swapusage; df -h ~/.cache; ps -Ao pid,%cpu,%mem,etime,comm -r | head -8

Load average lags — it reads higher right after the kills and decays over minutes. Swap + memory_pressure respond faster; trust those first. An mds_stores spike after a large sweep is a transient reaction to hundreds of exits.

8. Standing risks

  • ~/.cache/nub/worktrees disk growth. Pruning the CHECKOUTS reclaims almost nothing — scripts/rust-build.sh CoW-clones with cp -c, so du bills shared APFS blocks to every referencing path. The <name>-target dirs are the real consumers; hunt orphaned ones first. Removing a CLEAN worktree is lossless (git worktree remove drops the directory; branch and commits stay), so git status --porcelain is the whole guard.
  • Keep stderr visible when a command's failure is what you are diagnosing — a silenced git worktree remove … 2>/dev/null in a loop makes a failed removal look like a CoW accounting effect.
  • Each abandoned fixture run leaks a nub + node pair. Real fix is upstream (nub should kill its node child on exit; the harness should signal the process group). Until then, rust-build-hygiene is how to stop creating the residue.

© nubjs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (scripts) in .claude/skills/cpu-reduction of nubjs/nub.

  • SKILL.md
  • scripts/clean-worktree-targets.py

Open the folder on GitHubat commit 568e73a

Compare with similar skills

Cpu Reduction next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cpu Reduction compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cpu Reduction this skillnubjs/nub4.4k—~2.8kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman42k—~2.6kAutomated safety check: PassGPL-3.0
Worktrunk CLI Output Rulesmax-sixty/worktrunk9k—~12kAutomated safety check: PassCustom licence
Projectatlasstyler-ai/ProjectAtlas440—~9.2kAutomated safety check: PassMIT
Tsz Disk Cache Hygienetsz-org/tsz577—~342Automated safety check: PassApache-2.0
QAarcee-ai/nac280—~6.8kAutomated safety check: PassApache-2.0

Similar skills

  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    42k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Worktrunk CLI Output Rules

    max-sixty/worktrunk

    CLI output standards for worktrunk: message functions, ANSI color nesting and the shell integration that changes directory after the wt command exits.

    9k GitHub stars~12k tokensUpdated today
    DevelopmentAuto-check passed
  • Projectatlas

    styler-ai/ProjectAtlas

    Use ProjectAtlas before broad source reads, preferring the installed short atlas CLI for an exact checkout and MCP for registered worktree routing, compact session briefs, or federated graph evidence.

    440 GitHub stars~9.2k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Prevent TSZ machines and worktrees from running out of disk while preserving useful build caches.

    577 GitHub stars~342 tokensUpdated 28 days ago
    DevelopmentAuto-check passed
  • QA

    arcee-ai/nac

    Run scalable, isolated live QA for nac development. An agent skill from arcee-ai/nac.

    280 GitHub stars~6.8k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.

    296k GitHub starsUsed in 5 repos~1.9k tokens
    DevelopmentAuto-check passed

More from nubjs/nub

All 31 skills in this repo
  • Reclaim disk on the maintainer's Mac when the volume is full or filling — ENOSPC, "no space left on device", a failed build or agent harness, or a routine sweep of Rust build residue.

    4.4k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Nub Charts

    nubjs/nub

    Build a performance chart for nubjs.com — the SVG bar figures in blog posts, docs pages and social posts (a runtime augmentation against plain node, an install or dispatch comparison, a cross-tool…

    4.4k GitHub stars~4.6k tokensUpdated today
    Auto-check passed
  • Audit Thread

    nubjs/nub

    A skill your agent uses when running a compatibility/parity AUDIT — enumerating where nub diverges from a reference it claims parity with (pnpm CLI grammar, a lockfile format, a Node behavior, a…

    4.4k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Linux Vm Test

    nubjs/nub

    Run ad-hoc Nub tests and debugging probes on real local Linux guests.

    4.4k GitHub stars~986 tokensUpdated today
    Auto-check passed
  • Performance-trace Nub package-manager installs using the existing phase timings, structured diagnostics, and sampling-profiler workflow.

    4.4k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Rust Build

    nubjs/nub

    A skill your agent uses when building or testing the nub Rust workspace inside a git worktree — cargo build/test/clippy for nub-cli/nub-core/aube in a worktree off origin/main.

    4.4k GitHub stars~4.4k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Cpu Reduction

What does Cpu Reduction do?

Diagnose and clear CPU, memory, and disk contention on the maintainer's dev host. Cpu Reduction is an agent skill from nubjs/nub. Diagnose and clear CPU, memory, and disk contention on the maintainer's dev host.

When should I use Cpu Reduction?

Cpu Reduction fits situations like: tasks that involve Git worktrees.

How do I install Cpu Reduction in Claude Code?

Run `npx skills add nubjs/nub --skill cpu-reduction -a claude-code`. Or copy the skill folder (.claude/skills/cpu-reduction in nubjs/nub) into .claude/skills/cpu-reduction in your project. Claude Code loads it when a task matches its description.

How do I install Cpu Reduction in Codex?

Run `npx skills add nubjs/nub --skill cpu-reduction -a codex`. Or copy the skill folder (.claude/skills/cpu-reduction in nubjs/nub) into .agents/skills/cpu-reduction in your project. Codex loads it when a task matches its description.

Can I use Cpu Reduction in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add nubjs/nub --skill cpu-reduction -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cpu-reduction, .gemini/skills/cpu-reduction, .github/skills/cpu-reduction and .opencode/skills/cpu-reduction in your project.

What does Cpu Reduction need to run?

Going by SKILL.md and its folder, Cpu Reduction needs Python for the scripts in its folder and the command-line tools its instructions call (tsc, git, python3, tsx, node and cargo). Our summary lists: Python 3.

Does Cpu Reduction access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Cpu Reduction safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Cpu Reduction use?

Cpu Reduction is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cpu Reduction use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cpu Reduction?

Skills that share tags, products or a category with Cpu Reduction: Migrate Core Code to Submodules (tinyhumansai/openhuman, 42k stars), Worktrunk CLI Output Rules (max-sixty/worktrunk, 9k stars), Projectatlas (styler-ai/ProjectAtlas, 440 stars) and Tsz Disk Cache Hygiene (tsz-org/tsz, 577 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cpu Reduction?

nubjs (a GitHub organization) maintains it in nubjs/nub, which has 4,372 GitHub stars. The repository holds 31 skills in this directory. The repository was last updated on October 7, 2026.

Source: nubjs/nub on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.