prompt-engineering-guidance
Control LLM output with regex and grammars, guarantee valid JSON/XML/code generation, enforce structured formats, and build multi-step workflows with Guidance - Microsoft Research's constrained generation framework
Target: Learning & research. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original English text
Topics in the source
- Guidance: Constrained LLM Generation
- When to Use This Skill
- Installation
- Quick Start
- Basic Example: Structured Generation
- With Anthropic Claude
- Core Concepts
- 1. Context Managers
Use Guidance when you need to: Control LLM output syntax with regex or grammars Guarantee valid JSON/XML/code generation Reduce latency vs traditional prompting approaches Enforce structured formats (dates, emails, IDs, etc.) Build multi-step workflows with Pythonic control flow Prevent invalid outputs through grammatical constraints GitHub Stars: 18,000+ | From: Microsoft Research Guidance uses Pythonic context managers for chat-style interactions. Benefits: Natural chat flow Clear role separation Easy to read and maintain Guidance ensures outputs match specified patterns using regex or grammars. How it works: Regex converted to grammar at token level Invalid tokens filtered during generation Model can only produce matching outputs Guidance automatically "heals" token boundaries between prompt and generation. Problem: Tokenization creates unnatural boundaries. Solution: Guidance backs up one token and regenerates. Benefits: Natural text boundaries No awkward spacing issues Better model performance (sees natural token sequences) Define complex structures using context-free grammars. Use cases: Complex structured outputs Nested data structures Programming language syntax Domain-spec
This is an excerpt. Refer to the complete source and its current requirements.
- Source repository
- davila7/claude-code-templates
- Source file
- cli-tool/components/skills/ai-research/prompt-engineering-guidance/SKILL.md
- Fixed revision
- 21be197f100a12b8d0dd9a211cc244c8179f84d3
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: davila7/claude-code-templates · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:43.369Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.