guidance

Constrain LLM outputs with regex and grammars for valid JSON, XML, and code.

Updated Jun 17, 2026
One-click install
npx skills add https://github.com/anilcan-kara/nozich-agent --skill guidance-anilcan-kara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/anilcan-kara/nozich-agent/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/anilcan-kara/nozich-agent --skill guidance-anilcan-kara

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Constrains LLM outputs to follow strict formats (regex, grammars) and standardizes multi-step workflows, reducing invalid results and accelerating reliable deployments.

Core Features & Use Cases

  • Constrained generation: Enforce JSON/XML/code structures, validation, and schema adherence.
  • Structured workflows: Build multi-step prompts and Pythonic control flow to orchestrate tasks.
  • Local model support: Works with local or API-backed backends, enabling privacy and cost control.

Quick Start

Generate a fixed-structure JSON object that includes a name, age, and email with strict formatting and validation.

Frequently Asked Questions about guidance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I constrain LLM outputs to guarantee valid JSON?

You can constrain LLM outputs to guarantee valid JSON by applying regex and grammar rules during generation. This enforces strict schema adherence and validation, ensuring the model only produces syntactically correct structured data.

What is constrained generation and when do I need it for structured outputs?

Constrained generation restricts LLM outputs to specific formats like JSON, XML, or code using grammars. You need it when validating multi-step workflows or data extraction tasks where invalid formatting would break downstream automation.

Can I use grammar-based generation with local LLM deployments?

Yes, grammar-based constrained generation works with both local and API-backed LLM deployments. This allows you to maintain privacy and control costs while enforcing strict output formatting through compiled grammars and token healing.

How do I build multi-step LLM workflows with Pythonic control flow?

You can build multi-step LLM workflows with Pythonic control flow by orchestrating sequential prompts and applying grammar constraints at each stage. This standardizes the workflow and delivers dependable, repeatable results across tasks.

Does regex validation work for XML and code generation as well as JSON?

Yes, regex validation and grammar compilation enforce valid structures for XML and code generation just as they do for JSON. This guarantees schema adherence and format compliance across multiple structured output types.

Why are my LLM data extraction results returning invalid formats?

LLM data extraction returns invalid formats when outputs are unconstrained. Applying regex and grammar rules during generation enforces strict schema validation, eliminating formatting errors and guaranteeing valid structured results.