solo-sgr
Skill18 starsChanged 4 months agoMITView on GitHub
Use when "design schemas", "structured output", "agent loop", "SGR", "constrained decoding", "tool dispatch", "Pydantic schema for LLM", or need to design a schema-guided reasoning pipeline for an agent or API. Do NOT use for general code review (/review) or planning (/plan).
In this repository62 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- solo-android-releaseSkill
- solo-apple-app-iconSkill
- solo-auditSkill
- solo-boardSkill
- solo-buildSkill
- solo-community-outreachSkill
- solo-content-genSkill
- solo-creator-growthSkill
- solo-customer-finderSkill
- solo-deep-researchSkill
- solo-deploySkill
- solo-diagnoseSkill
- solo-domainSkill
- solo-factorySkill
- solo-github-outreachSkill
- solo-gmail-cliSkill
- solo-grillSkill
- solo-hackathonSkill
- solo-humanizeSkill
- solo-i18nSkill
- solo-index-youtubeSkill
- solo-initSkill
- solo-ios-devSkill
- solo-ios-releaseSkill
- solo-kaggle-gpuSkill
- solo-kindleSkill
- solo-knowledgeSkill
- solo-landing-genSkill
- solo-launchSkill
- solo-legalSkill
- solo-memory-auditSkill
- solo-metrics-trackSkill
- solo-mirrorSkill
- solo-model-shrinkSkill
- solo-music-reels-cutSkill
- solo-open-datasetSkill
- solo-paperSkill
- solo-pdf-printSkill
- solo-pipelineSkill
- solo-planSkill
- solo-redditSkill
- solo-researchSkill
- solo-retroSkill
- solo-reviewSkill
- solo-scaffoldSkill
- solo-secretsSkill
- solo-seo-auditSkill
- solo-seo-cliSkill
- solo-setupSkill
- solo-skill-auditSkill
- solo-skill-shelfSkill
- solo-stem-splitSkill
- solo-streamSkill
- solo-supervoxSkill
- solo-swiftui-design-systemSkill
- solo-transcribeSkill
- solo-validateSkill
- solo-video-editSkill
- solo-video-promoSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 38
If "audit": scan project for existing Pydantic/Zod schemas, evaluate against SGR patterns
- Distinctive: line 39
If task description: design SGR pipeline from scratch
- Distinctive: line 40
If empty: ask "What domain/task should the SGR pipeline handle?"
- Distinctive: line 123
Document the reasoning cascade in a comment or docstring
- Distinctive: line 127
Check: do schemas follow cascade order?
- Very specific: line 175
Fix: Use response_format=Schema (OpenAI), tools with schema (Anthropic).
- Distinctive: line 179
Fix: Always include a completion signal in the Union.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/sgr
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
Core Principle
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 dispatchWhen to Use
- Designing agent tool dispatch (NextStep pattern)
- Building structured analysis pipelines (compliance, code review, evaluation)
- Replacing prompt chains with single structured call
- Any place where LLM output must be parseable and actionable
Steps
- Parse task from
$ARGUMENTS:- If "audit": scan project for existing Pydantic/Zod schemas, evaluate against SGR patterns
- If task description: design SGR pipeline from scratch
- If empty: ask "What domain/task should the SGR pipeline handle?"
Identify the reasoning cascade — interview the domain:
- What decisions does a human expert make? In what order?
- What information does each step need from previous steps?
- Where does the expert need to "look before deciding"?
- What are the possible actions at the end?
This is the critical step. SGR quality = how well you translate the expert's mental checklist.
Design the schema following SGR patterns:
The NextStep Pattern (agent loop)
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" )The Analysis Cascade Pattern (single-shot)
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 decidingThe Tool Dispatch Pattern
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):- Cascade order matters — put analysis before decision, evidence before verdict
- Constrain enums —
Literal["pass", "fail"]notstr - Limit lists —
Annotated[list[str], MinLen(1), MaxLen(5)] - Discriminated unions —
tool: Literal["name"]for routing - Verification after decision — add
reasoning_for_XAFTER the enum field, not before - One schema per reasoning path — don't mix analysis and action in one model
- Discount > 50% guard —
Annotated[int, Le(50)]— bake constraints into types
Implement 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 in
schemas/ormodels/directory - Dispatch in
dispatch.pyor equivalent - Tests: validate schema parsing, test each tool independently
- Document the reasoning cascade in a comment or docstring
- Schemas in
- Audit mode (if
$ARGUMENTS= "audit"):- Find all Pydantic BaseModel / Zod z.object in project
- Check: do schemas follow cascade order? Are enums constrained? Are unions discriminated?
- Report: which schemas are SGR-compliant, which need fixes
Output
## 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 testsKey References
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 internals
Libraries & Implementations
Rust
- sgr-agent (crate, v0.6.1) — SGR LLM client + agent framework: structured output, function calling, agent loop, 3 agent variants. Core crate for all Rust SGR agents. Part of rust-code
- openai-oxide — typed Rust client for OpenAI API (SGR at compile time via strong types)
In Rust, SGR is even stronger: #[serde(tag = "tool")] gives discriminated union dispatch at zero runtime cost. Enum variants = tools, serde deserialization = constrained decoding.
Python
- sgr-agent-core (1K+ stars) — SGR agentic system design framework by neuraldeep community. Reference Python implementation
- Abdullin's demo in
references/sgr-demo.py— minimal standalone example (304 lines, CRM agent)
Common Issues
Schema too flat
Cause: Tried to put everything in one model. Fix: Split into analysis model + action model. Cascade, don't flatten.
LLM ignores enum constraints
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.
Agent loops forever
Cause: No task_completed gate or ReportCompletion tool.
Fix: Always include a completion signal in the Union. Cap loop iterations.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

