feat(skills): add memory-leak-debug skill for heap snapshot diagnosis#4468
Conversation
Provides a step-by-step workflow for diagnosing memory leaks in the CLI using Node.js heap snapshots and the chrome-devtools CLI memory tools. Includes a helper script for tmux PID discovery and a worked example from the react-reconciler PerformanceMeasure leak (dbdc94b).
📋 Review SummaryThis PR adds a well-structured debugging skill for diagnosing memory leaks using heap snapshots and the 🔍 General Feedback
🎯 Specific Feedback🔵 Low
🟢 Medium
🟡 High
✅ Highlights
|
There was a problem hiding this comment.
Overall: LGTM, approve to merge
The motivation is well-founded — memory leak diagnosis is a core operational capability for a long-running CLI. Codifying the workflow while the ink 7 PerformanceMeasure leak investigation is still fresh is the right engineering culture.
The worked example is high quality: a complete five-phase closed loop (symptom → diagnosis → root cause → fix → verification) referencing a specific commit dbdc94be9, which shows the author actually walked through the full process. find-leaf-node.sh is clean and effective. Integration with tmux-real-user-testing is natural.
Two non-blocking suggestions — can follow up after merge:
- Pin
chrome-devtools-mcpversion: Prerequisites saynpm i chrome-devtools-mcp@latest -g.@latesthas no version pinning; a breaking change upstream could silently break this skill in a few months. Consider pinning to a verified minimum version (e.g.>=0.x.y). - Unify
$SESSIONvariable usage in examples: In Step 1, afterevalcaptures$SESSION, subsequent examples use the literal"<session-name>"placeholder instead of$SESSION. This can trip up both agents and humans. Consider using$SESSIONconsistently.
中文说明
整体判断:认可,可以 merge
动机完全正当——内存泄漏诊断是长期运行 CLI 的核心运维能力,趁 ink 7 PerformanceMeasure 泄漏事件的热度把经验固化下来,是正确的工程文化。
Worked example 质量很高:symptom → diagnosis → root cause → fix → verification 五段完整闭环,引用了具体 commit dbdc94be9,说明作者确实走过一遍。find-leaf-node.sh 简洁有效,与 tmux-real-user-testing 的集成也很自然。
两个 non-blocking 建议,merge 后跟进也行:
chrome-devtools-mcp版本锁定:Prerequisites 里写的是npm i chrome-devtools-mcp@latest -g,@latest没有版本锁定,三个月后可能 breaking change。建议锁定一个已验证的最低版本号(如>=0.x.y),避免 Skill 静默腐化。$SESSION变量示例统一:Step 1 里eval拿到$SESSION后,后续示例用的是"<session-name>"字面量而不是$SESSION,容易让 agent 或人卡住。建议统一改成$SESSION。
— Qwen Code
yiliang114
left a comment
There was a problem hiding this comment.
LGTM — clean skill addition, no runtime impact. The worked example and script are solid.
|
It is intentionally written as |
…4500) Pulls 5 main commits since #4469 (2026-05-24): - #4464 fix(weixin): send decryptable image payloads - #4465 fix(weixin): allow Windows image paths inside workspace - #4470 fix(cli): resolve stale closure race in text buffer submit handler - #4468 feat(skills): add memory-leak-debug skill for heap snapshot diagnosis - #4288 feat(cli): do not append trailing space for directory completions (#4092) 11 manual conflicts resolved + 2 add/add conflicts taken from main wholesale: Manual UU (12, all daemon-side preferred except text-buffer.ts): - packages/acp-bridge/package.json — kept HEAD's fuller description (F1 lift expanded the package surface; main has stale pre-F1 wording). - packages/cli/src/acp-integration/acpAgent.ts — kept HEAD's WorkspaceMcpBudget import (F2 needs it). - packages/cli/src/acp-integration/acpAgent.worktree.test.ts (AA): kept HEAD's superset of mocks (MCP_BUDGET_WARN_FRACTION, getMCPDiscoveryState, MCPServerStatus, McpTransportPool, WorkspaceMcpBudget, workspace/debug/mcp config mocks). HEAD already includes main-side SessionStartSource + SessionEndReason mocks. - packages/cli/src/ui/commands/directoryCommand.tsx — pure formatting (HEAD wrapped vs main inline). Kept HEAD. - packages/cli/src/ui/commands/directoryCommand.test.tsx — pure formatting. Kept HEAD. - packages/cli/src/ui/commands/skillsCommand.ts — pure formatting. Kept HEAD. - packages/cli/src/ui/hooks/useCommandCompletion.tsx — pure formatting. Kept HEAD. - packages/cli/src/ui/hooks/useCommandCompletion.test.ts — pure formatting. Kept HEAD. - packages/cli/src/ui/hooks/useSlashCompletion.test.ts — pure formatting. Kept HEAD. - packages/core/src/config/config.test.ts — kept HEAD's TrustGateError import (daemon-added). text-buffer.ts (4 zones — took MAIN wholesale for #4470's stale-closure fix): - Import: useRef instead of useReducer (daemon side had useReducer as a dead import — file uses dispatch via useCallback, not useReducer; verified via grep). useRef is needed for stateRef + #4470's currentText capture. - writeFileSync zone: use stateRef.current.lines.join('\n') instead of stale closure-captured `text`. Fixes #4470's bug. - text comparison: `newText !== currentText` not `newText !== text`. - dep array: `[dispatch, ...]` not `[text, ...]` (callback reads from ref now, doesn't need to re-bind on text change). AA (2, main wholesale via git checkout --theirs): - packages/core/src/permissions/dangerousRules.ts + .test.ts Original #4151 Auto-mode added these on main, came into daemon via #4469 squash. Main then landed #4371 ("strip additional dangerous interpreter rules") as a follow-up that daemon side never saw. Take main's evolved version wholesale. Verification: - packages/core tsc: 50 errors PRE-merge, 50 errors POST-merge (pre-existing baseline — none introduced by this sync). - packages/acp-bridge tsc: clean. - 5 spot-test runs on conflict-resolved files: 132 + 17 + 24 + 30 + 1 = 204 tests pass (text-buffer / directoryCommand / useCommandCompletion / useSlashCompletion / skillsCommand). Mirrors #4469's pattern (squash merge daemon_mode_b_main-side). Unblocks #4490 daemon_mode_b_main → main reverse integration merge (currently CONFLICTING precisely because of these 5 main commits).
Summary
.qwen/skills/memory-leak-debug/skill that provides a step-by-step workflow for diagnosing memory leaks in the Qwen Code CLI using Node.js heap snapshots and thechrome-devtoolsCLI memory analysis tools.Validation
Scope / Risk
chrome-devtools-mcppackage.Testing Matrix
Testing matrix notes:
Linked Issues / Bugs
No linked issues.
🤖 Generated with Qwen Code