.agents/skills/openui-forge-go/SKILL.md
OpenUI generative UI with Go (net/http) backend. Direct OpenAI API streaming via HTTP.
npx skillsauth add OthmanAdi/openui-forge openui-forge-goInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Build generative UI apps with a React frontend + Go backend. Streams OpenAI API responses directly via net/http.
OPENAI_API_KEY environment variable setnpm install @openuidev/react-ui @openuidev/react-headless @openuidev/react-lang lucide-react zod
npx @openuidev/cli generate ./src/lib/library.ts --out backend/system-prompt.txt
go run main.go on :8080, frontend on :3000backend/go.modmodule openui-backend
go 1.21
require (
github.com/joho/godotenv v1.5.1
)
backend/main.gopackage main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
_ "github.com/joho/godotenv/autoload"
)
var systemPrompt string
func init() {
data, err := os.ReadFile("system-prompt.txt")
if err != nil {
log.Fatal("system-prompt.txt not found: ", err)
}
systemPrompt = string(data)
}
func corsMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "http://localhost:3000")
w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
if r.Method == "OPTIONS" {
w.WriteHeader(204)
return
}
next.ServeHTTP(w, r)
})
}
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
}
type ChatRequest struct {
Messages []Message `json:"messages"`
}
func chatHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "Method not allowed", 405)
return
}
var req ChatRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, "Bad request", 400)
return
}
messages := append([]Message{{Role: "system", Content: systemPrompt}}, req.Messages...)
body, _ := json.Marshal(map[string]interface{}{
"model": "gpt-4o", "stream": true, "messages": messages,
})
apiReq, _ := http.NewRequest("POST", "https://api.openai.com/v1/chat/completions", bytes.NewReader(body))
apiReq.Header.Set("Content-Type", "application/json")
apiReq.Header.Set("Authorization", "Bearer "+os.Getenv("OPENAI_API_KEY"))
resp, err := http.DefaultClient.Do(apiReq)
if err != nil {
http.Error(w, "OpenAI request failed", 502)
return
}
defer resp.Body.Close()
w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Connection", "keep-alive")
flusher, ok := w.(http.Flusher)
if !ok {
http.Error(w, "Streaming not supported", 500)
return
}
io.Copy(w, resp.Body)
flusher.Flush()
}
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/api/chat", chatHandler)
fmt.Println("Go backend listening on :8080")
log.Fatal(http.ListenAndServe(":8080", corsMiddleware(mux)))
}
app/chat/page.tsx"use client";
import { FullScreen } from "@openuidev/react-ui";
import { openuiLibrary } from "@openuidev/react-ui";
import {
openAIReadableStreamAdapter,
openAIMessageFormat,
} from "@openuidev/react-headless";
export default function ChatPage() {
return (
<FullScreen
componentLibrary={openuiLibrary}
adapter={openAIReadableStreamAdapter}
messageFormat={openAIMessageFormat}
apiUrl="http://localhost:8080/api/chat"
/>
);
}
npx @openuidev/cli generate ./src/lib/library.ts --out backend/system-prompt.txt
system-prompt.txt exists in the Go backend directoryOPENAI_API_KEY is set in environment or .envapiUrl points to http://localhost:8080/api/chatopenAIReadableStreamAdapter and openAIMessageFormat| Error | Cause | Fix |
|-------|-------|-----|
| CORS blocked | Origin mismatch | Update Access-Control-Allow-Origin in middleware |
| system-prompt.txt not found | File missing from backend dir | Run CLI generate command |
| 502 Bad Gateway | OpenAI API unreachable or key invalid | Check OPENAI_API_KEY and network |
| Stream not flushing | Missing http.Flusher | Ensure handler calls flusher.Flush() |
| Empty response | Body not forwarded | Verify io.Copy pipes OpenAI response to client |
development
Build generative UI with OpenUI — any LLM provider, any backend language. Scaffold, integrate, validate.
data-ai
使用 OpenUI 构建生成式 UI 应用 — 支持任意 LLM 提供商、任意后端语言。脚手架、集成、验证。
tools
OpenUI generative UI with Vercel AI SDK. streamText, toUIMessageStreamResponse, and tools support.
development
OpenUI generative UI with Rust Axum backend. Async SSE streaming with reqwest and async-stream.