guidance

Constrain LLM outputs with regex and grammars for structured JSON or XML.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires guidance, transformers.

What problem does it solve?

LLMs often produce unstructured or invalid outputs; Guidance addresses this by enforcing syntax and structure through regex constraints and context-free grammars, guaranteeing valid JSON/XML/code formats and reliable multi-step workflows.

Core Features & Use Cases

  • Constrained generation using regex and grammars to produce structured, verifiable outputs.
  • Token healing, grammar-based generation, and grammar caching for robust results.
  • Local and API-backed backends for flexible deployments, including multi-step Pythonic workflows.

Quick Start

Use Guidance to generate a JSON payload that strictly matches a schema by applying a grammar constraint to the output.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I constrain LLM outputs to ensure valid JSON generation?

Constrain LLM outputs to produce valid JSON by applying regex constraints and context-free grammars during generation. This enforces deterministic syntax, guaranteeing structured data formats without parsing errors through grammar-based generation.

What is constrained generation and how does token healing work?

Constrained generation restricts LLM outputs to match specific grammars or regex patterns. Token healing fixes boundary artifacts during generation, ensuring outputs strictly adhere to defined context-free grammars and structured syntax constraints.

Can I use regex to validate structured output in multi-step LLM workflows?

Yes, you can use regex to validate structured output in multi-step LLM workflows. Guidance orchestrates Pythonic workflows applying regex constraints and grammar caching across local and cloud environments, ensuring reliable structured format validation.

Do I need the transformers library to apply grammar-based generation?

Yes, the transformers library is required to apply grammar-based generation. Guidance depends on it alongside its own library to enforce context-free grammars and execute constrained generation workflows in local and cloud environments.

Best way to force an LLM to generate XML instead of unstructured text?

The best way to force XML generation instead of unstructured text is enforcing context-free grammars. This applies constrained generation to guarantee valid XML formats, preventing invalid syntax through deterministic grammar-based output control.