guidance

Constrain LLM outputs with regex and grammars for valid JSON, XML, and code.

Updated Mar 24, 2026
One-click install
npx skills add https://github.com/1thirteeng3/greenmoire --skill guidance-1thirteeng3
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/1thirteeng3/greenmoire/tree/main/integrations/hermes-agent/skills/mlops/inference/guidance
Command: npx skills add https://github.com/1thirteeng3/greenmoire --skill guidance-1thirteeng3

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance enables precise control over LLM outputs using regex and grammars to guarantee structured results across JSON, XML, and code, while enabling reproducible, multi-step workflows.

Core Features & Use Cases

  • Regex and grammar constraints to enforce output formats and reduce invalid results
  • JSON/XML/code validation and structured formatting for reliable data interchange
  • Multi-step, Pythonic workflows and token healing to manage complex tasks end-to-end

Quick Start

Run a simple constrained generation task to produce a valid JSON object from a natural language prompt.

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 guarantee valid JSON?

To constrain LLM outputs and guarantee valid JSON, you apply regex and grammar constraints during generation, forcing the model to produce syntactically correct structured data while reducing invalid results.

What is grammar-based generation and how does it control language models?

Grammar-based generation controls language models by defining strict structural rules that the output must follow, ensuring that generated text conforms to specified formats like JSON or XML rather than relying on post-hoc validation.

Can I use regex to enforce structured formats for LLM data extraction?

Yes, you can use regex to enforce structured formats for LLM data extraction, applying pattern constraints directly during generation to ensure outputs match exact specifications for reliable data interchange.

What's the best way to build multi-step workflows for constrained generation?

The best way to build multi-step workflows for constrained generation is using Pythonic orchestration to chain generation steps, applying token healing to manage complex tasks end-to-end across different backends.

Does constrained generation work across different LLM backends?

Constrained generation works across different LLM backends by applying Pythonic orchestration and grammar-based rules, allowing you to maintain consistent structured outputs regardless of the underlying model provider.

Why do I need token healing when validating structured LLM outputs?

You need token healing when validating structured LLM outputs because it repairs token boundaries during generation, preventing partial tokens from corrupting regex and grammar constraints in multi-step workflows.