guidance

Constrain LLM outputs to JSON, XML, and code formats with grammar-based generation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Guidance helps developers and teams control LLM outputs by enforcing regex and grammar constraints, ensuring consistent, valid structured data.

Core Features & Use Cases

  • Regex and grammar-based constrained generation to produce valid JSON, XML, and code outputs.
  • Token healing, multi-step workflows, and Pythonic guidance functions to orchestrate reliable prompts and responses.
  • Local-model support (Transformers, llama.cpp) for privacy-preserving, offline development and testing.

Quick Start

Set up a constrained generation workflow using Guidance to produce structured JSON/XML outputs.

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

You can constrain LLM outputs to valid JSON by applying regex and grammar-based constraints during generation. This enforces strict structured data formats and includes token healing to prevent invalid syntax across multi-step workflows.

What is grammar-based constrained generation for large language models?

Grammar-based constrained generation restricts LLM token sampling to specific structures like JSON, XML, or code. It uses Pythonic guidance functions and regex constraints to ensure outputs strictly adhere to required formats and validation rules.

Can I use constrained generation with local models like Transformers or llama.cpp?

Yes, constrained generation works with local model backends like Transformers and llama.cpp. This enables privacy-preserving, offline development and testing while applying grammar-based generation and strict output validation.

How do I enforce regex constraints across multi-step LLM workflows?

You can enforce regex constraints across multi-step workflows using Pythonic guidance functions. This orchestrates reliable prompts and responses while maintaining strict format validation throughout the generation sequence.

What's the best way to validate structured LLM outputs without external parsers?

The best way to validate structured outputs without external parsers is using grammar-based generation with token healing. This natively restricts LLM outputs to JSON, XML, or code formats during inference, eliminating the need for post-generation validation.

Does constrained generation work with ReAct-style tooling on cloud and local models?

Yes, constrained generation supports ReAct-style tooling on both cloud and local models. It integrates regex and grammar constraints with Pythonic guidance functions to orchestrate reliable multi-step tool usage and structured responses.