guidance-grammars

Apply Guidance grammar primitives to produce structured, template-bound LLM outputs.

6|1|Updated Nov 29, 2025
One-click install
npx skills add https://github.com/manutej/categorical-meta-prompting --skill guidance-grammars
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance-grammars
Source: https://github.com/manutej/categorical-meta-prompting/tree/main/.claude/skills/guidance-grammars
Command: npx skills add https://github.com/manutej/categorical-meta-prompting --skill guidance-grammars

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a framework for grammar-constrained generation using Guidance to produce structured, template-bound outputs from language models, reducing drift and ensuring format compliance.

Core Features & Use Cases

  • Grammar-based generation: apply formal grammars to control text structure and allowed tokens.
  • Composition and interleaving: build multi-step prompts with deterministic composition and captured variables.
  • Type-safe templates: create templates with bound captures that map to structured data or schemas.
  • Use cases: generate standardized reports, code templates, or constrained QA pairs with predictable formats.

Quick Start

Install Guidance, define a simple grammar, and run a constrained generation task to produce a templated output.

Frequently Asked Questions about guidance-grammars

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

FAQPage Schema
How do I enforce structured output from an LLM using grammar constraints?

You constrain LLM generation by applying formal grammar primitives to control allowed tokens and text structure, ensuring predictable template-bound responses. This method uses the Guidance library to reduce drift and guarantee format compliance for structured prompts.

What is the best way to generate type-safe prompts for data extraction?

Using grammar-guided templates with bound captures that map to structured schemas is the best way to generate type-safe prompts. This technique ensures deterministic composition and predictable format compliance for data extraction tasks.

How do I build multi-step LLM prompts with interleaved computation?

You build multi-step LLM prompts by composing grammar primitives that interleave deterministic computation with captured variables. This framework enables structured, step-by-step template generation while maintaining strict format compliance across all stages.

Do I need the Guidance library and Python runtime for constrained text generation?

Yes, you need the Guidance library and a Python runtime to define grammars, execute guided generation, and access grammar primitives. These dependencies are required to produce the constrained, template-bound outputs from language models.

Why does my LLM output drift from the required template format during generation?

LLM output drifts from required template formats when generation is unconstrained. Applying formal grammar constraints restricts allowed tokens and binds outputs to templates, directly reducing drift and ensuring strict format compliance.