kotlin-coroutines-structured-concurrency

Analyze Kotlin coroutine code for scope misuse and cancellation anti-patterns.

13|Updated Jun 24, 2021
One-click install
npx skills add https://github.com/costular/Minitask --skill kotlin-coroutines-structured-concurrency-costular
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-coroutines-structured-concurrency
Source: https://github.com/costular/Minitask/tree/main/.agents/skills/kotlin-coroutines-structured-concurrency
Command: npx skills add https://github.com/costular/Minitask --skill kotlin-coroutines-structured-concurrency-costular

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires kotlinpoet, kotlinx.coroutines, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill identifies and resolves common pitfalls in Kotlin coroutine usage, ensuring better-structured code and enhanced system resilience.

Core Features & Use Cases

  • Identify Unowned Scopes: Detects the improper usage of long-lived CoroutineScope properties.
  • Prevent Silent Cancellation: Ensures that coroutines are properly managed and cancellations are handled.
  • Analyze Anti-Patterns: Identifies and provides solutions for common anti-patterns in coroutine usage.

Quick Start

Analyze your Kotlin code using this Skill and review any instances where a CoroutineScope is stored as a property.

Frequently Asked Questions about kotlin-coroutines-structured-concurrency

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

FAQPage Schema
How do I detect unowned CoroutineScope properties in Kotlin?

To detect unowned CoroutineScope properties in Kotlin, analyze your code to identify long-lived coroutine scopes stored as properties. This process reveals improper scope usage and provides specific recommendations for refactoring to ensure better-structured concurrency and system stability.

Why does silent cancellation happen in Kotlin coroutines and how can I prevent it?

Silent cancellation in Kotlin coroutines happens when coroutines are improperly managed and cancellation states are ignored. You can prevent silent cancellation by analyzing anti-patterns in your asynchronous programming and applying targeted refactoring to ensure cancellations are explicitly handled.

What are common Kotlin coroutine anti-patterns for asynchronous programming?

Common Kotlin coroutine anti-patterns include storing long-lived CoroutineScope instances as properties and ignoring silent cancellation. Analyzing these asynchronous programming patterns helps identify structural weaknesses and provides specific solutions to refactor the code for enhanced resilience.

Can I use this to analyze existing Kotlin code for structured concurrency issues?

Yes, you can analyze existing Kotlin code for structured concurrency issues by reviewing instances where a CoroutineScope is stored as a property. The analysis identifies improper usage of long-lived scopes and silent cancellation, providing specific refactoring recommendations to boost code quality.

Do I need Kotlin analysis tools to refactor structured concurrency anti-patterns?

Yes, you need Kotlin analysis tools and an understanding of asynchronous programming patterns to refactor structured concurrency anti-patterns. Analyzing the code to identify improper long-lived coroutine scopes requires specific dependencies to generate accurate refactoring recommendations.