DEV Community

Cover image for How I Built a Fully Automated Coding Loop in OpenCode
Peng Qian
Peng Qian

Posted on • Originally published at dataleadsfuture.com

How I Built a Fully Automated Coding Loop in OpenCode

Introduction

If you've been following the AI agent space recently, you've probably heard the term Loop Engineering. Claude Code and OpenClaw both mention it.

But nobody really explains what it means.

Until Andrew Ng posted a clear breakdown of what Loop Engineering actually is. That post gave me the direction I needed to build it inside OpenCode.


What Andrew Ng Says About the Coding Loop

Andrew Ng's explanation centers around this diagram:

3 key product development loops. Image by Andrew Ng

Three loops, simply put:

  • The first loop is the code agent's implementation loop. You give the agent a product spec and a measurable target. The agent starts building features on its own, runs tests, and keeps iterating until every requirement in the spec is met.
  • The second loop is the engineer feedback loop. Here the engineer acts as QA for their own product. They test what the coding agent built, and check if it matches their vision. If something is off, they write a new spec and kick off another round in the first loop.
  • The third loop is the external feedback loop. Once the engineer is happy with the product, it goes to the open-source community or gets handed to a product team. Real user feedback comes in. The engineer collects that feedback regularly, feeds it back into the engineer feedback loop, and from there back into the code implementation loop.

All three loops keep running. With AI in the mix, they push the product forward until it gets to where it needs to be.


My Attempts

Following Professor Andrew Ng's breakdown, I gave it a try in OpenCode. I built a /goal command that lets users just type in what they want the AI to do, and the AI will kick off a coding loop to get it done automatically.

I tested this command out and honestly, the results were way better than I expected.

Here are some of the test scenarios I ran:

1. Write a Fibonacci script

This test checks whether the agent picks the best algorithm. The prompt is:

/goal Write a Fibonacci calculation script with the best possible performance.
Enter fullscreen mode Exit fullscreen mode

What's pretty cool is that DeepSeek went with a fast doubling algorithm, and it's incredibly performant.

2. Build a Tower of Hanoi web game

Everyone knows this game. You could honestly just prompt an LLM directly and get it built. But that predictability is exactly what makes it useful for testing whether each step of the coding loop is working correctly.

/goal Build a playable Tower of Hanoi web game.
Enter fullscreen mode Exit fullscreen mode

The Towers of Hanoi game built using the /goal command comes with a built-in AI solver.

3. Build a chess web game

Maybe you are not impressed by the Tower of Hanoi example, since a regular prompt to any frontier model can do the same thing without a coding loop. Fair. The chess game experiment is something you should actually try for yourself.

/goal Build a playable chess web game. 
Include easy, medium, and hard difficulty levels. 
No online multiplayer needed. 
Use a Python backend as the AI engine.
Enter fullscreen mode Exit fullscreen mode

A full-stack chess game with both frontend and backend, built using the /goal command. Image by Author

4. A typing practice game for kids

/goal I want to build a typing practice web app for kids. 
At the bottom of the screen are 9 keys representing the positions of 10 fingers, with the thumbs sharing a wider spacebar key that takes up two slots. 
Above those 9 keys is a gradient-transparent rectangle. 
Letters fall down from the top toward that rectangle, aligned to their matching key positions. 
Press the right key as the letter enters the zone and it counts as a hit, triggering a hit effect. 
Consecutive correct hits build up increasingly dramatic effects. 
The falling speed gradually increases. 
At the top of the screen is a scoreboard that adds 1 point for each hit, with a pop animation. 
The whole thing should feel exciting and dopamine-triggering, with plenty of visual encouragement.
Enter fullscreen mode Exit fullscreen mode

A typing mini-game created with /goal command.


Pretty cool, right? Feeling curious?

Go ahead and check out my latest article No Plugins Needed, I Built a Fully Automated Coding Loop in OpenCode for the full tutorial, which covers:

  1. My implementation approach.
  2. How to use it.
  3. The complete source code.

It's all free, so what are you waiting for?


Further Reading

How I built a coding workflow in OpenCode, Oh-My-OpenCode-Slim, and OpenSpec that rivals Claude Code:

How I Use OpenCode, Oh-My-OpenCode-Slim, and OpenSpec to Build My Own AI Coding Environment

How I added a reflection agent to the OpenSpec workflow and got DeepSeek-V4 to match or beat Claude Opus:

Reflection SDD: Use a Reflection Harness to Level Up Your OpenSpec Workflow

Still can't get your DeepSeek-V4 or GLM-5.2 to read images? Try my method:

DeepSeek-V4 Can't Read Images? I Made It Read

Top comments (0)