Query Food Nutrition Data
A structured food-database skill for nutrition lookup, food comparison, smart recommendations, and automatic meal nutrition calculation.
Why it matters
Access and analyze detailed nutritional information for a wide variety of foods. This asset enables precise queries, comparisons, and recommendations based on structured food data.
Outcomes
What it gets done
Retrieve nutritional data for specific foods by name.
Compare nutritional profiles between different food items.
Recommend foods based on specific nutritional criteria or health goals.
Calculate nutritional content for custom food portions.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-food-database-query | bash Overview
Food Database Query Skill
Food Database Query looks up, compares, and recommends foods from a structured 50-food nutrition database, and automatically calculates meal-level nutrition from free-text food and portion descriptions. Use it for database-backed food nutrition lookup, comparison, recommendation, or meal calculation - not as a substitute for professional dietary guidance.
What it does
Food Database Query is a nutrition data-query skill built on a structured food database rather than free-text advice. Its database (data/food-database.json) covers 50 common foods, each with 30+ nutrition metrics, organized under a category system (data/food-categories.json) of 10 major categories and 30+ subcategories. It supports six core functions: nutrition lookup, food comparison, smart recommendation, automatic nutrition calculation, category browsing/search, and portion conversion/estimation.
Food query supports exact lookup by Chinese name, English name, or alias, with fuzzy and alias matching, returning basic info, macronutrients (calories, protein, carbs, fat, fiber), micronutrients (vitamins, minerals), special nutrients (Omega-3/6, choline), glycemic index, health tags, suitable-for groups, and common portions. Fuzzy search filters by nutrient criteria such as "high protein" or "low GI", by combined criteria, by category, or by suitable-for group (vegetarian-friendly, hypertension, diabetes). Category browsing walks a hierarchy - for example, protein sources branch into meat, poultry, fish/shrimp/shellfish, eggs, legumes, nuts/seeds, and dairy - sortable by nutrient, GI, or health tag.
Food comparison evaluates two foods across macronutrients, micronutrients, glycemic index/load, and overall nutrient density, returning a comparison table with percent differences and a recommendation, plus multi-dimension modes limited to specific nutrients, GI only, or a specific health tag (e.g. "/nutrition compare Salmon ChickenBreast nutrients"). Recommendation supports single-nutrient thresholds (high protein >=15g/100g, high fiber >=5g/100g, low GI <=55, vitamin C >=50mg/100g, Omega-3 >=1g/100g, high calcium >=100mg/100g, high iron >=3mg/100g), combined-condition recommendations, and health-condition-based recommendations for hypertension (DASH-style: low sodium, high potassium, high magnesium/calcium), diabetes (low GI, high fiber, low carb), high blood lipids (high Omega-3, low saturated fat, high fiber), osteoporosis (high calcium, vitamin D, magnesium/zinc), and anemia (iron, folate, vitamin B12).
Automatic nutrition calculation parses free-text meal descriptions like "oatmeal 1 cup + egg 1 + milk 250ml" into individual foods and portions, normalizes each food name, converts common portion units (1 cup, 1 piece, 1 slice, or grams) using a portion database, and scales each food's per-100g nutrition to the actual portion size:
def calculate_nutrition(food, portion_grams):
nutrition = {}
for nutrient, value_per_100g in food.nutrition_per_100g.items():
# 按100g比例计算
nutrition[nutrient] = (value_per_100g * portion_grams) / 100
return nutrition
It also corrects for cooking effects, such as oats roughly tripling in weight when cooked and retaining 60-80% of B vitamins. Smart search adds alias matching (e.g. oats = oatmeal = rolled oats) and Levenshtein-distance-based spelling correction with a configurable maximum edit distance.
Each food record follows a fixed JSON schema: id, Chinese and English names, aliases, category/subcategory, standard portion, a nutrition_per_100g block covering 30+ macro/vitamin/mineral fields, special nutrients, glycemic index and load, common portions, cooking-effect data, health tags, suitable-for groups, and notes. RDA reference tables are included for adult males and females aged 19-50, covering calories, macronutrients, vitamins, and minerals, with sex-specific differences such as iron requirements.
When to use - and when NOT to
Use this skill when querying a food's nutrition content, comparing foods, doing nutrition calculations, browsing or filtering the food database by category, or when structured, database-backed analysis is needed instead of free-text nutrition advice.
Do not treat its output as a substitute for professional dietary guidance - the skill itself flags that its current database covers only 50 common foods, that cooking-effect data is based on raw or standard cooking methods, that individual nutrient absorption varies by person, and that food nutrition content can vary by region. Its own usage guidance recommends not relying on a single food, diversifying food choices, applying moderation even for healthy foods, and consulting a registered dietitian for special dietary needs. Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Inputs and outputs
Input is a food name (Chinese, English, or alias), a nutrient/category search criterion, two foods to compare, or a free-text meal description with portions. Output is structured data: a full nutrition profile, a filtered/sorted list of matching foods, a comparison table with percentage differences and recommendations, or a calculated per-meal nutrition summary with RDA percentages for key micronutrients.
Integrations
The skill is designed to integrate with a nutrition-logging module (auto-querying nutrition data, precise per-meal analysis, data-driven food suggestions), a health module (condition-specific filtering for hypertension, diabetes, and high blood lipids), and an exercise module (pre/post-workout food suggestions, high-protein picks for muscle gain, low-calorie high-protein picks for fat loss). Data accuracy is sourced from the China Food Composition Table (6th edition) and USDA data, cross-validated across sources. Implementation files live at data/food-database.json, data/food-categories.json, .claude/commands/nutrition.md, and .claude/skills/food-database-query/SKILL.md, with database indexing and query caching for performance.
Who it's for
Nutrition and wellness applications, coaches, or agents that need database-backed food lookup, comparison, and automatic meal nutrition calculation instead of generic dietary advice - currently scoped to a 50-food database with English and Chinese name support.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.