Agent skill

Profile Memory

by marcus in marcus/sidecar

Profile memory usage in sidecar using Go pprof, system tools, and heap analysis.

MITAuto-check passedDevelopment

Install Profile Memory

skills CLI
$ npx skills add marcus/sidecar --skill profile-memory -a claude-code

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

GitHub CLI
$ gh skill install marcus/sidecar profile-memory --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/marcus/sidecar.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/profile-memory .claude/skills/profile-memory && 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
profile-memory
GitHub stars
1.1k
Token cost
~1.9k tokens
SKILL.md length
540 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

Profile memory usage in sidecar using Go pprof, system tools, and heap analysis.

  • Works in 4 steps: Check goroutines for blocked operations → Check SQLite locks: lsof -p | grep '.db' → Check stuck tea.Cmd goroutines → …
  • Investigating memory issues
  • SKILL.md covers Quick Triage, System-Level Profiling (No…, Go pprof (Runtime Profiling) and What to Look For, plus 5 more sections
  • Calls curl, go and brew

What it does

Profile Memory is an agent skill from marcus/sidecar. Profile memory usage in sidecar using Go pprof, system tools, and heap analysis. Covers identifying memory leaks, goroutine leaks, file descriptor accumulation, and CPU profiling. Use when investigating memory issues, profiling performance, debugging memory leaks, or diagnosing unresponsive plugins.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Async programming and Performance optimization. It works with SQLite. The repository describes itself as: Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td. The licence is MIT.

When your agent uses it

  • Investigating memory issues
  • Profiling performance
  • Debugging memory leaks
  • Diagnosing unresponsive plugins

Example prompts

  • “/profile-memory”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Check goroutines for blocked operations
  2. Check SQLite locks: lsof -p | grep '.db'
  3. Check stuck tea.Cmd goroutines
  4. Check for swap pressure: vmmap --summary | grep -E 'Physical|Swapped'

What it can do on your machine

Read from SKILL.md and the folder at commit 3792a4e. 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

    Shell commands in SKILL.md call:

    • curl
    • go
    • brew
    • apt

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

  • Network

    No URLs in SKILL.md. Its commands use curl, 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

Profile Memory loads about 1.9k tokens when it runs. Until then it costs about 79 tokens; SKILL.md has 540 words of instructions outside code blocks.

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

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); files beside SKILL.md are not scanned.

SKILL.md

The full file from marcus/sidecar at commit 3792a4e, republished under its MIT licence (© marcus). 540 words, ~1,851 tokens.

Download SKILL.mdSave it as .claude/skills/profile-memory/SKILL.md (or your agent's skills folder).
name
profile-memory
description
Profile memory usage in sidecar using Go pprof, system tools, and heap analysis. Covers identifying memory leaks, goroutine leaks, file descriptor accumulation, and CPU profiling. Use when investigating memory issues, profiling performance, debugging memory leaks, or diagnosing unresponsive plugins.
disable-model-invocation
true

Memory Profiling for Sidecar

Quick Triage

SymptomToolAction
High RSS / memory growthvmmap, pprof heapCheck system memory, then heap profile
Too many open fileslsofCheck FD count and breakdown
High CPUpprof cpu, psCapture CPU profile
Goroutine leakpprof goroutinesCheck goroutine count and stacks
Plugin unresponsivelsof + goroutinesCheck SQLite locks, blocked goroutines
Triage flow: Is RSS high? -> Check FD count -> Check vmmap -> Check heap profile

System-Level Profiling (No pprof Required)

Find the Process
bash
pgrep -f sidecar
ps aux | grep sidecar
Basic Stats
bash
# RSS, VSZ, CPU%, thread count
ps -o pid,rss,vsz,%cpu,nlwp -p <PID>

# Human-readable RSS
ps -o pid,rss -p <PID> | awk 'NR>1{printf "%d MB\n", $2/1024}'

# Watch over time
while true; do ps -o rss,%cpu -p <PID> | tail -1; sleep 5; done
System Memory

macOS (vmmap):

bash
vmmap --summary <PID>

Key sections: VM_ALLOCATE (Go heap), MALLOC (C heap/SQLite), Physical footprint, Swapped.

Red flags:

  • RESIDENT SIZE >500MB for idle sidecar
  • REGION COUNT in thousands for VM_ALLOCATE = mmap leak
  • SWAPPED SIZE growing = memory pressure

Linux:

bash
cat /proc/<PID>/status | grep -E 'VmRSS|VmSize|Threads'
pmap -x <PID> | tail -5
ls /proc/<PID>/fd | wc -l
File Descriptor Analysis
bash
# Count and breakdown
lsof -p <PID> | wc -l
lsof -p <PID> | awk '{print $5}' | sort | uniq -c | sort -rn

# Find leaked files
lsof -p <PID> | grep REG | awk '{print $9}' | sort | uniq -c | sort -rn | head -20

# Check session file leaks
lsof -p <PID> | grep -c '\.claude/projects'
lsof -p <PID> | grep -c '\.codex/sessions'

# Watch FD count
while true; do echo "$(date): $(lsof -p <PID> 2>/dev/null | wc -l) FDs"; sleep 30; done

Healthy baselines: Total FDs 50-150, REG files 10-30, PIPEs 10-30, DIRs 5-15.

Red flags: 1000+ total FDs, same file opened 4+ times, growing count over time.

Thread Count
bash
# macOS
ps -M -p <PID> | wc -l
# Linux
ls /proc/<PID>/task | wc -l
# Expected: 20-60 threads. 100+ = goroutine leak likely

Go pprof (Runtime Profiling)

Enable pprof
bash
SIDECAR_PPROF=1 sidecar        # Default port 6060
SIDECAR_PPROF=6061 sidecar     # Custom port
Heap Profile (Current Allocations)
bash
curl http://localhost:6060/debug/pprof/heap > heap.prof
go tool pprof -top heap.prof
go tool pprof heap.prof   # Interactive: top20, list <func>, web
Allocs Profile (All Allocations Since Start)
bash
curl http://localhost:6060/debug/pprof/allocs > allocs.prof
go tool pprof -top allocs.prof
Goroutine Profile
bash
# Count
curl -s http://localhost:6060/debug/pprof/goroutine?debug=1 | head -1

# Full stacks
curl http://localhost:6060/debug/pprof/goroutine?debug=2 > goroutines.txt

# Find stuck goroutines
grep -A5 'runtime.chanrecv' goroutines.txt
Memory Stats
bash
curl http://localhost:6060/debug/pprof/heap?debug=1 | head -30
Compare Snapshots (Best for Finding Leaks)
bash
curl http://localhost:6060/debug/pprof/heap > heap1.prof
# Wait (1 hour or overnight)
curl http://localhost:6060/debug/pprof/heap > heap2.prof
go tool pprof -base heap1.prof heap2.prof
# Then: top20
Continuous Monitoring
bash
./scripts/mem-monitor.sh         # Default: port 6060, 60s interval
./scripts/mem-monitor.sh 6061 30 # Custom port and interval

Output: CSV time,heap_alloc_bytes,heap_inuse_bytes,goroutines,rss_mb to mem-YYYYMMDD-HHMMSS.log.

CPU Profile
bash
curl http://localhost:6060/debug/pprof/profile?seconds=30 > cpu.prof
go tool pprof -top cpu.prof
go tool pprof cpu.prof   # Interactive: top20, list <func>, web
Web UI
bash
go tool pprof -http=:8080 http://localhost:6060/debug/pprof/heap

Requires Graphviz (brew install graphviz / apt install graphviz) for flame graphs.

What to Look For

Goroutine leaks: Count should stabilize at 20-50 after startup. Steady growth = leak. Search for runtime.chanrecv1, runtime.chansend1, time.Sleep.

Heap growth: HeapAlloc should stabilize after loading sessions. Consistent upward trend = leak.

Common pprof signatures: bufio.Scanner (buffer not returned), json.Unmarshal (large objects retained), append in loops (slice growing), channel operations (blocked senders/receivers).

Diagnosing Unresponsive Plugins

  1. Check goroutines for blocked operations:
    bash
    curl -s http://localhost:6060/debug/pprof/goroutine?debug=2 | grep -A10 'monitor\|td'
  2. Check SQLite locks: lsof -p <PID> | grep '\.db'
  3. Check stuck tea.Cmd goroutines:
    bash
    curl -s http://localhost:6060/debug/pprof/goroutine?debug=2 | grep -B2 'fetchData\|FetchData'
  4. Check for swap pressure: vmmap --summary <PID> | grep -E 'Physical|Swapped'

Common causes: SQLite locked by concurrent td CLI, memory pressure causing swap thrashing, goroutine blocked on unread channel, accumulating fetchData() goroutines.

Known Leak Patterns

File Descriptor Accumulation (Adapter/Watcher Layer)

Files: internal/adapter/claudecode/watcher.go etc. Uses fsnotify to watch directories.

Symptoms: RSS grows to 5-15GB overnight, lsof shows 1000+ session files open.

bash
lsof -p <PID> | grep '\.claude/projects' | wc -l
lsof -p <PID> | grep '\.codex/sessions' | wc -l
Show full SKILL.md (220 more words)Show less
OutputBuffer Substring Retention

OutputBuffer.Update() uses strings.Split() creating substrings sharing backing array. NOT a leak if Update() keeps being called. Only retains if polling stops.

Poll Chain Duplication

Entering interactive mode without incrementing generation counter creates parallel poll chains. Doubles CPU but no memory leak. Fix: increment shellPollGeneration or pollGeneration on entry.

Go MADV_FREE (macOS)

Go runtime uses MADV_FREE marking pages reusable without returning to OS. RSS appears high but memory is available. NOT a leak. Use vmmap --summary and compare "Physical footprint (peak)" vs current.

Investigation Workflow

  1. ps -o pid,rss,%cpu -p <PID> -- establish baseline
  2. lsof -p <PID> | wc -l -- if >200, focus on FD leak
  3. lsof -p <PID> | grep REG | awk '{print $9}' | sort | uniq -c | sort -rn | head -20
  4. vmmap --summary <PID> -- RESIDENT vs VIRTUAL, region count
  5. If pprof available: heap snapshot comparison over time
  6. If pprof unavailable: restart with SIDECAR_PPROF=1, reproduce the leak

Overnight Test Procedure

  1. Start: SIDECAR_PPROF=1 sidecar
  2. Baseline: curl .../heap > baseline.prof
  3. Note goroutine count
  4. Leave overnight (caffeinate -i on macOS)
  5. Morning: capture new profiles
  6. Compare: go tool pprof -base baseline.prof morning.prof
  7. Check goroutines for stuck ones

Notes

  • pprof adds ~1-2MB overhead, no TUI performance impact
  • HTTP server runs in separate goroutine, localhost only
  • On macOS, vmmap/lsof need no special permissions for own processes

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

Files

Just SKILL.md in .claude/skills/profile-memory of marcus/sidecar.

Open the folder on GitHubat commit 3792a4e

Compare with similar skills

Profile Memory 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.

Profile Memory compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Profile Memory this skillmarcus/sidecar1.1k—~1.9kAutomated safety check: PassMIT
Swift Concurrencysupabitapp/supaterm172—~3.3kAutomated safety check: PassCustom licence
Swift ConcurrencyAFK-surf/OpenBridge430—~2.8kAutomated safety check: PassMIT
Golang Prodavila7/claude-code-templates32k8 repos~1.9kAutomated safety check: PassMIT
Python Prodavila7/claude-code-templates32k8 repos~1.8kAutomated safety check: PassMIT
Python ExpertRightNow-AI/openfang18k—~765Automated safety check: PassApache-2.0

Similar skills

  • Swift Concurrency

    supabitapp/supaterm

    Diagnose data races, convert callback-based code to async/await, implement actor isolation patterns, resolve Sendable conformance issues, and guide Swift 6 migration.

    172 GitHub stars~3.3k tokensUpdated 13 days ago
    DevelopmentAuto-check passed
  • Swift Concurrency

    AFK-surf/OpenBridge

    Expert guidance on Swift Concurrency best practices, patterns, and implementation.

    430 GitHub stars~2.8k tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • Golang Pro

    davila7/claude-code-templates

    Master Go 1.21+ with modern patterns, advanced concurrency, performance optimization, and production-ready microservices.

    32k GitHub starsUsed in 8 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Python Pro

    davila7/claude-code-templates

    Master Python 3.12+ with modern features, async programming, performance optimization, and production-ready practices.

    32k GitHub starsUsed in 8 repos~1.8k tokens
    DevelopmentAuto-check passed
  • Python Expert

    RightNow-AI/openfang

    Python expert for stdlib, packaging, type hints, async/await, and performance optimization

    18k GitHub stars~765 tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • External Mindstudio Ascend Profiler DB Explorer

    ascend-ai-coding/awesome-ascend-skills

    面向 Ascend PyTorch Profiler / msprof DB(如 ascendpytorchprofiler.db、msprof.db)的 SQL 分析技能。将自然语言问题(算子耗时、通信、下发、调度、schema/table 查询)转为安全可执行 SQL,并按需从官方文档提取表结构详情。

    174 GitHub stars~1.4k tokensUpdated today
    DevelopmentAuto-check passed

More from marcus/sidecar

All 19 skills in this repo
  • Create Adapter

    marcus/sidecar

    Create conversation adapters for importing AI chat history from different tools (Claude Code, Cursor, Warp, Codex, etc.).

    1.1k GitHub stars~4.8k tokensUpdated 2 days ago
    Auto-check passed
  • Create Modal

    marcus/sidecar

    Create declarative modals using the modal library API. An agent skill from marcus/sidecar.

    1.1k GitHub stars~2.6k tokensUpdated 2 days ago
    Auto-check passed
  • Create Plugin

    marcus/sidecar

    Create new sidecar plugins implementing the plugin.Plugin interface, rendering views with Bubble Tea, handling keyboard input via keymap contexts, and integrating with the app shell (footer hints…

    1.1k GitHub stars~2.3k tokensUpdated 2 days ago
    Auto-check passed
  • Project Switching

    marcus/sidecar

    Project switching implementation in sidecar: project discovery, state management, UI flow, modal rendering, filtering, theme preview, and plugin reinitialization.

    1.1k GitHub stars~1.8k tokensUpdated 2 days ago
    Auto-check passed
  • Shell Integration

    marcus/sidecar

    Interactive shell/TTY integration with tmux session management, shell command execution, control-mode output capture with polling fallback, native cursor rendering, lazy scrollback, selection, paste…

    1.1k GitHub stars~3.6k tokensUpdated 2 days ago
    Auto-check passed
  • Sidecar Website

    marcus/sidecar

    Writing and maintaining the Sidecar Docusaurus documentation site, including page structure, doc authoring, blog posts, styling, images, and deployment workflow.

    1.1k GitHub stars~1.7k tokensUpdated 2 days ago
    Auto-check passed

Works with

Categories

Questions about Profile Memory

What does Profile Memory do?

Profile memory usage in sidecar using Go pprof, system tools, and heap analysis. Profile Memory is an agent skill from marcus/sidecar. Profile memory usage in sidecar using Go pprof, system tools, and heap analysis.

When should I use Profile Memory?

Profile Memory fits situations like: investigating memory issues; profiling performance; debugging memory leaks; diagnosing unresponsive plugins.

How do I install Profile Memory in Claude Code?

Run `npx skills add marcus/sidecar --skill profile-memory -a claude-code`. Or copy the skill folder (.claude/skills/profile-memory in marcus/sidecar) into .claude/skills/profile-memory in your project. Claude Code loads it when a task matches its description.

How do I install Profile Memory in Codex?

Run `npx skills add marcus/sidecar --skill profile-memory -a codex`. Or copy the skill folder (.claude/skills/profile-memory in marcus/sidecar) into .agents/skills/profile-memory in your project. Codex loads it when a task matches its description.

Can I use Profile Memory 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 marcus/sidecar --skill profile-memory -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/profile-memory, .gemini/skills/profile-memory, .github/skills/profile-memory and .opencode/skills/profile-memory in your project.

What does Profile Memory need to run?

Going by SKILL.md and its folder, Profile Memory needs the command-line tools its instructions call (curl, go, brew and apt).

Does Profile Memory access the network?

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

Is Profile Memory 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. Review the folder before installing.

What licence does Profile Memory use?

Profile Memory 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 Profile Memory use?

About 1.9k tokens (SKILL.md is roughly 7.4k 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 Profile Memory?

Skills that share tags, products or a category with Profile Memory: Swift Concurrency (supabitapp/supaterm, 172 stars), Swift Concurrency (AFK-surf/OpenBridge, 430 stars), Golang Pro (davila7/claude-code-templates, 32k stars) and Python Pro (davila7/claude-code-templates, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Profile Memory?

marcus (a GitHub user) maintains it in marcus/sidecar, which has 1,085 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 5, 2026.

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