guidance

Constrain LLM output with regex and grammars for valid JSON, XML, and code.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/choice5346/BiSHE --skill guidance-choice5346
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/choice5346/BiSHE/tree/main/.github/skills/guidance
Command: npx skills add https://github.com/choice5346/BiSHE --skill guidance-choice5346

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 responses through constrained generation techniques.

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 all fields (name, age, email) adhere to strict formats, preventing errors in downstream processing.

Quick Start

Use the guidance skill to generate a valid JSON object for a user profile.

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 regex and grammars to enforce specific formats. This ensures structured, predictable responses and prevents errors in downstream processing without relying on traditional prompting.

What is constrained generation for large language models?

Constrained generation is a technique that provides fine-grained control over LLM output by using regex and grammars. It enforces structured formats for dates, emails, and IDs, ensuring responses are valid and predictable.

Does constrained generation work with Anthropic and OpenAI models?

Constrained generation supports various backends including OpenAI, Anthropic, and local models via Transformers and llama.cpp. This allows you to enforce structured formats across different platforms and environments.

How do I build multi-step workflows with structured LLM output?

Build multi-step workflows with structured LLM output by using grammars to enforce specific formats at each step. This facilitates creating complex conversational agents and reasoning chains while reducing latency compared to traditional prompting.

What is the best way to enforce specific formats like XML from an LLM?

The best way to enforce specific formats like XML from an LLM is using constrained generation techniques with regex and grammars. This guarantees valid, structured output and reduces latency compared to traditional prompting methods.