guidance

Constrain LLM outputs with regex and grammar-based generation.

228|35|Updated Mar 9, 2026
One-click install
npx skills add https://github.com/kaminocorp/hermes-alpha --skill guidance-kaminocorp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/kaminocorp/hermes-alpha/tree/main/hermes-agent/skills/mlops/inference/guidance
Command: npx skills add https://github.com/kaminocorp/hermes-alpha --skill guidance-kaminocorp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance offers constraint-based generation to ensure predictable, structure-compliant outputs from LLMs by applying regex and CFG grammars to JSON, XML, and code generation tasks, reducing post-editing and validation effort.

Core Features & Use Cases

  • Regex-based constraints for validating outputs (e.g., emails, dates, IDs) to guarantee correct formatting.
  • Grammar-based generation using context-free grammars to produce complex structured data (JSON, XML, code).
  • Token healing to preserve natural token boundaries and minimize rewrites across generations.
  • Multi-step workflows and reusable patterns to orchestrate end-to-end prompt pipelines.
  • Use Cases: automated data extraction, schema-constrained content generation, and production-grade structured outputs.

Quick Start

Provide a short prompt that generates a valid JSON object using a simple grammar constraint.

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?

You constrain LLM outputs for valid JSON by applying context-free grammars during generation. This enforces schema rules directly in the decoding process, ensuring predictable, structure-compliant outputs and eliminating post-generation validation.

What is constrained generation and when do I need it for data extraction?

Constrained generation controls LLM outputs using regex and grammars to guarantee correct formatting. You need it for data extraction when outputs must strictly match schemas, valid JSON, or XML formats without requiring manual post-editing or validation.

Can I use regex patterns to validate structured outputs like emails and dates?

Yes, regex constraints validate structured outputs like emails, dates, and IDs during generation. This guarantees correct formatting by restricting the LLM to only produce tokens matching the specified regex pattern.

Do I need Python to use grammar-based generation for prompt engineering?

Yes, grammar-based generation requires Python and the Guidance library. This setup enables context-managed generation, token healing, and grammar compilation caching to orchestrate end-to-end prompt pipelines.

How do I build multi-step workflows for structured output generation?

Build multi-step workflows for structured output using reusable guidance functions and patterns. This orchestrates end-to-end prompt pipelines, combining regex constraints and grammars for production-grade data extraction and schema-constrained content generation.

Why does token healing matter when generating structured data with LLMs?

Token healing matters because it preserves natural token boundaries and minimizes rewrites across generations. This prevents boundary artifacts when applying grammar constraints, maintaining structured data integrity during automated extraction.