guidance

Automates and validates structured model outputs using regex, grammars, and token healing.

2|1|Updated May 10, 2026
One-click install
npx skills add https://github.com/zli5460/hermes-agent-X-Phoenix-Architecture --skill guidance-zli5460
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/zli5460/hermes-agent-X-Phoenix-Architecture/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/zli5460/hermes-agent-X-Phoenix-Architecture --skill guidance-zli5460

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Generating valid, structured, and constrained outputs from language models can be challenging; Guidance provides precise control using regex, grammars, and token healing.

Core Features & Use Cases

  • Constrained Generation: Enforce output formats such as JSON, XML, or code via regex and grammars.
  • Token Healing: Automatically correct token boundaries for natural and seamless text generation.
  • Workflows & Control Flow: Build multi-step prompts with logic, loops, and reusable functions for complex AI orchestration.
  • Use Case: Develop a chatbot that reliably outputs valid JSON for user profiles, ensuring data integrity without manual validation.

Quick Start

Use Guidance to generate a JSON object with specific fields and constraints, such as validating email formats or dates with regex, in a single, structured prompt.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce structured output and validate JSON formats from large language models?

To enforce structured output, you apply regex constraints and grammars to precisely control language model responses, ensuring reliable data formats like JSON or XML without needing manual validation.

What is token healing and how does it fix token boundaries in constrained generation?

Token healing is a mechanism that automatically corrects token boundaries during constrained generation, ensuring natural and seamless text generation without breaking the structural integrity of your specified output format.

How do I build multi-step prompts with logic and loops for complex AI workflows?

You build multi-step AI workflows by using control flow features to orchestrate logic, loops, and reusable functions, allowing you to automate complex agents and validate structured responses step by step.

Can I use this constrained generation approach with OpenAI and local transformer models?

Yes, this approach supports constrained generation across OpenAI and local transformer models, allowing you to apply regex constraints, grammars, and token healing within your existing Python environment.

Why does my language model output invalid JSON even when I provide strict instructions in the prompt?

Models often break format constraints due to tokenization issues; applying rule-based grammars and token healing directly forces valid JSON generation by controlling the decoding process rather than relying on prompt instructions.

What is the best way to automate reliable structured data generation for AI chatbots?

The best way to automate reliable structured data generation is implementing workflow orchestration with regex constraints and grammars, directly validating user profile fields like email formats or dates inside the prompt logic.