mirascope-and-lilypad-best-practices

mirascope-and-lilypad-best-practices is a cursor rule for Cursor from greyhaven-ai/sygaldry. It costs 8 tokens per session (1,243 once invoked), scanned A, original, MIT.

Coding rules for building Mirascope and Lilypad features, which are tools for creating and observing AI-powered applications.

In plain words
What is it for?
Use them when adding or reviewing prompt templates, AI response models, tool functions, and related application code.
Why use it?
They provide consistent patterns for prompts, structured responses, and tool functions, helping keep AI code easier to validate and maintain.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use them when adding or reviewing prompt templates, AI response models, tool functions, and related application code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/greyhaven-ai/sygaldry

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mirascope-and-lilypad-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices/github.svg)](https://agentmods.dev/rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices)
Your own site
<a href="https://agentmods.dev/rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices"><img src="https://agentmods.dev/badge/rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mirascope-and-lilypad-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices"><img src="https://agentmods.dev/badge/rules/greyhaven-ai/sygaldry/mirascope-and-lilypad-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 8 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,243 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00008 $0.01243
Opus 5 $0.00004 $0.00622
Sonnet 5 $0.00002 $0.00249
Haiku 4.5 $0.00001 $0.00124

Measured 13d ago against content hash 5075ba37c1fa, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

mirascope-and-lilypad-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 13d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/mirascope-and-lilypad-best-practices.mdc · 99 lines

How it starts

The opening of the file, as written. The whole thing — 99 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Mirascope and Lilypad Best Practices

This rule outlines best practices for using @Mirascope and @Lilypad in this codebase. Follow these guidelines to ensure maintainable, scalable, and idiomatic LLM-powered features with robust observability.

1. Prompt Templates

  • Always use @prompt_template decorators for prompt construction. Prefer prompt templates over shorthand string or list returns for clarity and reusability.
  • Keep prompt logic modular: define each prompt as a separate function, ideally in a prompts/ module.
  • Type all prompt template arguments for clarity and static analysis.
  • Inject chat history and context using template arguments, not global state.

2. Response Models

  • Define a Pydantic response model for every LLM call. Use the response_model argument in the call decorator (e.g., @llm.call(provider="openai", model="gpt-4o-mini", ..., response_model=MyModel)).
  • Validate and parse LLM outputs using these models to ensure structured, reliable results.
  • Store response models in a dedicated module (e.g., schemas/llm_responses.py).

3. Tools as Functions

  • Write tools as plain functions using Mirascope's functional tool API, not as subclasses of BaseTool unless absolutely necessary.
  • Annotate tool arguments and return types for all tool functions.
  • Register tools using the appropriate Mirascope decorator or registry pattern.
  • Keep tool logic stateless and side-effect free where possible.

4. Parallel and Async Calls

  • Prefer async def for all LLM calls and tool functions to maximize concurrency.
  • Use Mirascope's async and parallel APIs to batch or parallelize LLM/tool calls when possible.
  • Avoid blocking I/O in any LLM, tool, or agent logic.

5. Agent and Call Structure

  • Organize agents, prompts, tools, and calls in separate modules for clarity.
  • Use chaining and composition: build complex agent flows by composing prompt templates, tools, and LLM calls.
  • Document each agent, tool, and prompt with clear docstrings and usage examples.

Read the full file on GitHub · 99 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 13d ago First seen · 99 lines · 8 tokens per session scan A 5075ba37c1fa

Subscribe to this mod's changes

mirascope-and-lilypad-best-practices is a cursor rule published in the GitHub repository greyhaven-ai/sygaldry (11 stars, last pushed 4mo ago), licensed MIT. It adds 8 tokens to every session and 1,243 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.