guidance

Generate LLM outputs constrained by regex and grammar across multiple frameworks and workflows.

Updated Feb 15, 2026
One-click install
npx skills add https://github.com/ricable/mcai --skill guidance-ricable
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/ricable/mcai/tree/main/.agents/skills/guidance
Command: npx skills add https://github.com/ricable/mcai --skill guidance-ricable

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance removes the uncertainty of free-form model prompting by constraining LLM output so it matches the format, schema, or workflow you need. It helps prevent invalid JSON, malformed code, inconsistent classifications, and brittle retry loops.

Core Features & Use Cases

  • Regex and grammar constraints for exact formats such as IDs, emails, dates, JSON, XML, CSV, and code.
  • Workflow orchestration for multi-step reasoning, ReAct-style tool use, extraction pipelines, and agent coordination.
  • Backend flexibility across Anthropic, OpenAI, Transformers, and llama.cpp with token healing and selection controls.
  • Use Case: Build a production parser that extracts entities from text and returns validated structured output without manual post-processing.

Quick Start

Ask Guidance to generate a valid structured response, such as a JSON object or classified label, using constrained generation and the backend of your choice.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I force LLM output to match a specific JSON schema or regex pattern?

Constrained generation applies regex and grammar controls to force valid JSON, XML, CSV, or code from LLMs. This prevents malformed structures and eliminates brittle retry loops by ensuring exact format compliance without manual post-processing.

Why does my LLM generate invalid JSON and how can I fix it?

Invalid JSON occurs during free-form prompting because models lack structural constraints. Applying grammar-based generation forces the LLM to output valid JSON, eliminating parsing errors and removing the need for retry loops or manual extraction.

Does constrained generation work with Anthropic, OpenAI, and local models?

Constrained generation works across Anthropic, OpenAI, Transformers, and llama.cpp backends. It applies token healing and categorical selection controls specific to each backend to maintain format consistency across both API and local model deployments.

What is the best way to build a multi-step agent workflow with validated output?

Workflow orchestration coordinates multi-step reasoning, ReAct-style tool use, and extraction pipelines to build agents. It enforces structured output at each step, ensuring validated data handoffs between tools without intermediate parsing failures.

When do I need token healing for structured output generation?

Token healing is required when applying constrained generation across different LLM backends. It corrects token boundary mismatches to ensure grammar and regex constraints produce exact categorical selections and valid structured output.