guidance

Enforce regex and grammar constraints on LLM text generation.

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

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 output by enforcing strict syntactic and structural constraints, ensuring that generated content is always valid, formatted, and reliable.

Core Features & Use Cases

  • Constrained Generation: Use regex, grammars, and selection lists to force the model to output specific formats like JSON, dates, or code.
  • Token Healing: Automatically fixes token boundary issues to ensure natural text flow and perfect spacing.
  • Multi-Step Workflows: Build complex, stateful agentic workflows with Pythonic control flow and tool integration.

Quick Start

Use the guidance skill to generate a valid JSON object containing a name and age field by applying a regex constraint to the output.

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 output valid JSON?

You can enforce valid JSON generation by applying regex constraints and grammars to the LLM output. This ensures the model produces syntactically correct, machine-readable JSON structures rather than unpredictable free text.

What is constrained generation for large language models?

Constrained generation is the process of enforcing syntactic and structural constraints on LLM text generation. It uses selection logic and grammars to guarantee reliable outputs in specific formats like JSON, XML, or domain-specific code.

Can I build multi-step reasoning workflows with LLM grammars?

Yes, you can build complex multi-step workflows using Pythonic control flow and tool integration. This allows for stateful agentic reasoning while maintaining strict token-level control over the generated output.

Does constrained generation work with remote model backends?

Yes, constrained generation integrates with both local and remote model backends. This provides token-level control and structured multi-step reasoning workflows across different model environments.

Why does my LLM output have spacing and token boundary issues?

Token boundary issues often cause unnatural text flow and bad spacing during generation. Token healing automatically fixes these issues to ensure perfect spacing and natural text continuity in the output.

What's the best way to validate domain-specific code formats from LLMs?

The best way to validate domain-specific code formats is by using grammars and selection lists to force the model into specific output structures. This prevents formatting errors and guarantees reliable, machine-readable outputs.