guidance

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

2|2|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/huidge/hermes-skills --skill guidance-huidge
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/huidge/hermes-skills/tree/main/mlops/inference/guidance
Command: npx skills add https://github.com/huidge/hermes-skills --skill guidance-huidge

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Regex and grammars to control LLM output, guaranteeing structured, valid JSON/XML/code results and reducing invalid generations.

Core Features & Use Cases

  • Regex and CFG-based constrained generation for reliable outputs.
  • Token healing and grammar-driven validation to prevent formatting errors.
  • Multi-step workflows and orchestration for complex prompts across local or cloud backends.

Quick Start

Generate a constrained JSON object for a user profile using Guidance with a JSON grammar.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I constrain LLM output to ensure valid JSON?▼

You can constrain LLM output to ensure valid JSON by applying regex and context-free grammars. This enforces structured generation rules, guaranteeing valid JSON or XML results and preventing formatting errors.

What is constrained generation and how does it work with regex?▼

Constrained generation uses regex and grammar-based validation to control LLM outputs. It restricts the generation process to valid patterns, ensuring structured results and reducing invalid generations across code and data formats.

Can I use grammars to constrain generation across local and API backends?▼

Yes, you can apply grammar-based constrained generation across local and API backends. This allows you to orchestrate multi-step workflows and guarded prompts consistently, regardless of your chosen backend environment.

Does constrained generation work for multi-step workflows and code generation?▼

Yes, constrained generation supports multi-step workflows and code generation by applying grammars to control LLM output. This ensures structured, valid results and orchestrates complex prompts across various backends.

Do I need the Guidance library to prevent LLM formatting errors with token healing?▼

Yes, you need the Guidance library to prevent formatting errors with token healing. It provides grammar-driven validation and guarded prompts to ensure precise, structured outputs and reduce invalid generations.