Guide

Share Templates
Across Projects

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.

Template Package + uv + Claude Skill
The Problem

Templates trapped in one project

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.

🔄

Copy-paste drift

Templates duplicated across repos diverge silently. A fix applied in one project never reaches the others — until a subtle inconsistency surfaces in production output.

📄

No versioning

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.

🚫

Can't use them in Claude

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.

The Solution

Package once, use everywhere

Publish your .mg files as a normal Python package. Any project installs them with uv add. Margarita finds them automatically — no config needed. Install the Claude skill once, and you can render any of them right from a chat message.

1
Create a template package
A template package is a normal Python package — the only convention is that .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.

Directory layout

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

pyproject.toml

The package-data entry is what makes Margarita work — it ensures .mg files are bundled into the installed package, not just the .py source.

[project]
name = "my-writing-templates"
version = "0.1.0"

[tool.setuptools.package-data]
"my_writing_templates" = [
  "templates/*.mg",
  "templates/**/*.mg",
]

my_writing_templates/templates/tone.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
---
name: tone
description: Sets the writing tone for any document.
parameter: style (string) - One of: "professional", "friendly", "concise".
---

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. >>

my_writing_templates/templates/draft.mg

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
---
name: draft
description: Drafts a piece of writing with a given topic and tone.
parameter: topic (string) - What to write about.
parameter: style (string) - Tone: "professional", "friendly", or "concise".
parameter: length (string) - Target length, e.g. "one paragraph", "500 words".
---

[[ my-writing-templates/tone
    style="${style}" ]]

<<
## Draft

Write ${length} about the following topic:

${topic}
>>

@effect run
2
Install the package with uv
From any project that needs the templates, 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.
From PyPI published package
# 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" ]]
Local dev editable install
# 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" ]]
3
Install the Margarita Claude skill
The Margarita skill lets Claude render any .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.
Install one-time setup
# Run from your project directory
uvx margarita install-claude-skill

# Output:
 Skill installed at .claude/skills/margarita.md
 Ready — restart Claude Code to activate
What it enables in Claude
# 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.
4
Render package templates from Claude
With the skill active and the package installed, Claude can render any of its templates directly. Pass variables in the chat and Claude handles the render — resolving includes, substituting variables, evaluating if blocks — and returns the final prompt or output.

Rendering a package template

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

Rendering a template with nested includes

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.

Asking Claude to create a new template

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
---
name: product_description
description: Drafts a product description with features and CTA.
parameter: product_name (string) - The product's name.
parameter: features (list) - Key features to highlight.
parameter: call_to_action (string) - The desired next step for the reader.
---
<<
# ${product_name}

${product_name} gives you:

for feature in features:
  - ${feature}

${call_to_action}
>>

@effect run
📦

One package, every project

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.

🔗

No extra config

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.

🤖

Claude as your template assistant

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.

Ready to share your templates?

Package your best prompt components once and install them everywhere — then let Claude render them for you.