Safeguard logo

Safeguard

Organization
Rune-kit
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.

Overview

PublisherRune-kit
Repositoryrune
Skill namesafeguard
Stars
88
Forks
26
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Rune-kit on GitHub. Read the source before you install it.

Installation

Install the Safeguard AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Rune-kit/rune/tree/master/skills/safeguard
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Rune-kit/rune.git /tmp/rune
mkdir -p .claude/skills
cp -r /tmp/rune/skills/safeguard .claude/skills/safeguard
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Safeguard in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Safeguard on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Safeguard is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

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:

typescript
// 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:

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

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

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

For planned new implementations, mark insertion points:

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

Step 4 — Config freeze

Use Bash to record current config state:

bash
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:

bash
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.

Frequently asked questions

What does the Safeguard AI skill do?

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.

Why use Safeguard on TypingMind?

Because you install it once and use it with any model. Safeguard is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Safeguard in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Rune-kit/rune/tree/master/skills/safeguard. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Safeguard?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Safeguard?

As many as you like. As long as a model supports skills, you can use Safeguard with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Safeguard AI skill free?

Yes. It is published on GitHub by Rune-kit under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇