From faostat-skills
Use when the user wants a short, FAOSTAT-style analytical brief — a multi-page PDF policy document in the FAOSTAT house visual style, with a HIGHLIGHTS box, global/regional/country sections, numbered figures with source lines, explanatory notes, and a data appendix. Use when the user asks for "an analytical brief on X", "a FAOSTAT-style brief", "a policy brief", "a FAO-style write-up", or a short policymaker-facing report. Keywords — analytical brief, policy brief, FAOSTAT brief, FAO-style, brief, briefing (policy), policymakers, short report (policy). Do NOT use for journalistic long-reads (use `faostat-story`), academic papers (forthcoming `faostat-scientific-paper`), or single-page visual summaries (forthcoming `faostat-infographic`).
How this skill is triggered — by the user, by Claude, or both
Slash command
/faostat-skills:analytical-briefThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Produce a multi-page PDF analytical brief in the FAOSTAT house visual style, with the corresponding multi-sheet xlsx data appendix so every figure and discussion point is reproducible.
Produce a multi-page PDF analytical brief in the FAOSTAT house visual style, with the corresponding multi-sheet xlsx data appendix so every figure and discussion point is reproducible.
Scope of the visual grammar (no FAO branding). The brief uses the FAOSTAT visual grammar — teal/dark-blue palette, serif titles, → arrow bullets, teal section banners, numbered figures with Source: FAOSTAT … lines, and the familiar section order (HIGHLIGHTS / BACKGROUND / GLOBAL / REGIONAL / COUNTRY / EXPLANATORY NOTES / NEXT RELEASE / REFERENCES). It does not reproduce the FAO logo, "Food and Agriculture Organization of the United Nations" masthead, ISSN strip, "FAO Statistics Division" stamp, "Required citation: FAO. …" line, or any other FAO branding. The output must be clearly attributable as a user-generated analysis, not an FAO publication.
Confirm the FAOSTAT MCP tools are available: faostat_get_data, faostat_search_codes, faostat_list_domains, faostat_get_metadata. If they are not, tell the user and stop.
Python packages (install on demand via pip install <pkg> --break-system-packages):
plotly, pandas, kaleido (figure rendering + PNG export, reused from faostat-map)reportlab (PDF assembly via Platypus)openpyxl (xlsx data appendix)The forthcoming figure renders compose on top of faostat-viz (line/bar/stacked-bar) and faostat-map (choropleths). When a brief needs a map, invoke the map skill's rendering guidance rather than reimplementing.
All 6 invariants from the FAOSTAT skill suite apply unchanged:
faostat_get_data takes FILTER codes (e.g., '2510'); never pass DISPLAY codes ('5510').'2010,2011,...,2024'); colon ranges return empty.faostat_get_data call.China (area 351) for country rankings, top-N lists and country-level analysis. Offer China, mainland (41) as an opt-in — do not substitute 41 unless the user asks for 41 explicitly. Flag the choice in the Methodology sheet, and include the caveat whenever a China number is quoted: FAOSTAT's own publications default to 41, so a brief using 351 will show a marginally larger "China" value than the FAO data-portal default. (Map figures inside the brief are an exception: they use the disaggregation path — area 41 on the CHN polygon with HKG / MAC / TWN rendered separately — because choropleths cannot sensibly render 351. See the map skill.)faostat_get_rankings HTTP-500 fallback. Reconstruct rankings from faostat_get_data + client-side sort; document fallback in the Methodology sheet.faostat_get_data call. Always resolve at runtime: faostat_search_codes(domain_code='<dom>', dimension_id='element', query='<metric name>') for elements; faostat_search_codes(domain_code='<dom>', dimension_id='item', query='<item name>') for items. Numeric codes shown in reference tables and code examples are verified hints — use them to validate the search result, not as the authoritative source. Domain letter-codes (QCL, TCL, GT, EM, FBS, FS…) are stable and may be used directly.Confirm or elicit from the user:
Produce an internal outline before any data pulls:
faostat-map.For each figure and table, plan a specific faostat_get_data call. Log every call for the Methodology sheet. Always:
response_format='compact'.show_unit=True.faostat_search_codes(domain_code='TCL', dimension_id='element', query='import quantity') → e.g. 2610; similarly for export quantity (~2910), import value (~2612), export value (~2912). Treat any numeric code here as a verified hint to validate against, not a value to pass directly.faostat_get_rankings; pull faostat_get_data for the domain and element (no area filter) and sort client-side, so an HTTP-500 from get_rankings doesn't block the brief.China (area 351) and drop 41 (mainland), unless the user opted into 41 explicitly. (Map figures inside the brief use the disaggregation path — area 41 + HKG 96 + MAC 128 + TWN 214 — because a choropleth cannot render 351 sensibly.)Pull the dataset metadata with faostat_get_metadata(domain_code=<D>) so EXPLANATORY NOTES can be auto-generated from the same source the FAOSTAT team uses.
In pandas, compute and store:
Keep the raw rows and the derived columns side-by-side for the xlsx appendix.
Use Plotly Express or Graph Objects with kaleido for static PNG export. Target:
scale=2 for line/bar/stacked-bar charts.scale=2 for choropleth maps (via faostat-map).#1F5E7B, dark blue #1A3A5F, warm grey #7F7F7F, accent ochre #D89B2E, accent green #4F8A3B.Source: FAO. YYYY. FAOSTAT: [Dataset name]. [Accessed MMM YYYY]. https://www.fao.org/faostat/en/#data/[DOMAIN]. Licence: CC-BY-4.0.Save PNGs under <outputs>/figures/fig<N>_<slug>.png.
Use ReportLab Platypus. Build a BaseDocTemplate with two page templates:
Cover page template — no FAO branding. Elements, top to bottom:
FAOSTAT ANALYTICAL BRIEF in small caps, teal, sans-serif (serial number omitted unless user supplied).Inside page template — teal header band with:
Body flow:
→, each carrying a hard number. Use <b> tags for the number. Render via Platypus Paragraph with custom bullet style.FAOSTAT [DOMAIN NAME] teal all-caps banner.BACKGROUND — 2–3 paragraphs of framing and policy context.GLOBAL — narrative + Figure 1.REGIONAL — narrative + Figure 2 (optionally Table 1 with regional indicators).COUNTRY — top-N narrative + Figure 4 (horizontal bar).faostat-map.EXPLANATORY NOTES — auto-generated from faostat_get_metadata covering the dataset scope, update cycle, coverage caveats, aggregation rules.NEXT RELEASE — single sentence with the next expected release window per FAOSTAT's update cadence.REFERENCES — DOI-linked bibliography.Figure rendering in Platypus:
story.append(Paragraph(f"<b>Figure {n}:</b> {caption}", fig_caption_style))
story.append(Image(png_path, width=16*cm, height=9*cm))
story.append(Paragraph(source_line, fig_source_style))
Typography:
#1A3A5F).#1F5E7B), all-caps.→ bullet marker.Subscripts. Never use Unicode subscripts (CO₂). Use Platypus XML markup: CO<sub>2</sub>.
Use openpyxl to write a workbook at <outputs>/<brief-slug>-data.xlsx with the following sheets. Every figure and every numeric claim in HIGHLIGHTS must trace back to a sheet row.
Required sheets:
README — brief title, pull date, scope, list of FAOSTAT domains/elements/years used, sheet index (sheet name + contents summary).Highlights_data — one row per HIGHLIGHTS bullet, columns: bullet_text, value, unit, source_sheet, source_row. This is the audit trail so any reviewer can check every headline number.Fig<N>_<slug> — one sheet per figure. Columns should match what was plotted (long form with area, year, element, item, value, unit as appropriate). Include any derived columns (CAGR, Δ, share) next to the raw ones.Tab<N>_<slug> — one sheet per in-brief table, same rows as rendered.Methodology — one row per faostat_get_data call, columns: call_id, domain, element_filter_code, item_codes, area_codes, year_list, response_format, timestamp_utc, notes (e.g., "China composite 351 used for country-level figures; area 41 dropped"; "map figure disaggregated China: 41 + HKG 96 + MAC 128 + TWN 214"; "get_rankings fallback via client-side sort on get_data").Sources — bibliography. Columns: id, citation, url, licence.Formatting conventions:
#1F5E7B, white text).0.0%), integers with thousands separator (#,##0), decimals where native.Link the xlsx from the brief footer: Data appendix: <brief-slug>-data.xlsx.
Replace every FAO-branded element with neutral author-and-source attribution:
Prepared by [user name / organisation] using FAOSTAT data.Suggested citation: [author], [year]. [Brief title]. Analytical brief based on FAOSTAT data, accessed [MMM YYYY]. — no "Required citation: FAO. …" line.Cover image: [source] — if using a stock or generic image, say so. Never use © FAO or FAO/<photographer>.Underlying data © FAO, used under CC-BY-4.0. https://creativecommons.org/licenses/by/4.0/.Save outputs to the session workspace:
<outputs>/<brief-slug>.pdf (primary)<outputs>/<brief-slug>-data.xlsx (required appendix)<outputs>/figures/fig<N>_<slug>.png (individual PNG figures)<outputs>/<brief-slug>.html (optional HTML sibling, if requested)Describe to the user:
Ask:
faostat-map).faostat_get_rankings HTTP 500. Use the faostat_get_data fallback (invariant 6). Log the fallback on the Methodology sheet.kaleido on demand and retry; if install still fails, fall back to the HTML sibling and tell the user the PDF path requires kaleido.Times-Roman / Helvetica without failing. Note the font fallback in the Methodology sheet.Provides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.
npx claudepluginhub berba-q/faostat-skills