agentleFS
boettiger-labboettiger-lab/agent-skills/pod-resources/SKILL.md

pod-resources

Skill4 starsChanged 15 days agoBSD-3-ClauseView on GitHub

Read the CPUs and memory actually available to this container before running parallel or memory-heavy work. Use before sizing any multiprocessing pool, parallel sweep, make -j, or large in-memory job. Allocations change, so never rely on remembered core or RAM numbers; query the cgroup each time.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Keep OMP_NUM_THREADS=1 inside workers, so each process uses one thread.

    line 30
  2. Very specific:

    Never pkill -f a pattern that also matches your own shell command line.

    line 33

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Sizing parallel work to the container

The pod's CPU and memory allocations change over time. Never size a job from a remembered number. Query them at the moment you launch.

Check

python3 ~/.claude/skills/pod-resources/resources.py [MB_PER_WORKER] [HEADROOM_MB]

This prints the usable CPUs, the cgroup memory limit, the memory in use (excluding reclaimable page cache) and the memory available, plus a suggested worker count.

In Python

import os, sys
sys.path.insert(0, os.path.expanduser("~/.claude/skills/pod-resources"))
from resources import safe_workers, cpus, memory_mb
workers = safe_workers(mb_per_worker=250, headroom_mb=3000)

Pitfalls

  • nproc honours OMP_NUM_THREADS and can report 1 on a many-core pod. Use the script (CPU affinity, capped by /sys/fs/cgroup/cpu.max).
  • Keep OMP_NUM_THREADS=1 inside workers, so each process uses one thread.
  • Estimate per-worker memory from one run (peak RSS), then add headroom: other processes share the limit.
  • Exceeding memory.max gets the pod OOM-killed. Re-check before each large launch, because other work may have started.
  • Never pkill -f a pattern that also matches your own shell command line; kill by PID.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.