last-30-days-research
Research what people actually say about any topic in the last 30 days. Pulls posts and engagement from Reddit, X, YouTube, TikTok, Hacker News, Polymarket, GitHub, and the web. Includes a doctor health check to diagnose broken or missing sources.
1How It Works & Mechanism
This skill combines an extensive prompt contract with a multi-source Python engine: 2,394 lines of SKILL.md dictate how the model plans, invokes the engine, and synthesizes output, while scripts/last30days.py and its 98 lib modules handle the actual data fetching and aggregation (~62,000 lines of Python).
You are inside the `/last30days` SKILL. This is a specific research tool with a 1400+ line instruction contract (the rest of this file) that defines EXACTLY how to produce the research output. It is not a generic "last 30 days of X" research prompt. Do NOT treat `/last30days` as a search keyword you can improvise against.
The model is enforced to act as a "planner": named-entity topics require a model-generated --plan (a JSON query plan containing resolved handles/subreddits/hashtags), reserving the engine's internal planner strictly for headless/cron workflows.
**LAW 7 - YOU ARE THE PLANNER. `--plan` IS MANDATORY ON NAMED-ENTITY TOPICS.** If you are the reasoning model hosting this skill (Claude Code, Codex, Hermes, Gemini, or any agent runtime that invoked `/last30days`), YOU generate the JSON query plan. You do not need an API key, "LLM provider" credentials, or an external planning service - you ARE the LLM.
Engine invocations are strictly templated: always locate scripts/last30days.py via ${SKILL_DIR} relative to the currently loaded SKILL.md, produce readable output using --emit=compact, and persist reports under a unified --save-dir.
SKILL_DIR="<absolute path of the directory containing the SKILL.md you just Read>"
Output is treated as a rigid contract rather than prose: 11 LAW rules govern the first-line badge, titles, dash usage, paragraph structure, verbatim passthrough of engine footers, prohibition of dumping raw evidence blocks, and weaving community quotes; violations constitute measurable failures (exemplified by 0/8 regression logs).
**BADGE (MANDATORY, FIRST LINE OF OUTPUT):** The Python engine now emits the badge as the first line of its `--emit=compact` stdout. Your correct behavior is to PASS THROUGH the script's output verbatim.
Discovery and trending queries follow a 3-command "model-as-judge" protocol: nominate-only → judgments → finalize (with optional angles), delegating topic naming and editorial angles to the model while the engine handles aggregation and rendering.
"${LAST30DAYS_PYTHON}" "${SKILL_DIR}/scripts/last30days.py" --discover --nominate-only --save-dir="${LAST30DAYS_MEMORY_DIR}"
Several offline fast-paths bypass the live research pipeline: library search, library feed, and topic queue commands read directly from local SQLite / saved briefs without network access, model calls, or setup steps.
This is deterministic offline FTS over the existing saved-brief scanner plus per-run SQLite store sightings; it does not call a model or the network.
The security design explicitly front-loads access to sensitive resources: a mandatory `--preflight` check runs before the first research task, reading configuration, declaring planned browser cookie modes and target write paths, and listing available commands and endpoint overrides—without reading cookies, writing files, or executing research.
**2. Permission preflight.** Run `"${LAST30DAYS_PYTHON:-python3}" "${SKILL_DIR}/scripts/last30days.py" --preflight` using the directory of the `SKILL.md` you loaded, then summarize the human-readable result before setup: config source, project config trust/ignore state, planned browser-cookie mode, planned writes, optional commands, and active/ignored endpoint overrides. This is safe: it does not read browser-cookie values, does not write setup/config/report files, and does not run research.
API keys and browser cookies are handled via separate credential channels and remain disabled by default: keys resolve through env vars → global .env (~/.config/last30days/.env) → project .env (only if LAST30DAYS_TRUST_PROJECT_CONFIG=1) → macOS Keychain → 1Password; reading browser cookies is off by default (inactive unless FROM_BROWSER is set).
Default (FROM_BROWSER unset): no browser-cookie reads. The Chromium family (Chrome, Brave, Edge, Vivaldi, Opera, Arc, Chromium) is available only when explicitly selected because reading their cookies on macOS requires the browser's Safe Storage Keychain key, which triggers a system password prompt that cannot be reliably suppressed.
Credential writes follow a restricted flow: `setup --store-key <NAME>` reads a single line from stdin and writes to the global .env with 0o600 permissions, echoing back only NAME=**** and a single JSON line to stdout, ensuring secret values never leak into stdout/stderr.
Reads exactly one line from stdin (bounded to ``STORE_KEY_MAX_BYTES``), strips whitespace, and writes it to the global ``.env`` as a 0o600 secret through ``setup_wizard.write_api_key``. An existing line for the same name is replaced, so a rejected credential can be rotated by running the command again. The value never reaches stdout or stderr: stdout carries ``NAME=****`` plus a JSON line ``{"persisted": bool, "key": NAME}``.
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| cli | python3 ≥ 3.12(引擎自身;SKILL.md 用 ${LAST30DAYS_PYTHON:-python3} 调用) |
| cli | yt-dlp(YouTube 搜索与字幕;首次 setup 会尝试安装)、digg-pp-cli(Digg)、arXiv 与 Techmeme 的 Printing Press CLI |
| cli | agentcookie(Linux 上的外部 cookie sidecar,仅当 PATH 存在该命令且未设 AGENTCOOKIE=off 时启用) |
| cli | macOS `security`(Keychain 取密钥)与 openssl(Chromium cookie 解密)、`pass`(1Password/密码库取密钥) |
| api | ScrapeCreators(TikTok/Instagram/Threads/Pinterest/LinkedIn/YouTube 评论等;frontmatter 的 primaryEnv) |
| api | LLM/搜索类可选密钥(推理与规划回退用):OpenAI、xAI、Google/Gemini、OpenRouter、Perplexity、Brave、Exa、Serper、Parallel、Apify、GitHub token、X API bearer、XQUIK、BrightData |
| network | 免密钥公开端点(默认路径即可用):Reddit 公开 JSON/RSS、HN Algolia、Polymarket Gamma API、GitHub API、Arctic Shift、Bluesky、StockTwits、TruthSocial、Digg、r.jina.ai |
| network | HTML 简报托管发布(显式 --publish 才发;文档提醒页面默认公开可被索引) |
| package | 第三方 vendored 组件:scripts/lib/vendor/ 下的 X 搜索客户端(.skillignore 注明 'still installed') |
4Recommended Governance & Evidence
- 本地凭据 / 浏览器配置: Accessing user login cookies/sessions/keychains: Process environment variables and ~/.config/last30days/.env (overridable via LAST30DAYS_CONFIG_DIR, empty string activates no-config mode): YES
- scripts/: Executing local scripts or system commands: python3 scripts/last30days.py <subcommand> (invoked on every run; includes --preflight / --welcome / setup)
- 外部 API: Posting content, creating resources, or mutating data on external platforms: None
- 本地工作目录: File read/write and artifact emission: Persisting research artifacts: Markdown reports and {slug}-raw.md under --save-dir (defaults to $HOME/Documents/Last30Days)
5Second-Pass Verification
- [ok] skill 路径(任务书标『待定位』) — 实际相对路径 skills/last30days(仓库 skills/ 下仅此一个子目录)。frontmatter name 为 'last30days',与任务书展示名 'Last 30 Days Research'/slug 'last-30-days-research' 不同名——本报告 skill.name 保留 frontmatter 真值 'last30days',文件名按任务书 slug 输出。
- [ok] 『1400+ 行指令契约』的量级声明 — SKILL.md 实测 2394 行(含契约与实现细节),『1400+』是保守表述,未夸大;OUTPUT CONTRACT 段落确实前置在文件开头附近(v3.0.8 起从第 ~1094 行前移),与文档自述一致。
- [ok] 『模型是规划者(--plan)』是否被代码支持 — SKILL.md 规定命名实体主题必须带 --plan;引擎侧确实消费 --plan(文档另说明缺省时用内部 planner 或确定性回退,仅 headless/cron 路径)。文档同时记录了把引擎 stderr 的 'provider' 一词误读为『需要凭证』的真实事故,属可复核的工程记录。
- [discrepancy] 浏览器 cookie 读取的默认状态(第一遍若笼统写『会读浏览器 cookie』则夸大) — 第二遍核对 env.py:'Default (FROM_BROWSER unset): no browser-cookie reads.',FROM_BROWSER=off 亦返回空;Linux 侧 agentcookie 还需 PATH 存在该二进制且未设 AGENTCOOKIE=off,MacBook 之外的 box-chrome CDP 路径需人工登录。结论修正为『能力存在、默认关闭、需显式同意』,已在 security 与 capabilities 中如实表述(不作默认行为)。
- [ok] 密钥来源分层与项目配置信任策略 — env.py 明确 CONFIG_FILE = Path.home()/'.config'/'last30days'/'.env'(可用 LAST30DAYS_CONFIG_DIR 覆盖),项目 .env 需 LAST30DAYS_TRUST_PROJECT_CONFIG;Keychain 仅 Darwin + security 在 PATH,LAST30DAYS_SKIP_KEYCHAIN 可关;另有 pass(1) 通道与 LAST30DAYS_KEYCHAIN_ALIASES 别名支持。
- [ok] 权限预检的『安全』承诺是否属实 — permission_preflight.build() docstring 为 'Build a stable, secret-free permission preflight object.';pipeline.py 中 browser_cookies 的 reads_values 在 safe 模式下恒为 False;代码注释要求 safe=True(doctor/--diagnose/--preflight)保持无网络。与 SKILL.md 的『does not read browser-cookie values, does not write … and does not run research』一致。
- [ok] 发布到第三方托管是默认还是 opt-in — last30days.py 的 --publish 帮助文本写明 'Publish --emit=html output to ht-ml.app (explicit opt-in; public by default)';SKILL.md 在 library feed 段要求先向用户解释页面公开可被索引再执行。非默认行为。
- [discrepancy] 外部依赖数量(避免把文档链接当成调用点) — 第一遍若按 https:// 出现频次直接列依赖会把文档链接(如 github.com、nodejs.org、ffmpeg.org、example.com)算进去。第二遍逐条回落到代码调用点:api.scrapecreators.com / api.github.com / hn.algolia.com / gamma-api.polymarket.com / arctic-shift.photon-reddit.com / api.x.ai / api.openai.com / generativelanguage.googleapis.com / openrouter.ai / api.perplexity.ai / api.stocktwits.com / bsky.social / truthsocial.com / di.gg / r.jina.ai / api.ht-ml.app 为真实请求端点;github.com、nodejs.org、ffmpeg.org、example.com 等仅出现在文档字符串或占位示例,未计入。
6Verdict & Scenarios
41f1dd6604aec716…