guidance

Control LLM outputs with regex and grammars for structured JSON, XML, and code generation.

539|39|Updated May 1, 2026
One-click install
npx skills add https://github.com/Tommy-yw/RunbookHermes --skill guidance-tommy-yw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/Tommy-yw/RunbookHermes/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/Tommy-yw/RunbookHermes --skill guidance-tommy-yw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires guidance, transformers, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill allows users to control LLM output using regex and grammars, ensuring valid JSON/XML/code generation, enforcing structured formats, and building multi-step workflows.

Core Features & Use Cases

  • Regex Constraints: Control LLM output syntax with regex or grammars.
  • Valid JSON/XML/Code Generation: Guarantee valid JSON/XML/code generation.
  • Structured Formats: Enforce structured formats like dates, emails, IDs, etc.
  • Multi-Step Workflows: Build multi-step workflows with Pythonic control flow.
  • Use Case: Generate a structured JSON object with a person's name, age, and email, ensuring valid formatting.

Quick Start

Generate a person object with the given name, age, and email: generate_person("John Doe", 30, "[email protected]").

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce valid JSON generation from an LLM?

You can enforce valid JSON generation by applying regex constraints and grammars to control the LLM output syntax. This approach guarantees the model generates structured data that strictly adheres to your required JSON format.

What is the best way to constrain LLM output to specific formats like dates and emails?

The best way to constrain LLM output to specific formats like dates and emails is by enforcing structured formats through grammars. This restricts the language model to generate only valid syntax matching your defined patterns.

Do I need the transformers library to control LLM output with grammars?

Yes, you need both the transformers and guidance libraries to control LLM output with grammars. These dependencies provide the required environment for executing structured formats and multi-step workflows with Pythonic control flow.

Can I build multi-step workflows for code generation using regex constraints?

Yes, you can build multi-step workflows for code generation using regex constraints and Pythonic control flow. This allows you to guarantee valid code generation while orchestrating complex, structured generation sequences across multiple steps.

Why does my LLM generate invalid XML and how can I prevent it?

LLMs generate invalid XML due to unconstrained token prediction; you can prevent this by enforcing structured formats with grammars. This ensures valid XML generation by strictly controlling the output syntax during the generation process.