guidance

Constrain LLM outputs with regex and grammars for valid structured data.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance enables precise control over LLM outputs by applying regex constraints and grammars, ensuring valid structured data and repeatable results across tasks.

Core Features & Use Cases

  • Constrained generation with regex and grammars to guarantee JSON/XML/code validity.
  • Token healing, multi-step workflows, and Pythonic composition for complex tasks.
  • Use cases include generating JSON documents, extracting structured data, and building constrained agents or pipelines.

Quick Start

Create a constrained JSON object with a name and age validated by regex.

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 constraints and grammars. This ensures deterministic structured data generation, preventing formatting errors and invalid syntax in the output.

What is token healing and how does it fix constrained generation?

Token healing is a feature that fixes tokenization boundary issues during constrained generation. It automatically adjusts token boundaries to ensure regex and grammar constraints apply smoothly without breaking the intended text structure.

Can I use constrained generation with local and API LLM backends?

Yes, constrained generation works across both local and API LLM backends. The underlying library loads constraints and grammars from references, enabling deterministic structured data generation regardless of the backend environment.

What's the best way to extract structured data from unstructured text using grammars?

The best way to extract structured data is by defining grammars or regex patterns to constrain the LLM output. This approach guarantees valid structured formats like JSON or XML directly from unstructured text inputs.

Does constrained generation work for multi-step workflows and pipelines?

Yes, constrained generation supports multi-step workflows and pipelines through Pythonic composition. You can chain multiple constrained generation steps together to build complex agents or data processing pipelines.