agentleFS
frankxaifrankxai/agentic-creator-os/.claude/skills/memory-guardian/SKILL.md

memory-guardian

Skill10 starsChanged 8 months agoApache-2.0View on GitHub

WSL2 memory safety and scaling guardrails for Claude Code sessions and parallel agents.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    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
  1. Distinctive:

    Before spawning 3+ parallel Task agents

    line 12
  2. Very specific:

    Before running npm run build or other memory-heavy operations

    line 13
  3. Distinctive:

    When SessionStart hook reports WARNING or CRITICAL memory status

    line 14
  4. Distinctive:

    When user mentions running multiple CC instances

    line 15
  5. Distinctive:

    Prefer sequential over parallel work

    line 31
  6. Very specific:

    Avoid npm run build alongside agents

    line 32
  7. Distinctive:

    Always run the memory check before:

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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

Memory Guardian Skill

Purpose

Monitors WSL2 memory usage and enforces safe scaling limits for Claude Code instances and parallel agents.

When This Skill Activates

  • Before spawning 3+ parallel Task agents
  • Before running npm run build or other memory-heavy operations
  • When SessionStart hook reports WARNING or CRITICAL memory status
  • When user mentions running multiple CC instances

Memory Check Command

free -m | awk '/^Mem:/{printf "RAM: %dMB/%dMB (%d%%)\n", $3, $2, $3*100/$2} /^Swap:/{if($3>0) printf "Swap: %dMB/%dMB\n", $3, $2}'

Scaling Rules

Green Zone (< 75% RAM usage)

  • Parallel Task agents: up to 4
  • Background builds: safe
  • No restrictions

Yellow Zone (75-89% RAM usage)

  • Parallel Task agents: max 2
  • Prefer sequential over parallel work
  • Avoid npm run build alongside agents
  • Warn user: "Memory pressure is high. Limiting parallel agents to 2."

Red Zone (>= 90% RAM usage)

  • Parallel Task agents: max 1 (or 0 — work sequentially)
  • NO background builds
  • Suggest user close other CC instances
  • Warn user: "Memory critically low. Working sequentially to prevent WSL crash."

Before Heavy Operations

Always run the memory check before:

  1. Spawning 3+ parallel Task subagents
  2. Running production builds (npm run build)
  3. Starting dev server + agents simultaneously

WSL Configuration Reference

  • Host: 16GB RAM
  • WSL limit: 12GB (C:\Users\Frank\.wslconfig)
  • Swap: 12GB
  • Per CC instance: ~500MB + ~100-150MB per MCP server
  • Safe concurrent CC instances: 4-5
  • autoMemoryReclaim: dropcache (aggressive)

Recovery If Memory Is Critical

# Check what's using memory
ps aux --sort=-%mem | head -20

# Kill any orphaned node processes from old CC sessions
pkill -f "node.*claude" 2>/dev/null

# Force kernel to drop caches (non-destructive)
echo 1 | sudo tee /proc/sys/vm/drop_caches 2>/dev/null

Integration

  • Hook: .claude/hooks/memory-check.sh runs on SessionStart
  • Statusline: Memory percentage visible if hook fires warning
  • Self-enforcing: CC reads this skill and self-limits before scaling

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.