guidance

Enforce structured LLM generation using regex and grammar constraints.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires guidance, transformers.

What problem does it solve?

Guidance enables strict control over LLM output using regex and grammars, ensuring consistent structure and preventing malformed generations.

Core Features & Use Cases

  • Constrained generation with regex and grammar constraints for JSON, XML, and code formats.
  • Token healing, grammar-based generation, and multi-step workflows to build robust AI-assisted pipelines.
  • Local-model support and reusable patterns to implement reproducible AI-driven automation.

Quick Start

Generate a constrained JSON payload from a plain-language instruction.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce structured JSON output from an LLM prompt?

By applying regex and grammar constraints to your LLM prompts, you can enforce strict structured generation, guaranteeing that the model produces syntactically valid JSON, XML, or code formats.

What is constrained generation and how does it work with grammars?

Constrained generation restricts LLM token generation using regex and grammar rules, ensuring the output strictly matches required formats like JSON or XML and preventing malformed responses.

Can I use regex to constrain LLM outputs for specific patterns?

Yes, you can apply regex constraints to LLM prompts to enforce strict pattern matching, ensuring the generated output conforms to specific structural formats and preventing malformed responses.

Does constrained generation work with local models and the transformers backend?

Yes, constrained generation works with local models through the Guidance and transformers backends, allowing you to enforce strict structured output formats like JSON and XML on local infrastructure.

What is token healing in structured LLM generation workflows?

Token healing is a technique in constrained generation that automatically repairs token boundary issues during LLM inference, ensuring smooth multi-step workflows and preventing malformed structured outputs.

When should I use grammar-based generation instead of standard prompting?

Use grammar-based generation instead of standard prompting when you need deterministic, strictly formatted outputs such as JSON or XML, preventing malformed generations and ensuring reproducible AI-driven automation.