Logo Graft

Graft

Tổ chức
Rune-kit
graft

Sao chép, chuyển đổi hoặc chuyển tính năng từ bất kỳ repo GitHub nào vào dự án của bạn. Dùng khi muốn lấy ý tưởng từ repo bên ngoài hoặc chuyển mã đã được kiểm chứng. Hiểu trước khi sao chép, chất vấn trước khi triển khai. Có 4 chế độ: port (viết lại), compare (phân tích), copy (ghép vào) và improve (sao chép + tối ưu).

Add to TypingMind

Tổng quan

Nhà phát hànhRune-kit
Kho mãrune
Tên kỹ nănggraft
Sao
88
Bản fork
26
Tệp đi kèm
2
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ộ.

  • 2 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • 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 Graft 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/graft
  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/graft .claude/skills/graft
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 Graft 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 Graft 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 Graft 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.

graft

Purpose

External code intelligence — structured workflow for learning from, adapting, and integrating features from any public repository into your project. Graft is NOT a copy-paste tool. It enforces understanding before adoption through a mandatory challenge gate that evaluates license compatibility, stack fit, scope, quality, and maintenance health before any code touches your codebase.

Core Rule: The Tree is a Menu, Not the Meal

When you clone a repo you see hundreds of files. That tree is a menu — options to order from, not a meal to eat. Grafting the whole tree is how context windows die and foreign patterns leak into your codebase.

  • Read the README + the 2-5 files that implement the target feature. Skip the rest.
  • If you cannot name the specific files you need before reading, you do not know what you want yet — go back to Step 0 and narrow scope.
  • WebFetch on raw GitHub URLs beats git clone whenever you know the exact files. Use clone only when discovery is genuinely needed.

Reading to understand is not grafting. The discipline above caps the graft scope — the files you actually transplant, port, or improve into your codebase (2-5, hard-cap 10). It does NOT cap how many files you may read to learn a pattern. Studying a 24-skill library to extract one convention legitimately reads dozens of files but grafts almost none. Keep the two counts separate: a wide read with a narrow graft is thorough; a wide graft is the failure mode.

This menu discipline applies to the transplant modes (port, copy, improve). Copy mode is not an excuse to import a directory wholesale — you still select files deliberately. Compare mode and survey scope (--deep) are exempt from the read cap by design: their job is breadth of understanding, not transplant. They still must NOT import code wholesale — wide reading, narrow (or zero) graft.

Modes

Port (default)

Rewrite the target feature using YOUR stack and patterns. Source code is a reference, not a template. Output is idiomatic to your codebase.

When: Different tech stack (Vue→React, Django→FastAPI), or source patterns conflict with your conventions.

Compare

Side-by-side analysis only. No code changes. Outputs a structured comparison report.

When: Evaluating whether to adopt a feature, benchmarking your implementation against another, or learning patterns without importing code.

Copy

Pure transplant with minimal adaptation. Stays as close to the original as possible — only changes imports, paths, and config to fit your project structure.

When: Same tech stack, source code is high quality, you want the exact implementation.

Improve

Copy the feature, then refactor and optimize. Fix anti-patterns, add missing tests, adapt to your codebase conventions, upgrade deprecated APIs.

When: Same stack but source has quality issues, or you want the feature but better.

Speed Options

FlagResearchChallenge GateUser Approval
(default)✅ Full✅ Yes✅ Each step
--auto✅ Full✅ Yes❌ Auto-approve
--fast❌ Skip❌ Skip❌ Auto-approve

--fast warning: Skipping challenge gate means no license check, no quality assessment. User accepts full responsibility. Announce: "Fast mode: skipping challenge gate. You are responsible for license and quality review."

Scope Depth

Orthogonal to mode and speed. Controls how widely you may read.

ScopeRead budgetGraft scopeWhen
(default)2-5 files, hard-cap 10the feature's filesTransplant one feature/module
--deep (survey)unbounded reads, full clone OKnarrow — patterns extracted, not files copiedStudy a whole repo/library to learn architecture or compare many components

--deep is for understanding, not importing. Use it when the goal is "what can I learn from this repo" rather than "port this function." Pairs naturally with compare mode. It relaxes the read cap and the scope-guard warning — but the transplant discipline still holds: extract the pattern, then graft narrowly (often into multiple existing skills/files rather than copying source files 1:1).

Smart Intent Detection

Input PatternDetected Mode
Contains "compare", "vs", "diff", "analyze"compare
Contains "copy", "exact", "as-is", "same"copy
Contains "improve", "better", "adapt", "upgrade"improve
Contains "port", "convert", "rewrite", "migrate"port
URL points to specific file/dir (not repo root)Auto-scope to that path
Contains "survey", "study", "learn from", "what can I take", "deep dive"compare + --deep
(default — no keyword match)port

Triggers

  • /rune graft <url> [--port|--compare|--copy|--improve] [--auto|--fast]
  • Delegated from cook when task contains "graft", "port from", "copy from repo", "clone feature from"
  • Auto-trigger: when user pastes a GitHub URL with context like "use this", "like this repo", "steal this"

Calls (outbound)

  • research (L3): fetch repo README, docs, understand purpose and architecture
  • scout (L2): scan LOCAL codebase for conventions, patterns, stack detection
  • fix (L2): implement adapted code (port and improve modes)
  • review (L2): post-graft quality check (improve mode only)

Called By (inbound)

  • User: /rune graft <url> direct invocation
  • cook (L1): delegation when task is "port feature from external repo"

Data Flow

Feeds Into →

  • fix (L2): adaptation plan → fix's implementation targets (port/improve modes)
  • review (L2): grafted code → review's analysis targets (improve mode)
  • test (L2): new grafted code → test coverage targets
  • journal (L3): graft.complete signal → auto-logged for pattern tracking

Fed By ←

  • scout (L2): local codebase conventions → graft's adaptation strategy
  • research (L3): repo analysis → graft's understanding of source architecture

Executable Steps

Step 0 — Parse Input

Extract from user input:

  1. URL — GitHub/GitLab/Bitbucket repo or file URL
  2. Mode — explicit flag or auto-detect via intent detection table
  3. Speed — --auto or --fast if present
  4. Scope — specific dir/file path if URL points to subdirectory, or user specifies "just the auth module"

Validate URL is accessible. If private repo or URL fails → suggest raw file URLs or manual paste.

Step 1 — Fetch & Scope

bash
# Sparse clone for large repos (skip if small or specific files)
git clone --depth 1 --filter=blob:none --sparse <url> /tmp/graft-<hash>
cd /tmp/graft-<hash>
git sparse-checkout set <target-dir>

For specific files or small repos: use WebFetch on raw GitHub URLs instead of cloning.

Read in this order (stop when you have enough context — see Core Rule: the tree is a menu):

  1. README.md — purpose, architecture overview
  2. Target dir's files — the actual code to graft (aim for 2-5 files, hard-cap at 10)
  3. package.json / pyproject.toml / Cargo.toml — dependencies and stack
  4. Tests for target feature — understand expected behavior

Scope guard: If target feature spans >15 files or >2000 LOC → WARN user: "Feature is large. Suggest narrowing to [specific module]. Continue anyway?" (Suppressed under --deep/compare — breadth is the point there.)

Menu discipline (transplant modes): Before reading file #6, pause and ask "do I actually need this to graft it, or am I eating the menu?" If the answer isn't a concrete reason tied to the target feature, stop reading and move to Step 2. Under --deep/survey scope this gate is lifted — read as widely as understanding requires, but keep the graft scope narrow (Step 5).

Step 2 — Analyze Source

Understand the target feature's architecture:

  • What it does — 2-3 sentence summary
  • How it works — key patterns, data flow, core logic
  • Dependencies — external packages required, internal imports
  • Stack — framework, language version, tooling
  • Quality signals — has tests? typed? documented? last commit date?

Output a brief analysis (not full report — save context for later steps).

Step 3 — Scan Local Codebase

Invoke rune:scout (or use cached output if codebase.scanned signal received):

  • Local tech stack and version
  • Naming conventions (camelCase vs snake_case, file structure)
  • Existing patterns that overlap with target feature
  • Import style, test framework, state management approach

Stack comparison: Produce a quick compatibility matrix:

| Aspect | Source | Local | Compatible? |
|--------|--------|-------|-------------|
| Framework | Next.js 14 | Next.js 15 | ✅ Minor adaptation |
| Language | TypeScript | TypeScript | ✅ |
| State | Redux | Zustand | ⚠️ Port needed |
| Testing | Jest | Vitest | ⚠️ Port needed |

If stack is identical → suggest copy or improve mode (not port). If stack differs significantly → force port mode.

Step 4 — Challenge Gate

Present challenge results to user:

## Challenge Gate Results

| Dimension | Score | Detail |
|-----------|-------|--------|
| License | ✅ | MIT — compatible |
| Stack Fit | ⚠️ | Redux → Zustand migration needed |
| Scope | ✅ | 6 files, ~400 LOC — manageable |
| Quality | ✅ | Typed, tested, documented |
| Maintenance | ⚠️ | Last commit 4 months ago |

**Verdict: PROCEED with caveats** (0 ❌, 2 ⚠️)

Wait for user approval (unless --auto).

Step 5 — Plan Adaptation

Graft scope stays narrow regardless of how widely you read. If this run used --deep/survey to study a library, the read cap was lifted — but the adaptation plan below still selects a small set of files/patterns to actually transplant. A wide survey legitimately feeds a copy/improve plan that grafts only the 2-5 best files; it does not license importing the surveyed tree.

Based on mode, produce adaptation plan:

Compare mode → skip to output. Write comparison report and STOP.

Copy mode → list files to transplant, import path changes, config adjustments. Minimal changes only.

Port mode → for each source component, describe the rewrite:

  • Source pattern → local pattern mapping
  • Dependencies to replace (Redux→Zustand, Jest→Vitest)
  • Files to create/modify in local project
  • What to keep vs what to rewrite from scratch

Improve mode → copy plan + improvement list:

  • Anti-patterns to fix (mutations, any types, missing error handling)
  • Missing tests to add
  • Deprecated APIs to upgrade
  • Convention mismatches to align

Present plan to user. Wait for approval (unless --auto).

Step 6 — Execute

Compare mode: Output report → emit graft.complete → done.

Copy/Port/Improve modes:

  1. Create/modify files per adaptation plan
  2. For port/improve: invoke rune:fix for complex rewrites
  3. For improve: invoke rune:review on grafted code
  4. Run project verification (lint, type-check, test if applicable)
  5. Clean up temp clone dir

Post-execution: Emit graft.complete signal with payload:

yaml
graft.complete:
  mode: "port|copy|improve|compare"
  source_url: "<url>"
  files_changed: ["src/auth/middleware.ts", "src/auth/types.ts"]
  challenge_score: { license: "pass", stack: "warn", scope: "pass", quality: "pass", maintenance: "warn" }

Output Format

Compare Mode Output

markdown
## Graft Comparison: [feature] — [source repo] vs [local]

### Summary
[2-3 sentences: what was compared, key differences]

### Comparison
| Aspect | Source | Local | Winner | Notes |
|--------|--------|-------|--------|-------|
| [aspect] | [approach] | [approach] | [which] | [why] |

### Recommendations
- [what to adopt from source]
- [what to keep from local]
- [what to graft: specific files/patterns]

Port/Copy/Improve Output

markdown
## Graft Complete: [feature] from [source]

### Mode: [port|copy|improve]
### Files Changed
- `path/file.ts` — [new|modified] — [what changed]

### Adaptations Made
- [adaptation 1]
- [adaptation 2]

### Verify
- [ ] `npm run lint` passes
- [ ] `npm run test` passes
- [ ] Feature works as expected

Returns

FieldTypeDescription
modeenumport, compare, copy, improve
source_urlstringSource repository URL
files_changedstring[]List of created/modified local files
challenge_scoreobject5-dimension scores (pass/warn/fail)
statusenumDONE, DONE_WITH_CONCERNS, BLOCKED
comparison_reportstring?Markdown report (compare mode only)

Constraints

  1. MUST run challenge gate before any code changes — no blind copying
  2. MUST clean up temp clone directories after completion
  3. MUST detect and warn about license incompatibility before proceeding
  4. MUST use sparse checkout for repos >100MB — never full clone large repos
  5. MUST respect local conventions — grafted code should look native, not foreign
  6. MUST NOT modify the source repository — read-only access only
  7. MUST NOT graft without scoping — always narrow to specific feature/module
  8. MUST treat the source file tree as a menu, not a meal for transplant — graft the 2-5 files the feature actually needs, not every file you can see. Reading widely to understand (esp. under --deep/compare) is allowed; grafting widely is not

Mesh Gates

GateRequiresIf Missing
Challenge Gate5-dimension score with 0-1 ❌BLOCK if 2+ ❌, WARN if 1 ❌
Scout GateLocal codebase scannedInvoke rune:scout first
Scope GateTarget feature ≤15 filesWARN user, suggest narrowing

Sharp Edges

Failure ModeSeverityMitigation
Grafting GPL code into MIT projectCRITICALChallenge gate checks license — blocks incompatible
Blindly copying code without understandingCRITICALHARD-GATE: challenge before implement
Context overflow from large source filesHIGHScope guard: >15 files or >2000 LOC triggers warning
Reading the whole repo instead of the featureHIGH"Tree is a menu" rule — pause before file #6, justify each read (transplant modes only)
Forcing a pattern-study graft into the 10-file feature capMEDIUMUse --deep/survey scope — wide read, narrow graft; cap counts grafted files, not reads
Grafted code doesn't match local conventionsHIGHStep 3 scans local patterns, Step 5 plans adaptation
Stale source (abandoned repo)MEDIUMMaintenance dimension in challenge gate
Private repo URL failsMEDIUMFallback to WebFetch raw URLs or manual paste
Port mode when copy would suffice (wasted effort)MEDIUMMode decision tree suggests optimal mode

Self-Validation

SELF-VALIDATION (run before emitting graft.complete):
- [ ] Challenge gate was executed (or --fast acknowledged)
- [ ] All grafted files follow local naming conventions
- [ ] No source-specific imports remain (wrong paths, missing packages)
- [ ] License compatibility confirmed (or user override documented)
- [ ] Temp clone directory cleaned up
- [ ] Grafted code compiles/lints without new errors
- [ ] **Graft scope** ≤10 files (files actually transplanted/ported/improved) — if >10, document why. This is NOT the read count: under `--deep`/compare you may read far more to understand, but the files you graft stay narrow.
IF ANY check fails → fix before reporting done. Do NOT defer to completion-gate.

Cross-cutting Updates

If this skill is added to the repo (first time):

  • README.md — skill count (61→62), L2 count (28→29)
  • docs/ARCHITECTURE.md — add graft to L2 list
  • CLAUDE.md — add graft to L2 list, routing table, skill count
  • docs/index.html — update meta stats if applicable

Done When

  • Input parsed: URL, mode, speed flags extracted
  • Source fetched and scoped (sparse clone or WebFetch)
  • Source analyzed: patterns, dependencies, stack understood
  • Challenge gate passed (5 dimensions scored, 0-1 ❌)
  • Local codebase scanned for conventions
  • Adaptation plan produced and approved
  • Code grafted per mode (port/copy/improve/compare)
  • Verification passed (lint, type-check, tests)
  • Temp files cleaned up
  • graft.complete signal emitted
  • Self-Validation: all checks passed

Cost Profile

~2000-4000 tokens input (SKILL.md + 1-2 references), ~3000-8000 tokens output (analysis + adaptation + code). Sonnet for execution. Heaviest when port mode rewrites significant code — but that's where the value is highest.

Scope guardrail: Do not become a general-purpose code review tool. Graft analyzes external code for adoption purposes only — use rune:review for reviewing your own code, rune:research for general technology research.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

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

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

Sao chép, chuyển đổi hoặc chuyển tính năng từ bất kỳ repo GitHub nào vào dự án của bạn. Dùng khi muốn lấy ý tưởng từ repo bên ngoài hoặc chuyển mã đã được kiểm chứng. Hiểu trước khi sao chép, chất vấn trước khi triển khai. Có 4 chế độ: port (viết lại), compare (phân tích), copy (ghép vào) và improve (sao chép + tối ưu).

Vì sao nên dùng Graft 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. Graft 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 Graft 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/graft. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà 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 Graft?

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 Graft 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 Graft 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 Graft 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 👇