---
title: Publish to Your Personal Cookbook
category: Platform
summary: How a Leo instance saves a reusable recipe to its owner's public cookbook at llamapress.ai/cookbook/u/<handle>, so every one of their Leos can reuse it.
tags: [cookbook, cross-instance, api]
status: stable
visibility: public
layers: [api]
---

> **This guide is for the Leo agent running on a LlamaPress instance.** It shows
> how to publish a pattern from THIS instance to the owner's personal cookbook,
> and how to reuse a recipe on any other instance. Nothing here is live code.

## What a personal cookbook is

Every LlamaPress user has a personal cookbook at
`https://llamapress.ai/cookbook/u/<handle>` — their own public library of
reusable recipes (a styled component, a Stimulus controller, a model pattern),
published from their Leo instances. Recipes are public Markdown served over
plain HTTP, so **any Leo can fetch and recreate them with no special access**.
That is the cross-instance sync mechanism: publish once, reuse everywhere.

## When to publish

Publish a recipe when the user says something like "save this so I can use it
in my other Leos", "add this to my cookbook", or "I want to reuse this
element". Write the recipe body the way the fleet cookbook writes guides: a
short intro, then the complete code in fenced blocks labeled with the file path
each block belongs in, then any gotchas. The reader is another AI agent that
must recreate the pattern from the text alone.

## How to publish (from this instance)

Your instance already holds its credentials:

- `MOTHERSHIP_API_TOKEN` — in `/home/ubuntu/Leonardo/.env`
- `instance_name` — in `/home/ubuntu/Leonardo/.leonardo/instance.json` (the `instance_name` key; it is also this box's dns name)

Write the recipe body to a file first (say `/tmp/recipe.md`), then:

```bash
cd /home/ubuntu/Leonardo
TOKEN=$(grep '^MOTHERSHIP_API_TOKEN=' .env | cut -d= -f2)
INSTANCE=$(python3 -c "import json;print(json.load(open('.leonardo/instance.json'))['instance_name'])")
python3 - "$INSTANCE" <<'PY' > /tmp/payload.json
import json, sys
print(json.dumps({
  "instance_name": sys.argv[1],
  "slug": "glow-toggle",                      # lowercase letters/digits/dashes
  "title": "Toggle with a glow effect",
  "summary": "Reusable glowing toggle switch.",
  "category": "UI Components",
  "body": open("/tmp/recipe.md").read()
}))
PY
curl -s -X POST "https://llamapress.ai/api/leonardo/cookbook_recipes" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  --data @/tmp/payload.json
```

The response returns the public URLs:

```json
{ "success": true, "created": true,
  "url": "https://llamapress.ai/cookbook/u/richie/glow-toggle",
  "md_url": "https://llamapress.ai/cookbook/u/richie/glow-toggle.md",
  "index_url": "https://llamapress.ai/cookbook/u/richie" }
```

**Always report the `url` back to the user** so they can see and share it.
POSTing the same `slug` again updates the recipe in place — republishing an
improved version is the normal flow. Pass `"visibility": "unlisted"` to keep a
recipe off the index while still reachable by URL. `GET` the same endpoint
(with the same auth) to list the owner's recipes; `DELETE
/api/leonardo/cookbook_recipes/<slug>` removes one.

## How to reuse a recipe (on any instance)

Fetch the raw Markdown and recreate the pattern in this app's codebase,
adapting names and styles to the current app:

```bash
curl -s https://llamapress.ai/cookbook/u/<handle>/<slug>.md
```

The user's index of recipes is at
`https://llamapress.ai/cookbook/u/<handle>.json` — check it when the user says
"use my cookbook" or "like the one I saved from my other Leo".

## Gotchas

- A recipe can only be published to the cookbook of the user who OWNS this
  instance — the server derives the owner from the instance token; there is no
  way to write to someone else's cookbook.
- Recipes are **public by default**. Never publish secrets, API keys, customer
  data, or anything from the app's database — code patterns only. If the code
  contains a credential, replace it with a placeholder before publishing.
- Body limit is 200 KB of Markdown. Keep one recipe = one pattern.
- The slug is permanent once shared: people bookmark the URL, so prefer
  updating an existing slug over creating near-duplicates.
