Vendor code from any git repo,
rewrite it, and still pull upstream updates

The problem with vendoring is what happens after you edit your copy: upstream keeps improving, but their changes have nowhere to land, so your copy slowly goes stale. regraft remembers what it gave you — and why you changed it.

$ curl -fsSL https://raw.githubusercontent.com/treadiehq/regraft/main/scripts/install.sh | bash

The whole loop

add → edit → note → pull → resolve. That's it.

# Vendor a directory (or a single file) from any git repo
$ regraft add owner/repo/tree/main/src/components lib/components
# regraft.json pins the source to a commit and hashes every file.
# Commit regraft.json and PATCH.md — the .regraft/ folder ignores itself.

How it works

┌──────────────────┐    regraft add     ┌─────────────────────┐
│  upstream repo   │───────────────────▶│     your repo       │
│  (any git host)  │                    │  lib/components/    │
└────────┬─────────┘                    │  regraft.json  ✓    │
         │                              │  PATCH.md      ✓    │
         │ new commits                  └──────────┬──────────┘
         ▼                                         │ edit + note
┌──────────────────┐     regraft pull              │
│  three-way merge │◀──────────────────────────────┘
│  (diff3)         │
└────────┬─────────┘
         │
    ┌────┴─────────────────┐
    ▼                      ▼
 no overlap             conflict
 merges on its own      markers + brief ──▶ regraft resolve
1.regraft add vendors the files and pins the source to a commit in regraft.json, with a hash of every file it wrote
2.You edit the copy to fit your project, then record why with regraft note — one sentence, committed in PATCH.md
3.regraft pull compares stored, disk, and upstream state — non-overlapping changes merge silently with a real three-way merge
4.True conflicts get diff3 markers plus a brief with your notes and the upstream changelog — you (or your coding agent) fix them and regraft resolve
01

It remembers what it gave you

A committed manifest (regraft.json) pins each source to a commit and hashes every file it wrote. It always knows whether you changed a file, upstream did, or both.

02

It remembers why you changed things

After editing, write one sentence with regraft note. Notes collect in a committed PATCH.md — so conflicts arrive with your reasons, not just a diff.

03

Real three-way merges

Merges use git merge-file --diff3. regraft knows the version your edits started from, and conflict markers include it, so you can see what both sides changed.

04

Briefs, not guesses

When a merge needs judgment, regraft stops and writes a reconciliation brief: the conflicts, your intent notes, and the upstream commit log. You or your agent makes the call.

05

Git-native fetching

Sources are fetched with your own git. If git clone works — GitHub, GitLab, self-hosted, private — regraft works. No tokens, no rate limits.

06

Built for CI and agents

regraft status exits 1 when anything needs attention. Every command takes --json with stable output shapes agents can pattern-match on.

Point it at anything git can reach

Whole repos, directories, single files, branches, tags — even a PR head, which is a moving branch, so pull keeps following it.

owner/repo # whole repo, default branch
owner/repo#ref # whole repo at a branch/tag
owner/repo/tree/main/src/components # a directory
owner/repo/blob/main/src/utils.ts # a single file
owner/repo/pull/42 # a PR head (live ref)
git@host:repo.git#ref:subpath # any git remote — ssh, https, file://

Fetching uses your own git and your existing credentials — GitHub, GitLab, self-hosted, private. No tokens, no rate limits.

Beyond the loop

A few habits that pay off once vendored code is part of your codebase.

# What did I change since vendoring? Handy right before writing a note.
$ regraft diff
# What would a pull bring in?
$ regraft diff --upstream

Made for coding agents too

regraft does the deterministic work: fetch, hash, merge. When a merge needs judgment, it stops and writes a brief instead of guessing — and whoever picks up the brief, you or a coding agent, makes the call.

# .regraft/briefs/2026-07-02T14-22-57.230Z.md contains:
· the conflicted file list
· the FULL text of every intent note that touches the conflicts
· the upstream commit log between the old and new pin
· explicit instructions for the resolving agent

If an agent works in your repo, point it at skills/regraft/SKILL.md.

Frequently asked questions

Vendoring, merging, and where regraft draws the line.

Stop letting vendored code go stale

Open source under FSL-1.1-MIT. Install it and vendor your first source in a minute.