<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ilya Kalinin</title>
    <description>The latest articles on DEV Community by Ilya Kalinin (@gerrux).</description>
    <link>https://dev.to/gerrux</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4203417%2Fd0a30909-9b33-4728-acf8-3a15e68b6a58.png</url>
      <title>DEV Community: Ilya Kalinin</title>
      <link>https://dev.to/gerrux</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gerrux"/>
    <language>en</language>
    <item>
      <title>xrun: smoke-test on a free Kaggle GPU, train on vast.ai, let the agent read the metrics</title>
      <dc:creator>Ilya Kalinin</dc:creator>
      <pubDate>Sun, 01 Nov 2026 18:48:47 +0000</pubDate>
      <link>https://dev.to/gerrux/xrun-smoke-test-on-a-free-kaggle-gpu-train-on-vastai-let-the-agent-read-the-metrics-2803</link>
      <guid>https://dev.to/gerrux/xrun-smoke-test-on-a-free-kaggle-gpu-train-on-vastai-let-the-agent-read-the-metrics-2803</guid>
      <description>&lt;p&gt;I train 3D computer vision models, and classical ones at hackathons. For a long time every run came with the same chores: &lt;code&gt;vastai create instance&lt;/code&gt;, &lt;code&gt;scp&lt;/code&gt; the data up, start the script, check on it, &lt;code&gt;scp&lt;/code&gt; the checkpoint back, remember to destroy the instance. Kaggle had its own version of that with &lt;code&gt;kaggle kernels push&lt;/code&gt;. I wanted to hand the whole loop to an agent: launch on whichever platform fits, smoke-test on a free Kaggle GPU before paying for the real training, and collect metrics the same way everywhere, so the agent can read them and decide what to do next.&lt;/p&gt;

&lt;p&gt;That became xrun, a Rust CLI with a Python Textual TUI on top. One YAML manifest describes a run: where the GPU comes from, what to upload, what to run and what to bring back. xrun rents the instance, uploads the data, starts training, follows stages and metrics, pulls the checkpoints and destroys the instance when it's over. It supports six vendors: vast.ai, Kaggle, Lightning AI, Google Colab, your own server over SSH, and the local machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feox5498ldzokl24cbv48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feox5498ldzokl24cbv48.png" alt="An experiment manifest for vast.ai next to a terminal: xrun ls with runs on vast, Kaggle, SSH, Colab and the local machine, the train_loss curve from xrun metrics --ascii, and xrun pull fetching the best checkpoint" width="799" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A manifest
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;resnet50_baseline&lt;/span&gt;
&lt;span class="na"&gt;vendor&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vast&lt;/span&gt;                    &lt;span class="c1"&gt;# vast | kaggle | lightning | colab | ssh | local&lt;/span&gt;

&lt;span class="na"&gt;vast&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pytorch/pytorch:2.4.1-cuda12.1-cudnn9-devel&lt;/span&gt;
  &lt;span class="na"&gt;gpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RTX&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;4090"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;count&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;1&lt;/span&gt; &lt;span class="pi"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;max_per_hour&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;0.55&lt;/span&gt; &lt;span class="pi"&gt;}&lt;/span&gt;

&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data/train.h5&lt;/span&gt;
    &lt;span class="na"&gt;dst&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/workspace/data/train.h5&lt;/span&gt;

&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;cmd&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python train.py&lt;/span&gt;
  &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;--lr&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5e-4&lt;/span&gt;
    &lt;span class="na"&gt;--epochs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;

&lt;span class="na"&gt;artifacts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;patterns&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;checkpoints/best*.pt"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;policy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;on_idle_minutes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;           &lt;span class="c1"&gt;# no output for 30 minutes: destroy&lt;/span&gt;
  &lt;span class="na"&gt;early_stop&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;                   &lt;span class="c1"&gt;# metric plateau: pull the best, then destroy&lt;/span&gt;
    &lt;span class="na"&gt;metric&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;val_f1&lt;/span&gt;
    &lt;span class="na"&gt;patience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the day-to-day loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xrun launch exp/resnet50.yaml &lt;span class="nt"&gt;--detach&lt;/span&gt; &lt;span class="nt"&gt;--max-cost&lt;/span&gt; 5
xrun events &amp;lt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--follow&lt;/span&gt;
xrun metrics &amp;lt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--key&lt;/span&gt; val_f1 &lt;span class="nt"&gt;--ascii&lt;/span&gt;
xrun pull &amp;lt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--ckpt&lt;/span&gt; best &lt;span class="nt"&gt;--into&lt;/span&gt; models/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The smoke test is a second manifest with &lt;code&gt;vendor: kaggle&lt;/code&gt; and a small config. The training script and the metrics code stay the same, so if it survives a few epochs on Kaggle, I launch the vast.ai one.&lt;/p&gt;

&lt;p&gt;A copy of the manifest is stored with the run, and its hash is part of the run's identity. I can edit the original freely and &lt;code&gt;xrun rerun &amp;lt;id&amp;gt;&lt;/code&gt; still reproduces exactly what ran. For hyperparameters, &lt;code&gt;xrun sweep exp/base.yaml --grid run.args.--lr=1e-3,5e-4 --launch&lt;/code&gt; writes out one manifest per variant.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqe7jpprc64id00clc67v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqe7jpprc64id00clc67v.png" alt="xrun launch --detach rents a GPU, uploads the data, starts training and returns to the shell; xrun events --follow shows the stages: provision, upload, setup, train and epochs" width="800" height="776"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Built for an agent to drive
&lt;/h2&gt;

&lt;p&gt;Every read command (&lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;show&lt;/code&gt;, &lt;code&gt;events&lt;/code&gt;, &lt;code&gt;metrics&lt;/code&gt;) has &lt;code&gt;--json&lt;/code&gt;, and whatever the TUI can do, the CLI can do too. &lt;code&gt;xrun show&lt;/code&gt; prints each metric's last value and step, so a score logged once at the end of a cross-validation run is visible without plotting anything. &lt;code&gt;xrun install skill --claude&lt;/code&gt; (or &lt;code&gt;--codex&lt;/code&gt;) installs a skill that teaches Claude Code or Codex to use xrun instead of hand-rolled &lt;code&gt;vastai&lt;/code&gt; and &lt;code&gt;ssh&lt;/code&gt; calls. So the agent can rerun the last experiment with a different learning rate, or pull the checkpoint of the run with the best val_f1 from the last day, through the same commands I would type.&lt;/p&gt;

&lt;p&gt;Metrics come from a small hook in the training script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;xrun_hook&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;done&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;notify&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;train&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ep&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;epochs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_one_epoch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;train_loss&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ep&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;val_loss&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;val_f1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ep&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;training&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;best val_f1 = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;done&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The hook writes &lt;code&gt;events.jsonl&lt;/code&gt; and &lt;code&gt;metrics.jsonl&lt;/code&gt;, and a background poller picks them up. On Kaggle xrun injects the hook into the kernel by itself. An uncaught exception gets recorded as an &lt;code&gt;error&lt;/code&gt; event.&lt;/p&gt;

&lt;h2&gt;
  
  
  A billing instance is never left alone
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;xrun launch --detach&lt;/code&gt; leaves that poller running. It counts the spend and destroys the instance when the run finishes, fails, goes silent, hits a metric plateau or runs into &lt;code&gt;--max-cost&lt;/code&gt; / &lt;code&gt;--max-hours&lt;/code&gt;. If the destroy call fails, you get a push saying the instance is still billing. The poller can't report its own death, so &lt;code&gt;xrun watchdog&lt;/code&gt; runs from the OS scheduler every five minutes: no heartbeat from the poller while the instance is alive means a notification and a respawned poller. It also catches instances that no run record knows about.&lt;/p&gt;

&lt;p&gt;Notifications go to ntfy, Telegram, a webhook (Slack, Discord) or desktop toasts. Replying &lt;code&gt;/stop &amp;lt;id&amp;gt;&lt;/code&gt; to the Telegram bot kills a run.&lt;/p&gt;

&lt;p&gt;The run history lives in a local SQLite database, with no tracking service or account involved. MLflow and W&amp;amp;B plug in as mirrors if you want their charts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rough edges
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;xrun_hook&lt;/code&gt; isn't on PyPI yet, so outside Kaggle it travels with your code. Kaggle shows metrics mid-run only when an MLflow server is configured; without one you see the start and the end. Lightning AI was smoke-tested live on a CPU Studio only, and for Lightning and Colab xrun doesn't know the price, so &lt;code&gt;--max-cost&lt;/code&gt; doesn't apply there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;macOS and Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sSf&lt;/span&gt; https://raw.githubusercontent.com/Gerrux/xrun/master/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows (PowerShell):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;irm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;https://raw.githubusercontent.com/Gerrux/xrun/master/install.ps1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;xrun doctor&lt;/code&gt; and then &lt;code&gt;xrun launch exp/templates/quickstart.yaml&lt;/code&gt; check the whole chain locally with no credentials, GPU or data. The code is on GitHub under MIT: &lt;a href="https://github.com/Gerrux/xrun/blob/master/README.en.md" rel="noopener noreferrer"&gt;Gerrux/xrun&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you run training on one of these vendors, a report of what broke is the most useful thing you could send me. Each of their APIs has its own habits, and half of the fixes so far came from exactly that.&lt;/p&gt;

&lt;p&gt;I built xrun together with my AI sidekick, Claude Code (Opus 5.5), and this post was written with its help too.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>automation</category>
      <category>cli</category>
      <category>rust</category>
    </item>
    <item>
      <title>15 Claude Code sessions were sitting on 11 GB of RAM. I built a mod to see which one</title>
      <dc:creator>Ilya Kalinin</dc:creator>
      <pubDate>Fri, 23 Oct 2026 21:09:44 +0000</pubDate>
      <link>https://dev.to/gerrux/15-claude-code-sessions-were-sitting-on-11-gb-of-ram-i-built-a-mod-to-see-which-one-3jdn</link>
      <guid>https://dev.to/gerrux/15-claude-code-sessions-were-sitting-on-11-gb-of-ram-i-built-a-mod-to-see-which-one-3jdn</guid>
      <description>&lt;p&gt;I usually have ten to fifteen Claude Code sessions open. One is fixing tests, another is working on a frontend in a neighbouring worktree, a third has been waiting for my answer since the morning, and I forgot about the fourth. Each has its own subagents and MCP servers, with a vite server up here and a pytest run there. At some point my 64 GB machine started lagging on every window switch.&lt;/p&gt;

&lt;p&gt;Task Manager showed a wall of identical &lt;code&gt;node&lt;/code&gt; and &lt;code&gt;claude&lt;/code&gt; processes. I could see how much they were eating, but not which session they belonged to, and I didn't want to close windows at random.&lt;/p&gt;

&lt;p&gt;So I wrote claude-load, a Claude Code mod that splits the machine's load by session. The first run showed 15 live sessions using 10.8 GB. Most had been idle for a while with merged PRs, and one was running a forgotten Python process whose parent had exited long ago.&lt;/p&gt;

&lt;p&gt;Code (MIT): &lt;a href="https://github.com/Gerrux/claude-load" rel="noopener noreferrer"&gt;github.com/Gerrux/claude-load&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Whose node is this?
&lt;/h2&gt;

&lt;p&gt;You can't tell sessions apart by process name, since they all run the same &lt;code&gt;claude&lt;/code&gt;, &lt;code&gt;node&lt;/code&gt; and &lt;code&gt;bash&lt;/code&gt;. But Claude Code keeps a registry of live sessions: &lt;code&gt;~/.claude/sessions/&lt;/code&gt; has a &lt;code&gt;&amp;lt;pid&amp;gt;.json&lt;/code&gt; for each one, with almost everything you need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"pid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;18636&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sessionId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a3a4722e-…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Refactor the auth middleware"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"busy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cwd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"C:&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;work&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;api"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"entrypoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"claude-desktop"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The format isn't documented, so the mod reads only these fields and doesn't fail if it catches a file mid-rewrite. It never opens the &lt;code&gt;*.key&lt;/code&gt; files with tokens that sit next to them.&lt;/p&gt;

&lt;p&gt;The sampler takes the list of all processes with their parents and walks up the PPID chain from each one until it hits a session's PID. The whole tree under a session counts as its load. Walked chains are cached, so hundreds of processes take a single pass.&lt;/p&gt;

&lt;p&gt;It turned out that even an idle session holds 0.5 to 0.7 GB: 300 to 450 MB for &lt;code&gt;claude&lt;/code&gt; itself, plus its own set of MCP servers on node. Fifteen forgotten windows add up to several gigabytes.&lt;/p&gt;

&lt;p&gt;In the pane, each session shows CPU, memory and a six-minute graph. Orphans come next, and at the bottom everything that isn't a session is folded by name. If it says &lt;code&gt;chrome ×31&lt;/code&gt; there, Claude is off the hook.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1glugu6pdm6drxmu4xqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1glugu6pdm6drxmu4xqv.png" alt="claude-load pane: CPU and RAM with graphs, sessions, an orphan and processes outside sessions" width="800" height="921"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When CPU goes over 50% or memory over 85%, a line with the top consumers appears above the prompt:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhmsy7z3bocw6aid59xhy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhmsy7z3bocw6aid59xhy.png" alt="Load line above the prompt" width="796" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the terminal, &lt;code&gt;/load&lt;/code&gt; prints the same thing as text:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgpgnb9j1rpucr6ypva80.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgpgnb9j1rpucr6ypva80.png" alt="/load report in the terminal" width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshots are rendered from demo data, because my real sessions are named after work projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Orphans and the "end" button
&lt;/h2&gt;

&lt;p&gt;By orphans I mean processes that don't belong to any session but clearly came from one: vite from a session I closed long ago, a language server with no editor, that Python run. I wanted to show them separately and let you end them with one button.&lt;/p&gt;

&lt;p&gt;In the first version, an orphan was any dev process outside sessions with noticeable load. The review before release showed that this pulled in my working PowerShell, IDE helpers and &lt;code&gt;conhost&lt;/code&gt;, and the button offered to end them along with all their children.&lt;/p&gt;

&lt;p&gt;The button itself was worse. It trusted an in-memory snapshot that could be arbitrarily old, and it didn't check the process name. In the meantime a PID can be freed and handed to another process, and &lt;code&gt;taskkill /T&lt;/code&gt; would have taken down an unrelated program together with its children.&lt;/p&gt;

&lt;p&gt;The rule is stricter now. An orphan is a tree whose root's parent is really dead. On Windows that means the parent PID isn't among the living, or the process with that PID was created after the child (the number was reused). On macOS and Linux the root has been reparented to &lt;code&gt;init&lt;/code&gt;, &lt;code&gt;systemd&lt;/code&gt; or &lt;code&gt;launchd&lt;/code&gt;. Only trees with a real dev tool in them are shown, not just shells, and only if they use at least 0.3% CPU or 150 MB. The terminal a session was started from and the sampler itself are never orphans.&lt;/p&gt;

&lt;p&gt;To attribute an orphan to a repository you need its working directory. On Linux it's &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/cwd&lt;/code&gt;, and on macOS &lt;code&gt;lsof&lt;/code&gt; reports it. Windows has no API for this, so the mod reads it from the other process's memory: &lt;code&gt;NtQueryInformationProcess&lt;/code&gt; gives the PEB address, &lt;code&gt;ProcessParameters&lt;/code&gt; is at offset &lt;code&gt;0x20&lt;/code&gt;, and &lt;code&gt;CurrentDirectory&lt;/code&gt; is at &lt;code&gt;0x38&lt;/code&gt; inside those. In code that's a couple of &lt;code&gt;ReadProcessMemory&lt;/code&gt; calls.&lt;/p&gt;

&lt;p&gt;Before ending anything, the mod takes a fresh snapshot, refuses to act on one older than 15 seconds, and checks that the PID still belongs to a process with the same name. Session processes and PIDs missing from the snapshot can't be ended from the pane. You can click the button half an hour after opening the pane and it's still safe.&lt;/p&gt;

&lt;h2&gt;
  
  
  One sampler per machine
&lt;/h2&gt;

&lt;p&gt;If each of fifteen sessions polled processes on its own, the monitor would add load of its own. So exactly one process per machine does the sampling: it writes &lt;code&gt;~/.claude/state/load/snapshot.json&lt;/code&gt;, and the mod in each session reads that file every five seconds, however many sessions there are.&lt;/p&gt;

&lt;p&gt;On Windows the sampler is a hidden PowerShell process that the mod starts when the snapshot is stale. Two measurements on my machine shaped it: &lt;code&gt;Get-Process&lt;/code&gt; takes 76 ms, while a full CIM query with parents takes 400 ms. So every four seconds it reads &lt;code&gt;Get-Process&lt;/code&gt;, and the parent tree from CIM is queried only when new PIDs appear, at most once every eight seconds. CPU share comes from the difference in accumulated time between passes.&lt;/p&gt;

&lt;p&gt;The sampler lives as long as someone needs it. Each session touches a &lt;code&gt;wanted&lt;/code&gt; file every 30 seconds; after three minutes without a touch, the sampler exits. If it crashes, the first session to see a stale snapshot starts a new one, and a PID file with a command-line check prevents a second copy. On a 12-thread machine with 15 sessions this costs about 0.35% CPU and 130 MB of memory.&lt;/p&gt;

&lt;p&gt;On macOS and Linux no separate process is needed, since &lt;code&gt;ps&lt;/code&gt; is cheap. There, one session holds a "lease" (a file with its ID and a timestamp) and does the sampling itself. If the lease isn't renewed for 15 seconds, another session takes over. CPU took some fiddling. On Linux the &lt;code&gt;%cpu&lt;/code&gt; column is the average over the process's whole life, so the mod uses the difference in the &lt;code&gt;time&lt;/code&gt; column instead. But Linux reports &lt;code&gt;time&lt;/code&gt; in whole seconds, and two passes one second apart draw spikes that never happened. So passes run at most once every four seconds and never overlap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results and limitations
&lt;/h2&gt;

&lt;p&gt;I wrote it over a couple of days together with my AI sidekick, Claude Code (Opus 5.5). The first cleanup worked right away. The "Sort it out with Claude" button sends a request to a bundled skill; Claude sorts idle sessions and orphans, asks once, and touches only what you approve. Of 15 sessions, 12 went to the archive: eight with merged PRs and four forgotten ones without a PR. Used memory dropped from 35.2 to 31.2 GB. I also turned on auto-archiving a session when its PR is merged in the desktop app.&lt;/p&gt;

&lt;p&gt;The mod hasn't run on a real Mac or Linux box yet. Tests cover recorded &lt;code&gt;ps&lt;/code&gt;, &lt;code&gt;vm_stat&lt;/code&gt;, &lt;code&gt;/proc/meminfo&lt;/code&gt; and &lt;code&gt;lsof&lt;/code&gt; output, but that doesn't replace a live machine. CPU on Linux is coarser than on Windows because &lt;code&gt;ps&lt;/code&gt; reports time in whole seconds; reading &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/stat&lt;/code&gt; would fix that. Under a strict PowerShell policy (&lt;code&gt;AllSigned&lt;/code&gt; or Constrained Language Mode) the sampler won't start, and the mod says so instead of showing "Waiting…" forever.&lt;/p&gt;

&lt;p&gt;The session registry is undocumented, so if Anthropic changes the &lt;code&gt;~/.claude/sessions&lt;/code&gt; format, the mod will need an update. On Windows the working directory is read from another process's memory. It's read-only and limited to the current user's processes, but an antivirus or EDR may not like it. The mod makes no network requests and has no telemetry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;You need Claude Code 2.1.287 or newer. The command below adds the repo as a marketplace and installs the mod for your user. On macOS, Linux and Git Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude plugin marketplace add Gerrux/claude-load &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; claude plugin &lt;span class="nb"&gt;install &lt;/span&gt;claude-load@claude-load &lt;span class="nt"&gt;--config&lt;/span&gt; &lt;span class="nv"&gt;language&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;auto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;claude&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;plugin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;marketplace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Gerrux/claude-load&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;$?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;claude&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;plugin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;claude-load&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;claude-load&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;language&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;auto&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the desktop app without a terminal: "+" next to the prompt, Plugins, Add marketplace, &lt;code&gt;Gerrux/claude-load&lt;/code&gt;, Add plugin. Then run &lt;code&gt;/reload-plugins&lt;/code&gt; and &lt;code&gt;/load&lt;/code&gt;. The &lt;a href="https://code.claude.com/docs/en/plugins/mods/overview" rel="noopener noreferrer"&gt;Claude Code docs&lt;/a&gt; cover mods in general.&lt;/p&gt;

&lt;p&gt;How many sessions do you usually keep open? If you're on a Mac or Linux, tell me what &lt;code&gt;/load&lt;/code&gt; showed and what broke.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was written with the help of Claude, the same way the mod was.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
