Skip to content
Skill

Memory leak diagnosis

Guides an agent to find and fix memory leaks, retain cycles and Task issues in Swift 6

Memory leak diagnosis is an open-source agent skill for developer tools. It is available on Claude Code.

Scripts
None
Platforms
Claude Code
GitHub stars
20
Last commit
License
MIT
Listing updated

Similar skills

About Memory leak diagnosis

This skill walks an agent through diagnosing memory growth in Swift 6 apps, focusing on retain cycles, ARC problems and long-lived Tasks that outlive their UI. It gives a decision tree that maps symptoms such as growth during navigation or closure cycles to the right Instruments view or code change.

The guidance favors structured concurrency: cancelling stored Tasks in deinit or view lifecycle hooks, checking Task.isCancelled inside loops, using weak self in stored closures, and preferring async APIs or @Observable over Combine sinks. A short Instruments path covers running the Leaks or Allocations template, exercising the suspect flow, and confirming the result in the Memory Graph.

The skill expects a Swift codebase and Xcode with Instruments available. It includes a pre-finish checklist asking the agent to identify the root cause before changing code and to re-profile afterward. It ships as a single SKILL.md with no bundled scripts.

When your agent uses it

Use when investigating memory growth, retain cycles, leaks in Instruments, Task cancellation issues, or ARC problems in Swift 6 apps.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 1 file (2 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the swift-modern-dev plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add pstuart/pstuart
/plugin install swift-modern-dev@pstuart

Or copy only this skill to ~/.claude/skills/memory-leak-diagnosis:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/memory-leak-diagnosis &&
cp -R "$tmp/plugins/swift-modern-dev/skills/memory-leak-diagnosis" ~/.claude/skills/memory-leak-diagnosis &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/memory-leak-diagnosis inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/memory-leak-diagnosis to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/memory-leak-diagnosis &&
cp -R "$tmp/plugins/swift-modern-dev/skills/memory-leak-diagnosis" ~/.agents/skills/memory-leak-diagnosis &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/memory-leak-diagnosis inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/memory-leak-diagnosis to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/memory-leak-diagnosis &&
cp -R "$tmp/plugins/swift-modern-dev/skills/memory-leak-diagnosis" ~/.cursor/skills/memory-leak-diagnosis &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/memory-leak-diagnosis inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/pstuart/pstuart.git --path plugins/swift-modern-dev/skills/memory-leak-diagnosis

Or copy the folder to ~/.gemini/skills/memory-leak-diagnosis yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/memory-leak-diagnosis:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/memory-leak-diagnosis &&
cp -R "$tmp/plugins/swift-modern-dev/skills/memory-leak-diagnosis" ~/.copilot/skills/memory-leak-diagnosis &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/memory-leak-diagnosis inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/pstuart/pstuart.git

Then copy pstuart/plugins/swift-modern-dev/skills/memory-leak-diagnosis into your agent's skills folder as memory-leak-diagnosis. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Symptom-based decision tree
Maps symptoms like navigation-driven growth or delegate cycles to the appropriate diagnostic or code fix.
Task lifecycle cancellation
Shows how to store, cancel and tie background Tasks to deinit, onDisappear or the .task modifier.
Closure capture fixes
Covers weak self and async alternatives for stored closures that create retain cycles.
Instruments profiling workflow
Step-by-step path through the Leaks and Allocations instruments, Cycles and Roots, and Memory Graph checks.
Common leak patterns table
Lists frequent leak sources such as uncancelled Tasks, NotificationCenter observers and timers with their fixes.
Evidence-first checklist
Requires a confirmed root cause and a clean re-profile before a fix is considered done.

Good for

  • Find why my SwiftUI app's memory keeps growing when I navigate between screens
  • Check my view model for a Task that never gets cancelled
  • Fix a retain cycle caused by a closure capturing self
  • Review how I replaced a Combine sink with async code for leaks
  • Walk me through profiling a suspected leak with Instruments

Memory leak diagnosis FAQ

What does Memory leak diagnosis need to run?

It is written for Swift 6 apps and points the agent to Xcode Instruments and the Memory Graph. It bundles no scripts, so the profiling itself is done by the developer in Xcode.

What does Memory leak diagnosis change in my project?

The skill only gives guidance. It describes fixes such as cancelling Tasks, adding weak self, and using structured async, but it does not define any file edits or automated changes.

When is Memory leak diagnosis triggered?

It applies when a task involves memory growth, retain cycles, leaks in Instruments, Task cancellation problems or ARC issues in Swift 6 apps.

How do I install Memory leak diagnosis in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/memory-leak-diagnosis to use it in all your projects, or to .claude/skills/memory-leak-diagnosis in one project. Or install the swift-modern-dev plugin, which includes it: /plugin marketplace add pstuart/pstuart, then /plugin install swift-modern-dev@pstuart.

Does Memory leak diagnosis run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Memory leak diagnosis?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

What are the best alternatives to Memory leak diagnosis?

The closest alternatives to Memory leak diagnosis are Axiom audit memory, Swift performance optimization, Axiom performance, Performance and Improve architecture.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from pstuart/pstuart

  1. Reports git state, activity and build evidence across every project in a folder

    • Open source
    • 20 GitHub stars
    • Developer tools
  2. Checks web pages against WCAG 2.1 AA contrast, labels, keyboard and ARIA rules

    • Open source
    • 20 GitHub stars
    • Developer tools
  3. Guides an AI agent through building and reviewing Nuxt 4 apps with the app/ layout

    • Open source
    • 20 GitHub stars
    • Developer tools
  4. Walks an agent through a web application security audit checklist and report

    • Open source
    • 20 GitHub stars
    • Security
  5. Guides an agent to style Nuxt and Vue UIs with Tailwind CSS 4 utilities and @theme tokens

    • Open source
    • 20 GitHub stars
    • Developer tools
  6. Guides an agent to write and review strict TypeScript in Vue, Nuxt and Node code

    • Open source
    • 20 GitHub stars
    • Developer tools