guidance

Generate structured LLM output using regex and grammatical constraints.

2|Updated Jun 8, 2026
One-click install
npx skills add https://github.com/vikrant-project/devil-agent-ai-platform --skill guidance-vikrant-project
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/vikrant-project/devil-agent-ai-platform/tree/main/agent_core/optional-skills/mlops/guidance
Command: npx skills add https://github.com/vikrant-project/devil-agent-ai-platform --skill guidance-vikrant-project

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires guidance, transformers, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill allows you to control LLM output with regex and grammars, ensuring valid JSON/XML/code generation, enforcing structured formats, and building multi-step workflows.

Core Features & Use Cases

  • Regex Constraints: Control LLM output syntax with regex or grammars.
  • Structured Output: Generate valid JSON/XML/code and enforce structured formats like dates, emails, and IDs.
  • Multi-Step Workflows: Build multi-step workflows with Pythonic control flow and grammatical constraints.
  • Use Case: Imagine you need to generate a JSON object with a structured name, age, and email. Use this Skill to create a Python function that guides the LLM to generate the desired output.

Quick Start

Use the guidance skill to generate a person object with the name "John Doe" and age "30".

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I ensure valid JSON generation from an LLM?

You can enforce valid JSON generation by applying regex constraints and grammatical rules to control LLM output. This forces the language model to produce structured formats, preventing syntax errors during automated data extraction.

What is the best way to control LLM output syntax for structured data extraction?

The best way to control LLM output syntax is using grammatical constraints and regex patterns. This ensures the generated text strictly matches required formats like dates, emails, and IDs for reliable structured data extraction.

Can I build multi-step workflows with Pythonic control flow for LLM generation?

Yes, you can build multi-step workflows combining Pythonic control flow with grammatical constraints. This allows you to guide the LLM through sequential generation steps, ensuring structured outputs at each stage of the process.

Does this approach require the Guidance library and transformers for regex constraints?

Yes, applying regex constraints and grammatical generation requires the Guidance library and the transformers package. These dependencies provide the necessary environment to control LLM output and enforce structured formats.

How do I enforce structured formats like XML and code during automated code generation?

You enforce structured formats like XML and code by applying grammatical constraints to the LLM. This restricts the generation to valid syntax, ensuring the automated code generation produces executable and parseable outputs.

Why does my LLM output fail validation when generating structured objects?

LLM output fails validation when generated without grammatical constraints, allowing syntax errors in structured objects. Applying regex constraints forces the model to generate valid formats, resolving validation failures.