guidance

Constrain LLM outputs with regex and grammar rules for JSON, XML, and code.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This capability enables developers to guarantee that LLM outputs adhere to predefined formats by applying regex and grammar constraints, ensuring data integrity and predictable results across downstream systems.

Core Features & Use Cases

  • Constraint-based generation: enforce JSON/XML/code structures and valid tokens via grammar rules.
  • Token healing and deterministic workflows: reduce nonsensical outputs and enable multi-step planning with Python-guided pipelines.
  • Backend-agnostic orchestration: configure local transformers or hosted models (OpenAI/Anthropic) with consistent output formats.

Quick Start

Generate a validated JSON object from a natural-language description.

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 generate valid JSON or XML?

You can constrain LLM outputs to valid JSON or XML by applying grammar and regex constraints during generation. This enforces syntax and structure, ensuring data integrity and predictable results for downstream systems.

What is constrained generation and when do I need it for structured outputs?

Constrained generation restricts LLM outputs to predefined formats using grammar rules and regex constraints. You need it when downstream systems require guaranteed syntax validity, such as generating structured JSON, XML, or code.

Does constrained generation work with both local transformers and hosted models like OpenAI?

Yes, constrained generation works across local transformers and hosted backends like OpenAI and Anthropic. It provides backend-agnostic orchestration so you can configure models while maintaining consistent output formats.

How do I use regex and grammar constraints to enforce syntax in LLM generation?

You enforce syntax in LLM generation by defining regex and context-free grammar constraints within a Python API. These rules restrict token selection during inference, ensuring the output matches your specified structure.

What is token healing and how does it reduce nonsensical LLM outputs?

Token healing is a technique that fixes tokenization boundary issues during constrained generation. It reduces nonsensical outputs by correcting token mismatches, enabling deterministic workflows and more reliable multi-step planning.

What are the limitations of using grammar constraints for multi-step LLM workflows?

Grammar constraints for multi-step workflows require defining explicit Python-guided pipelines and CFG support. Limitations include the complexity of authoring strict grammar rules and dependency on backend support for constrained token generation.