guidance

Generate structured text from LLMs using regex and grammar constraints in Python.

Updated Mar 13, 2026
One-click install
npx skills add https://github.com/hochoa13/Asistente-Harlest --skill guidance-hochoa13
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/hochoa13/Asistente-Harlest/tree/main/skills/mlops/inference/guidance
Command: npx skills add https://github.com/hochoa13/Asistente-Harlest --skill guidance-hochoa13

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill allows you to precisely control and structure the output of Large Language Models (LLMs), ensuring generated text adheres to specific formats, grammars, or selections, thereby reducing errors and improving reliability.

Core Features & Use Cases

  • Constrained Generation: Guarantee valid JSON, XML, or code by enforcing regex or grammar rules.
  • Structured Output: Enforce specific formats for dates, emails, phone numbers, and more.
  • Multi-Step Workflows: Build complex conversational agents and automated processes with Pythonic control flow.
  • Use Case: Generate a JSON object representing a user profile, ensuring the email address is valid and the age is a number, preventing downstream errors in your application.

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 constrain LLM output to generate valid JSON?

To constrain LLM output and generate valid JSON, you can enforce specific grammar rules or regex patterns during text generation. This ensures the model produces deterministic, structured data, preventing formatting errors in downstream applications.

What is constrained generation in large language models?

Constrained generation is a technique that forces large language models to adhere to specific formats, grammars, or selections. It solves the problem of unpredictable outputs by ensuring generated text reliably matches defined structural rules.

Can I enforce regex patterns for structured LLM output?

Yes, you can enforce regex patterns to achieve structured LLM output. This allows you to validate specific formats like dates, emails, and phone numbers directly during generation, guaranteeing the text matches your exact constraints.

How do I build multi-step workflows with Pythonic control flow for LLMs?

You can build multi-step workflows with Pythonic control flow by applying constrained generation techniques to large language models. This enables the creation of complex conversational agents and automated processes with deterministic outputs.

Does constrained generation work with custom grammars for LLMs?

Yes, constrained generation works with custom grammars for LLMs. You can apply grammar rules alongside regex and selection constraints to guarantee valid code, XML, or structured data generation.