Use cases/Document agents

How to review every change an agent makes to your files

A step-by-step guide to giving an agent its own copy of a client’s files, reading everything it changed, and letting only what you approve reach the real folder.

  • 12 min read
  • TypeScript
  • Beginner friendly
q3-books mainWaiting for you
ledger.csvmodified · +3 lines
q3-summary.mdadded · new file
  • + 2026-07-11,Millers Flour Co.,1180.00,Supplies
  • + 2026-08-02,ColdChain Services,260.00,Repairs
  • + 2026-09-15,Hearth Oven Repair,845.00,Equipment

One wrong line in the ledger

Agents usually get the same access people do: the real folder, with permission to write. There is no draft and no “are you sure?”. Whatever the agent saves becomes the new truth, and afterwards it’s hard to tell which lines it touched. A small mistake, like a repair booked as new equipment, goes out with the next report before anyone sees it. The mistake is small. The setup gives nobody a chance to catch it.

The usual fixes each cost something. You can copy the folder before every run, but client folders are large, the copies pile up, and someone still has to move the good changes back by hand. Or you can let the agent only suggest changes and type them in yourself. That is safe, but now you’re doing the work again. It ends up all or nothing: trust the agent fully, or don’t use it.

The usual setup

Agent Writes straight inClient’s real files

What we’ll build

AgentIts own copy You approve Client’s real files

In this guide we’ll do it the other way. The agent never touches the client’s real files. It works on its own copy, which costs nothing to make, and every save it makes is recorded with a reason. You read the changes, fix what’s wrong, and approve. Only then do they reach the real files.

What we’re building

By the end, you’ll have:

  • A client’s folder saved on a disk, with every version kept.
  • An agent key that can reach only that one client.
  • A private copy for each agent run, ready in 10 ms.
  • A clear list of what the agent changed, commit by commit and line by line.
  • One approve step, made by you, and a way to undo it later.

You’ll need a Skywake API key with the admin role and Node. Set SKYWAKE_API_KEY, then install the SDK with npm i skywake.

Step 1

Save the folder

We’ll use the books of Acme Bakery, a small client, as the running example. It’s a small folder: a ledger, the quarter’s invoices, and a note from the accountant.

acme-books/

  • ledger.csv# the file the agent will edit
  • invoices/millers-flour-0711.txt
  • invoices/coldchain-0802.txt
  • invoices/oven-repair-0915.txt# the one it gets wrong
  • notes.md# “small repairs go to Repairs”

Each client gets its own disk: a set of files with branches and history. We upload the folder to its first branch, main. A branch is a line of saved versions, like a Git branch. Each save is a commit, and every commit is kept.

save-folder.ts
import { Skywake } from "skywake";

const sky = new Skywake();

const acme = sky.disk("acme");
const start = await acme.upload("./acme-books", {
  message: "Acme books before the Q3 close",
});

start is the commit we just made. Keep it: it marks where the agent began. From now on, main holds the real books, and the agent never writes to it.

Step 2

Give the agent its own copy

The agent should not use your key. We make it one of its own, with the write role, for this one client, that expires in a week.

Then the agent forks main. A fork is a new branch that starts exactly where the old one is. It copies nothing, so it’s ready at once, whatever the size of the folder.

agent-copy.ts
const { key } = await sky.createKey({
  name: "bookkeeper",
  role: "write",
  only: ["acme"],
  expiresInDays: 7,
});
const agentSky = new Skywake({ key });

const work = await agentSky.disk("acme").fork("q3-books");

The agent now has q3-books, a full copy of Acme’s books. Its key reaches only the acme disk. If it tries to open another client’s disk, the request is refused.

Step 3

Give it tools that write to the copy

Your agent works through tools: small functions the model is allowed to call. We give it three. It can list the files, read one, and write one. Every tool points at work, so there is no way for it to reach the real folder.

tools.ts
const tools = {
  list: async () => {
    const entries = await work.list("", { recursive: true });
    return entries.filter((e) => e.kind === "file").map((e) => e.path);
  },
  read: (path: string) => work.read(path),
  write: (path: string, text: string, reason: string) =>
    work.write(path, text, { message: reason }),
};

await yourAgent(tools);

Look at write. It asks the agent for a reason, and that reason becomes the commit message. So every change arrives with the agent’s own words on why it made it.

Tip: ask for one change per write

In your prompt, ask the agent to make one change per write and to explain it in a short sentence. Small commits with clear reasons are much easier to review than one big save at the end.

Now hand the tools to your model and let it work. Here yourAgent stands for your own agent loop. In our run, the agent added three lines to ledger.csv, one for each invoice, and wrote a new file, q3-summary.md. That made two commits on its copy. main did not change at all.

Step 4

Read what it changed

The run is done. Now it’s your turn, with your own key. First, the story of the run: each commit since start, with its reason.

review.ts
const review = sky.disk("acme", { branch: "q3-books" });

for await (const commit of review.log()) {
  if (commit.id === start) break;
  console.log(commit.message);
}

const changed = await review.diff("main");
console.log(changed);

log lists the branch’s commits, newest first, so we stop at start. diff gives the sum of them: each file the agent added, removed or modified, compared with main.

q3-books, since start

  1. 1Book 3 supplier invoices for Q3modified · ledger.csv
  2. 2Write the Q3 summaryadded · q3-summary.md

The summary is new, so you can just read it. The ledger was modified, so you want to see the exact lines. Read the file on both branches and keep the lines that are new:

lines.ts
const before = (await acme.read("ledger.csv")).split("\n");
const after = (await review.read("ledger.csv")).split("\n");
const added = after.filter((line) => !before.includes(line));

added holds the three new lines. Two are right. The third books the oven repair as Equipment, though Acme’s own notes say small repairs go to Repairs.

Step 5

Fix one line, approve the rest

You don’t have to throw the run away for one bad line. Fix it on the agent’s copy, as one more commit with your own reason. Then merge: bring the copy’s changes into main.

approve.ts
const fixed = after.join("\n").replace(
  "Hearth Oven Repair,845.00,Equipment",
  "Hearth Oven Repair,845.00,Repairs",
);
await review.write("ledger.csv", fixed, {
  message: "Oven repair goes to Repairs",
});

const approved = await review.mergeInto("main", {
  message: "Approve Q3 books",
});

If something on main changed the same file meanwhile, the merge stops with a MergeConflict that names the file, and nothing is saved. Here nothing clashes, so the merge lands: the ledger on main now has all three lines, with your fix, and the summary is there too.

ledger.csv on main, after approval

2026-07-11,Millers Flour Co.,1180.00,Supplies

2026-08-02,ColdChain Services,260.00,Repairs

2026-09-15,Hearth Oven Repair,845.00,Equipment Repairs
Fixed by you · approved as one merge

Keep the merge out of the agent’s tools. The agent can do the work. Only you approve it.

Step 6

Keep the record, undo if you must

Weeks later, a client asks why the oven repair sits under Repairs. Every commit that changed the ledger is kept, with its message:

record.ts
for await (const commit of acme.log({ path: "ledger.csv" })) {
  console.log(commit.created, commit.message);
}

The newest is Approve Q3 books, and the oldest is Acme books before the Q3 close. The approval is a merge commit, and it records which commit it brought in.

Changed your mind after approving? Revert the approval. A revert is a new commit that puts back what an old one changed.

undo.ts
await acme.revert(approved.commit!, {
  message: "Undo the Q3 approval",
});

The ledger is back to how it was before the run, and the undo is in the history too. Once a run is approved or rejected, delete its branch. If you reject a run, that’s all you do: main never saw it.

reject.ts
await review.destroy();

Running it for every client

One client is the easy case. A few things to know as you grow to hundreds of clients and many runs a day:

  • One disk per client. Name them acme, globex, and give each agent a key for just the client it works on.
  • Copies stay instant. A fork copies nothing, so a copy of 20,000 files is ready in about 10 ms.
  • Short-lived keys. Make the agent’s key expire soon after the job, so an old key can’t be used for the next one.
  • Tidy up branches. Delete a run’s branch once you merge or reject it. main keeps its own history, approval included.
  • It all stays yours. Every version of every file lives in your own bucket.

Questions

Start building with Skywake.

One shared disk for all your agents, with search built in.