guidance

Generate valid JSON, XML, and code using regex and grammars.

Updated Jan 12, 2026
One-click install
npx skills add https://github.com/MesferAli/XCircle --skill guidance-mesferali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/MesferAli/XCircle/tree/main/.claude/skills/guidance
Command: npx skills add https://github.com/MesferAli/XCircle --skill guidance-mesferali

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides fine-grained control over Large Language Model (LLM) output, ensuring structured, valid, and predictable generation through constrained text generation.

Core Features & Use Cases

  • Constrained Generation: Guarantee valid JSON, XML, or code by using regex and grammars.
  • Structured Output: Enforce specific formats for dates, emails, IDs, and more.
  • Multi-Step Workflows: Build complex conversational agents and reasoning chains.
  • Use Case: Generate a JSON object representing a user profile, ensuring the email address follows a valid format and the age is a number.

Quick Start

Use the guidance skill to generate a JSON object for a user with a name and email.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I guarantee valid JSON output from an LLM?

To guarantee valid JSON output from an LLM, use constrained generation with grammars to enforce specific formatting and structure. This methodology ensures predictable responses, preventing malformed text generation.

What is constrained LLM generation and how does it work?

Constrained LLM generation is a technique that controls model output using regex and grammars. It works by restricting the generation process to ensure structured data formatting, yielding valid JSON, XML, or code.

Can I use constrained generation with OpenAI, Anthropic, and local models?

Yes, you can apply constrained generation across OpenAI, Anthropic, and local models. It supports backends via Transformers and llama.cpp, ensuring precise control over LLM responses across different environments.

How do I enforce specific formats like emails and dates in LLM responses?

To enforce specific formats like emails and dates in LLM responses, apply prompt engineering with regex patterns. This restricts the output structure, ensuring generated text strictly matches your defined validation rules.

What is the best way to build multi-step conversational agents with LLMs?

The best way to build multi-step conversational agents is by using constrained generation to facilitate reasoning chains. This enforces precise control over LLM responses, enabling complex multi-step workflows with structured outputs.