encapsulated-method-object
Installation
SKILL.md
1. When to use this skill
Use this skill when you encounter a Dart function or class method suffering from the "Bloated Closure" or "Deeply Nested Scope" smell. Specifically, target functions matching these criteria:
- Deeply Nested Scope: The function declares one or more inner/local functions to perform sub-tasks.
- Shared Local State: Those local functions rely heavily on capturing variables declared in the outer function's scope (closure capturing).
- High Complexity: The top-level function contains many local variables, is difficult to unit test in isolation, or has high cyclomatic complexity.
- Parameter Bloat: If you try to extract local functions to separate methods, you must pass large amounts of state as parameters.
When NOT to use (Overuse Guardrails)
Do NOT apply Method Object extraction when any of the following contraindications exist: