guidance

Generate structured JSON or XML outputs using Pythonic syntax, regex, and grammars.

3|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/ihatesea69/HieuNghi-AI-Skills --skill guidance-ihatesea69
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/ihatesea69/HieuNghi-AI-Skills/tree/main/airesearch_skills/16-prompt-engineering/guidance
Command: npx skills add https://github.com/ihatesea69/HieuNghi-AI-Skills --skill guidance-ihatesea69

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill empowers you to precisely control and structure the output of Large Language Models (LLMs), ensuring predictable and valid results for complex tasks.

Core Features & Use Cases

  • Constrained Generation: Guarantee outputs adhere to regex patterns, grammars, or specific selections.
  • Structured Data: Reliably generate valid JSON, XML, or code.
  • Multi-Step Workflows: Build complex agentic behaviors with Pythonic control flow.
  • 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, age, 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 guarantee valid JSON or XML?

You constrain LLM output by applying Pythonic syntax, regex patterns, and grammars directly to the generation process. This guarantees structured outputs like valid JSON or XML by forcing the language model to adhere to specific formatting rules.

Can I use constrained generation with local Transformers models and OpenAI backends?

Constrained generation supports various backends including OpenAI, Anthropic, and local Transformers models. This allows you to apply fine-grained LLM control and structured output enforcement across different model environments.

What is the best way to build multi-step agentic workflows with LLMs?

Building multi-step agentic workflows is best achieved using Pythonic control flow to guide LLM behavior. This approach provides fine-grained control over responses, facilitating complex sequences and structured generation for reliable task execution.

How do I ensure LLM-generated email addresses match a specific regex pattern?

You ensure LLM-generated email addresses match a regex pattern by applying constrained generation rules. Defining the regex within your Pythonic syntax forces the LLM to generate values that strictly adhere to the specified format.

Why does my LLM output fail to follow structured data formats during generation?

LLM output fails to follow structured data formats when generation lacks constraints. Enforcing grammars or regex patterns through Pythonic constraints eliminates formatting errors and guarantees valid structured outputs like JSON.