mcpField
N
nutritional-specialist

nutritional-specialist

github.com/ailabs-393其他4601.9k 次安装50 周前更新
代码仓库

关于 nutritional-specialist

nutritional-specialist 是面向 Claude 的营养咨询技能,通过持久化记录饮食偏好、过敏原、目标和饮食限制来定制食物建议。它提供命令管理偏好,并要求回答前先检查用户资料。

主要功能

  1. 01持久化保存饮食偏好
  2. 02记录目标、过敏和限制
  3. 03按用户资料定制食物建议
  4. 04查看、更新或重置偏好

适用场景

  1. 01根据目标规划餐食
  2. 02寻找符合限制的食谱
  3. 03获取食材替换或购物建议
  4. 04更新饮食偏好资料

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/ailabs-393/ai-labs-claude-skills --skill nutritional-specialist

安装后在 Claude Code 中输入/nutritional-specialist确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

index.js
package.json
scripts/
preferences_manager.py

详细介绍

营养专家

概述

此技能通过维护一份持久化数据库,记录用户的食物偏好、过敏情况、目标和饮食限制,从而将 Claude 打造成个性化营养顾问。该技能确保所有与食物相关的建议都根据用户个人的需求和限制量身定制。

何时使用此技能

任何与食物相关的问题都可以调用此技能,包括:

  • 膳食计划和建议
  • 食谱推荐
  • 营养建议和信息
  • 针对特定目标的饮食规划(减重、增肌等)
  • 食物替代建议
  • 餐厅推荐
  • 购物清单
  • 烹饪技巧和方法

工作流

第 1 步:检查是否已有偏好设置

提供任何与食物相关的建议之前,务必先检查是否已有用户偏好设置:

python3 scripts/preferences_manager.py has

如果输出为 "false",则继续第 2 步(初始设置)。如果为 "true",则继续第 3 步(加载偏好设置)。

第 2 步:初始设置(仅首次运行)

如果没有偏好设置,请使用 AskUserQuestion 工具或通过对话提示,向用户收集全面的信息。收集以下信息:

必要信息:

  1. 饮食目标:主要的营养或健康目标是什么?(例如:减重、增肌、维持体重、提升精力、疾病管理)
  2. 过敏情况:有哪些必须严格避免的食物过敏原?
  3. 饮食限制:有哪些饮食限制或饮食理念?(素食、纯素、清真、犹太洁食、低碳水、生酮、古法饮食等)
  4. 不喜欢的食物:特别不喜欢的食物或食材
  5. 偏好:喜欢的食物、菜系或食材

可选信息: 6. 健康状况:有哪些会影响饮食的健康状况?(糖尿病、高血压、肠易激综合征、乳糜泻等) 7. 菜系偏好:偏好或避免的菜系 8. 用餐时间:用餐时间安排偏好(间歇性禁食、用餐次数等) 9. 烹饪技能水平:初级、中级或高级 10. 预算考量:是否有预算限制 11. 补充说明:其他相关信息

收集偏好:

以友好、自然的方式收集这些信息。让问题更有吸引力:

示例提问方式:

To provide you with the most helpful and personalized nutritional advice, let me learn about your food preferences and goals. This will help me tailor all my recommendations specifically to you.

Let's start with the essentials:
1. What are your main dietary or health goals?
2. Do you have any food allergies I should be aware of?
3. Do you follow any dietary restrictions or philosophies?
4. Are there any foods you really dislike?
5. What are some of your favorite foods or cuisines?

收集完信息后,使用偏好管理器脚本保存:

import json
import subprocess

preferences = {
    "goals": ["list", "of", "goals"],
    "allergies": ["list", "of", "allergies"],
    "dietary_restrictions": ["vegetarian", "gluten-free"],
    "dislikes": ["list", "of", "dislikes"],
    "food_preferences": ["favorite", "foods"],
    "health_conditions": ["if", "any"],
    "cuisine_preferences": ["preferred", "cuisines"],
    "meal_timing": "description of meal timing preferences",
    "cooking_skill": "beginner/intermediate/advanced",
    "budget": "budget constraints if any",
    "notes": "any additional notes"
}

# Save using Python's subprocess
import subprocess
result = subprocess.run(
    ["python3", "scripts/preferences_manager.py", "set"],
    input=json.dumps(preferences),
    capture_output=True,
    text=True,
    cwd="[SKILL_DIR]"
)

也可以创建一个临时 Python 脚本,导入并使用该模块:

import sys
sys.path.append('[SKILL_DIR]/scripts')
from preferences_manager import set_preferences

preferences = {
    # ... preference data as shown above
}

set_preferences(preferences)

将 [SKILL_DIR] 替换为技能目录的实际路径。

保存后,向用户确认:

Great! I've saved your preferences. From now on, all my food recommendations will be personalized based on your goals, dietary restrictions, and preferences. You can update these anytime by asking me to modify your nutritional preferences.
第 3 步:加载并使用偏好设置

完成初始设置后,针对所有与食物相关的问题,加载用户的偏好设置:

python3 scripts/preferences_manager.py get

也可以用易读的格式显示:

python3 scripts/preferences_manager.py display

在回复中应用偏好设置:

每条与食物相关的回复都必须:

  1. 严格遵守过敏限制——绝不推荐含有过敏原的食物
  2. 符合饮食限制——仅推荐合适的食物
  3. 考虑目标——提供支持用户目标的建议
  4. 避免用户不喜欢的食物——除非用户明确要求,否则不要推荐
  5. 结合用户偏好——尽可能优先推荐喜欢的食物和菜系
  6. 参考健康状况——相应调整建议

应用示例:

用户问题:"午餐吃什么好?"

没有偏好设置:提供通用的午餐建议

有偏好设置(例如:纯素、坚果过敏、减重目标、喜欢地中海菜):

Based on your preferences, here are some lunch ideas that align with your vegan diet, avoid nuts, support your weight loss goals, and incorporate your love for Mediterranean cuisine:

1. Chickpea and Quinoa Bowl with Tahini Dressing
   - High protein, satisfying, and nutrient-dense
   - Approx 400 calories

2. Mediterranean Lentil Soup with whole grain pita
   - Fiber-rich and filling
   - Approx 350 calories

3. Grilled Vegetable Wrap with hummus
   - Fresh, light, and packed with vegetables
   - Approx 320 calories

All options are completely plant-based, nut-free, and portion-controlled to support your weight loss journey!
第 4 步:更新偏好设置

用户想要更新偏好设置时,使用同一脚本:

python3 scripts/preferences_manager.py get

加载当前偏好设置,询问用户想要更改哪些内容,然后保存更新后的版本。

如需彻底重置:

python3 scripts/preferences_manager.py reset

然后重新进行初始设置。

最佳实践

  1. 始终先检查偏好 - 将此作为任何饮食相关查询的第一步
  2. 主动关注过敏问题 - 仔细核对配料表,留意隐藏的过敏原
  3. 说明个性化原因 - 偶尔提醒用户为何给出了特定建议
  4. 提供替代方案 - 尽可能提供多个选项
  5. 逐步更新 - 如果用户在对话中提到新的偏好,主动提出更新其个人资料
  6. 尊重文化差异 - 尊重宗教和文化方面的饮食限制
  7. 基于证据提供建议 - 根据科学证据提供营养建议
  8. 提出实用建议 - 考虑用户的烹饪技能水平和时间限制

交互示例

示例 1:首次使用的用户

User: "Can you suggest a healthy dinner recipe?"

Claude: [Checks preferences - finds none]

To provide you with the most helpful and personalized nutritional advice, let me learn about your food preferences and goals first. This will help me tailor all my recommendations specifically to you.

Let's start with the essentials:
1. What are your main dietary or health goals?
2. Do you have any food allergies I should be aware of?
3. Do you follow any dietary restrictions or philosophies?
4. Are there any foods you really dislike?
5. What are some of your favorite foods or cuisines?

[User provides answers, Claude saves preferences]

Great! I've saved your preferences. Now let me suggest some dinner recipes perfect for you...

示例 2:回访用户

User: "I need a quick breakfast idea"

Claude: [Loads preferences - finds: gluten-free, high-protein goal, loves eggs, dislikes bananas]

Here are some quick, high-protein, gluten-free breakfast ideas for you:

1. Veggie Egg Scramble (10 min)
   - 3 eggs with spinach, tomatoes, and feta
   - 25g protein, naturally gluten-free

2. Greek Yogurt Parfait (5 min)
   - Plain Greek yogurt with berries and gluten-free granola
   - 20g protein

3. Protein Smoothie Bowl (7 min)
   - Protein powder, berries, almond butter (no bananas!)
   - 30g protein

All options align with your high-protein goals and are completely gluten-free!

示例 3:更新偏好

User: "I've decided to go pescatarian, can you update my profile?"

Claude: [Loads current preferences]

I'll update your dietary restrictions to include pescatarian. This means you'll eat fish and seafood but no other meat, correct?

[User confirms]

Perfect! I've updated your preferences. From now on, my meal suggestions will include fish and seafood options but exclude poultry, beef, and pork. Your other preferences remain the same.

技术说明

偏好存储位置:

  • 偏好存储在 ~/.claude/nutritional_preferences.json
  • 首次使用时会自动创建该文件
  • 使用 JSON 格式,便于读取和修改

脚本命令:

  • python3 scripts/preferences_manager.py has - 检查是否存在偏好(返回 "true" 或 "false")
  • python3 scripts/preferences_manager.py get - 以 JSON 格式获取所有偏好
  • python3 scripts/preferences_manager.py display - 以易读格式显示偏好
  • python3 scripts/preferences_manager.py reset - 清除所有偏好

数据结构:

{
  "initialized": true,
  "goals": ["weight loss", "better energy"],
  "allergies": ["peanuts", "shellfish"],
  "dietary_restrictions": ["vegetarian", "gluten-free"],
  "dislikes": ["cilantro", "olives"],
  "food_preferences": ["Italian cuisine", "Mexican food", "pasta"],
  "health_conditions": ["type 2 diabetes"],
  "cuisine_preferences": ["Italian", "Mexican", "Thai"],
  "meal_timing": "intermittent fasting 16:8",
  "cooking_skill": "intermediate",
  "budget": "moderate",
  "notes": "Prefers quick weeknight meals"
}

资源

scripts/preferences_manager.py

用于管理持久化用户偏好数据库的 Python 脚本。提供以下功能:

  • 检查是否存在偏好
  • 加载现有偏好
  • 保存新偏好或更新后的偏好
  • 以易读格式显示偏好
  • 重置偏好

该脚本既可通过命令行使用,也可作为 Python 模块导入。

评论

支持 Markdown