/dev-refactor
重构子类型规范 — 测试覆盖前置确认 + 三段式重构流程
$ npx -y skills add devcodex-labs/devcodex --skill dev-refactor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/dev-refactor
Context preview
The summary Claude sees to decide when to auto-load this skill.
重构子类型规范 — 测试覆盖前置确认 + 三段式重构流程
SKILL.md
dev-refactor.SKILL.mdname: dev-refactor description: 重构子类型规范 — 测试覆盖前置确认 + 三段式重构流程
Dev Refactor Skill
触发条件
用户意图为重构现有代码(不改变外部行为),典型场景:提取公共模块、消除重复代码、改善架构分层、升级编码风格。
前置检查(必须在 CP1 前完成)
| 项 | 内容 | |----|------| | 测试覆盖确认 | 确认被重构模块已有测试覆盖(单测/集成测试),无测试时**禁止继续**,优先补测试 | | 基线快照 | 记录当前接口签名、导出列表、公开 API | | 类型契约基线 | TypeScript 项目须区分必须保持兼容的公开类型契约与允许修正的旧类型缺陷 |
执行流程
CP1(范围确认)→ CP2(方案确认)→ [plan-review] → [impact-review] → CP3(计划确认)→ 执行
**plan-review**:PR-1 在 CP2 前自检,PR-2~PR-7 在 CP2→CP3 之间执行;PR-5② 跨模块依赖变更时继续 `impact-review`,🔴 阻断时回 CP2。
**执行阶段**: 1. 最小增量重构,每步可独立回滚 2. 重构后运行测试套件(零新增失败) 3. 更新 API 文档(若接口签名变更) 4. document-sync(更新架构文档)
关键规则
- 🔴 重构前测试覆盖率不足时,**必须先补测试再重构**(C-REF-01)
- 禁止在重构 PR 中混入功能变更(行为不变原则)
- Breaking Changes 必须在 CP2 中列出并评估
- TypeScript 类型迁移或重构不得机械复制旧版本类型缺陷;应按公开契约与消费面逐步完善,跨模块业务契约、公开类型与配置类型优先集中到 types 契约层,本地私有 interface 可保留但须说明理由
Intent-driven AI coding workflow runtime for consistent context, skills, approvals, validation, and handoffs across six AI coding hosts.
Repo: devcodex-labs/devcodex
Other skills on devcodex.
ai-agent-system-archit…
AI Agent 系统架构专家 Owner — 当任务涉及 Agent 路由、工具调用、上下文管理、记忆、状态机、权限、人机协作、可观测性、回放验证或模型辅助治理时使用;要求把…
ai-evaluation-engineer…
AI 评测工程专家 Owner — 当任务涉及模型/Prompt 评测、模型选择、黄金集、评分量表、LLM-as-judge、Judge…

