跳到正文
cccskills
免费在 GitHub 公开

safeguard

Build safety nets before refactoring. Use when running surgeon or any risky refactor that needs a rollback point. Creates characterization tests, boundary markers, config freezes, and rollback points.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md7.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

safeguard

Purpose

Build safety nets before any refactoring begins. Safeguard creates characterization tests that capture current behavior, adds boundary markers to distinguish legacy from new code, freezes config files, and creates git rollback points. Nothing gets refactored without safeguard running first.

<HARD-GATE> Characterization tests MUST pass on the current (unmodified) code before any refactoring starts. If they do not pass, safeguard is not complete. </HARD-GATE>

Called By (inbound)

  • rescue (L1): Phase 1 SAFETY NET — build protection before surgery
  • surgeon (L2): untested module found during surgery

Calls (outbound)

  • scout (L2): find all entry points and public interfaces of the target module
  • test (L2): write and run characterization tests for the target module
  • verification (L3): verify characterization tests pass on current code

Cross-Hub Connections

  • surgeon → safeguard — untested module found during surgery

Execution Steps

Step 1 — Identify module boundaries

Call rune:scout targeting the specific module. Ask scout to return:

  • All public functions, classes, and exported symbols
  • All files that import from this module (consumers)
  • All files this module imports from (dependencies)
  • Existing test files for this module (if any)

Use Read to open the module entry file and confirm the public interface.

Step 2 — Write characterization tests

Create a test file at tests/char/<module-name>.test.ts (or .js, .py matching project convention).

Use Write to create the characterization test file. Rules for characterization tests:

  • Tests MUST capture what the code CURRENTLY does, not what it should do
  • Include edge cases that currently produce surprising output — test for that actual output
  • Do NOT fix bugs in characterization tests — if the current code returns wrong data, test for that wrong data
  • Cover every public function in the module
  • Include at least one integration test calling the module as an external consumer would

Example structure:

// tests/char/<module>.test.ts
// CHARACTERIZATION TESTS — DO NOT MODIFY without running safeguard again
// These tests capture existing behavior as of: [date]

describe('<module> — characterization', () => {
  it('existing behavior: [function] with [input] returns [actual output]', () => {
    // ...
  })
})

Step 3 — Add boundary markers

Use Edit to add boundary comments at the top of the module file and at key function boundaries:

// @legacy — rune-safeguard [date] — do not refactor without characterization tests passing

For functions flagged by autopsy as high-risk, add:

// @do-not-touch — coupled to [module], change both or neither

For planned new implementations, mark insertion points:

// @bridge — new-v2 will replace this interface

Step 4 — Config freeze

Use Bash to record current config state:

mkdir -p .rune
cp tsconfig.json .rune/tsconfig.frozen.json 2>/dev/null || true
cp .eslintrc* .rune/ 2>/dev/null || true
cp package-lock.json .rune/package-lock.frozen.json 2>/dev/null || true
echo "Config frozen at $(date)" > .rune/freeze.log

This preserves the baseline config so surgery can be verified against it.

Step 5 — Create rollback point

Use Bash to create a git tag:

git add -A
git commit -m "chore: safeguard checkpoint before [module] surgery" --allow-empty
git tag rune-safeguard-<module>

Replace <module> with the actual module name. Confirm the tag was created.

Step 6 — Verify

Call rune:verification and explicitly pass the characterization test file path.

If characterization tests fail on the CURRENT (unchanged) code → STOP.
Fix the tests to match actual behavior before proceeding.
Characterization tests MUST pass on current code. This is non-negotiable.

Only after verification passes, declare the safety net complete.

Output Format

## Safeguard Report
- **Module**: [module name]
- **Tests Added**: [count] characterization tests
- **Coverage**: [before]% → [after]%
- **Markers Added**: [count] boundary comments
- **Rollback Tag**: rune-safeguard-[module]
- **Config Frozen**: [list of files in .rune/]
- **Hard Gate**: PASSED — all characterization tests pass on current code

### Characterization Tests
- `tests/char/[module].test.ts` — [count] tests capturing current behavior

### Boundary Markers
- `@legacy`: [count] files marked
- `@do-not-touch`: [count] files protected
- `@bridge`: [count] insertion points marked

### Config Frozen
- [list of locked config files in .rune/]

### Next Step
Safe to proceed with: `rune:surgeon` targeting [module]

Constraints

  1. MUST write characterization tests that pass on CURRENT code before any refactoring
  2. MUST NOT proceed to surgery if characterization tests fail — the safety net is broken
  3. MUST cover critical paths identified by autopsy — not just easy-to-test functions
  4. MUST verify tests are meaningful — tests that always pass regardless of code are useless

Sharp Edges

Known failure modes for this skill. Check these before declaring done.

Failure ModeSeverityMitigation
Characterization tests that always pass regardless of code (trivial asserts)CRITICALConstraint 4: tests must fail if the module is deleted or its logic is changed
Not covering critical paths identified by autopsyHIGHConstraint 3: cover high-risk functions first — autopsy flags which ones
Characterization tests written to "correct" behavior instead of current behaviorHIGHTests capture ACTUAL output, including bugs — do not fix behavior in the tests
Skipping config freeze stepMEDIUMStep 4 is required — baseline config needed for comparison after surgery
No git tag created before declaring safeguard completeMEDIUMTag rune-safeguard-<module> must exist before surgery begins

Done When

  • Module boundaries identified via scout (public functions, consumers, dependencies)
  • Characterization tests written for all public functions
  • Tests PASS on current (unmodified) code — HARD-GATE verified
  • Boundary markers added (@legacy, @bridge, @do-not-touch)
  • Config files frozen to .rune/
  • Git tag rune-safeguard-<module> created
  • Safeguard Report emitted with test count, coverage, and rollback tag

Returns

ArtifactFormatLocation
Characterization test fileTypeScript/JS/Python testtests/char/<module>.test.*
Boundary markersCode comments (@legacy, @bridge)in-source
Frozen config snapshotCopies of config files.rune/*.frozen.*
Git rollback tagGit tagrune-safeguard-<module>
Safeguard ReportMarkdowninline

Cost Profile

~2000-5000 tokens input, ~1000-2000 tokens output. Sonnet for test writing quality.

Scope guardrail: safeguard builds safety nets only — it does not refactor code. All surgery is delegated to surgeon after the safeguard HARD-GATE passes.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

adversary

免费

Pre-implementation red-team analysis. Use when a plan is high-risk, critical path, or expensive to reverse. Challenges plans before code is written — finds edge cases, security holes, scalability bottlenecks, error propagation risks, and integration conflicts. Catches flaws at plan time (10x cheaper than post-implementation).

中文简介正在准备中。当前显示原文说明。

Rune-kit/rune862026年8月16日 更新

Creates code-based visual assets — SVG icons, OG image HTML templates, social banners, and icon sets. Use when generating visuals as code (vector/HTML), NOT raster images — for raster generation see @rune-pro/media. Outputs files with usage instructions.

中文简介正在准备中。当前显示原文说明。

Rune-kit/rune862026年8月16日 更新

audit

免费

Comprehensive project audit — security, dependencies, code quality, architecture, performance, infra, docs, and mesh analytics. Use when needing a full 8-dimension health-score snapshot before a major release, M&A diligence, or quarterly review. Delegates to specialist skills (sentinel, dependency-doctor, perf, autopsy, etc.).

中文简介正在准备中。当前显示原文说明。

Rune-kit/rune862026年8月16日 更新

autopsy

免费

Full codebase health assessment. Use when diagnosing project health or starting a rescue workflow on legacy code — OR when evaluating an external GitHub repo for dependency / fork / contribution decisions (--external mode). Analyzes complexity, dependencies, dead code, tech debt, and git hotspots. Produces a health score and rescue plan.

中文简介正在准备中。当前显示原文说明。

Rune-kit/rune862026年8月16日 更新

ba

免费

Business Analyst agent. Use when starting a new feature requiring requirements elicitation BEFORE plan or cook. Asks probing questions, identifies hidden requirements, maps stakeholders, defines scope boundaries, and produces a structured Requirements Document that plan and cook consume.

中文简介正在准备中。当前显示原文说明。

Rune-kit/rune862026年8月16日 更新

Creative ideation and solution exploration. Generates multiple approaches with trade-offs, uses structured frameworks (SCAMPER, First Principles), and hands off to plan for structuring.

中文简介正在准备中。当前显示原文说明。

Rune-kit/rune862026年8月16日 更新

查看 Rune-kit 的全部技能

报告此技能的问题