guidance

Constrain LLM generation to produce valid JSON, XML, and code outputs.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/JKhyro/HERMES-AGENT --skill guidance-jkhyro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/JKhyro/HERMES-AGENT/tree/main/skills/mlops/inference/guidance
Command: npx skills add https://github.com/JKhyro/HERMES-AGENT --skill guidance-jkhyro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance removes the guesswork from LLM output generation by enforcing syntax, structure, and field-level constraints so models produce valid results instead of messy retries and post-processing.

Core Features & Use Cases

  • Regex and grammar constraints for emails, dates, IDs, JSON, XML, and code.
  • Selection and control flow for multi-step workflows, branching logic, and agent-style tool use.
  • Backend flexibility across API models and local runtimes such as Transformers and llama.cpp.
  • Use Case: Turn a free-form prompt into a guaranteed-valid JSON record, a structured extraction pipeline, or a ReAct-style agent loop without fragile validation passes.

Quick Start

Ask Guidance to generate a valid JSON object with constrained fields for a person profile.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I force an LLM to generate valid JSON instead of unstructured text?

Constrained generation forces an LLM to produce valid JSON by applying grammar enforcement and field-level constraints during inference, eliminating the need for post-processing. This guarantees structured outputs match your exact schema.

Can I use regex validation to control specific fields in LLM outputs?

Yes, regex validation enforces token-level pattern constraints on specific LLM output fields like emails, dates, and IDs. This guarantees generated text matches exact format requirements during generation, preventing invalid data.

What is token healing and when do I need it for constrained generation?

Token healing repairs boundary artifacts at prompt endings to ensure smooth transitions into structured outputs. You need it when enforcing grammar or syntax constraints to prevent malformed tokens and maintain generation continuity.

Does constrained generation work with local models like llama.cpp and Transformers?

Constrained generation works with local runtimes like Transformers and llama.cpp and API models. This backend flexibility ensures deterministic format control and grammar enforcement across different deployment environments without changing your workflow.

How do I build a multi-step agent workflow with selection-driven branching?

Build multi-step agent workflows by applying selection and control flow constraints to drive branching logic and tool use. This ensures models follow deterministic paths and execute ReAct-style loops reliably within enforced grammatical structures.

What is the best way to guarantee valid XML and code generation from LLMs?

The best way to guarantee valid XML and code generation is by applying grammar enforcement constraints during inference. This directly controls output structure and ensures syntax compliance for complex formats without relying on fragile validation passes.