Guide
Package your
.mg
files as a Python library, install them anywhere with
uv,
and render them directly inside Claude with the Margarita skill — no copy-paste, no stale copies.
You've written great prompt components for one project. The next project needs the same ones. So you copy them. Then they drift. Then you have three subtly different versions of the same tone file — and no idea which is current.
Templates duplicated across repos diverge silently. A fix applied in one project never reaches the others — until a subtle inconsistency surfaces in production output.
A copied file has no version. You can't pin a project to v1.2 of your tone template or
upgrade it deliberately — you just have whatever was current the day you copied it.
Even if your templates are well-organised locally, there's no easy way to ask Claude to render one. You paste the content manually or describe what you want from memory.
.mg files live under a templates/ subdirectory. Add a
pyproject.toml with a package-data entry so the
.mg files are included when the package is built and installed.
The package name on disk is my-writing-templates. The importable Python module is
my_writing_templates (hyphens become underscores). Templates live under
my_writing_templates/templates/.
my-writing-templates/
pyproject.toml
templates/
tone.mg
draft.mg
techniques/
show_dont_tell.mg
The package-data entry is what makes Margarita work — it ensures
.mg files are bundled into the installed package, not just the
.py source.
name = "my-writing-templates"
version = "0.1.0"
"my_writing_templates" = [
"templates/*.mg",
"templates/**/*.mg",
]
A reusable tone component. Pass style at include time and the right
block is selected — one file covers every variation.
# my_writing_templates/templates/tone.mg
if style == "professional":
<< Write in a professional, polished tone. Be direct and precise.
Avoid casual phrasing or filler words. >>
elif style == "friendly":
<< Write in a warm, approachable tone. Use plain language and
make the reader feel at ease. >>
elif style == "concise":
<< Be extremely concise. Lead with the answer. No preamble,
no filler. One sentence where possible. >>
Pulls in tone.mg from the same package and adds a structured drafting
prompt. The include path uses the package name as the namespace.
# my_writing_templates/templates/draft.mg
[[ my-writing-templates/tone
style="${style}" ]]
<<
## Draft
Write ${length} about the following topic:
${topic}
>>
@effect run
uv add. Margarita
scans the project's .venv/ at render time and automatically discovers
any installed packages that expose a templates/ directory — no extra
configuration needed.
# Install from PyPI once the package is published
uv add my-writing-templates
# Pin to a specific version for reproducibility
uv add "my-writing-templates==0.1.0"
# Margarita now resolves this include automatically:
[[ my-writing-templates/tone
style="professional" ]]
# During development, install from a local path
uv add --editable ../my-writing-templates
# Changes to .mg files are picked up immediately —
# no reinstall needed.
# The include works the same way:
[[ my-writing-templates/tone
style="friendly" ]]
.mg template — including ones from
installed packages — without leaving the conversation. Run the install command once per
project, then restart Claude. The skill is registered in your local .claude/
directory and is picked up automatically.
# Run from your project directory
uvx margarita install-claude-skill
# Output:
✓ Skill installed at .claude/skills/margarita.md
✓ Ready — restart Claude Code to activate
# Render a local template
Can you render "templates/greeting.mg"
with {"name": "Alice"}?
# Render a template from an installed package
Can you render "my-writing-templates/tone"
with {"style": "professional"}?
# Ask Claude to create a new template
Create a margarita template for a
product description with name, features,
and a call to action.
if blocks — and returns the final prompt
or output.
Claude resolves the package include, selects the right if block for
style="concise", and returns the rendered text — all without leaving
the chat.
// You type in Claude:
Can you render "my-writing-templates/tone"
with {"style": "concise"}?
// Claude responds:
Rendered output of my-writing-templates/tone
─────────────────────────────────────────────
Be extremely concise. Lead with the answer.
No preamble, no filler.
One sentence where possible. ◄ "concise" block selected
draft.mg includes tone.mg from the same package.
Claude resolves the entire tree and returns the assembled prompt, then runs it.
// You type in Claude:
Can you render "my-writing-templates/draft" with:
{
"topic": "why shorter prompts get better results",
"style": "friendly",
"length": "one paragraph"
}
// Claude assembles and runs the template:
## Assembled prompt
Write in a warm, approachable tone. Use plain ◄ from tone.mg
language and make the reader feel at ease.
## Draft
Write one paragraph about the following topic:
why shorter prompts get better results
// Then Claude runs the prompt and returns the draft.
You don't have to author .mg files by hand. Describe what you need
and Claude writes a ready-to-save template that follows Margarita conventions.
// You type in Claude:
Create a margarita template for a product
description. I want it to include the product
name, a list of features, and a call to action.
// Claude responds:
// file: product_description.mg
<<
# ${product_name}
${product_name} gives you:
for feature in features:
- ${feature}
${call_to_action}
>>
@effect run
Templates live in one place and are versioned like any other dependency.
Every project that runs uv add my-writing-templates gets the same
source of truth — no drift, no stale copies.
Margarita discovers installed packages automatically by scanning the project's
.venv/. There's nothing to register or configure — install the package
and the includes just work.
The Margarita skill turns Claude into a first-class template environment. Render,
compose, and author .mg files in plain conversation — no terminal
required for day-to-day use.
Package your best prompt components once and install them everywhere — then let Claude render them for you.