Copied to Clipboard
vite';import react from '@vitejs/plugin-react';export default defineConfig({plugins:[react()]});",
"frontend/index.html": "<!doctype html><html><head><meta charset='UTF-8'><title>Notes</title></head><body><div id='root'></div><script type='module' src='/src/main.jsx'></script></body></html>",
"frontend/src/main.jsx": "import React from 'react';import ReactDOM from 'react-dom/client';import App from './App.jsx';ReactDOM.createRoot(document.getElementById('root')).render(<React.StrictMode><App /></React.StrictMode>);",
"frontend/src/App.jsx": "import { useEffect, useState } from 'react';export default function App(){const [notes,setNotes]=useState([]);const [text,setText]=useState('');const fetchNotes=async()=>{try{const r=await fetch('http://localhost:8000/notes');const d=await r.json();setNotes(Array.isArray(d)?d:[]);}catch(e){console.error(e);setNotes([]);}};useEffect(()=>{fetchNotes();},[]);const add=async()=>{try{await fetch('http://localhost:8000/notes',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({content:text})});setText('');fetchNotes();}catch(e){console.error(e);}};const update=async(id)=>{const newText=prompt('Update note');if(!newText)return;try{await fetch(`http://localhost:8000/notes/${id}`,{method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({content:newText})});fetchNotes();}catch(e){console.error(e);}};const del=async(id)=>{try{await fetch(`http://localhost:8000/notes/${id}`,{method:'DELETE'});fetchNotes();}catch(e){console.error(e);}};return(<div style={{padding:20}}><h1>Notes</h1><input value={text} onChange={e=>setText(e.target.value)}/><button onClick={add}>Add</button><ul>{notes.map(n=>(<li key={n.id}>{n.content} <button onClick={()=>update(n.id)}>Edit</button> <button onClick={()=>del(n.id)}>Delete</button></li>))}</ul></div>);}"
}
"""
executor.py
Runs backend.
import subprocess
import os
import time
import requests
def run_backend(workdir):
backend_path = os.path.join(workdir, "backend")
# Ensure Go modules are ready
subprocess.run(["go", "mod", "tidy"], cwd=backend_path)
process = subprocess.Popen(
["go", "run", "./cmd/server"],
cwd=backend_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
# --------------------------------------------------
# WAIT FOR SERVER TO BE READY
# --------------------------------------------------
for _ in range(10):
try:
r = requests.get("http://localhost:8000/notes")
if r.status_code == 200:
return True, process, ""
except Exception:
pass
time.sleep(0.5)
# --------------------------------------------------
# IF NOT READY → REAL ERROR
# --------------------------------------------------
out, err = process.communicate()
print("\nBACKEND ERROR:")
print(err or out)
return False, None, err or out
def stop_backend(process):
if process:
process.terminate()
try:
process.wait(timeout=2)
except Exception:
process.kill()
tester.py
Tests
import subprocess
import os
def run_tests(workdir):
backend_path = os.path.join(workdir, "backend")
result = subprocess.run(
["go", "test", "./..."],
cwd=backend_path,
capture_output=True,
text=True
)
if result.returncode == 0:
return True, ""
return False, result.stdout + result.stderr
validator.py
Performs HTTP validation.
import requests
BASE = "http://localhost:8000"
def validate_api():
try:
r = requests.post(f"{BASE}/notes", json={"content": "hello"})
note = r.json()
note_id = note["id"]
requests.get(f"{BASE}/notes")
requests.put(f"{BASE}/notes/{note_id}", json={"content": "updated"})
requests.delete(f"{BASE}/notes/{note_id}")
return True, ""
except Exception as e:
return False, str(e)
installer.py
Handles environment fixes.
import subprocess
import sys
import os
import re
def install_missing(error: str | None, workdir: str) -> bool:
"""
Attempts to fix environment/dependency issues based on error output.
Returns:
True -> something was installed/fixed
False -> nothing actionable
"""
if not error:
return False
error_lower = error.lower()
backend_path = os.path.join(workdir, "backend")
frontend_path = os.path.join(workdir, "frontend")
# --------------------------------------------------------
# GO MODULE ISSUES
# --------------------------------------------------------
if "go.mod file not found" in error_lower:
print("[installer] Initializing go module")
subprocess.run(
["go", "mod", "init", "backend"],
cwd=backend_path
)
subprocess.run(
["go", "mod", "tidy"],
cwd=backend_path
)
return True
if "cannot find module" in error_lower or "no required module provides package" in error_lower:
print("[installer] Running go mod tidy")
subprocess.run(
["go", "mod", "tidy"],
cwd=backend_path
)
return True
# --------------------------------------------------------
# NPM / FRONTEND
# --------------------------------------------------------
if "npm" in error_lower or "node_modules" in error_lower:
if os.path.exists(frontend_path):
print("[installer] Installing npm dependencies")
subprocess.run(
["npm", "install"],
cwd=frontend_path
)
return True
# --------------------------------------------------------
# PYTHON MODULE (requests etc.)
# --------------------------------------------------------
if "no module named" in error_lower:
try:
pkg = re.findall(r"No module named ['\"](.+?)['\"]", error)[0]
except:
return False
# Avoid installing internal modules
if pkg.startswith(("agent", "backend", "frontend")):
print(f"[installer] Skipping internal module: {pkg}")
return False
print(f"[installer] Installing python package: {pkg}")
subprocess.run(
[sys.executable, "-m", "pip", "install", pkg]
)
return True
return False
utils.py
Writes files.
import os
import shutil
def write_files(base, file_map: dict):
# CLEAN previous generation
if os.path.exists(base):
shutil.rmtree(base)
os.makedirs(base, exist_ok=True)
# Write fresh files
for path, content in file_map.items():
full_path = os.path.join(base, path)
os.makedirs(os.path.dirname(full_path), exist_ok=True)
with open(full_path, "w") as f:
f.write(content)
config.py
import os
WORKDIR = "project_agentic_coded_full_system_go"
MAX_ATTEMPTS = 5
MAX_STAGNATION = 2
SERVER_START_DELAY = 2
PORT = 8000
.gitignore
What should not get into the Git repository
# Python
__pycache__/
*.pyc
*.pyo
*.pyd
# Virtual env
.venv/
venv/
# Generated projects (ignore agent output)
project_agentic_coded_full_system_go/
# OS
.DS_Store
Appendix B — Backend Generated Example (Go)
main.go (simplified)
http.HandleFunc("/notes", notesHandler)
http.HandleFunc("/notes/", noteByIDHandler)
Supports:
Includes:
- in-memory store
- JSON encoding
- CORS headers
Appendix C — Frontend Example (React)
Features:
fetch notes
create note
update note
delete note
Uses fetch API.
Appendix D — Iteration Strategy
Problem
Fixed loops:
- stop too early
- waste iterations
Solution
MAX_ATTEMPTS = 10
MAX_STAGNATION = 2
Behavior
- stop on success
- stop on stagnation
- bounded retries
Final Takeaway
This approach moves development from:
code generation → system generation
The agent becomes:
- builder
- tester
- validator
- debugger
Full Modular System Example Git Repository
In this Git repository you can clone the implentation of this Agent.
GitHub - mmmattos/agentic-coding-full-system-go: Agentic Coding for full system in Go: Backend and...
Agentic Coding for full system in Go: Backend and Frontend - mmmattos/agentic-coding-full-system-go
github.com