
Cs Refactor
Behavior-preserving refactoring skill that enforces equivalence checks before and after each structural change.
- skills.sh installs
- 1.2K
- GitHub stars
- 1.1K
- last updated
- Jul 14, 2026
What it does
- Covers the refactor workflow: pre-change checks for lessons and docs, stepwise edits, and a final regression pass
- Requires an equivalence-proving test, type check, or output baseline before any code is changed
- Stops and reports to the owner when a change would alter externally observable behavior, redirecting to feature or issue skills
- Scales review and verification to identified risks, with independent change review triggered only by trust-boundary, data, or concurrency changes
Install
$ npx -y skills add codestable/codestable --skill cs-refactor -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
cs-refactor
改结构,不改行为,并且能证明行为没变。
开工
- 有
.codestable/attention.md就先读。 - 按目标模块关键词检索
.codestable/lessons/、项目文档,以及存在的 v1 只读知识目录:.codestable/roadmap/、.codestable/features/、.codestable/issues/、.codestable/refactors/、.codestable/goals/、.codestable/compound/、.codestable/audits/、.codestable/brainstorms/、.codestable/feedback/;命中要报告来源路径。上述 v1 目录不得继续生成、原地改写或批量迁移,新结论按归属进入 v2 Epic、项目文档、ADR 或 lesson。 - 先确认诉求真是行为不变:一旦包含"顺便支持 X / 改成 Y",把那部分拆出去转
cs-feat或cs-issue,不夹带。 - 结构好坏用深度衡量:小接口承载大行为是深,接口和实现一样复杂是浅;重构应让调用方用更少认知换更多能力,不为"看起来干净"搬家,不把模块越拆越碎。
持续学习
检索到 lesson 后先做 read-repair。只做一次有界、最低成本的定向核实,优先读取已有代码、测试或
canonical 文档;不得仅为核实 lesson 运行大范围测试或反复复现。仍不足时跳过该 lesson,不阻塞正常任务。
只有 scope 符合、未退役、当前事实成立,并真实改变计划或验证,或明确排除一个具体且合理的错误路径
的条目才算有效命中;按
经验命中:{path}({status});核验:{fact};影响:{plan_or_check} 报告。retired 不应用;
observed / validated 先核实再用;旧 lesson 缺 status 按 observed 读取,不批量迁移。只是相关
但没有改变行为时不制造复用证据;当前事实明确反证时立即停止应用,证据不足时不猜。
任务内只在内存保留最多 3 条候选,按新证据替换低价值项,不暂停或询问。强信号只包括:owner 纠正实际改变方案/代码/术语/验证;可复现证据推翻根因;同一路径失败两次后更换假设; blocking/important finding 暴露未编码不变量;新 red -> green 捕获可复发失败;lesson 真实改变本次行为 或被反证;重复 workaround;方法显著降低重试、成本或风险。
Details
- Repository
- github.com/codestable/codestable
- Categories
- Code Review & Quality, Testing & QA, Agent Workflow & Planning
- First seen
- May 16, 2026
More from codestable/codestable
All 5Similar to Cs Refactor
More Code Review & Quality
cs-feat-implliuzhengdongfortest/codestable1.2K installsImplementation skill for new features and feature changes, sized to risk: small changes proceed directly, high-risk ones align on design first.
code-refactoring-refactor-cleansickn33/agentic-awesome-skills982 installsRefactoring playbook that analyzes code smells and applies incremental, behavior-preserving changes with test verification.
safe-refactorjuliusbrussee/caveman128.3K installsRestructures code while preserving behavior, with verification bracketing each structural edit.
cs-feat-designliuzhengdongfortest/codestable1.2K installsImplements new features and feature changes with process strength matched to risk, separate from bug fixes, refactors, and epics.