Community编程与开发github.com

安全重构

在保持行为不变的前提下重构代码。适用于提取、合并、所有权转移或清理,但需用验证来约束结构性编辑。

安全重构 是什么?

该技能“安全重构”指导AI代理在重构过程中保持代码行为不变,确保每一次结构性修改都经过验证。它强调在编辑前定义行为保护边界并建立验证机制,避免将功能变更混入重构,每次只移动一个所有权边界,并保留公共接口、失败行为、顺序和兼容性(除非显式设定范围)。中间状态必须可构建和可测试,同时避免不必要地增加依赖或配置。执行后运行相同验证,直到行为匹配且结构达到要求。此技能适用于Claude Code、Cursor等AI代理工具,帮助开发者在提取、合并、清理等任务中安全地进行大型重构,减少风险。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/JuliusBrussee/caveman/tree/main/skills/safe-refactor

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

安全重构 是做什么的?

在结构性编辑前定义行为保护边界并建立验证机制。

  • 将功能变更排除在重构之外。
  • 一次只移动一个所有权边界。
  • 保留公共接口、失败行为、顺序和兼容性,除非显式设定了变更范围。
  • 保持中间状态可构建且可测试。
  • 避免在没有正确性需求的情况下增加依赖或配置。

修改后执行相同的验证。当行为匹配且所需结构达成时停止。

Individual skills in this repo

This repo contains 12 individual skills — each has its own dedicated page.

JuliusBrussee/caveman-discover

Find and label every LLM workflow in the repository so Caveman Cloud groups spend by workflow instead of one bucket. Use for "discover workflows" or breaking LLM spend down by workflow.

JuliusBrussee/caveman-evidence-review

Read-only review of Caveman Cloud evidence: cost, Cave Score, workflows, traces, latency, errors, routing, savings. Use when asked what Caveman found or where LLM spend goes.

JuliusBrussee/caveman-explore

Read-only repository explorer for cold-start orientation, broad cross-file localization, or when a direct search failed. Skip it when the exact file or symbol is already named. Returns path:line citations only; its reads stay out of main context.

JuliusBrussee/caveman-learn

Act on a Caveman learn report - review the ranked token sinks, apply cost-lowering fixes with per-edit consent, and report what those fixes returned. Use when asked to lower an agent's token cost, what caveman has saved, to trim a heavy CLAUDE.md, or to offload re-pasted context into cavemem.

JuliusBrussee/caveman-manage

Inspect Caveman Cloud's experiment lifecycle and block unsafe execution. Use when asked to start, approve, cancel, promote or roll back a Caveman experiment.

JuliusBrussee/caveman-optimize

Turn a Caveman optimization observation into an operator-chosen candidate with a paired baseline evaluation. Use when asked to inspect or evaluate a Caveman optimization report. Needs explicit approval.

JuliusBrussee/caveman-setup

Wire a repository through the Caveman Cloud gateway so every LLM request is measured, with no behavior change. Use for "set up caveman" or adding LLM spend observability.

JuliusBrussee/investigate-first

Diagnose ambiguous failures before editing. Use for unknown causes, intermittent behavior, performance regressions, or investigations needing evidence-ranked hypotheses.

JuliusBrussee/lean-build

Build feature work with high overbuilding risk. Use for new behavior, product slices, or integrations where repository reuse, strict scope, and an explicit stop condition matter.

JuliusBrussee/migration

Implement reversible compatibility-safe transitions. Use for schema, data, API, protocol, configuration, or dependency migrations requiring rollback and preservation proof.

JuliusBrussee/surgical-patch

Fix bugs and small behavior changes at the narrowest responsible layer. Use when regression proof, preserved surrounding behavior, and task-relevant tests matter.

JuliusBrussee/verify-and-stop

Prove existing work meets acceptance conditions without expanding scope. Use for validation-only tasks, completion checks, focused gate runs, and last-mile proof.

相关技能