logoalt Hacker News

fatyesterday at 9:31 PM0 repliesview on HN

Sure – our API is built specifically for common LLM workflows. Here's a great example.

LLMs are often used for changing code. If an LLM creates a patch that touches 10 files, you need to take the following steps to save that patchfile on GitHub using their rest API.

.

1. Get the base branch SHA

2. Create a new branch (ref)

3. Create blobs (one per file… 10 blobs!)

4. Create a tree containing those 10 file changes

5. Create a commit

6. Update the branch ref to point to the new commit

7. Pull the GitHub api until it stops returning 422's (an eventual consistency issue when GitHub is under high load)

.

About 15 total requests…

With code.storage you just post the complete diff:

```

const result = await repo.createCommitFromDiff({

  targetBranch: "my-branch",

  commitMessage: "Apply generated SDK patch",

  author: { name: "Diff Bot", email: "[email protected]" },

  committer: { name: "Diff Bot", email: "[email protected]" },

  diff,
});

```

or better you can stream us your updated files, and we'll apply the diff for you.

```

const result = await repo

  .createCommit({

    targetBranch: "main",

    commitMessage: "Update dashboard docs",

    author: { name: "Docs Bot", email: "[email protected]" },

  })

  .addFileFromString("docs/changelog.md", "# v2.1.0\n- refresh docs\n")

  .addFile("public/logo.svg", await fs.readFile("assets/logo.svg"))

  .deletePath("docs/legacy.txt")

  .send();

```

On top of ergonomics, we have first class APIs for git notes, grep, get archive (include/exclude by blob), and other filesystem behavior that is exceeding helpful when working with LLMs.