{"slug":"publish-to-your-personal-cookbook","meta":{"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/\u003chandle\u003e, so every one of their Leos can reuse it.","tags":["cookbook","cross-instance","api"],"status":"stable","visibility":"public","layers":["api"]},"body":"\u003e **This guide is for the Leo agent running on a LlamaPress instance.** It shows\n\u003e how to publish a pattern from THIS instance to the owner's personal cookbook,\n\u003e and how to reuse a recipe on any other instance. Nothing here is live code.\n\n## What a personal cookbook is\n\nEvery LlamaPress user has a personal cookbook at\n`https://llamapress.ai/cookbook/u/\u003chandle\u003e` — their own public library of\nreusable recipes (a styled component, a Stimulus controller, a model pattern),\npublished from their Leo instances. Recipes are public Markdown served over\nplain HTTP, so **any Leo can fetch and recreate them with no special access**.\nThat is the cross-instance sync mechanism: publish once, reuse everywhere.\n\n## When to publish\n\nPublish a recipe when the user says something like \"save this so I can use it\nin my other Leos\", \"add this to my cookbook\", or \"I want to reuse this\nelement\". Write the recipe body the way the fleet cookbook writes guides: a\nshort intro, then the complete code in fenced blocks labeled with the file path\neach block belongs in, then any gotchas. The reader is another AI agent that\nmust recreate the pattern from the text alone.\n\n## How to publish (from this instance)\n\nYour instance already holds its credentials:\n\n- `MOTHERSHIP_API_TOKEN` — in `/home/ubuntu/Leonardo/.env`\n- `instance_name` — in `/home/ubuntu/Leonardo/.leonardo/instance.json` (the `instance_name` key; it is also this box's dns name)\n\nWrite the recipe body to a file first (say `/tmp/recipe.md`), then:\n\n```bash\ncd /home/ubuntu/Leonardo\nTOKEN=$(grep '^MOTHERSHIP_API_TOKEN=' .env | cut -d= -f2)\nINSTANCE=$(python3 -c \"import json;print(json.load(open('.leonardo/instance.json'))['instance_name'])\")\npython3 - \"$INSTANCE\" \u003c\u003c'PY' \u003e /tmp/payload.json\nimport json, sys\nprint(json.dumps({\n  \"instance_name\": sys.argv[1],\n  \"slug\": \"glow-toggle\",                      # lowercase letters/digits/dashes\n  \"title\": \"Toggle with a glow effect\",\n  \"summary\": \"Reusable glowing toggle switch.\",\n  \"category\": \"UI Components\",\n  \"body\": open(\"/tmp/recipe.md\").read()\n}))\nPY\ncurl -s -X POST \"https://llamapress.ai/api/leonardo/cookbook_recipes\" \\\n  -H \"Authorization: Bearer $TOKEN\" -H \"Content-Type: application/json\" \\\n  --data @/tmp/payload.json\n```\n\nThe response returns the public URLs:\n\n```json\n{ \"success\": true, \"created\": true,\n  \"url\": \"https://llamapress.ai/cookbook/u/richie/glow-toggle\",\n  \"md_url\": \"https://llamapress.ai/cookbook/u/richie/glow-toggle.md\",\n  \"index_url\": \"https://llamapress.ai/cookbook/u/richie\" }\n```\n\n**Always report the `url` back to the user** so they can see and share it.\nPOSTing the same `slug` again updates the recipe in place — republishing an\nimproved version is the normal flow. Pass `\"visibility\": \"unlisted\"` to keep a\nrecipe off the index while still reachable by URL. `GET` the same endpoint\n(with the same auth) to list the owner's recipes; `DELETE\n/api/leonardo/cookbook_recipes/\u003cslug\u003e` removes one.\n\n## How to reuse a recipe (on any instance)\n\nFetch the raw Markdown and recreate the pattern in this app's codebase,\nadapting names and styles to the current app:\n\n```bash\ncurl -s https://llamapress.ai/cookbook/u/\u003chandle\u003e/\u003cslug\u003e.md\n```\n\nThe user's index of recipes is at\n`https://llamapress.ai/cookbook/u/\u003chandle\u003e.json` — check it when the user says\n\"use my cookbook\" or \"like the one I saved from my other Leo\".\n\n## Gotchas\n\n- A recipe can only be published to the cookbook of the user who OWNS this\n  instance — the server derives the owner from the instance token; there is no\n  way to write to someone else's cookbook.\n- Recipes are **public by default**. Never publish secrets, API keys, customer\n  data, or anything from the app's database — code patterns only. If the code\n  contains a credential, replace it with a placeholder before publishing.\n- Body limit is 200 KB of Markdown. Keep one recipe = one pattern.\n- The slug is permanent once shared: people bookmark the URL, so prefer\n  updating an existing slug over creating near-duplicates.\n"}