Open Code and OpenCode: A Coding Agent You Can Read
A coding agent is the same loop as the robot loop, with the body swapped for a computer: read, decide, act, check the result. The version you can inspect and host yourself is opencode.
What a coding agent is
It is the same loop as the robot loop, with the body swapped for a computer. Read the files, decide on a change, make the change, run the build or the tests, read the error output, change something else, and repeat. The difference from a chat assistant is that the agent can act on your project and verify its own work by running it.
That verification step is the whole value. A text assistant can tell you what a fix looks like, but it cannot tell you whether the fix compiled. An agent that runs the code gets a fact instead of an opinion, and the loop closes the same way a control loop closes. In a classroom this is the difference between a student reading generated code and a student testing it.
What opencode is, and why open source matters here
opencode is an open-source AI coding agent that runs in the terminal as a keyboard-driven interface, and it now also ships as a desktop app and an IDE extension. It is MIT licensed, developed by Anomaly, and deliberately model-agnostic: it connects to more than 75 model providers through Models.dev, including locally hosted models, so a school is not tied to one vendor's subscription or to one company's data policy.
For a school, the open-source part is the point. The tool itself can be read, audited and hosted by you, and the same agent works with a free model, a paid one, or a model running on a Raspberry Pi in the lab. It also has a plan mode, where the agent breaks a task into steps and waits for you to approve the plan before it touches a file, which is the difference between an agent you supervise and one you merely observe.
Step by step
-
Install it in an empty folder
Run the installer, start it in a directory with nothing in it, and ask it to list the files. Do not point it at your project on the first day.
-
Give it one small task and read every diff
Ask for one change to one file, then read the diff line by line. If you cannot explain every line, you are not reviewing the work, you are accepting it.
-
Let it run the build
Point it at the compile or upload command and watch it read the error output and try again. This is the step that makes an agent different from a chat window.
-
Use the plan mode for anything bigger
For work that spans several files, make it produce a plan first and approve or reject the plan before it writes any code.
-
Point it at a local model
Configure it to use a model running on a Raspberry Pi in your classroom and nothing leaves the building. You give up some quality and you gain privacy.
-
Set the rules before you need them
Work inside a git repository, review each diff before accepting it, and never let it push. The failure mode of coding agents is an overconfident edit, and a commit history is the cheapest insurance there is.
What you'll need
| Item | Qty | Why |
|---|---|---|
| Laptop or desktop with 16 GB of RAM | 1 | Runs the agent, and the model too if you point it at a local one on the same machine. |
| Arduino Uno R3 | 1 | The target of the generated code, which is what stops the exercise being about text. |
| USB cable and breadboard | 1 set | So the code the agent writes is actually flashed and run, not just read on a screen. |
| HC-SR04 ultrasonic sensor | 1 | Gives the generated program something physical to do, with numbers you can check against reality. |
| Pushbutton and LED assortment | 1 kit | The simplest possible target for a first generated sketch that you can verify by eye. |
| Raspberry Pi 5 with 8 GB | 1 | Optional, for hosting a local model so that no student code or data leaves the lab. |
Practise it before you build it
Every step above has a matching circuit in the ThinkEdge Learn simulator. The simulator runs a real
Arduino sketch against a modified-nodal-analysis solver, so digitalWrite actually drives the
LED on screen and the readings change when you change the wiring — no hardware, no burnt components.
The Mega has 4 hardware serial ports (Serial, Serial1, Serial2, Serial3). That means you can talk to 4 different devices at the SAME time — like a GPS, a Bluetooth module, an XBee radio, and the USB. Use 3 of those ports to read 3 different sensors in parallel and stream their data to the Serial Monitor as a CSV row every second. This is the foundation of every real Arduino data logger.
The classic first Arduino project — blink the built-in LED on pin 13 — but done the RIGHT way. Most beginners use delay(1000) to make the LED blink, but delay() blocks the whole CPU so you can't do anything else while the LED blinks. The real Arduino idiom is to track time with millis() and only toggle the LED when enough time has passed. This is how every non-trivial Arduino sketch works.
A 10-segment LED bar graph is the easiest way to visualize an analog input: spin a potentiometer and 1, 2, 3 ... 10 LEDs light up in sequence. This is a "VU meter" — the kind you see on stereo equipment. The Mega is ideal because it has 10 free digital pins without stealing any from the analog or serial pins. The same code can be extended to 20, 30, or 100 LEDs on a Mega.
A real Arduino project almost always involves a sensor + a way to see the data. The DHT11 reads temperature and humidity, and the Serial Monitor (the window in the Arduino IDE) shows the readings. The Nano is perfect for this because it plugs directly into a breadboard with no extra wiring for power — you can build a complete data logger in 5 minutes.
Mount an HC-SR04 ultrasonic sensor on top of a servo. Sweep the servo from 0° to 180° and back, and at each step measure the distance. Print the results to the Serial Monitor as "angle,distance" pairs. Open the Serial Plotter in the Arduino IDE to see a live radar-like graph of the room. With Processing on your computer, you can build a full visual radar.
In factories, conveyor belts carry products past a sensor that counts them. A simple "break-beam" sensor (a light source + photodetector) registers each object as it passes. In this project, you'll simulate the conveyor with your hand: every time you press the button (mimicking a product passing the sensor), the counter increments and the LED blinks. Add a buzzer to beep once for every 10 items. This is the same logic as a people counter at a door, a coin counter at a bank, or a bottle counter on a bottling line.
Common questions
Is opencode free?
The tool is MIT licensed and costs nothing to install or run. The cost depends on the model you connect: opencode includes free models, a paid provider bills per token, and a local model on your own hardware costs only electricity. Open source also means you can read the code, which matters more in a school than the licence fee does.
Can an AI coding agent do my homework?
It can, and that is exactly why the interesting use is different. Ask it to explain the error you got, to write the test that catches a bug, or to review your code and tell you which line is wrong. That turns it into a tutor that never gets bored. Handing over the whole project turns it into a way of avoiding the practice, and your examiner can tell the difference from the code alone.
Is it safe to let a coding agent run commands on my computer?
Not without rules, because an agent that can run commands can delete files or rewrite your project. Keep the work in a git repository so every change is a diff you can read and undo, run it in a copy of the folder, and never give it credentials. The setup takes five minutes and removes almost all of the risk.
Related guides
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. NCERT Science mapping on 47 projects, with Arabic and English copy in the regional builds.