guidance

Enforce structured output formats and validation constraints on language model generation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps prevent unreliable language model outputs by enforcing formats, validating generated structures, and controlling token generation through constraints.

Core Features & Use Cases

  • Constrained Generation: Apply regex, grammar, and selection constraints to produce valid JSON, XML, code, and other structured formats.
  • Workflow Control: Build multi-step LLM workflows, agents, and extraction pipelines with Pythonic generation patterns and backend support.
  • Use Case: Use this Skill when building an AI application that must reliably generate schema-compliant data, validated API responses, or structured content without repeated correction loops.

Quick Start

Use the guidance skill to create a constrained generation workflow that produces valid JSON output from a language model.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I force an LLM to generate valid JSON output instead of unstructured text?

Constrained generation enforces regex constraints and grammar-based rules during token generation, forcing the LLM to output valid JSON. This guarantees schema-compliant structured data without requiring repeated correction loops.

What is grammar-based generation and how does it control LLM outputs?

Grammar-based generation restricts language model token selection by applying formal grammar rules and selection constraints during decoding. This mechanism guarantees the output strictly conforms to specified structured formats like JSON or XML.

Can I use regex constraints to validate structured data extraction from LLMs?

Yes, regex constraints can validate structured data extraction by enforcing specific pattern rules during LLM generation. This prevents unreliable outputs by ensuring tokens strictly match required formats before generation completes.

How do I build reliable multi-step agent workflows with LLMs?

Build reliable multi-step agent workflows by applying Pythonic generation patterns and validation constraints across each step. This approach leverages backend integration and token healing to maintain structured output integrity throughout the pipeline.

What is the best way to prevent LLMs from generating invalid API responses?

Prevent invalid API responses by enforcing structured output formats and validation constraints during generation. Applying grammar rules and regex constraints guarantees the LLM produces validated, schema-compliant responses without repeated correction loops.

Why does my language model output invalid JSON during data extraction?

Language models output invalid JSON because token generation is probabilistic and lacks inherent structural validation. Applying grammar-based generation and regex constraints forces the model to only produce tokens that form valid structured data.