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.

Core Concepts

This is a Dart-specific variation of Martin Fowler's classic refactoring "Replace Method with Method Object". It consists of three primary elements:

Installs
2
GitHub Stars
4
First Seen
Jun 17, 2026
encapsulated-method-object — kevmoo/kevmoo_skills