weather-skill by mateeb11/weather-forecast
npx skills add https://github.com/mateeb11/weather-forecast --skill weather-skill使用两个免费 API 提供任意地点的当前天气和预报:
scripts/geocode.pyscripts/fetch_weather.pyscripts/geocode.py "<location>"。它返回包含 display_name、lat、lon 和一个 ambiguous 标志的 JSON。如果存在歧义,请让用户澄清。Provides current weather and forecasts for any location using two free APIs:
scripts/geocode.pyscripts/fetch_weather.pyscripts/geocode.py "<location>". It returns JSON with display_name, lat, lon, and an ambiguous flag. If ambiguous, ask the user to clarify.广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
scripts/fetch_weather.pyreferences/clothing_guide.md 并包含相关的穿衣建议。scripts/geocode.py将地点字符串转换为坐标。
python scripts/geocode.py "Tokyo"
python scripts/geocode.py "King Abdullah Financial District, Riyadh"
python scripts/geocode.py "Times Square, New York"
返回 JSON:
{
"display_name": "Tokyo, Japan",
"lat": 35.6764,
"lon": 139.6500,
"importance": 0.82,
"ambiguous": false
}
如果 ambiguous 为 true,则会包含一个 alternatives 列表——询问用户指的是哪一个。
scripts/fetch_weather.py获取给定坐标的天气数据。
# 仅当前天气状况
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution current
# 逐小时预报(适用于今天、明天、未来12小时、特定某天)
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution hourly
# 逐日预报(适用于多天范围、下周等)
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution daily
# 自定义时区(默认为"auto",使用地点所在时区)
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution hourly --timezone Asia/Tokyo
# 当用户询问过去天气时包含历史数据
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution daily --past-days 7
根据分辨率返回包含 meta、current、hourly 和/或 daily 部分的 JSON。
JSON 响应示例 (--resolution current):
{
"meta": {
"lat": 35.6764,
"lon": 139.65,
"timezone": "Asia/Tokyo",
"resolution": "current",
"forecast_days": 16,
"past_days": 0
},
"current": {
"time": "2026-02-25T14:00",
"temperature_c": 12.3,
"apparent_temperature_c": 10.8,
"weather_code": 1,
"weather_description": "Mainly clear",
"wind_speed_kmh": 14.2,
"humidity_pct": 48,
"precipitation_mm": 0.0
},
"hourly": null,
"daily": null
}
该脚本始终请求 forecast_days=16(最大预报范围)。仅在请求过去天气时使用 --past-days (0..92)。
智能体应解读用户的自然语言以确定三件事:
从查询中提取地点名称。示例:
"Jeddah""London""Tokyo""AlUla"如果未提及地点,请询问用户。
| 用户表述 | 分辨率 | past_days | 备注 |
|---|---|---|---|
| "now" / "current" / 未指定时间 | current (同时包含未来24小时逐小时数据) | 0 | 预报请求始终使用16天。 |
| "today" / "tonight" / "tomorrow" / "tomorrow morning" | hourly | 0 | 使用逐小时数据回答特定时间段。 |
| "this weekend" / "on Friday" / "hourly for next 12 hours" | hourly | 0 | 在响应中筛选返回的时间序列。 |
| "next 3 days" | hourly | 0 | 根据逐小时数据进行总结。 |
| "next 7 days" / "next week" / "first week of March" | daily | 0 | 从逐日数据中总结相关日期。 |
| "March" / "in April" / "05/01 to 06/30" | daily | 0 | 如果超出预报范围,请明确说明限制。 |
| "past weather" / "last 3 days" / "yesterday" | daily (或针对短时间窗口用 hourly) | 根据请求设置 | 如果用户只说"past"未指定天数,默认为 7。 |
用户可能以各种格式指定日期(MM/DD、DD/MM、"May 1st"、"1 March"等)——根据上下文进行解读,并相应地筛选返回的时间线。除非明确说明或暗示了其他年份,否则使用当前年份。
对于范围 > 3 天的情况使用 daily,对于较短窗口使用 hourly,对于即时查询使用 current(但仍包含逐小时数据以提供上下文)。
默认(未指定时间):当前状况 + 未来24小时逐小时预报。
记住: 预报固定为16天。对于过去请求,使用 past_days (0..92)。
检测用户是否计划去某个地方。查找关键词如:pack, wear, travel, visiting, going to, headed to, trip, vacation, holiday, outing, flight, should I bring
如果检测到出行意图 → 同时包含穿衣指南(见下文)。
用户: "What's the weather in Jeddah now?"
回复:
沙特阿拉伯吉达的天气
目前天气为晴朗,气温28°C(体感温度30°C)。北风轻拂,风速12 km/h,湿度45%。预计无降水。
接下来几小时:
- 下午 3 点:29°C,晴朗,降水概率 0%
- 下午 4 点:28°C,局部多云,降水概率 0%
- 下午 5 点:26°C,晴朗,降水概率 0% (依此类推...)
用户: "Forecast for London this weekend"
回复:
英国伦敦周末预报
周六,3月1日: 最高温11°C,最低温5°C。预计有中雨(概率70%,约4mm)。风速最高可达25 km/h。
周日,3月2日: 最高温13°C,最低温6°C。局部多云,降水概率20%。风力较轻,约15 km/h。
总体情况:周六有雨,周日转晴。周六请带好雨伞。
用户: "I'm going to Tokyo next week — what should I pack?"
回复:
日本东京 — 下周预报 (3月3日–9日)
日期 最高温 最低温 天气状况 降水概率 风速 周一 12°C 4°C 局部多云 10% 15 km/h 周二 10°C 3°C 小雨 65% 20 km/h ... ... ... ... ... ... 穿衣建议: 预计天气寒冷(最低温接近3°C),周中有雨。请打包:
- 保暖衣物:抓绒或羊毛衫 + 保暖夹克
- 周二/周三备好防水夹克和雨伞
- 防水闭口鞋
- 早晚可佩戴围巾和薄手套
参见:clothing_guide.md — 章节:寒冷、雨天
用户: "How windy will it be in AlUla on Friday?"
回复:
沙特阿拉伯欧拉 — 周五,2月28日 风力预报
风速将在午后达到峰值 35 km/h,傍晚时分降至约15 km/h。早晨风力较轻,约10 km/h。
⚠️ 预计中午时段风力中等偏强 —— 请固定好松散物品,如果户外活动请考虑穿防风衣。
当天气状况显著时,请包含警告:
当检测到出行意图时,请读取 references/clothing_guide.md 并在回复中包含相关建议。
地点未找到: 请用户提供更具体的信息(添加城市、国家)。
地点存在歧义: 提供备选方案并询问用户指的是哪一个。
API 故障 / 网络被阻止: 脚本返回一个 JSON 错误信封,而不是回溯信息:
{
"error": {
"code": "NETWORK_UNAVAILABLE",
"message": "无法连接到远程天气服务。",
"details": "URLError: ...",
"retryable": true,
"hint": "启用出站网络访问或以提升的权限重新运行。"
}
}
错误代码:
INVALID_INPUT:用户输入错误(无效的 past_days、缺少地点、无结果)。NETWORK_UNAVAILABLE:与上游天气 API 的 DNS/连接/超时问题。UPSTREAM_API_ERROR:上游 HTTP/API 响应问题。退出代码:
0:成功。1:用法或输入验证失败。2:网络/上游 API 故障。操作指南: 如果在沙箱中网络被阻止,请请求提升权限或从具有出站互联网访问权限的环境中运行脚本。
超出预报范围: 告知用户16天的限制,返回可用的预报信息。
未指定时间: 默认为当前天气 + 未来24小时预报。
每周安装次数
121
代码仓库
首次出现
2026年2月26日
安全审计
安装于
cursor118
gemini-cli118
github-copilot118
amp118
codex118
kimi-cli118
scripts/fetch_weather.py with the lat/lon and appropriate flags. See script usage below.references/clothing_guide.md and include relevant clothing advice.scripts/geocode.pyConverts a location string to coordinates.
python scripts/geocode.py "Tokyo"
python scripts/geocode.py "King Abdullah Financial District, Riyadh"
python scripts/geocode.py "Times Square, New York"
Returns JSON:
{
"display_name": "Tokyo, Japan",
"lat": 35.6764,
"lon": 139.6500,
"importance": 0.82,
"ambiguous": false
}
If ambiguous is true, an alternatives list is included — ask the user which they meant.
scripts/fetch_weather.pyFetches weather data for given coordinates.
# Current conditions only
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution current
# Hourly forecast (good for today, tomorrow, next 12 hours, specific day)
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution hourly
# Daily forecast (good for multi-day ranges, next week, etc.)
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution daily
# Custom timezone (default is "auto" which uses the location's timezone)
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution hourly --timezone Asia/Tokyo
# Include historical data when user asks about past weather
python scripts/fetch_weather.py --lat 35.6764 --lon 139.65 --resolution daily --past-days 7
Returns JSON with meta, current, hourly, and/or daily sections depending on resolution.
Example JSON response (--resolution current):
{
"meta": {
"lat": 35.6764,
"lon": 139.65,
"timezone": "Asia/Tokyo",
"resolution": "current",
"forecast_days": 16,
"past_days": 0
},
"current": {
"time": "2026-02-25T14:00",
"temperature_c": 12.3,
"apparent_temperature_c": 10.8,
"weather_code": 1,
"weather_description": "Mainly clear",
"wind_speed_kmh": 14.2,
"humidity_pct": 48,
"precipitation_mm": 0.0
},
"hourly": null,
"daily": null
}
The script always requests forecast_days=16 (max forecast horizon). Use --past-days only for past weather requests (0..92).
The agent should interpret the user's natural language to determine three things:
Extract the place name from the query. Examples:
"Jeddah""London""Tokyo""AlUla"If no location is mentioned, ask the user.
| User says | Resolution | past_days | Notes |
|---|---|---|---|
| "now" / "current" / no time specified | current (also include hourly for next 24h) | 0 | Forecast request always uses 16 days. |
| "today" / "tonight" / "tomorrow" / "tomorrow morning" | hourly | 0 | Use hourly data to answer specific time windows. |
| "this weekend" / "on Friday" / "hourly for next 12 hours" | hourly | 0 | Filter the returned series in the response. |
| "next 3 days" | hourly | 0 | Summarize from hourly data. |
| "next 7 days" / "next week" / "first week of March" | daily | 0 | Summarize relevant days from daily data. |
| "March" / "in April" / "05/01 to 06/30" | daily | 0 | If outside forecast horizon, clearly state limits. |
| "past weather" / "last 3 days" / "yesterday" | daily (or hourly for short windows) | set from request | If user says "past" without a number, default to 7. |
The user may specify dates in various formats (MM/DD, DD/MM, "May 1st", "1 March", etc.) — interpret based on context and filter the returned timeline accordingly. Use the current year unless another year is stated or implied.
Use daily for ranges > 3 days, hourly for shorter windows, current for right-now queries (but still include hourly for context).
Default (no time specified): current conditions + next 24 hours hourly.
Remember: Forecast is fixed to 16 days. For past requests, use past_days (0..92).
Detect if the user is planning to go somewhere. Look for keywords like: pack, wear, travel, visiting, going to, headed to, trip, vacation, holiday, outing, flight, should I bring
If travel intent is detected → also include clothing guidance (see below).
User: "What's the weather in Jeddah now?"
Response:
Weather in Jeddah, Saudi Arabia
Right now it's Clear sky with a temperature of 28°C (feels like 30°C). Wind is light at 12 km/h from the north, and humidity is at 45%. No precipitation expected.
Next few hours:
- 3 PM: 29°C, Clear sky, 0% rain
- 4 PM: 28°C, Partly cloudy, 0% rain
- 5 PM: 26°C, Clear sky, 0% rain (and so on...)
User: "Forecast for London this weekend"
Response:
Weekend Forecast for London, UK
Saturday, Mar 1: Highs of 11°C, lows of 5°C. Moderate rain expected (70% probability, ~4mm). Wind up to 25 km/h.
Sunday, Mar 2: Highs of 13°C, lows of 6°C. Partly cloudy, 20% rain chance. Lighter wind at 15 km/h.
Overall: A wet Saturday clearing into a drier Sunday. Bring an umbrella for Saturday.
User: "I'm going to Tokyo next week — what should I pack?"
Response:
Tokyo, Japan — Next Week Forecast (Mar 3–9)
Day High Low Conditions Rain Wind Mon 12°C 4°C Partly cloudy 10% 15 km/h Tue 10°C 3°C Slight rain 65% 20 km/h ... ... ... ... ... ... What to Wear: Expect cold conditions (lows near 3°C) with rain mid-week. Pack:
- Warm layers: fleece or wool sweater + insulated jacket
- Waterproof jacket and umbrella for Tuesday/Wednesday
- Closed-toe waterproof shoes
- Scarf and light gloves for mornings/evenings
See: clothing_guide.md — sections: cold, rainy
User: "How windy will it be in AlUla on Friday?"
Response:
Wind Forecast for AlUla, Saudi Arabia — Friday, Feb 28
Wind speeds will peak at 35 km/h in the early afternoon, settling to around 15 km/h by evening. Morning winds are lighter at ~10 km/h.
⚠️ Moderately windy conditions expected midday — secure loose items and consider a windbreaker if you'll be outdoors.
Include warnings when conditions are notable:
When travel intent is detected, read references/clothing_guide.md and include relevant advice in the response.
Location not found: Ask the user to be more specific (add city, country).
Ambiguous location: Present the alternatives and ask which one.
API failure / network blocked: Scripts return a JSON error envelope instead of a traceback:
{
"error": { "code": "NETWORK_UNAVAILABLE", "message": "Unable to reach remote weather service.", "details": "URLError: ...", "retryable": true, "hint": "Enable outbound network access or rerun with elevated permissions." } }
Error codes:
INVALID_INPUT: bad user input (invalid past_days, missing location, no results).NETWORK_UNAVAILABLE: DNS/connectivity/timeouts to upstream weather APIs.UPSTREAM_API_ERROR: upstream HTTP/API response issues.Exit codes:
0: success.1: usage or input validation failures.2: network/upstream API failures.Operational guidance: If network is blocked in a sandbox, request elevated permissions or run scripts from an environment with outbound internet access.
Beyond forecast horizon: Inform them of the 16-day limit, return what's available.
No time specified: Default to current + next 24 hours.
Weekly Installs
121
Repository
First Seen
Feb 26, 2026
Security Audits
Installed on
cursor118
gemini-cli118
github-copilot118
amp118
codex118
kimi-cli118
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
40,000 周安装
Meta AI Segment Anything Model (SAM) 零样本图像分割完整指南 | 安装使用教程
232 周安装
API模拟框架:开发测试必备的API Mock工具,支持契约验证与并行开发
233 周安装
数据库设计实战指南:规范化、索引优化与零停机迁移策略
228 周安装
零依赖前端幻灯片工具 - 创建动画丰富的HTML演示文稿,无需构建工具
230 周安装
使用 Playwright 编写 tldraw 端到端测试:完整指南与最佳实践
230 周安装
tldraw 单元测试与集成测试编写指南:Vitest 测试框架与 TestEditor 使用详解
234 周安装