一键导入
refactor-for-testability
Use when refactoring code to improve testability, separate side effects, remove hidden dependencies, or introduce dependency injection.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when refactoring code to improve testability, separate side effects, remove hidden dependencies, or introduce dependency injection.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | refactor-for-testability |
| description | Use when refactoring code to improve testability, separate side effects, remove hidden dependencies, or introduce dependency injection. |
Refactor toward explicit boundaries.
Prefer pure functions for core behavior.
Move side effects to the outer boundary.
At the boundary, convert untrusted outside-world values into application-owned data before they reach core logic.
Boundary code should handle runtime validation, parsing, normalization, and semantic error mapping.
Inject dependencies explicitly.
Avoid importing hidden dependencies into core logic.
Hidden dependencies include:
Keep dependency records minimal.
Do not create large dependency containers.
Do not introduce classes or inheritance unless explicitly requested.
Do not introduce a dependency injection framework unless explicitly requested.
Preserve behavior first.
Add characterization tests when behavior is not already covered.
Keep each refactor small and reversible.
Prefer this order:
When a refactor would become too large, stop at a clean boundary and summarize the next step.
Do not mix unrelated cleanup with the testability refactor.
Use when the user proposes a technical solution, asks for architectural feedback, asks whether an approach is good, or wants a Staff+/Principal-level engineering review. Do not use for small mechanical edits.
Use when creating a human-facing report, implementation plan, architecture comparison, codebase review, PR review, migration analysis, testability audit, performance investigation, or stakeholder summary where visual structure, diagrams, tables, or collapsible sections make the result easier to review. Do not use for canonical repository documentation, small answers, README files, AGENTS.md, SKILL.md, or files intended for clean git diffs.
Use when a task spans multiple logical changes and the user wants the working tree prepared for review or later commits.
Use when writing, updating, or reviewing automated tests. Use for unit tests, behavior changes, regression tests, and testability refactors.