AGENT SKILL

printable-recipe-card

Turn any online recipe (a HelloFresh link, a food blog, AllRecipes, NYT Cooking, Serious Eats, Minimalist Baker, a pasted recipe, or a screenshot or PDF of one) into a clean 2-page printable recipe card PDF. Page 1 has the photo, the ingredients, and an info bar. Page 2 is all steps. It doubles as an offline archive copy. Along the way it fixes broken recipe data such as missing prep steps, "1 unit" amounts, meat stock in veggie recipes, and inconsistent names. Use this whenever the user shares a recipe link or recipe text and wants a card, printable, PDF, offline copy, or "make this one into a card like the others", or says a site's print or PDF button is broken. Also use it for follow-ups like "do this one too" or "and this one".

License 许可
Apache-2.0
最近更新
2026-11-03
Stars
★ 0
Forks
0

01 前言 Front Matter

name
printable-recipe-card
description
Turn any online recipe (a HelloFresh link, a food blog, AllRecipes, NYT Cooking, Serious Eats, Minimalist Baker, a pasted recipe, or a screenshot or PDF of one) into a clean 2-page printable recipe card PDF. Page 1 has the photo, the ingredients, and an info bar. Page 2 is all steps. It doubles as an offline archive copy. Along the way it fixes broken recipe data such as missing prep steps, "1 unit" amounts, meat stock in veggie recipes, and inconsistent names. Use this whenever the user shares a recipe link or recipe text and wants a card, printable, PDF, offline copy, or "make this one into a card like the others", or says a site's print or PDF button is broken. Also use it for follow-ups like "do this one too" or "and this one".

02 资源文件 5

03 SKILL.md 正文

Printable Recipe Card

The user prints these cards to cook from instead of reading a phone. They also keep the PDFs as an offline archive in case a recipe site disappears. So each card needs to be:

  • Complete: every ingredient, quantity, temperature, and time from the original.
  • Correct: obvious data errors are fixed.
  • Easy to read at the stove.

The look is based on HelloFresh's printed cards: a big photo, a green ingredient panel, and steps with titles and bullets, with ingredient names in bold.

Configuration

This skill can save each finished card to a Google Drive folder and log it in a Google Sheet (step 8). Those two destinations belong to each user, so they are not filled in. Fill them in here, or let the skill ask on first use.

LOCAL_FOLDER      = <UNSET>   # full path of the recipe-card folder on the user's computer,
                              # inside a Google Drive for desktop synced location
DRIVE_FOLDER_ID   = <UNSET>   # ID of that same folder in Google Drive (the string after /folders/ in its URL)
SPREADSHEET_ID    = <UNSET>   # ID of the tracking sheet (the string between /d/ and /edit in its URL)
SHEET_TAB         = Sheet1    # tab name inside the sheet

Check these before starting any recipe. If any value still reads <UNSET>:

  1. Say in one line that Drive saving and sheet logging are not set up yet.
  2. Ask the user (AskUserQuestion works well) for the three values, or whether to skip Drive and the sheet and just deliver the PDF. Tell them where to find each one:
    • Folder path: right-click the folder in File Explorer or Finder and copy its path. It must be inside the Google Drive for desktop folder so it syncs.
    • Folder ID: open the folder in drive.google.com and copy the last part of the URL.
    • Sheet ID: open the sheet and copy the part of the URL between /d/ and /edit.
  3. Use the answers for the rest of the session. Do not edit this file. Suggest they paste the values into the Configuration block (or save them in their memory or notes) so they are not asked again.
  4. If they choose to skip, run steps 1 to 7 only and say that step 8 was skipped by choice.

If the sheet is brand new and row 1 is empty, write the header row first: Name, Course, Cuisine, Type, Saved Recipe, Original Recipe. If the sheet already has a different column layout, ask the user how to map the six values instead of changing their layout.

The Drive and Sheets connectors run as whichever Google account the user connected to Claude. That account must be able to see the folder and edit the sheet. If the folder lives in a different Google account (a personal Drive for desktop sync, say), the folder and sheet need to be shared with the connected account.

Standing preferences

  • Page 1 has:

    • a header: title, subtitle, a stats line (time, servings, calories, protein), and up to 3 tags
    • the hero photo on the left, with ingredients to its right
    • a full-width info bar along the bottom: the intro blurb (no "Hello" heading) and Before you start, Cooking tools, Pantry ingredients and Allergens, a 2-column Nutrition table, and Notes

    There is no "Not included in your delivery" block, no "Some of the produce…" note, and no logo.

  • Page 2 is only the steps, full width. There is no "Cook for YOUR Crowd" section. The whole back page goes to the method, so long recipes fit:

    • photo steps: up to 8 (3 or 4 columns by 2 rows)
    • text-only steps: up to about 12 (2–4 columns)
  • Use real quantities, never "1 unit". Whole-item counts (1 lime, 2 buns) are fine.

  • If a recipe is labeled vegetarian or tofu but contains meat-based stock, swap in veggie stock everywhere. Don't change the protein in recipes that are genuinely meat recipes.

  • Fix obvious errors without asking, then list every fix in the reply.

  • If Drive and sheet saving is configured (see Configuration), every finished card is also saved to the user's recipe folder and logged in their tracking sheet (step 8).

Workflow

1. Get the recipe

Run python scripts/fetch_recipe.py <url> /home/claude/work (use a fresh work directory for each recipe).

  • HelloFresh: you get ingredient icons, a photo for every step, and 2|4 serving amounts.
  • Most other recipe sites: the script reads the schema.org Recipe data, which gives the hero photo, ingredient lines, steps, yield, times, and nutrition. Some sites also include step photos.
  • Exit code 2 (blocked or no structured data): see Fallback below.

Fallback

Many sites (AllRecipes, Budget Bytes, Serious Eats, Cookie and Kate, and others) block the container's curl. When that happens:

  1. Call web_fetch on the user's URL. It usually works where curl doesn't, and it returns the page text, often including image URLs.
  2. Try to download the main photo URL from that result with curl -L -o img/hero.jpg <url>. Image CDNs are usually not blocked. Check the file with file.
  3. If there's still no photo, build without one. The ingredients then take the full width of page 1.
  4. If the user pasted text or uploaded a screenshot or PDF, work straight from that.
  5. Note any "Recipe Notes" or FAQ tips on the page (storage, substitutions, make-ahead). They go in the card's Notes section because they're valuable in an archive copy.

2. Look at the photos and set focal points

Make a contact sheet of the downloaded images and view it. Check three things:

  • The hero is the finished dish. If not, use the final plated step photo.
  • The photos match the recipe. On HelloFresh they often show a different protein; see the fixes reference.
  • Step photos are usable. Tiny images or images with text overlays are better left out.

Then choose a focal point for every image you use. The card crops each photo to a landscape box, and by default it keeps the dead center. Blog photos are often tall phone shots (for example 1200x2133), so a center crop can land on the background, a cookbook, or empty counter instead of the food. To fix that:

  1. Make a second contact sheet with horizontal gridlines labeled 0.1 to 0.9 down the side of each image (PIL ImageDraw works) and view it.
  2. For each image, read off where the food or the action in that step sits, and write it as [fx, fy] (fractions of the full image; 0,0 is top-left). Set hero_focus for the hero and focus on each step. Tall images mostly need fy; wide images mostly need fx.
  3. Aim the crop at what the step is about (the mixer beaters in "Cream Together", the candy in "Add Candy"), not just at the largest blob of food.
  4. After building, check the crops in step 6 and adjust any focal point that cut off the subject.

3. Audit and fix

Read references/fixes-and-quantities.md and go through its checklist. It has a general section for any recipe and a HelloFresh section for the errors those recipes usually have.

4. Write the spec

Save it as /home/claude/work/spec.json following references/spec-format.md. Key points:

  • Steps: group the method into logical stages. Aim for 4–9 steps without photos, or 6 with photos. Blog recipes often have 10–15 tiny steps; don't pad them out or merge them aggressively. Name the stages ("Bake Tofu", "Make Sauce", "Fry & Serve") and rewrite each in your own concise words. Keep every quantity, temperature, time, and doneness cue. Bold the ingredient names, times, and temperatures that someone glancing at the card needs. Put 4-serving variants and "(you'll use the rest later)" notes in <g>. Put the steps in real cooking order: start the longest-running task first, and flag parallel work with <g>While X cooks:</g>.

  • Time: recalculate the real start-to-plate time with the overlapping work taken into account (checklist item 11). Don't copy the site's figure.

  • Ingredients: HelloFresh cards use the icon grid with "2 | 4" amounts. Everything else uses list mode:

    • Split each ingredient into amount (quantity and unit, like "2-3 TBSP" or "4 cloves") and name (with the prep, like "garlic, minced").
    • Keep the recipe's own ingredient groups (Sauce, Topping) as {"section": ...} rows.
    • List every ingredient, including salt and oil. There is no "shipped" concept for non-HelloFresh recipes, so leave out pantry or use it only for "to taste" extras.
    • Keep the original yield. Don't rescale unless the user asks.
  • Hello / Before you start: write one short, useful sentence for each in your own words: what makes the dish good, and one prep tip. Don't copy the site's intro prose.

  • Prep ahead (prep_ahead, 2–3 bullets): always include it. List what can be done earlier in the day, or days before, so dinner goes faster. Each bullet should say when to do it and how to store it. Good candidates:

    • pressing tofu earlier in the day so it is well drained by dinner
    • cooking grains ahead (day-old rice is better for fried rice)
    • mixing sauces, dressings, and marinades
    • quick-pickling
    • chopping sturdy veg (carrots, onions, peppers)
    • making dough
    • toasting nuts

    Skip anything that suffers from sitting, such as cut avocado or apple, dressed greens, or anything meant to be crispy. These bullets appear under "Before you start" in the page 1 info bar.

  • Nutrition: include it if the source gives it. If the source doesn't list nutrition, leave it out and don't make numbers up.

  • Allergens: work them out from the ingredients (soy, wheat or gluten, milk, eggs, peanuts, tree nuts, sesame, fish, shellfish).

  • Tips and tricks (many blogs have a dozen or more): keep only the ones a cook wouldn't guess and that change the result, and cap Notes at about 4 bullets of one or two lines each. Put a tip inline in the step it applies to when it is a quick cue (<g>It goes from amber to burnt fast.</g>) or a specific mistake to avoid. Put it in Notes when it covers the whole recipe: storage life and why, freezing, swaps, shortcuts, and judging doneness by a visual cue instead of time. Fold ingredient-choice tips into the ingredient line ("instant pudding mix, not cook-and-serve"). Drop common sense ("read the recipe first", "use fresh ingredients"), repeats of what a step already says, and reader comments. The card is a page to cook from, so a tip that needs more than two lines is a sign to cut it down.

  • Source: set source to the URL without https://. The footer adds "Saved <date>" for the archive.

  • Tags: 1–3 short tags, like Veggie, Vegan, Quick, Gluten-Free, or Spicy.

5. Build

Run: python scripts/build_card.py /home/claude/work/spec.json "/mnt/user-data/outputs/<Recipe-Name>-Recipe-Card.pdf"

The script sizes the info bar to its content and uses one text size for all steps. When steps have photos, it shrinks the photos before the text, so the text stays readable. It shrinks text only as a last resort. It prints WARNING: lines for anything that still overflows, such as a step, an info-bar column, the ingredient list, or a dropped tag. Fix every warning. Trim the wording or merge steps. If the info bar is too tall, shorten the Hello, tip, or Notes text. Then rebuild.

6. Check visually

Render both pages with pdftoppm -r 70 -png and view them. Look for:

  • Text colliding with other text.
  • A cramped step that would be hard to read while cooking.
  • A photo that is cropped badly (the subject cut off or the crop landing on background). Fix it by changing hero_focus or the step's focus, not by swapping the photo.

Fix and rebuild before delivering.

7. Deliver

Send the PDF with SendUserFile (or present_files if that is the tool the session offers). Then do step 8 unless the user asked for the card only. Keep the reply short: a bulleted list of the fixes you made, which quantities are estimates, and anything that's missing (for example, no photo because the site blocked it, or no nutrition listed). Add one line on where the card was saved and which sheet row it got, or why that was skipped.

For several recipes at once, run steps 1–6 for each one in its own work directory, then deliver all the PDFs together and do step 8 for all of them.

8. Save to Drive and log it in the sheet

Skip this step when the user chose to skip it, or when the Configuration values are unset and they declined to provide them. Otherwise do it after the card is built and delivered.

Locations come from the Configuration section: LOCAL_FOLDER (the synced folder on the user's computer), DRIVE_FOLDER_ID (the same folder as the Drive connector sees it), SPREADSHEET_ID and SHEET_TAB. The sheet columns A to F are Name, Course, Cuisine, Type, Saved Recipe, Original Recipe.

Steps

  1. Reach the folder. Call device_list_dir on LOCAL_FOLDER. If it says the folder is not connected, call device_request_folder_access for that one folder (reason: copy finished recipe cards into the synced recipe card folder). The user has to approve a dialog on their computer, and a new chat needs this again. If the device tools are missing, the request times out, or it is declined, go to Fallback.
  2. Write the file. Call device_commit_files with stagedPath set to the PDF in /mnt/user-data/outputs/ and devicePath set to LOCAL_FOLDER plus the same file name. Several cards can go in one call. Do not use device_bash for this, because that shell can be unavailable. If device_list_dir shows a card with the same name, only overwrite it when the user asked to rebuild that recipe, and pass the listed mtimeMs as expectedMtimeMs.
  3. Confirm it reached Drive. Search with the Drive connector: parentId = '<DRIVE_FOLDER_ID>' and title = '<file name>'. Syncing can take a minute, so retry a few times with a short wait between tries. Accept the result when its fileSize equals the local file's size in bytes, and take the file id from it. Compare against the size of the final PDF in /mnt/user-data/outputs/ (stat -c %s), not a remembered number. If Drive has a different size, the commit picked up an older copy of the file (this happens if the card was rebuilt shortly before the commit). Re-commit it with expectedMtimeMs set to the mtimeMs that device_list_dir shows for that file, then check again. If it never shows up, do not log a row. Tell the user the file is in their local folder and the sync has not finished.
  4. Add the row. Read column A of the sheet (SPREADSHEET_ID, SHEET_TAB) first. If the recipe name is already there, skip the append and say so. Otherwise append one row to the tab: Name (the recipe title as on the card), Course, Cuisine, Type, Saved Recipe (https://drive.google.com/file/d/<id>/view), and Original Recipe (the source URL, left blank for the user's own recipes). Reuse the labels already in the sheet; on an empty sheet use the header names from Configuration. Course is one of Dessert, Main Dish, Breakfast, Beverage, Bread, Side, Appetizer, or Condiment. Cuisine is a specific cuisine such as Korean, Thai, or Mexican. Type is the dish form, such as Tofu, Pasta, Soup, Sandwich, or Cookies.

Never put a PDF into Drive by pasting its base64 text into the Drive connector's create_file. A 60 KB card arrived as 13 KB that way and was unusable.

Fallback. If the folder cannot be reached, the user still has the PDF from step 7. Say in one line that the Drive copy and the sheet row were skipped and why. They can drag the file into the folder and ask for the row afterward.

04 同仓库更多 Skills