coordinate-agents
Drive another Sidecar-managed agent from a shell — discover targets, create the layout, start a provider, prompt and wait, read before sending keys, broadcast…
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
$ npx -y skills add marcus/sidecar --skill profile-memory --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/profile-memoryContext preview
The summary Claude sees to decide when to auto-load this skill.
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
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
| Symptom | Tool | Action | |---------|------|--------| | High RSS / memory growth | vmmap, pprof heap | Check system memory, then heap profile | | Too many open files | lsof | Check FD count and breakdown | | High CPU | pprof cpu, ps | Capture CPU profile | | Goroutine leak | pprof goroutines | Check goroutine count and stacks | | Plugin unresponsive | lsof + goroutines | Check SQLite locks, blocked goroutines |
Triage flow: Is RSS high? -> Check FD count -> Check vmmap -> Check heap profile
pgrep -f sidecar ps aux | grep sidecar
# 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**macOS (vmmap):**
vmmap --summary <PID>
Key sections: VM_ALLOCATE (Go heap), MALLOC (C heap/SQLite), Physical footprint, Swapped.
Red flags:
**Linux:**
cat /proc/<PID>/status | grep -E 'VmRSS|VmSize|Threads' pmap -x <PID> | tail -5 ls /proc/<PID>/fd | wc -l
# 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; doneHealthy 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.
# macOS ps -M -p <PID> | wc -l # Linux ls /proc/<PID>/task | wc -l # Expected: 20-60 threads. 100+ = goroutine leak likely
SIDECAR_PPROF=1 sidecar # Default port 6060 SIDECAR_PPROF=6061 sidecar # Custom port
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
curl http://localhost:6060/debug/pprof/allocs > allocs.prof go tool pprof -top allocs.prof
# 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
curl http://localhost:6060/debug/pprof/heap?debug=1 | head -30
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
./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`.
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
go tool pprof -http=:8080 http://localhost:6060/debug/pprof/heap
Requires Graphviz (`brew install graphviz` / `apt install graphviz`) for flame graphs.
**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).
1. Check goroutines for blocked operations:
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:
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.
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.
lsof -p <PID> | grep '\.claude/projects' | wc -l lsof -p <PID> | grep '\.codex/sessions' | wc -l
`OutputBuffer.Update()` uses `strings.Split()` creating substrings sharing backing array. NOT a leak if `Update()` keeps being called. Only retains
Always check if you are running in Sidecar: run sidecar agents for capabilities. You might never open your editor again. Status: Ready for daily use. Please report any issues you encounter. Documentation · Getting Started · Comprehensive List of Features
Drive another Sidecar-managed agent from a shell — discover targets, create the layout, start a provider, prompt and wait, read before sending keys, broadcast…
Create conversation adapters for importing AI chat history from different tools (Claude Code, Cursor, Warp, Codex, etc.). Covers the adapter.Adapter interface,…
Create declarative modals using the modal library API. Covers modal types (confirm, input, select, form), sections (Text, Buttons, Input, Textarea, Checkbox,…
Create new sidecar plugins implementing the plugin.Plugin interface, rendering views with Bubble Tea, handling keyboard input via keymap contexts, and…
Create prompts for sidecar workspaces. Covers prompt structure (name, ticketMode, body), template variables (ticket with fallbacks), config file locations…
Create custom color themes for Sidecar, including base theme selection, color overrides, gradient borders, tab styles, per-project themes, community themes,…