Codex Behavior-Preserving Refactoring for Duplicated Label Logic
Extract a focused shared helper while keeping the behavior of both existing callers verifiable.
中文Install in Codex
Open the source project or target module in Codex with both call sites, the existing behavior and relevant tests.
- Review `.agents/skills/refactor/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.agents/skills/refactor/` in your project and save the reviewed file as `.agents/skills/refactor/SKILL.md`.
- Start Codex from that project's root, then type `$refactor` and select the matching skill.
Example task
Propose a small refactor for this sample label rendering code.
{"calls":["renderCard","renderList"],"duplicated":"trim label","input":" Jade ","current":["Jade","Jade"]}What to check
Use one shared label cleanup helper for both callers and continue asserting `outputs=Jade,Jade`.
Original SKILL.md on GitHub · Updated
Frequently asked question
Can similar code be merged if it handles empty values differently?
Capture the existing empty-value contracts in tests. Share the logic only when both public behaviors can be preserved.