Install
openclaw skills install memguardMemory leak & resource management scanner -- detects unclosed handles, event listener leaks, circular references, unbounded caches, missing cleanup, dangling...
openclaw skills install memguardMemGuard scans codebases for memory leaks and resource management issues: unclosed file handles, event listener leaks, circular references, unbounded caches/maps, missing cleanup in React useEffect, dangling timers/intervals, unreleased database connections, missing stream close, forgotten subscriptions, and retained DOM references -- across JS/TS, Python, Java, Go, Rust, and C#. It uses regex-based pattern matching against 90+ resource lifecycle patterns, lefthook for git hook integration, and produces markdown reports with actionable remediation recommendations. 100% local. Zero telemetry.
memguard scan [file|directory]One-shot memory leak and resource management scan of files or directories.
How to execute:
bash "<SKILL_DIR>/scripts/memguard.sh" scan [target]
What it does:
Example usage scenarios:
memguard scan .memguard scan src/app.tsmemguard scan src/memguard scan .memguard scan .memguard hook installInstall git pre-commit hooks that scan staged files for memory leaks before every commit.
How to execute:
bash "<SKILL_DIR>/scripts/memguard.sh" hook install
What it does:
memguard hook uninstallRemove MemGuard git hooks.
bash "<SKILL_DIR>/scripts/memguard.sh" hook uninstall
memguard report [directory]Generate a markdown resource health report with findings, severity breakdown, and remediation steps.
bash "<SKILL_DIR>/scripts/memguard.sh" report [directory]
What it does:
memguard watch [directory]Continuous monitoring mode that watches for file changes and re-scans automatically.
How to execute:
bash "<SKILL_DIR>/scripts/memguard.sh" watch [directory]
What it does:
memguard ci [directory]CI/CD integration mode with structured exit codes and machine-readable output.
bash "<SKILL_DIR>/scripts/memguard.sh" ci [directory]
What it does:
memguard team-report [directory]Aggregate team metrics across the codebase with trend analysis.
bash "<SKILL_DIR>/scripts/memguard.sh" team-report [directory]
What it does:
memguard baseline [directory]Establish a baseline of known resource issues for tracking progress over time.
bash "<SKILL_DIR>/scripts/memguard.sh" baseline [directory]
What it does:
memguard statusShow license and configuration information.
bash "<SKILL_DIR>/scripts/memguard.sh" status
MemGuard detects 90+ resource lifecycle patterns across 6 categories:
| Category | Examples | Severity |
|---|---|---|
| File Handles (FH) | Python open() without close/with, Java FileInputStream without close, Node fs.open without fs.close, missing using/with statements, unclosed database connections | Critical/High |
| Event Listeners (EL) | addEventListener without removeEventListener, on() without off(), missing event cleanup in React lifecycle, event emitter leaks, global event handlers never removed | High/Medium |
| Circular References (CR) | Parent-child circular refs, self-referencing objects, closure-captured references to parent scope, mutual references between classes, WeakRef/WeakMap needed but not used | High/Medium |
| Unbounded Caches (UC) | Map/Set growing without limit, in-memory cache without TTL/eviction, global arrays accumulating, memoization without size limit, localStorage unbounded writes | High/Medium |
| React Cleanup (RC) | useEffect without cleanup return, setInterval in useEffect without clearInterval, subscription in useEffect without unsubscribe, state update after unmount, ref held after unmount | High/Medium |
| Timers & Streams (TM) | setInterval without clearInterval, setTimeout in loops, stream pipe without error handling, readable stream not destroyed, missing stream.end(), unclosed WebSocket | Critical/High |
Users can configure MemGuard in ~/.openclaw/openclaw.json:
{
"skills": {
"entries": {
"memguard": {
"enabled": true,
"apiKey": "YOUR_LICENSE_KEY_HERE",
"config": {
"severityThreshold": "high",
"ignorePatterns": ["**/test/**", "**/fixtures/**", "**/*.test.*"],
"ignoreChecks": [],
"allowlistFile": ".memguard-allowlist",
"reportFormat": "markdown"
}
}
}
}
}
hook install, prompt to install itThe user might say things like:
brew install lefthook