← Wiki

SGR — schemas first, logic second, UI last

Schema-Guided Reasoning (SGR): all projects built from schemas to logic, not the other way around. Schemas are the contract between AI agent, business logic, and UI.

Order: Define domain (typed schemas) → Then logic (services work with schemas) → UI last (displays schemas, doesn’t parse strings).

When an AI agent works on a project, it MUST:

SGR is the technical implementation of DDD:

By stack: Pydantic (Python), Zod (TypeScript), SwiftData @Model (iOS), data class + kotlinx.serialization (Kotlin). See SGR in practice: openai-oxide (Rust client with typed responses), rust-code (structured agent loop).

Skill: /sgr in solo-factory — design and implement SGR pipelines (NextStep agent loop, analysis cascade, tool dispatch). 4 reference files incl. working 304-line demo.

Libraries: sgr-agent crate v0.6.1 (Rust core for SGR agents), sgr-agent-core (Python, 1K+ stars), openai-oxide (typed Rust client).

Sources

Related