guidance

Constrain LLM outputs with regex and CFG grammars for structured JSON or XML.

78|16|Updated Apr 23, 2026
One-click install
npx skills add https://github.com/sheawinkler/hermes-agent-ultra --skill guidance-sheawinkler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/sheawinkler/hermes-agent-ultra/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/sheawinkler/hermes-agent-ultra --skill guidance-sheawinkler

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance enables you to control LLM outputs using regex and grammars to guarantee structured outputs, reducing invalid results and post-processing effort.

Core Features & Use Cases

  • Constrained generation with regex and CFG grammars for JSON/XML/text outputs
  • Token healing, multi-step workflows, and safe, local backends
  • Real-world use cases: data extraction, form validation, and automated content generation

Quick Start

Run a constrained generation example: specify a simple pattern and generate a valid JSON object.

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 generate valid JSON and XML?

To constrain LLM outputs to generate valid JSON and XML, you apply regex and context-free grammars during the generation process, which guarantees structured outputs and eliminates invalid formatting. This approach reduces the need for post-processing.

What is constrained generation and how does it enforce structured outputs?

Constrained generation is a workflow that uses regex and grammars to enforce valid structured outputs from large language models. It ensures robust validation and applies token healing to automatically correct partial tokens at generation boundaries.

Can I use grammars and regex for form validation and data extraction?

Yes, you can use grammars and regex for form validation and data extraction by defining a constrained generation workflow. This guarantees that the extracted data strictly matches your required JSON or XML schemas without requiring extensive manual post-processing.

What happens when grammar constraints conflict or inputs are incomplete?

When grammar constraints conflict or inputs are incomplete, the constrained generation workflow applies graceful fallbacks to handle the errors. This ensures the process continues safely without crashing, maintaining robust validation throughout the generation task.

Does constrained generation work with local backends for safe report automation?

Yes, constrained generation works with safe, local backends to securely automate report generation and validate structured outputs. You can define multi-step workflows that apply regex and grammars locally to ensure data privacy and robust validation.

What is the best way to guarantee structured outputs for automated content generation?

The best way to guarantee structured outputs for automated content generation is to implement a constrained generation workflow using regex and CFG grammars. This method enforces valid JSON or XML formats, utilizing token healing and graceful fallbacks for robust results.