faostat-skills 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +22 -0
- package/LICENSE +21 -0
- package/README.md +184 -0
- package/commands/faostat-climate.md +6 -0
- package/commands/faostat-commodity.md +6 -0
- package/commands/faostat-compare.md +6 -0
- package/commands/faostat-country-profile.md +6 -0
- package/commands/faostat-explore.md +6 -0
- package/commands/faostat-story.md +6 -0
- package/commands/faostat-trade.md +6 -0
- package/commands/faostat-trends.md +6 -0
- package/commands/faostat-viz.md +6 -0
- package/package.json +34 -0
- package/skills/climate/SKILL.md +152 -0
- package/skills/commodity/SKILL.md +124 -0
- package/skills/compare/SKILL.md +109 -0
- package/skills/country-profile/SKILL.md +122 -0
- package/skills/explore/SKILL.md +119 -0
- package/skills/story/SKILL.md +161 -0
- package/skills/trade/SKILL.md +154 -0
- package/skills/trends/SKILL.md +114 -0
- package/skills/viz/SKILL.md +160 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: faostat-trends
|
|
3
|
+
description: Use when the user wants to identify biggest changes, fastest-growing or declining agricultural productions, or anomalies in FAOSTAT data over a time window for a region or set of countries. Keywords: trends, growth, decline, anomaly, change, biggest movers, acceleration, deceleration, monitoring, shift, surge, drop, spike
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agricultural Trend Monitor
|
|
7
|
+
|
|
8
|
+
Identify the biggest changes and anomalies in agricultural production data over a specified time window and geography.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
Before starting, confirm the FAOSTAT MCP tools are available by checking that tools `faostat_get_data`, `faostat_search_codes`, and `faostat_get_rankings` are accessible. If they are not, inform the user that this skill requires the FAOSTAT MCP server to be connected and stop.
|
|
13
|
+
|
|
14
|
+
## Workflow
|
|
15
|
+
|
|
16
|
+
### Step 1 — Gather Parameters
|
|
17
|
+
|
|
18
|
+
Ask the user for:
|
|
19
|
+
- **Region or countries** — one or more countries, a continent, or a region (e.g., "Africa", "Brazil and Argentina", "Southeast Asia")
|
|
20
|
+
- **Time window** — default to the last 5 years if not specified
|
|
21
|
+
- **Focus** (optional) — specific commodity groups to monitor, or leave broad for all major groups
|
|
22
|
+
|
|
23
|
+
If the user provides these in their initial message, proceed without re-asking.
|
|
24
|
+
|
|
25
|
+
### Step 2 — Resolve Area Codes
|
|
26
|
+
|
|
27
|
+
Use `faostat_search_codes` with `domain_code='QCL'` and `dimension_id='area'` to resolve each country or region name to its FAOSTAT area code.
|
|
28
|
+
|
|
29
|
+
**CRITICAL:** If `requires_confirmation` is `true` in the response (multiple matches), present the options to the user and ask them to choose before proceeding. Do NOT guess.
|
|
30
|
+
|
|
31
|
+
### Step 3 — Pull Production Data for Major Commodity Groups
|
|
32
|
+
|
|
33
|
+
Query the **QCL** (Crops and Livestock Products) domain using `faostat_get_data`. Pull production quantity data (element filter code `'5510'`) across major commodity groups.
|
|
34
|
+
|
|
35
|
+
For broad monitoring, query across these key items:
|
|
36
|
+
- Cereals (wheat, rice, maize, barley, sorghum, millet)
|
|
37
|
+
- Oilcrops (soybeans, palm fruit, sunflower seed, rapeseed)
|
|
38
|
+
- Roots and tubers (cassava, potatoes, yams, sweet potatoes)
|
|
39
|
+
- Fruits (bananas, citrus, mangoes, avocados)
|
|
40
|
+
- Vegetables (tomatoes, onions)
|
|
41
|
+
- Livestock products (milk, meat — cattle, chicken, pig, sheep)
|
|
42
|
+
|
|
43
|
+
Use `faostat_search_codes` with `domain_code='QCL'` and `dimension_id='item'` to resolve each item name to its item code.
|
|
44
|
+
|
|
45
|
+
For each query, use `response_format='compact'` when pulling data for multiple entities to keep payloads efficient. Set `limit` appropriately to cover the full time window.
|
|
46
|
+
|
|
47
|
+
**Important:** Element FILTER codes differ from DISPLAY codes. When calling `faostat_get_data`, use the filter code for the `element` parameter. Production quantity filter code is `'5510'`. If you need to look up the correct filter code, use `faostat_search_codes` with `dimension_id='element'`.
|
|
48
|
+
|
|
49
|
+
### Step 4 — Calculate Period-over-Period Changes
|
|
50
|
+
|
|
51
|
+
For each country-commodity pair:
|
|
52
|
+
1. Identify the **baseline value** (first year or average of first 2 years in the window)
|
|
53
|
+
2. Identify the **latest value** (most recent year or average of last 2 years)
|
|
54
|
+
3. Calculate:
|
|
55
|
+
- **Absolute change** = latest - baseline
|
|
56
|
+
- **Percentage change** = ((latest - baseline) / baseline) * 100
|
|
57
|
+
- **Annualized growth rate** = ((latest / baseline)^(1/years) - 1) * 100
|
|
58
|
+
|
|
59
|
+
Exclude any country-commodity pairs where baseline data is zero or missing.
|
|
60
|
+
|
|
61
|
+
### Step 5 — Rank by Magnitude
|
|
62
|
+
|
|
63
|
+
Sort all country-commodity pairs by:
|
|
64
|
+
- **Percentage change** (descending) for top growers
|
|
65
|
+
- **Percentage change** (ascending) for top decliners
|
|
66
|
+
|
|
67
|
+
Select:
|
|
68
|
+
- **Top 5 fastest-growing** productions (highest positive percentage change)
|
|
69
|
+
- **Top 5 largest declines** (most negative percentage change)
|
|
70
|
+
|
|
71
|
+
### Step 6 — Flag Anomalies
|
|
72
|
+
|
|
73
|
+
For each country-commodity time series:
|
|
74
|
+
1. Calculate the mean and standard deviation of annual values across the time window
|
|
75
|
+
2. Flag any year where the value deviates by more than 2 standard deviations from the mean
|
|
76
|
+
3. Note the direction (spike up or drop down) and the year
|
|
77
|
+
|
|
78
|
+
An anomaly could indicate a drought, bumper harvest, policy change, conflict, or data issue.
|
|
79
|
+
|
|
80
|
+
### Step 7 — Compile the Trend Report
|
|
81
|
+
|
|
82
|
+
Present the results in a structured format:
|
|
83
|
+
|
|
84
|
+
**Top 5 Growing Productions**
|
|
85
|
+
For each entry: country, commodity, baseline value, latest value, percentage change, annualized growth rate. Add a brief note on possible drivers if context is evident.
|
|
86
|
+
|
|
87
|
+
**Top 5 Declining Productions**
|
|
88
|
+
Same format as above. Flag any that may indicate food security concerns.
|
|
89
|
+
|
|
90
|
+
**Anomaly Flags**
|
|
91
|
+
For each anomaly: country, commodity, year, actual value vs. expected range, direction (spike/drop). Note if additional investigation is warranted.
|
|
92
|
+
|
|
93
|
+
**Trend Directions Summary**
|
|
94
|
+
A concise table showing all analyzed country-commodity pairs with trend direction indicators:
|
|
95
|
+
- Strong growth (>20% over period)
|
|
96
|
+
- Moderate growth (5-20%)
|
|
97
|
+
- Stable (-5% to +5%)
|
|
98
|
+
- Moderate decline (-5% to -20%)
|
|
99
|
+
- Sharp decline (>20% decline)
|
|
100
|
+
|
|
101
|
+
### Step 8 — Attribution
|
|
102
|
+
|
|
103
|
+
End the report with:
|
|
104
|
+
|
|
105
|
+
> Source: FAOSTAT (FAO), accessed [current date]. Domain: QCL (Crops and Livestock Products).
|
|
106
|
+
|
|
107
|
+
Replace `[current date]` with today's date.
|
|
108
|
+
|
|
109
|
+
### Step 9 — Offer Next Steps
|
|
110
|
+
|
|
111
|
+
Suggest to the user:
|
|
112
|
+
- "Would you like me to visualize any of these trends as charts?" (invokes the visualization skill)
|
|
113
|
+
- "Want a deeper dive into any specific commodity or country?" (invokes the commodity or country-profile skill)
|
|
114
|
+
- "Should I check the trade data for any of the anomalies?" (invokes the trade skill)
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: faostat-viz
|
|
3
|
+
description: Use when the user asks to visualize, chart, graph, or plot FAOSTAT data, or when they want a visual representation of agricultural statistics. Also use when another skill needs to produce a chart. Keywords: chart, graph, plot, visualize, visualization, bar chart, line chart, scatter plot, stacked bar, HTML, interactive, Chart.js, trend chart, comparison chart
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FAOSTAT Data Visualizer
|
|
7
|
+
|
|
8
|
+
Generate interactive, standalone HTML charts from FAOSTAT data. Charts use Chart.js via CDN and are designed to be self-contained, responsive, accessible, and properly attributed.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
Before starting, verify that the FAOSTAT MCP tools are available: `faostat_search_codes`, `faostat_get_data`. If they are not available and the user has not provided data in the conversation context, inform the user they need the FAOSTAT MCP server configured and stop.
|
|
13
|
+
|
|
14
|
+
If data is already available in the conversation context (e.g., from a previous query or another skill), skip directly to chart generation.
|
|
15
|
+
|
|
16
|
+
## Chart Type Selection
|
|
17
|
+
|
|
18
|
+
Choose the chart type based on the data relationship. If the user does not specify a chart type, select the most appropriate one:
|
|
19
|
+
|
|
20
|
+
| Data Relationship | Chart Type | When to Use |
|
|
21
|
+
|-------------------|------------|-------------|
|
|
22
|
+
| Values over time | **Line chart** | Trends, time series, historical data |
|
|
23
|
+
| Values across categories | **Bar chart** | Comparing countries, commodities, or regions |
|
|
24
|
+
| Composition breakdown | **Stacked bar chart** | Shares of a total (e.g., emissions by source, trade by partner) |
|
|
25
|
+
| Two-variable relationship | **Scatter plot** | Correlations (e.g., fertilizer use vs. emissions) |
|
|
26
|
+
|
|
27
|
+
Do NOT use pie charts. They are difficult to read with more than 3-4 categories and do not convey FAOSTAT data well.
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
### Step 1: Determine data source
|
|
32
|
+
|
|
33
|
+
Check if usable data already exists in the conversation context:
|
|
34
|
+
- If YES: extract the relevant data points (values, labels, years, units) and proceed to Step 4.
|
|
35
|
+
- If NO: proceed to Step 2 to query FAOSTAT.
|
|
36
|
+
|
|
37
|
+
### Step 2: Query data (if needed)
|
|
38
|
+
|
|
39
|
+
1. Ask the user what they want to visualize if not clear from context:
|
|
40
|
+
- What metric? (production, yield, trade volume, emissions, etc.)
|
|
41
|
+
- Which entities? (countries, commodities, regions)
|
|
42
|
+
- What time range?
|
|
43
|
+
|
|
44
|
+
2. Resolve all codes using `faostat_search_codes`:
|
|
45
|
+
- Resolve area codes: `faostat_search_codes(domain_code='<domain>', dimension_id='area', query='<name>')`
|
|
46
|
+
- Resolve item codes: `faostat_search_codes(domain_code='<domain>', dimension_id='item', query='<name>')`
|
|
47
|
+
- Handle `requires_confirmation` for every search -- present options and wait for user choice.
|
|
48
|
+
|
|
49
|
+
3. Pull data using `faostat_get_data`:
|
|
50
|
+
```
|
|
51
|
+
faostat_get_data(
|
|
52
|
+
domain_code='<domain>',
|
|
53
|
+
area='<codes>',
|
|
54
|
+
item='<codes>',
|
|
55
|
+
element='<filter_code>',
|
|
56
|
+
response_format='compact'
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Step 3: Prepare data
|
|
61
|
+
|
|
62
|
+
Extract from the query results:
|
|
63
|
+
- **Labels**: years (for time series) or entity names (for comparisons)
|
|
64
|
+
- **Datasets**: one dataset per series (e.g., one per country in a multi-country comparison)
|
|
65
|
+
- **Values**: numeric data points
|
|
66
|
+
- **Units**: the unit of measurement (tonnes, hectares, gigagrams CO2eq, etc.)
|
|
67
|
+
- **Title elements**: what is being shown, for whom, over what period
|
|
68
|
+
|
|
69
|
+
### Step 4: Generate the HTML chart
|
|
70
|
+
|
|
71
|
+
Create a standalone HTML file with the following structure and requirements:
|
|
72
|
+
|
|
73
|
+
**Color Palette (colorblind-friendly -- use these in order):**
|
|
74
|
+
```
|
|
75
|
+
#2196F3 (blue)
|
|
76
|
+
#FF9800 (orange)
|
|
77
|
+
#4CAF50 (green)
|
|
78
|
+
#E91E63 (pink)
|
|
79
|
+
#9C27B0 (purple)
|
|
80
|
+
#00BCD4 (cyan)
|
|
81
|
+
#FF5722 (deep orange)
|
|
82
|
+
#795548 (brown)
|
|
83
|
+
#607D8B (blue-grey)
|
|
84
|
+
#CDDC39 (lime)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**HTML Template Requirements:**
|
|
88
|
+
- DOCTYPE html with UTF-8 charset and viewport meta tag
|
|
89
|
+
- Chart.js loaded from CDN: `https://cdn.jsdelivr.net/npm/chart.js`
|
|
90
|
+
- A single `<canvas>` element for the chart
|
|
91
|
+
- Responsive: chart container should be `max-width: 900px; margin: 0 auto;`
|
|
92
|
+
- Chart must fill its container with `responsive: true` and `maintainAspectRatio: false`
|
|
93
|
+
- Chart container height: at least 500px
|
|
94
|
+
- Clean background: white or very light grey (#fafafa)
|
|
95
|
+
|
|
96
|
+
**Chart Configuration Requirements:**
|
|
97
|
+
- **Title**: descriptive, includes what is measured, for whom, and the time period. Use Chart.js plugin title: `plugins: { title: { display: true, text: '<title>', font: { size: 16 } } }`
|
|
98
|
+
- **Axes**: both axes must be labeled. Y-axis label must include the unit of measurement (e.g., "Production (tonnes)", "Emissions (Gg CO2eq)"). Use `scales: { x: { title: { display: true, text: '...' } }, y: { title: { display: true, text: '...' } } }`
|
|
99
|
+
- **Legend**: display with `plugins: { legend: { display: true, position: 'top' } }`
|
|
100
|
+
- **Tooltips**: enabled by default in Chart.js, ensure they show the value with appropriate precision
|
|
101
|
+
- **Data labels**: for bar charts with few bars (< 6), consider adding value labels
|
|
102
|
+
|
|
103
|
+
**Source Attribution (REQUIRED):**
|
|
104
|
+
Add a footer below the chart canvas:
|
|
105
|
+
```html
|
|
106
|
+
<p style="text-align: center; color: #666; font-size: 12px; margin-top: 10px;">
|
|
107
|
+
Source: FAOSTAT (FAO), accessed [current date]
|
|
108
|
+
</p>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Line Chart Specifics:**
|
|
112
|
+
- Use `tension: 0.3` for slightly smoothed lines
|
|
113
|
+
- Use `pointRadius: 3` for visible but not overwhelming data points
|
|
114
|
+
- Set `fill: false` unless showing area comparison
|
|
115
|
+
|
|
116
|
+
**Bar Chart Specifics:**
|
|
117
|
+
- Use `borderWidth: 1` with a slightly darker border color
|
|
118
|
+
- For grouped bars (multiple datasets), ensure `barPercentage` and `categoryPercentage` provide adequate spacing
|
|
119
|
+
- For horizontal bars, swap x and y axis configurations with `indexAxis: 'y'`
|
|
120
|
+
|
|
121
|
+
**Stacked Bar Specifics:**
|
|
122
|
+
- Set `scales: { x: { stacked: true }, y: { stacked: true } }`
|
|
123
|
+
- Use distinct colors from the palette for each stack segment
|
|
124
|
+
|
|
125
|
+
**Scatter Plot Specifics:**
|
|
126
|
+
- Use `pointRadius: 5` for visibility
|
|
127
|
+
- Add axis labels that clearly identify the two variables
|
|
128
|
+
- Consider adding a trend line if correlation is being demonstrated
|
|
129
|
+
|
|
130
|
+
### Step 5: Save and offer to open
|
|
131
|
+
|
|
132
|
+
1. Save the HTML file to a meaningful filename:
|
|
133
|
+
- Format: `faostat-<subject>-<chart-type>.html`
|
|
134
|
+
- Examples: `faostat-wheat-production-trends-line.html`, `faostat-emissions-comparison-bar.html`
|
|
135
|
+
- Save in the current working directory unless the user specifies otherwise.
|
|
136
|
+
|
|
137
|
+
2. Tell the user the file path and offer to open it in their default browser:
|
|
138
|
+
- On macOS: `open <filepath>`
|
|
139
|
+
- On Linux: `xdg-open <filepath>`
|
|
140
|
+
- On Windows: `start <filepath>`
|
|
141
|
+
|
|
142
|
+
### Step 6: Describe the chart
|
|
143
|
+
|
|
144
|
+
Provide a brief text description of what the chart shows:
|
|
145
|
+
- The main trend or comparison visible
|
|
146
|
+
- Any notable outliers or patterns
|
|
147
|
+
- What conclusions can be drawn
|
|
148
|
+
|
|
149
|
+
This ensures the insight is captured even if the user cannot view the chart immediately.
|
|
150
|
+
|
|
151
|
+
## Important Rules
|
|
152
|
+
|
|
153
|
+
- Always use `faostat_search_codes` before `faostat_get_data` to resolve codes. Never guess or hardcode codes.
|
|
154
|
+
- When `requires_confirmation` is true in a search result, always present options and wait for the user to choose.
|
|
155
|
+
- Use `response_format='compact'` for queries with multiple entities or time ranges.
|
|
156
|
+
- For `faostat_get_data`, use FILTER element codes (e.g., '2510'). For `faostat_get_rankings`, use DISPLAY element codes (e.g., '5510').
|
|
157
|
+
- Every chart MUST include source attribution: "Source: FAOSTAT (FAO), accessed [current date]"
|
|
158
|
+
- Use the colorblind-friendly palette defined above. Do not use default Chart.js colors.
|
|
159
|
+
- The HTML file must be fully standalone -- no external dependencies except the Chart.js CDN.
|
|
160
|
+
- Always include the source attribution line at the end of any text output as well.
|