guidance

Enforce regex and grammar constraints on LLM outputs for valid JSON and XML.

2|1|Updated Jul 14, 2026
One-click install
npx skills add https://github.com/heysuhas/hermes_cli --skill guidance-heysuhas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/heysuhas/hermes_cli/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/heysuhas/hermes_cli --skill guidance-heysuhas

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This skill solves the challenge of unpredictable LLM outputs by enforcing strict syntax, structure, and format constraints, ensuring that generated content is always valid and usable.

Core Features & Use Cases

  • Constrained Generation: Use regex and context-free grammars to guarantee valid JSON, XML, or code output.
  • Token Healing: Automatically fix unnatural token boundaries to ensure perfect text concatenation.
  • Multi-Step Workflows: Build complex, stateful agentic workflows using Pythonic control flow.
  • Use Case: If you need to generate a JSON object representing a user profile, this skill ensures the output strictly adheres to your schema, preventing common LLM formatting errors.

Quick Start

Use the guidance skill to generate a valid JSON object for a person with name and age fields using the provided grammar constraints.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce strict JSON schema validation on LLM outputs?

To enforce strict JSON schema validation on LLM outputs, apply context-free grammars and regex constraints during generation. This ensures the model produces syntactically valid JSON that perfectly adheres to your defined data structures.

Why does my LLM generate broken JSON when formatting structured data?

Broken JSON often occurs due to unnatural token boundaries during text generation. Applying token healing automatically fixes these boundaries, ensuring perfect text concatenation and preventing common structural formatting errors.

Can I use constrained generation with local and API-based models?

Yes, constrained generation integrates with both local and API-based models to provide deterministic control. This guarantees valid JSON, XML, or domain-specific code output for automated pipelines across different environments.

What is the best way to build stateful agentic workflows with LLMs?

The best way to build stateful agentic workflows is using Pythonic control flow to orchestrate multi-step reasoning. This approach enforces strict structural constraints on outputs, ensuring reliable data extraction.

Does constrained generation work for XML and domain-specific code structures?

Yes, constrained generation works for XML and domain-specific code structures by enforcing strict syntax constraints. Using regex and grammars guarantees the generated output remains valid and usable for automated pipelines.

When do I need grammar constraints for LLM data extraction?

You need grammar constraints for LLM data extraction when automated pipelines require deterministic, perfectly formatted output. This prevents unpredictable formatting errors and guarantees valid structured data.