guidance

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

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/AlexKoncept/omnia-hub --skill guidance-alexkoncept
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/AlexKoncept/omnia-hub/tree/main/HERMES/optional-skills/mlops/guidance
Command: npx skills add https://github.com/AlexKoncept/omnia-hub --skill guidance-alexkoncept

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Constrain LLM outputs with regexes and grammars to guarantee structured, valid results and reduce hallucinations in automated workflows.

Core Features & Use Cases

  • Regex- and grammar-based constraints to enforce JSON, XML, or code formats.
  • Multi-step workflows and Pythonic control flow for complex generation tasks.
  • Token healing and format enforcement to speed up pipelines and ensure reproducibility.
  • Suitable for data pipelines, form processing, documentation generation, and structured data extraction.

Quick Start

Configure Guidance to produce a compliant, structured payload by applying regex and grammar constraints to the prompt.

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 by applying regex and grammar constraints to enforce valid JSON formats. This ensures structured, compliant results and reduces hallucinations in automated data pipelines.

What is grammar-based generation for structured output?

Grammar-based generation restricts LLM token selection to satisfy predefined regex and grammar rules. This mechanism guarantees structured output, preventing invalid formats during multi-step workflows and data extraction.

Can I use regex to enforce structured output in Pythonic workflows?

Yes, you can apply regex constraints within Pythonic control flows to enforce structured output. This allows you to build multi-step workflows that generate reliable, formatted text for automation pipelines.

Does token healing help with format enforcement in LLM pipelines?

Token healing repairs partial tokens at prompt boundaries to enforce strict formatting rules. It speeds up generation pipelines by ensuring reproducible, constrained outputs without requiring multiple sampling attempts.

What is the best way to extract structured data from LLM responses?

The best way to extract structured data is applying grammar-based constraints and regex patterns directly during generation. This guarantees valid JSON or XML payloads for reliable form processing and data extraction.

When should I use constrained generation for LLM workflows?

Use constrained generation when you need guaranteed valid JSON, XML, or code formats from LLMs. It is essential for automated data pipelines, form processing, and documentation generation where invalid outputs break workflows.