guidance

Constrain LLM outputs with regex and grammar constraints.

Updated Mar 16, 2026
One-click install
npx skills add https://github.com/arsity/scholar-tools --skill guidance-arsity
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/arsity/scholar-tools/tree/main/vendor/ai-research-skills/16-prompt-engineering/guidance
Command: npx skills add https://github.com/arsity/scholar-tools --skill guidance-arsity

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance enables deterministic LLM generation by enforcing regex and CFG-based constraints, reducing invalid or non-compliant outputs and minimizing post-processing.

Core Features & Use Cases

  • Regex-based constraints ensure formats like emails, URLs, dates, and IDs are valid in outputs.
  • Grammar-based generation provides structured outputs such as JSON, XML, or DSLs with guaranteed structure.
  • Multi-step workflows, token healing, and reusable guidance functions support robust pipelines and local-model workflows.

Quick Start

Constrain a JSON object to a predefined schema using regex and grammar constraints with Guidance.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I constrain LLM output to a specific JSON schema using regex?

Grammar-based generation enforces structured formats like JSON or XML by constraining the LLM during generation, ensuring valid syntax and reducing invalid outputs.

How do I force an LLM to generate valid structured output like JSON or XML?

Grammar-based generation enforces structured formats like JSON or XML by constraining the LLM during generation, ensuring valid syntax and reducing invalid outputs.

Can I use grammar constraints with both local and API-backed LLMs?

Token healing fixes tokenization artifacts at the boundaries of constrained text, ensuring regex patterns and grammar rules apply smoothly without breaking token boundaries during generation.

What is token healing and how does it improve constrained generation?

Token healing fixes tokenization artifacts at the boundaries of constrained text, ensuring regex patterns and grammar rules apply smoothly without breaking token boundaries during generation.

Does constrained generation eliminate the need for output post-processing?

Yes, by enforcing regex and context-free grammar constraints during generation, invalid or non-compliant outputs are minimized, effectively reducing or eliminating post-processing steps.