guidance

Constrain LLM outputs with regex and grammar constraints for structured JSON/XML generation.

1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/cryptopafi/nexusos-skills --skill guidance-cryptopafi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/cryptopafi/nexusos-skills/tree/main/mlops/inference/guidance
Command: npx skills add https://github.com/cryptopafi/nexusos-skills --skill guidance-cryptopafi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance helps developers ensure that language model outputs adhere to strict formats and schemas by applying regex and grammar constraints, reducing invalid responses and post-editing overhead.

Core Features & Use Cases

  • Regex and grammar constraints enforce structured outputs (JSON/XML) and valid code or data formats.
  • Token healing and validation minimize spacing issues and reduce retries for correct token boundaries.
  • Multi-step workflows enable Pythonic orchestration of complex generation tasks, decisions, and tool use.

Quick Start

Create a constrained generation workflow that returns a validated JSON object from a user 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 ensure valid JSON generation?

You can constrain LLM outputs to ensure valid JSON generation by applying regex and grammar constraints. This enforces structured formats, reducing invalid responses and post-editing overhead.

Can I use grammar constraints with API backends or only local transformers?

Grammar constraints can be applied across both local transformers and API backends. This allows you to enforce structured data formats and validation regardless of your chosen generation environment.

How do I orchestrate multi-step workflows for complex generation tasks?

You can orchestrate multi-step workflows for complex generation tasks using Pythonic logic. This enables you to sequence decisions, tool use, and structured content generation within a single workflow.

What is token healing and how does it minimize spacing issues?

Token healing is a technique used during constrained generation to minimize spacing issues and correct token boundaries. It reduces the need for retries by ensuring accurate token formatting.

Do I need the Guidance library to enforce XML schemas in LLM responses?

Yes, you need the Guidance library to enforce XML schemas in LLM responses. It provides the necessary regex and grammar constraints to validate structured outputs and ensure format compliance.