guidance

Constrain LLM outputs with regex patterns, grammars, and guided workflows.

Updated May 1, 2026
One-click install
npx skills add https://github.com/xiaoquqi/hermes-agent-skills --skill guidance-xiaoquqi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/xiaoquqi/hermes-agent-skills/tree/main/mlops/inference/guidance
Command: npx skills add https://github.com/xiaoquqi/hermes-agent-skills --skill guidance-xiaoquqi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Constraint-heavy generation to produce valid, structured outputs (JSON/XML/code) while minimizing post-processing and retries.

Core Features & Use Cases

  • Regex constraints: enforce formats for dates, emails, IDs, and other fields.
  • Grammar-based generation: generate structured outputs like JSON, XML, or code with correctness guarantees.
  • Token healing: automatically fix token boundaries to prevent spacing issues and improve output quality.
  • Multi-step workflows: Pythonic control flow to orchestrate complex prompting sequences and validations.
  • Structured formats enforcement: ensure outputs adhere to predefined schemas and formats across backends (local or API).
  • Use cases: JSON data extraction, form validation, code and data structure generation, and end-to-end constrained pipelines.

Quick Start

Install Guidance, then define a constrained generation workflow using regex or grammars to produce a guaranteed structured output.

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 formats?

To constrain LLM outputs for valid JSON and XML, apply grammar-based generation and regex patterns to enforce predefined schemas. This guarantees structured output correctness while minimizing post-processing and retries.

What is token healing and how does it fix LLM generation spacing issues?

Token healing is a constrained generation technique that automatically fixes token boundaries to prevent spacing issues. It improves output quality by correcting tokenization artifacts during the LLM generation process.

Can I use regex patterns to enforce structured output formats for data extraction?

Yes, you can apply regex constraints to enforce specific formats for dates, emails, IDs, and other fields during data extraction. This ensures LLM outputs adhere to required formats for form validation tasks.

How do I build multi-step workflows for complex prompting sequences and validations?

Build multi-step workflows using Pythonic control flow to orchestrate complex prompting sequences and validations. This enables end-to-end constrained pipelines for multi-step decision workflows in software engineering.

Does constrained generation work with both local and API backends?

Constrained generation integrates with Guidance backends to enforce structured formats across both local and API environments. This ensures outputs adhere to predefined schemas regardless of the backend used.

How do I stop my LLM from generating invalid JSON structures and code?

To stop invalid JSON and code generation, apply grammar-based constraints that provide correctness guarantees for structured outputs. This prevents malformed generation by enforcing valid syntax during the process.