> swift-memory-management
Standards for ARC, Weak/Unowned References, and Capture Lists. Use when managing Swift ARC, avoiding retain cycles, or configuring capture lists in closures. (triggers: **/*.swift, weak, unowned, capture, deinit, retain)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/swift-memory-management?format=md"Swift Memory Management
Priority: P0
Implementation Guidelines
ARC Fundamentals
- Default: Strong references. Swift automatically manages retain/release.
- Weak: Use
weakfor delegate patterns and parent-child relationships. - Unowned: Use
unownedonly when reference guaranteed to outlive (rare).
Capture Lists
- Closures: Always use
[weak self]or[unowned self]in escaping closures. - Self in Structs: No capture list needed (
selfis copied by value). - Multiple Captures:
[weak self, weak delegate].
Retain Cycles
- Delegates: Always
weak var delegate. - Closures as Properties: Use
weakorunownedin capture list. - two-way References: One side must be
weak.
Anti-Patterns
- Strong Delegates:
**No strong var delegate**: Use weak. - Missing Capture List:
**No self in escaping closures**: Use [weak self]. - Unowned Misuse:
**Avoid unowned**: Use weak unless certain.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)