Split long files by responsibility while keeping public interfaces, dependencies, and behavior consistent.
Triggers
Activate when
- "Split long files by responsibility while keeping public interfaces, dependencies, and behavior consistent."
- “Refactor a large file into cohesive modules.”
Do not activate when
- Only querying this Skill's description, or requesting tasks unrelated to the above results; do not perform actual business operations.
- When the user only wants a preview or review, do not enter the modify, commit, or publish branches.
Execution boundary
A natural language request is enough to trigger it; no legacy slash path, parameter interpolation, or specified assistant is needed. Clearly parse the project, target files, options, and output location in the current request; use the file, search, CLI, and browser capabilities actually provided by the current host. Verify project dependency versions and external APIs at execution time; do not assume the examples are current configuration. Resolve bundled scripts from the Skill root, and business files from the target project root. Read the current state first, and protect existing uncommitted content and the staging area of other tasks. Keep analysis and preview requests read-only; execute modifications, commits, pushes, deployments, and releases according to the explicit scope of the current request. Do not bypass protections, automatically send messages, forcibly terminate user processes, or seize the foreground. On failure, preserve the diagnosable original error.
Workflow
-
Read the target file, callers, exported interfaces, state, and side effects to find truly separable responsibilities; length itself is not a reason for splitting.
-
Propose the minimum modules and dependency direction, preserving the project's existing naming conventions; a pure planning request delivers only the structural plan.
-
Move implementations module by module and update import/export, avoiding barrel files introducing cycles, changes in initialization order, and duplication of shared state.
-
Check public APIs, exceptions, asynchronous timing, and resource release, preserve necessary compatibility exports, and do not needlessly expose internal functions.
-
Run type checks and relevant behavior tests, and deliver the responsibilities of the new files and the dependency graph.
Composition
Before execution, read capability composition, and hand off adjacent capabilities according to explicit artifacts.
Runtime context (shared)
Before running, read this package's skill.yaml and Profile contract. Priority is the current request, project context, this Skill's records, shared preferences, brand/user Profile, and safe defaults. Read only declared fields; hosts without a dedicated runtime can use scripts/profile_store.py to read the shared Profile. For missing configuration, ask only one question that affects the result. Values the user explicitly asks to save long-term are written atomically through that script, and report the actual path; do not save inferences, credentials, or materials from other tasks.