T08-L01 · Write code · Level 1 User · 15-minute read, plus 60 minutes of doing

Almost what you need

A colleague left you a small search page. In the lab it finds reagents; in a company it finds stock. It only matches the start of a name, so "buffer" finds nothing, although Tris buffer and HEPES buffer are on the list.

The fix is one line. In this book you set up OpenCode and let it find, change and undo that line, one step and one screenshot at a time. You are at Level 1 User: you work on your own copy, so only you are affected if something goes wrong.

After this you can

  • Install OpenCode Desktop, open a project folder and choose a free model that keeps no copy of your prompts.
  • Set up the safety net (Git) so that Undo really restores your files.
  • Use Plan to have OpenCode explain code without changing it, and Build to make one narrow change.
  • Read the change in the Review panel and check it against a before-and-after table.
  • Undo the change and bring it back with Redo.

Before you start

  • Books: T01-L01 · From Idea to Working Result: The Four-Quadrant Method for the four-quadrant method.
  • A Windows or Mac computer you may install software on. If IT controls installs on your work computer, ask them to install OpenCode and Git.
  • Notepad or TextEdit, and a web browser.
  • About 75 minutes: 15 to read, 60 to do. Steps 1 to 6 take 20 minutes, once.

Last verified 25 September 2026. OpenCode Desktop is free, and so are its built-in models. The default one, Space Bunny Free, keeps none of your prompts. Most other free models may use them for training. All of them run in the US. Details for experts at the end of this book.

The idea in one page

  • OpenCode works in one folder. Unlike a chat assistant, it opens, changes and runs the files in the folder you give it. It asks before it touches anything outside that folder.
  • Plan explains, Build changes. In Plan, OpenCode can only read. Ask there first, then switch to Build for the change.
  • The Review panel shows what really changed: removed lines in red, added lines in green. Trust it more than OpenCode's own summary.
  • Git is the way back. It's a free program that keeps saved versions of a folder. OpenCode's Undo needs it, and it has to be in the folder before OpenCode first opens it. Step 8 shows how.
  • Ask narrowly: the file, what happens now, what you want instead (with one example) and what must stay the same.

Watch it once (2 minutes)

The pointer shows every button this book uses, in the order you'll use them. It was recorded live with the free model and the same made-up page.

The video has no sound; the captions at the bottom explain each scene. Read the tour as text (opens in a new tab).

Set up OpenCode (steps 1 to 6, once)

Step 1: Install OpenCode Desktop. Go to opencode.ai/download and choose Desktop. Windows: pick x64 (almost every PC). Mac: pick Apple silicon, or Intel if Apple menu → About This Mac names an Intel processor. Run the download and start OpenCode.

You should see: the home screen with Projects on the left.

Step 2: Make your OpenCode folder and add it. In File Explorer (Windows) or Finder (Mac), create a folder OpenCode in Documents. In OpenCode, click the folder icon with a plus next to Projects, choose the new folder and confirm.

OpenCode home screen: Projects on the left, listing reagent-finder and OpenCode, with Settings and Help below; on the right, today's sessions and a New session button

You should see: OpenCode in the Projects list. (This picture is from later, when a second project has been added.) This folder is your workbench: you'll keep every project inside it and use it only to prepare them.

Step 3: Start a session on the workbench. Click OpenCode in the Projects list, then New session at the top right. A session is one conversation about one project.

You should see: a large message box, with OpenCode named below it.

Step 4: Choose the free model. Click the model name under the message box and choose Space Bunny.

The Select model window: eight free models provided by OpenCode, with Space Bunny ticked, and below them buttons to add models from OpenCode Go, OpenCode Console, OpenAI, Anthropic, Google and GitHub Copilot

You should see: Space Bunny Free under the message box. It keeps none of your prompts; stay with it.

Step 5: Turn on the Plan/Build switch. Press Ctrl+, (Cmd+, on a Mac) to open Settings. Under Preferences, turn on Show agent. Leave Auto-accept permissions off. Click Back to app.

Settings, Preferences page: the Show agent switch is on, and Auto-accept permissions above it is off

You should see: Build with a small arrow under the message box. Click it to switch to Plan; Ctrl+. does the same.

The mode menu open above the message box, showing Build with a tick and Plan below it

Step 6: Learn the eight parts of the screen.

A session screen with eight numbered markers: 1 the grid icon at the top left, 2 the session tab, 3 the three dots next to the session title, 4 the rightmost icon at the top right, 5 the message box, 6 the plus below it, 7 the mode, 8 the model

  1. Home: projects and sessions (Ctrl+B).
  2. Session tab: one per open session. Closing it doesn't delete the session.
  3. ⋯: rename, export or delete the session.
  4. Review panel (Ctrl+Shift+R).
  5. Message box: Enter sends, Shift+Enter adds a line.
  6. +: attach a file or a picture.
  7. Mode: Plan or Build.
  8. Model.

On a Mac, use Cmd wherever this book says Ctrl. Grey lines such as Used 1 Read only list what OpenCode did; you can let them pass.

Worked example: fix the reagent finder, step by step

The method is the one from T01-L01 · From Idea to Working Result: The Four-Quadrant Method. Mia, a lab technician, follows it; you do the same steps.

Structure it

Step 7: Write what you want in one sentence.

"When I search 'buffer', I want Tris buffer and HEPES buffer instead of 'Nothing found'. Everything else stays as it is."

Choose tools

OpenCode with Space Bunny, Plan and Build, Git for Undo, the Review panel and your browser. That's all this change needs.

Build it: prepare the project

Step 8: Create the page. Inside your OpenCode folder, create a folder reagent-finder. In Notepad or TextEdit, paste the text below and save it there as index.html. In Notepad, set Save as type to All files; in TextEdit, choose Format → Make Plain Text first.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Reagent finder</title>
</head>
<body>
<h1>Reagent finder</h1>
<label>Search by name: <input id="search"></label>
<ul id="results"></ul>
<p id="none" hidden>Nothing found.</p>
<script>
const items = [
  { id: "R01", name: "Tris buffer 1 M, pH 8.0", place: "Shelf A2" },
  { id: "R02", name: "PBS 10x", place: "Shelf A3" },
  { id: "R03", name: "Ethanol 70 %", place: "Flammables cabinet" },
  { id: "R04", name: "HEPES buffer 1 M", place: "Fridge 2" },
];

function show() {
  const query = document.getElementById("search").value.trim().toLowerCase();
  const results = document.getElementById("results");
  results.innerHTML = "";
  for (const item of items) {
    if (item.name.toLowerCase().startsWith(query)) {
      const line = document.createElement("li");
      line.textContent = item.id + " · " + item.name + " · " + item.place;
      results.appendChild(line);
    }
  }
  document.getElementById("none").hidden = results.children.length > 0;
}

document.getElementById("search").addEventListener("input", show);
show();
</script>
</body>
</html>

You should see: double-click the file and your browser shows Reagent finder with four reagents. If Windows opens it as text, the name ends in .txt: in File Explorer's View menu, turn on File name extensions and rename it.

Step 9: Set up Git from the workbench. Go to your OpenCode workbench session (not a reagent-finder one), check the mode says Build, and send:

Set up Git in the folder reagent-finder so changes there can be tracked and undone:
create a Git repository inside reagent-finder and save its current files as the first version.
Do not change any file.

A session in the OpenCode project titled Initialize Git in reagent-finder. OpenCode's reply: initialized a Git repository in reagent-finder and saved the current files as the first version, commit Initial version, tracked file index.html, status clean, no existing files were changed

You should see: "Initialized a Git repository in reagent-finder", within half a minute. If it says Git isn't installed: on Windows, install Git for Windows from git-scm.com with its default choices; on a Mac, click Install when macOS offers the command line developer tools. Restart the computer, then repeat this step.

Step 10: Open reagent-finder as its own project. Add the reagent-finder folder with the folder-and-plus icon (as in step 2). Click it in Projects, then New session.

A new session for reagent-finder: under the message box, the project name reagent-finder, Local, and a branch label reading master

You should see: a branch label such as master or main under the message box. That means Undo will work.

The same place in a folder without Git: the project name followed by a grey label reading No Git

If you see No Git instead: Undo won't restore files here. Go to the first item in What goes wrong.

Understand it

Step 11: Ask for an explanation in Plan. Switch the mode to Plan and send:

Read index.html. Don't change anything yet.
Explain in plain English, pointing to the exact lines:
1. where the page reads what I type,
2. which line decides whether an item is shown,
3. where it writes the result.
Then tell me why searching "buffer" finds nothing.

OpenCode in Plan mode explaining the file: line 21 reads what you type, line 25 decides with startsWith, lines 23 to 28 write the result, and buffer finds nothing because it sits in the middle of the two buffer names. The mode under the message box reads Plan.

You should see: an answer within seconds that points to the line with startsWith, meaning "the name begins with what I typed". Your wording will differ. To check it, search the file for startsWith with Ctrl+F in your text editor.

Mia also notices that an empty search box shows every item. She adds to her sentence: keep that, the order and the Nothing-found message.

Build it: make and check the change

Step 12: Ask for the narrow change in Build. Switch the mode to Build and send:

Change index.html so the search finds the text anywhere in the name,
not only at the start. "buffer" must find R01 and R04.
Change only the line that decides whether an item is shown.
Keep the item list, the order, the "Nothing found." message and the
show-everything-when-empty behaviour exactly as they are.
Show me the changed line.

You should see: a reply showing one changed line with includes, meaning "the name contains what I typed". Build edits files in the project without asking first.

Step 13: Read the change in the Review panel. Click the rightmost icon at the top right of the session.

The session with the Review panel open on the right: Files Changed 1, Git changes +1 -1, and in index.html line 25 shown twice, the old line with startsWith in red and the new line with includes in green, with unchanged lines around them. On the left, OpenCode's reply: Changed only index.html:25

You should see: Files Changed 1 and +1 −1, with line 25 in red (before) and green (after). If more lines changed, ask: "Why did you change these other lines? Revert everything except the matching rule."

Step 14: Check before and after. Reload the page in your browser and fill in the last column.

You typeBeforeAfter
trisR01R01
bufferNothing foundR01, R04
BUFFERNothing foundR01, R04
(empty box)all fourall four
R01Nothing foundNothing found

The reagent finder page twice, both with buffer typed in the search box. Left, before the change: Nothing found. Right, after the change: R01 Tris buffer and R04 HEPES buffer with their shelves

You should see: "buffer" now finds both buffers, and the last two rows haven't changed.

Step 15: Undo. Press Ctrl+P, type undo and press Enter on Undo.

The search window with undo typed in it and one result under Commands: Undo, Undo the last message

You should see: your request back in the message box, and "buffer" finds nothing again after a reload. Close and reopen the Review panel: it now says No file changes yet.

The message box after Undo, holding the change request again, ready to send

Step 16: Redo. Press Ctrl+P, type redo and choose Redo.

You should see: after a reload, "buffer" finds both buffers again.

What it taught Mia: three lines were enough to judge the change, and the empty-box row protected a behaviour she'd almost forgotten.

Company: the product finder

Jonas runs a stockroom. His page lists four products, and "mug" finds only "Mug lid, blue". He does steps 7 to 16 with a folder product-finder and these four lines in place of the reagents:

  { id: "P01", name: "Blue coffee mug 300 ml", place: "Aisle 3" },
  { id: "P02", name: "Mug lid, blue", place: "Aisle 3" },
  { id: "P03", name: "Travel mug 450 ml", place: "Aisle 4" },
  { id: "P04", name: "Tea towel, cotton", place: "Aisle 7" },

After the change, "mug" finds P01, P02 and P03, and an empty box still shows all four. Before changing a page other people rely on, he'll ask its maintainer: that's a Level 2 job (T08-L02 · Get a Script Your Colleague Can Rerun, Without Being a Developer).

Working with OpenCode day to day

  • One session per task. Start a new one with New session or Ctrl+Shift+S; long sessions get slow and vague.
  • Point at a file by typing @ and part of its name.

The message box with Explain @ind typed, and above it a suggestion list showing index.html

  • Answer permission questions. Before OpenCode goes outside the project folder, it asks. Allow once if you expected it; Deny if you didn't, then ask why.

A Permission required box with a warning sign above the message box: Access files outside the project directory, with the folder it wants to reach, and three buttons: Deny, Allow always, Allow once

What goes wrong

Undo leaves the file changed. Symptom: after Undo the page still behaves the new way; a new session shows No Git. Fix: OpenCode opened the folder before it had Git. Change the line back (or ask Build to). Copy the folder inside OpenCode under a new name, set up Git in the copy (step 9) and add the copy as a project (step 10). To remove the old one, open Settings → Projects, click ⋯ and choose Close.

The Review panel is empty or out of date. Symptom: it only says Track, review, and undo changes in this project, or still shows an undone change. Fix: empty means no Git (see above); out of date means close and reopen it.

Plan refuses to change the file.

OpenCode in Plan mode answering a change request: You're in Plan mode, so I can't modify the file. Switch agents and I can make the one-line change. It then shows the line it would write

Fix: that's Plan doing its job ("switch agents" means switch the mode). Switch to Build and send "Go ahead and make that change now."

Asking for "better". Symptom: "Improve the search" returns a rewritten page. Fix: name the file, one example, the expected result and what must stay the same.

Trusting the reply instead of the Review panel. Symptom: the reply says "only line 25", the panel shows +7 −3. Fix: ask why each extra line changed and have it revert them.

Checking the old page. Symptom: the change "didn't work". Fix: reload the page, and make sure it's the file from the project folder.

Pasting real data. Symptom: you paste the real reagent or customer list "for context". Fix: everything you send goes to the model provider in the US. Use four made-up rows (T12-L01 · Decide What You May Paste Into AI at Work).

Do it yourself (60 minutes)

Use a small page or script of your own that almost does what you want, or change the reagent finder to search the shelf as well as the name.

  1. Set up (20 min, first time only): steps 1 to 6.
  2. Structure it (5 min): "When I ___, I want ___ instead of ___."
  3. Choose tools and prepare (10 min): put the file in a new folder inside OpenCode, then steps 9 and 10. Write your before-and-after table with five inputs, one of which must not change.
  4. Understand it (10 min): step 11 with your file.
  5. Build it (15 min): steps 12 to 16.

Exit check

What you hand in: your before-and-after table of five inputs, a screenshot of the Review panel showing the change (Windows+Shift+S, or Cmd+Shift+4 on a Mac), and one sentence on how you undid and redid it.

It passes when all five results match, including the one that must not change, the Review panel shows only the line you asked for, and Undo brought the old behaviour back.

Rule to remember

Explain in Plan, change in Build, read the Review panel, and keep Git as the way back.

Details for experts

Checked on 25 September 2026. You don't need this to follow the book; it's for setting things up or answering a colleague.

WhatDetailsWhat it means for you
VersionOpenCode Desktop 2.0.16 on Windows 11. It updates itself. Downloads exist for Windows, macOS and Linux.Older 1.x versions look different: the Plan/Build switch was always visible, and Undo was typed as /undo.
Free modelsEight free models run on OpenCode Zen, OpenCode's own service in the US. Space Bunny Free keeps no copy of prompts and isn't trained on them. The NVIDIA Nemotron models don't link what you send to you. Others, such as Big Pickle, MiMo and Muse Spark, may learn from your prompts while they're free.Space Bunny is the safest free choice, and it still sends everything to a US service: send only made-up or approved data. Free models can disappear or change without notice.
PermissionsInside the project folder most actions are allowed. Reaching outside it asks first. Allow always lasts for the current session. Files named .env, where programs often keep passwords, are blocked.The project folder is your safety boundary. Stricter rules go into a settings file, opencode.json; more in T08-L04 · Use OpenCode Desktop on Your Organisation's Real Repositories.
Undo and RedoFound through Ctrl+P; no shortcut of their own. Before each change OpenCode saves a hidden copy of the files, and it needs Git to do that.No Git, no restored files. Settings → Shortcuts lets you give Undo a key.
Why Git comes firstThe Desktop app starts a helper program that keeps running after you close the window. It checks a folder for Git the first time it opens it and keeps the answer until the computer restarts.That's why the workbench sets up Git before you open a new folder.
ShortcutsCtrl+B home, Ctrl+Shift+S new session, Ctrl+. Plan/Build, Ctrl+' model, Ctrl+Shift+R Review panel, Ctrl+U attach, Ctrl+` terminal. Cmd on a Mac.The terminal is a window for typed commands; you don't need it at Level 1.
Next steps/init writes a short project description into AGENTS.md, which OpenCode reads at the start of every session. The model list also connects paid models or your institute's own model (Custom OpenAI-compatible provider).Both belong to team set-up: T08-L04 · Use OpenCode Desktop on Your Organisation's Real Repositories.

Further reading and tools

Next books

Tools

  • OpenCode: Taught. The Desktop app is the course's coding assistant.
  • Git: Taught, one request deep. OpenCode uses it to show and undo changes.
  • Claude Code, Cursor: Catalogued. Other coding assistants with the same explain-change-review workflow.