combine-code-review

Review Swift Combine code for memory leaks, operator misuse, and error handling.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/javierhbr/random-poc --skill combine-code-review
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: combine-code-review
Source: https://github.com/javierhbr/random-poc/tree/main/custom-skills/beagle-main/plugins/beagle-ios/skills/combine-code-review
Command: npx skills add https://github.com/javierhbr/random-poc --skill combine-code-review

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps Swift developers identify and fix common issues in their Combine framework code, preventing bugs related to memory leaks, operator misuse, and improper error handling.

Core Features & Use Cases

  • Memory Leak Detection: Identifies potential retain cycles caused by improper handling of AnyCancellable and strong self-captures.
  • Operator Misuse: Checks for incorrect usage of Combine operators like flatMap and switchToLatest.
  • Error Handling Validation: Ensures errors are handled gracefully and publisher chains remain alive.
  • Use Case: Before merging a feature branch, run this Skill on the new Combine code to catch a potential memory leak in a sink closure that could lead to UI crashes.

Quick Start

Use the combine-code-review skill to analyze the provided Swift code for Combine-related issues.

Frequently Asked Questions about combine-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find memory leaks in Swift Combine publishers and sinks?

To find memory leaks in Swift Combine code, review your `AnyCancellable` handling and self-captures within `sink` closures. Identifying improper strong references prevents retain cycles and subsequent UI crashes in reactive chains.

How do I handle errors in Combine publisher chains without terminating them?

Handling errors in Combine requires validating that publisher chains remain alive by replacing failing streams or using correct error propagation. Reviewing error handling ensures graceful failure recovery instead of crashing the subscription pipeline.

What is the correct way to use flatMap and switchToLatest in Combine?

The correct way to use Combine operators like `flatMap` and `switchToLatest` involves validating your reactive logic against standard best practices. Checking operator usage prevents unintended concurrent publisher behaviors and data inconsistencies.

Can I review Swift Combine code for subscription management best practices?

You can review Swift Combine code to validate subscription management and error propagation by targeting publishers, subjects, and cancellables. This ensures robust and efficient reactive code before merging new feature branches.

Why does my Combine sink closure cause a retain cycle?

A Combine `sink` closure causes a retain cycle when it strongly captures self while holding an active `AnyCancellable` reference. Detecting these improper captures breaks the memory leak and stops unexpected UI crashes.

When do I need to check my reactive Swift code for operator misuse?

You need to check reactive Swift code for operator misuse when implementing complex pipelines with publishers and subjects. Validating operator usage before merging a feature branch catches incorrect stream manipulations early.