Logo Rescue

Rescue

Tổ chức
Rune-kit
rescue

Legacy refactoring orchestrator. Use when user says 'refactor', 'modernize', 'clean up this mess', 'rescue', or when dealing with old/messy/legacy code. Multi-session workflow — autopsy, safety net, incremental surgery, progress tracking.

Add to TypingMind

Tổng quan

Nhà phát hànhRune-kit
Kho mãrune
Tên kỹ năngrescue
Sao
88
Bản fork
26
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được Rune-kit công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Rescue trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/Rune-kit/rune/tree/master/skills/rescue
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

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/rescue .claude/skills/rescue
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Rescue trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Rescue ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Rescue với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

rescue

Purpose

Legacy refactoring orchestrator for safely modernizing messy codebases. Rescue runs a multi-session workflow: assess damage (autopsy), build safety nets (safeguard), perform incremental surgery (surgeon), and track progress (journal). Designed to handle the chaos of real-world legacy code without breaking everything.

Triggers

  • /rune rescue — manual invocation on legacy project
  • Auto-trigger: when autopsy health score < 40/100

Calls (outbound)

  • autopsy (L2): Phase 0 RECON — full codebase health assessment
  • safeguard (L2): Phase 1 SAFETY NET — characterization tests and protective measures
  • surgeon (L2): Phase 2-N SURGERY — incremental refactoring (1 module per session)
  • retro (L2): post-rescue retrospective — capture lessons learned
  • journal (L3): state tracking across rescue sessions
  • plan (L2): create refactoring plan based on autopsy findings
  • review (L2): verify each surgery phase
  • session-bridge (L3): save rescue state between sessions
  • onboard (L2): generate context for unfamiliar legacy project
  • dependency-doctor (L3): audit dependencies in legacy project
  • context-pack (L3): create structured handoff briefings before spawning subagents
  • neural-memory | Phase start + phase end | Recall past refactoring patterns, capture new ones

Called By (inbound)

  • User: /rune rescue direct invocation
  • team (L1): when team delegates rescue work

Execution

Step 0 — Initialize TodoWrite

Rescue is multi-session. On first invocation, build full todo list. On resume, read RESCUE-STATE.md and restore todo list to current phase.

TodoWrite([
  { content: "RECON: Run autopsy, onboard, and save initial state", status: "pending", activeForm: "Assessing codebase health" },
  { content: "SAFETY NET: Add characterization tests and rollback points", status: "pending", activeForm: "Building safety net" },
  { content: "SURGERY [Module N]: Refactor one module with surgeon", status: "pending", activeForm: "Performing surgery on module N" },
  { content: "CLEANUP: Remove @legacy and @bridge markers", status: "pending", activeForm: "Cleaning up markers" },
  { content: "VERIFY: Run full test suite and compare health scores", status: "pending", activeForm: "Verifying rescue outcome" }
])

Note: SURGERY todos are added dynamically — one per module identified in Phase 0. Each module gets its own todo entry.


Phase 0 — RECON

Mark todo[0] in_progress.

Call neural-memory (Recall Mode) for past refactoring patterns in similar codebases.

0a. Full health assessment.

REQUIRED SUB-SKILL: rune:autopsy
→ Invoke `autopsy` with scope: "full".
→ autopsy returns:
    - health_score: number (0-100)
    - modules: list of { name, path, loc, cyclomatic_complexity, test_coverage, health }
    - issues: list of { severity, file, description }
    - recommended_patterns: map of module → refactoring pattern

0b. Generate project context if missing.

Check: does CLAUDE.md exist in project root?
  If NO:
    REQUIRED SUB-SKILL: rune:onboard
    → Invoke `onboard` to generate CLAUDE.md with project conventions.

0c. Audit dependencies.

REQUIRED SUB-SKILL: rune:dependency-doctor
→ Invoke `dependency-doctor` to identify: outdated packages, security vulnerabilities, unused deps.
→ Capture: dependency report (used in surgeon prompts).

0d. Save initial state.

REQUIRED SUB-SKILL: rune:journal
→ Invoke `journal` to write RESCUE-STATE.md with:
    - health_score_baseline: [autopsy score]
    - modules_to_rescue: [ordered list from autopsy, worst-first]
    - current_phase: "RECON complete"
    - sessions_used: 1
    - dependency_report: [summary]

REQUIRED SUB-SKILL: rune:session-bridge
→ Invoke `session-bridge` to snapshot state for cross-session resume.

Bash: git tag rune-rescue-baseline

0e. Build module surgery queue.

From autopsy.modules, filter: health < 60
Sort: ascending health score (worst first)
Add one TodoWrite entry per module:
  { content: "SURGERY [module.name]: [recommended_pattern]", status: "pending", ... }

Mark todo[0] completed.


Phase 1 — SAFETY NET

Mark todo[1] in_progress. This phase runs once before any surgery.

1a. Characterization tests.

REQUIRED SUB-SKILL: rune:safeguard
→ Invoke `safeguard` with action: "characterize".
→ safeguard writes tests that capture CURRENT behavior (even buggy behavior).
→ These tests are the rollback oracle — if they break, surgery went wrong.
→ Capture: test file paths, test count.

1b. Add boundary markers.

REQUIRED SUB-SKILL: rune:safeguard
→ Invoke `safeguard` with action: "mark".
→ safeguard adds inline markers to legacy code:
    @legacy     — old implementation to be replaced
    @new-v2     — new implementation being introduced
    @bridge     — compatibility shim between old and new

1c. Config freeze + rollback point.

REQUIRED SUB-SKILL: rune:safeguard
→ Invoke `safeguard` with action: "freeze".
→ safeguard commits current state as checkpoint.

Bash: git add -A && git commit -m "chore: rescue safety net — characterization tests + markers"
Bash: git tag rune-rescue-safety-net

Mark todo[1] completed.


Phase 2-N — SURGERY (one module per session)

For each module in the surgery queue (one per session):

Mark the corresponding SURGERY todo in_progress.

Sa. Pre-surgery check.

Verify:
  [ ] Safety net tests pass (run characterization tests)
  [ ] Module is not coupled to another in-progress module
  [ ] Blast radius ≤ 5 files

Blast radius check:
  Bash: grep -r "import.*[module-name]\|require.*[module-name]" --include="*.ts" --include="*.js" -l
  Count files. If > 5:
    → STOP surgery on this module
    → Report: "Blast radius [N] files exceeds limit of 5 — use Strangler Fig pattern to reduce scope first"
    → Pick a smaller sub-module to start with

Sb. Execute surgery.

REQUIRED SUB-SKILL: rune:surgeon
→ Invoke `surgeon` with:
    - module: [module name and path]
    - pattern: [recommended_pattern from autopsy]
    - blast_radius_files: [list from pre-surgery check]
    - dependency_report: [from Phase 0]
    - characterization_tests: [paths from Phase 1]

Supported patterns:
  Strangler Fig          — for modules > 500 LOC: route traffic to new impl gradually
  Branch by Abstraction  — for replacing implementations: introduce interface first
  Expand-Migrate-Contract — for safe transitions: expand API, migrate callers, contract old API
  Extract & Simplify     — for cyclomatic complexity > 10: extract pure functions

surgeon returns: modified files list, refactoring summary, test results.

Sc. Review surgery output.

REQUIRED SUB-SKILL: rune:review
→ Invoke `review` with: modified files, surgeon summary.
→ review checks: code quality, pattern adherence, no regressions introduced.
→ Capture: review verdict (pass | fail | warnings).

If review verdict == fail:
  → STOP, do not commit
  → Report review findings to user
  → Revert surgeon changes: Bash: git checkout [modified-files]

Sd. Run characterization tests.

Bash: [project test command, e.g. npm test or pytest]
If tests fail:
  → STOP immediately
  → Report: "Characterization tests broken by surgery on [module] — reverting"
  → Bash: git checkout [modified-files]
  → Do NOT mark todo complete
  → Update RESCUE-STATE.md with failure note

Se. Commit and save state.

Bash: git add [modified-files]
Bash: git commit -m "refactor([module]): [pattern] — [brief description]"

REQUIRED SUB-SKILL: rune:journal
→ Update RESCUE-STATE.md:
    - module [name]: status=complete, health_before=[X], health_after=[Y]
    - sessions_used: [increment]

REQUIRED SUB-SKILL: rune:session-bridge
→ Save updated state for next session resume.

Context check — before continuing to next module:

If approaching context limit (50+ tool calls or user signals fatigue):
  → STOP after current module commit
  → Report: "Session limit reached. Rescue state saved. Resume with /rune rescue to continue."
  → Do NOT start next module in same session

Mark SURGERY todo completed.

Repeat for each module in queue across subsequent sessions.


Phase N+1 — CLEANUP

Mark CLEANUP todo in_progress.

Run only after ALL surgery todos are completed.

Remove boundary markers.

Grep: find all @legacy, @bridge markers in codebase
  Bash: grep -rn "@legacy\|@bridge" --include="*.ts" --include="*.js" -l

For each file with markers:
  → Remove @legacy blocks (old implementation replaced)
  → Remove @bridge shims (migration complete)
  → Keep @new-v2 comments only if they add documentation value; otherwise remove
  Edit each file to strip markers.

Verify markers removed.

Bash: grep -rn "@legacy\|@bridge" --include="*.ts" --include="*.js"
Expected: no output. If any remain → fix before continuing.
Bash: git add -A && git commit -m "chore: rescue cleanup — remove @legacy and @bridge markers"

Mark CLEANUP todo completed.


Phase N+2 — VERIFY

Mark VERIFY todo in_progress.

Bash: [full test command]
Capture: passed, failed, coverage %.

If tests fail:
  → Do NOT mark rescue complete
  → Identify which module introduced failure
  → Report: "Final verify failed: [failing test list]"
REQUIRED SUB-SKILL: rune:autopsy
→ Invoke `autopsy` again with scope: "full".
→ Capture: health_score_final.

Compare health scores.

health_score_baseline: [from Phase 0 RESCUE-STATE.md]
health_score_final:    [from this autopsy]
improvement:           [final - baseline]

Report:
  Rescue complete.
  Health: [baseline] → [final] (+[improvement] points)
  Modules refactored: [count]
  Sessions used: [count]
REQUIRED SUB-SKILL: rune:journal
→ Final RESCUE-STATE.md update: status=complete, health_final=[score].

Bash: git tag rune-rescue-complete

Call neural-memory (Capture Mode) to save refactoring patterns and decisions from this rescue.

Mark VERIFY todo completed.


Status Command

/rune rescue status — reads RESCUE-STATE.md via journal and presents:

## Rescue Dashboard
- **Health Score**: [before] → [current] (target: [goal])
- **Modules**: [completed]/[total]
- **Current Phase**: [phase]
- **Sessions Used**: [count]

### Module Status
| Module | Status | Health | Pattern |
|--------|--------|--------|---------|
| auth | done | 72→91 | Strangler Fig |
| payments | in-progress | 34→?? | Extract & Simplify |
| legacy-api | pending | 28 | TBD |

Safety Rules

NEVER refactor 2 coupled modules in same session
ALWAYS run characterization tests after each surgery
Max blast radius: 5 files per session
If context low → STOP, save state via journal + session-bridge, commit partial
Rollback point: git tag rune-rescue-baseline (set in Phase 0)

Constraints

  1. MUST run autopsy diagnostic BEFORE planning any refactoring — understand before changing
  2. MUST create safety net (characterization tests via safeguard) BEFORE any code surgery
  3. MUST NOT refactor two coupled modules simultaneously — one module per session
  4. MUST run full test suite after EVERY individual edit — never accumulate failing tests
  5. MUST tag a safe rollback point before starting surgery
  6. MUST NOT exceed blast radius of 5 files per surgical session

Mesh Gates

GateRequiresIf Missing
Autopsy Gateautopsy report with health score before planningRun rune:autopsy first
Safety Gatesafeguard characterization tests passing before surgeryRun rune:safeguard first
Surgery GateEach edit verified individually (tests pass)Revert last edit, fix, re-verify

Output Format

## Rescue Report: [Module Name]
- **Status**: complete | partial | blocked
- **Modules Refactored**: [count]
- **Tests Before**: [count] ([pass rate]%)
- **Tests After**: [count] ([pass rate]%)
- **Health Score**: [before] → [after]
- **Rollback Tag**: [git tag name]

Returns

ArtifactFormatLocation
Rescue stateMarkdownRESCUE-STATE.md (updated each session)
Characterization testsSource filesWritten by rune:safeguard per module
Refactored modulesSource filesModified in-place, committed per surgery session
Health score comparisonInline (Rescue Report)Baseline vs final autopsy scores
Rescue ReportMarkdown (inline)Emitted at session end (per module and final)

Document Ownership

ScopeAccessFiles
Owns (read + write)RESCUE-STATE.md, .rune/rescue-*.md, git tags (rune-rescue-*), refactored source files (one module per session)
Reads (never writes)CLAUDE.md, autopsy reports, safeguard test files, .rune/contract.md
Never modifiesTest files written by safeguard (characterization tests are the safety net — rescue reads them, never edits), compiler/**, SKILL.md files

Rescue delegates to surgeon for actual code changes and safeguard for test creation. Rescue owns the orchestration state, not the artifacts.

Anti-Patterns

Common legacy refactoring failures. These turn "rescue" into "make it worse."

Anti-PatternWhy It FailsCorrect Approach
Big bang refactor — rewriting everything at onceNo rollback path. One bug = entire refactor is brokenOne module per session. Commit + verify after each module
Surgery without safety net — refactoring before characterization tests existNo way to verify behavior is preserved. "It compiles" ≠ "it works"HARD-GATE: safeguard tests must pass BEFORE any surgery begins
Coupled module surgery — refactoring two interdependent modules simultaneouslyChanges in module A break module B mid-surgery. Neither is stableOne module per session. Stabilize A completely before touching B
Ignoring the autopsy — starting refactoring without understanding current healthFixes symptoms not causes. Wastes effort on low-impact modulesPhase 0 autopsy is mandatory. Surgery queue ordered by impact, not convenience
Prototype patterns in production — replacing legacy code with quick-and-dirty rewritesCreates new legacy. The "rescue" becomes the next rescue targetApply proven refactoring patterns from autopsy recommendations. Clean code, not fast code
No rollback point — surgery without a tagged baselineIf surgery goes wrong, no safe state to return togit tag rune-rescue-baseline before ANY code changes

Sharp Edges

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

Failure ModeSeverityMitigation
Starting surgery before safety net committed and taggedCRITICALHARD-GATE: rune-rescue-safety-net git tag must exist before Phase 2
Refactoring two coupled modules in the same sessionHIGHHARD-GATE: one module per session — split coupled modules into sequential sessions
Blast radius > 5 files before surgery haltedHIGHCount importers before each surgery — stop if > 5 and split scope
Not saving state between sessions (rescue spans many sessions)MEDIUMjournal + session-bridge mandatory after each session — RESCUE-STATE.md must be current
Continuing surgery after characterization tests fail on current codeMEDIUMTests must PASS on unmodified code first — fix the test if current behavior is captured wrongly

Done When

  • autopsy complete with quantified health score and surgery queue
  • safeguard characterization tests passing on current code (HARD-GATE)
  • All modules in surgery queue processed (one per session)
  • @legacy and @bridge markers removed from codebase (CLEANUP phase)
  • Final autopsy run — health_score_final > health_score_baseline
  • Rescue Report emitted with before/after health comparison and session count

Cost Profile

~$0.10-0.30 per session. Sonnet for surgery, opus for autopsy. Multi-session workflow.

Câu hỏi thường gặp

Kỹ năng AI Rescue làm được gì?

Legacy refactoring orchestrator. Use when user says 'refactor', 'modernize', 'clean up this mess', 'rescue', or when dealing with old/messy/legacy code. Multi-session workflow — autopsy, safety net, incremental surgery, progress tracking.

Vì sao nên dùng Rescue trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Rescue là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Rescue trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Rune-kit/rune/tree/master/skills/rescue. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Rescue?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Rescue với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Rescue với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Rescue có miễn phí không?

Có. Kỹ năng này được Rune-kit phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇