guidance

Control LLM outputs with regex and grammars for structured JSON and XML formats.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Control LLM outputs with regex and grammars to enforce structured formats and reduce invalid or ambiguous results.

Core Features & Use Cases

  • Constrained generation with regex and grammars to guarantee valid JSON/XML/code formats.
  • Token healing and grammar-based validation to improve correctness and reliability.
  • Multi-step workflows and Pythonic guidance functions to orchestrate complex tasks.

Quick Start

Generate a JSON object with fields name (alphabetic only) and email (valid email format).

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I ensure LLM outputs strictly match a JSON or XML schema?

To ensure LLM outputs match a JSON or XML schema, you apply constrained generation using regex and grammars. This enforces structured formats during decoding, guaranteeing valid syntax and preventing malformed output.

What is constrained generation and how does it work with local models?

Constrained generation controls LLM outputs by applying regex patterns and grammars during token sampling. It works with local models by enforcing token healing and grammar-based validation to improve correctness and reliability.

Can I use regex to validate specific fields like emails in LLM responses?

You can use regex to validate specific fields like emails in LLM responses by applying grammar constraints. This forces the model to generate text matching the regex pattern, ensuring valid email formats and structured output.

How do I orchestrate multi-step prompts with structured outputs?

You orchestrate multi-step prompts with structured outputs by using Pythonic guidance functions. This allows you to build multi-step workflows that apply constraints and grammar-based generation across complex task sequences.

Does constrained generation work for generating code with validation?

Constrained generation works for generating code with validation by applying grammars to enforce syntax rules. Token healing and grammar-based validation improve correctness, making it suitable for reliable code generation and audit trails.

What is token healing and when do I need it for structured output?

Token healing is a technique that fixes boundary token issues during constrained generation. You need it for structured output when applying regex and grammars to prevent tokenization errors and ensure seamless format compliance.