From solo
Designs Schema-Guided Reasoning (SGR) pipelines translating domain expert checklists into Pydantic/Zod schemas for constrained LLM decoding in agent loops and analysis cascades.
How this skill is triggered — by the user, by Claude, or both
Slash command
/solo:sgrThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Design and implement Schema-Guided Reasoning (SGR) pipelines. Translate domain expert mental checklists into structured reasoning schemas for LLMs.
Design and implement Schema-Guided Reasoning (SGR) pipelines. Translate domain expert mental checklists into structured reasoning schemas for LLMs.
Source: Rinat Abdullin — Schema-Guided Reasoning
SGR = guide LLM reasoning through predefined steps via constrained decoding. Instead of free-form text → enforce a schema that defines what steps, in which order, where to focus attention.
Domain expert mental checklist → Pydantic/Zod schema → Constrained decoding → Deterministic dispatch
Parse task from $ARGUMENTS:
Identify the reasoning cascade — interview the domain:
This is the critical step. SGR quality = how well you translate the expert's mental checklist.
Design the schema following SGR patterns:
class NextStep(BaseModel):
current_state: str # thinking space
plan_remaining_steps: list[str] # 1-5 steps, only first used
task_completed: bool # routing gate
function: Union[Tool1, Tool2, ..., ReportCompletion] = Field(
..., description="execute first remaining step"
)
class Analysis(BaseModel):
preliminary: str # initial assessment
classification: Literal["a", "b", "c"] # force categorization
evidence: list[str] # cite sources
gaps: list[GapItem] # structured findings
verdict: Literal["pass", "partial", "fail"] # final decision
reasoning_for_verdict: str # explain after deciding
class SendEmail(BaseModel):
tool: Literal["send_email"] # discriminator
recipient: str
subject: str
body: str
class SearchDB(BaseModel):
tool: Literal["search_db"]
query: str
# Union with Literal discriminator = deterministic routing
Action = Union[SendEmail, SearchDB, ReportDone]
Apply SGR design rules (from references/sgr-rules.md):
Literal["pass", "fail"] not strAnnotated[list[str], MinLen(1), MaxLen(5)]tool: Literal["name"] for routingreasoning_for_X AFTER the enum field, not beforeAnnotated[int, Le(50)] — bake constraints into typesImplement the dispatch loop (if agent):
for i in range(MAX_STEPS):
response = client.beta.chat.completions.parse(
model=MODEL,
response_format=NextStep,
messages=log,
)
job = response.choices[0].message.parsed
if isinstance(job.function, ReportCompletion):
break # done
result = dispatch(job.function) # deterministic routing
log.append(assistant_message(job))
log.append(tool_result(result))
Add to project:
schemas/ or models/ directorydispatch.py or equivalentAudit mode (if $ARGUMENTS = "audit"):
## SGR Pipeline: {domain}
**Pattern:** {NextStep | Analysis Cascade | Tool Dispatch}
**Schemas:** {N} models
**Tools:** {N} (if agent loop)
### Reasoning Cascade
{step 1} → {step 2} → ... → {decision/action}
### Files
- schemas/{name}.py — {N} models
- dispatch.py — tool routing
- tests/test_{name}.py — validation tests
references/sgr-rules.md — design rules and anti-patternsreferences/sgr-demo.py — complete working example (Abdullin's CRM demo, 304 lines Python)references/sgr-patterns.md — cascade patterns for 6 domainsreferences/sgr-full-guide.md — full SGR guide with theory, code, tool calling internalsIn Rust, SGR is even stronger: #[serde(tag = "tool")] gives discriminated union dispatch at zero runtime cost. Enum variants = tools, serde deserialization = constrained decoding.
references/sgr-demo.py — minimal standalone example (304 lines, CRM agent)Cause: Tried to put everything in one model. Fix: Split into analysis model + action model. Cascade, don't flatten.
Cause: Model not supporting constrained decoding, or wrong API.
Fix: Use response_format=Schema (OpenAI), tools with schema (Anthropic). Check references/sgr-rules.md for provider-specific notes.
Cause: No task_completed gate or ReportCompletion tool.
Fix: Always include a completion signal in the Union. Cap loop iterations.
npx claudepluginhub fortunto2/solo-factory --plugin soloGuides Pydantic schema design for Atomic Agents apps using BaseIOSchema. Covers fields, constraints, validators, enums, and patterns like chat input/output.
Provides Claude Code templates for agentic design patterns like prompt chaining, routing, reflection, tool use, planning, and multi-agent workflows using 4-layer stack. For LLM task decomposition.
Routes tasks to the best specialist agent using file patterns, intent keywords, and domain context. Loaded every session to activate 58 agents across categories.