npx skills add https://github.com/zc277584121/marketing-skills --skill github-traffic获取并分析 GitHub 仓库流量数据——页面浏览量、Git 克隆数、来源渠道、热门页面和星标增长情况。可选择生成 PNG 格式的趋势图表。
前提条件:
- 必须安装并认证
ghCLI- 需要目标仓库的 推送(写入)权限 —— GitHub 的流量 API 在只读权限下无法工作
matplotlib是可选的(用于生成 PNG 图表;如果不可用则回退到 ASCII 图表)
GitHub 仅提供 最近 14 天 的流量数据。为了跟踪更长时间段(30天、90天等)的趋势,脚本会将每次获取的数据存储在本地历史文件中(~/.github-traffic/<repo>_traffic.json)。需要定期快照才能积累历史数据。
建议:设置 cron 任务或 CI 计划定期运行快照命令:
# 通过 cron 每日快照(无输出,仅存储数据)
0 9 * * * python /path/to/scripts/github_traffic.py owner/repo --snapshot
Fetch and analyze GitHub repository traffic data — page views, git clones, referral sources, popular pages, and star growth. Optionally generate trend charts as PNG images.
Prerequisites:
ghCLI must be installed and authenticated- Push (write) access to the target repository is required — GitHub's Traffic API does not work with read-only access
matplotlibis optional (for PNG chart generation; falls back to ASCII if unavailable)
GitHub only provides the last 14 days of traffic data. To track trends over longer periods (30 days, 90 days, etc.), the script stores each fetch in a local history file (~/.github-traffic/<repo>_traffic.json).
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
python /path/to/skills/github-traffic/scripts/github_traffic.py <owner/repo>
这将:
gh api 获取当前流量数据~/.github-traffic/ 以进行历史跟踪# 生成 PNG 趋势图表(最近 30 天,默认)
python .../github_traffic.py owner/repo --chart
# 最近 7 天
python .../github_traffic.py owner/repo --chart --days 7
# 最近 90 天(需要积累的历史数据)
python .../github_traffic.py owner/repo --chart --days 90
# ASCII 图表(无需 matplotlib)
python .../github_traffic.py owner/repo --ascii
PNG 图表最多包含 3 个面板:
| 标志 | 默认值 | 描述 |
|---|---|---|
repo (位置参数) | 必需 | 仓库,格式为 owner/name |
--chart | 关闭 | 生成 PNG 趋势图表 |
--ascii | 关闭 | 强制输出 ASCII 条形图 |
--days | 30 | 图表中包含的天数 |
--history-dir | ~/.github-traffic/ | 历史数据存储目录 |
--output | <repo>_traffic.png | 图表图像输出路径 |
--snapshot | 关闭 | 仅获取和存储数据(不显示) |
# 快速流量摘要
python .../github_traffic.py zilliztech/memsearch
# 每周趋势图表
python .../github_traffic.py zilliztech/memsearch --chart --days 7
# 每月趋势图表,自定义输出路径
python .../github_traffic.py zilliztech/memsearch --chart --days 30 --output ./reports/traffic.png
# 仅存储快照(用于 cron 任务)
python .../github_traffic.py zilliztech/memsearch --snapshot
# 当 matplotlib 不可用时使用 ASCII 图表
python .../github_traffic.py zilliztech/memsearch --ascii --days 14
每次运行都会将当前的 14 天窗口数据合并到持久化的 JSON 文件 ~/.github-traffic/<owner>_<repo>_traffic.json 中。该文件包含:
要构建有意义的 30/90 天图表,请至少每 14 天运行一次脚本(最好是每天)。超过 14 天的间隔将在图表中显示为数据缺失。
GitHub 流量 API 需要仓库的 推送权限。这意味着:
如果遇到权限错误,请检查 gh auth status 并确保您的令牌具有 repo 作用域。
| 问题 | 解决方案 |
|---|---|
| "必须具有推送权限" 错误 | 您需要仓库的写入权限。检查 gh auth status。 |
| 图表仅显示 14 天数据 | GitHub 仅提供 14 天窗口期。定期运行 --snapshot 以积累历史数据。 |
| 未找到 matplotlib | 使用 pip install matplotlib 安装。或使用 --ascii 生成基于文本的图表。 |
| 某些日期无数据 | GitHub 可能不报告零流量的日期。这些空白是正常的。 |
每周安装数
89
仓库
首次出现
8 天前
安全审计
安装于
mcpjam89
antigravity89
kilo89
replit89
junie89
windsurf89
Recommended: set up a cron job or CI schedule to run the snapshot command periodically:
# Daily snapshot via cron (no output, just stores data)
0 9 * * * python /path/to/scripts/github_traffic.py owner/repo --snapshot
python /path/to/skills/github-traffic/scripts/github_traffic.py <owner/repo>
This will:
gh api~/.github-traffic/ for historical tracking# Generate PNG trend chart (last 30 days, default)
python .../github_traffic.py owner/repo --chart
# Last 7 days
python .../github_traffic.py owner/repo --chart --days 7
# Last 90 days (needs accumulated history)
python .../github_traffic.py owner/repo --chart --days 90
# ASCII chart (no matplotlib needed)
python .../github_traffic.py owner/repo --ascii
The PNG chart includes up to 3 panels:
| Flag | Default | Description |
|---|---|---|
repo (positional) | required | Repository in owner/name format |
--chart | off | Generate PNG trend chart |
--ascii | off | Force ASCII bar chart output |
--days | 30 | Number of days to include in chart |
--history-dir | ~/.github-traffic/ | Directory for historical data storage |
--output | <repo>_traffic.png | Output path for chart image |
--snapshot | off | Fetch and store data only (no display) |
# Quick traffic summary
python .../github_traffic.py zilliztech/memsearch
# Weekly trend chart
python .../github_traffic.py zilliztech/memsearch --chart --days 7
# Monthly trend chart, custom output path
python .../github_traffic.py zilliztech/memsearch --chart --days 30 --output ./reports/traffic.png
# Just store a snapshot (for cron jobs)
python .../github_traffic.py zilliztech/memsearch --snapshot
# ASCII chart when matplotlib is not available
python .../github_traffic.py zilliztech/memsearch --ascii --days 14
Each run merges the current 14-day window into a persistent JSON file at ~/.github-traffic/<owner>_<repo>_traffic.json. The file contains:
To build meaningful 30/90-day charts, run the script at least every 14 days (daily is ideal). Gaps longer than 14 days will show as missing data in charts.
The GitHub Traffic API requires push access to the repository. This means:
If you get a permission error, check your gh auth status and ensure your token has the repo scope.
| Problem | Solution |
|---|---|
| "Must have push access" error | You need write access to the repo. Check gh auth status. |
| Chart shows only 14 days | GitHub only provides 14-day windows. Run --snapshot regularly to accumulate history. |
| matplotlib not found | Install with pip install matplotlib. Or use --ascii for text-based charts. |
| No data for some dates | GitHub may not report days with zero traffic. These gaps are normal. |
Weekly Installs
89
Repository
First Seen
8 days ago
Security Audits
Installed on
mcpjam89
antigravity89
kilo89
replit89
junie89
windsurf89
前端代码审计工具 - 自动化检测可访问性、性能、响应式设计、主题化与反模式
49,600 周安装