github-traffic
zc277584121/marketing-skills
Fetch and visualize GitHub repository traffic data with trend charts and historical snapshots.
What is github-traffic?
Fetches GitHub repository traffic metrics (views, clones, referrers, stars) via the GitHub CLI and stores snapshots for long-term trend analysis. Use this to monitor repository engagement, generate traffic reports, and track growth over time. Requires push access to the target repository.
- Fetch current page views, git clones, referral sources, and popular pages from GitHub Traffic API
- Store daily snapshots in local history to build trends beyond GitHub's 14-day window
- Generate PNG trend charts showing views, clones, and star growth over configurable time periods
- Display ASCII charts as a fallback when matplotlib is unavailable
- Support scheduled snapshots via cron for continuous historical data collection
How to install github-traffic
npx skills add https://github.com/zc277584121/marketing-skills --skill github-traffic- GitHub CLI (gh) installed and authenticated with a token that has repo scope
- Push (write) access to the target repository—read-only access will fail with 403 error
- matplotlib (optional; falls back to ASCII charts if unavailable)
How to use github-traffic
- 1.Run `python .../github_traffic.py owner/repo` to fetch and display current traffic summary
- 2.Add `--chart` flag to generate a PNG trend chart: `python .../github_traffic.py owner/repo --chart`
- 3.Use `--days N` to customize the chart period (e.g., `--days 7` for weekly, `--days 90` for quarterly)
- 4.Set up a daily cron job with `--snapshot` flag to automatically store data: `0 9 * * * python /path/to/github_traffic.py owner/repo --snapshot`
- 5.Use `--ascii` flag to generate text-based charts when matplotlib is not installed
Use cases
- Monitor weekly or monthly traffic trends for a public repository to assess adoption
- Generate a traffic report chart to include in project documentation or share with stakeholders
- Set up daily cron snapshots to build a 90-day traffic history for long-term analysis
- Check referral sources and popular pages to understand how users discover your project
- Track star growth correlation with traffic spikes to measure marketing impact
- Repository owners and maintainers tracking project visibility
- Open-source project leads reporting on community engagement
- DevRel and marketing teams analyzing repository metrics
- Contributors with write access to repositories
github-traffic FAQ
GitHub's Traffic API only provides the last 14 days of data. To see longer trends, you must run the script regularly (daily is ideal) with the `--snapshot` flag to accumulate history in ~/.github-traffic/. Then use `--chart --days 30` or `--days 90` to visualize accumulated data.
You need push (write) access to the repository. Repository owners, admins, and collaborators with write/maintain roles have access. Read-only users and forkers cannot access the Traffic API and will receive a 403 error.
Yes. Use the `--ascii` flag to generate text-based bar charts. matplotlib is only required for PNG chart generation.
Add a cron job like `0 9 * * * python /path/to/github_traffic.py owner/repo --snapshot` to run daily. The `--snapshot` flag fetches and stores data without displaying output.
Check your GitHub authentication with `gh auth status` and ensure your token has the `repo` scope. If you don't have write access to the repository, you cannot use this skill.
Full instructions (SKILL.md)
Source of truth, from zc277584121/marketing-skills.
name: github-traffic description: Fetch, store, and visualize GitHub repository traffic data (views, clones, referrers, stars) with trend charts. Requires repo push access.
Skill: GitHub Traffic
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)
When to Use
- The user asks about repository traffic, page views, clone counts, or where visitors come from
- The user wants to see traffic trends over time (weekly, monthly, quarterly)
- The user wants to generate traffic report charts for sharing or documentation
- The user wants to periodically snapshot traffic data to build long-term history
Important: GitHub Traffic API Limitations
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). Regular snapshots are required to build up history.
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
Default Workflow
python /path/to/skills/github-traffic/scripts/github_traffic.py <owner/repo>
This will:
- Fetch current traffic data via
gh api - Save a snapshot to
~/.github-traffic/for historical tracking - Display a formatted summary (views, clones, referrers, popular pages)
Generating Charts
# 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:
- Page Views — total views and unique visitors (area chart)
- Git Clones — total clones and unique cloners (bar + line chart)
- Star Growth — star count over time (line chart, shown when multiple snapshots exist)
Script Options
| 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) |
Examples
# 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
History & Long-Term Tracking
Each run merges the current 14-day window into a persistent JSON file at ~/.github-traffic/<owner>_<repo>_traffic.json. The file contains:
- Daily views: date → {views, unique}
- Daily clones: date → {clones, unique}
- Star snapshots: date → star count
- Fetch metadata: timestamp, 14-day totals, stars, forks
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.
Permissions
The GitHub Traffic API requires push access to the repository. This means:
- Repository owners and admins: full access
- Collaborators with write/maintain role: full access
- Read-only users and forkers: no access (API returns 403)
If you get a permission error, check your gh auth status and ensure your token has the repo scope.
Troubleshooting
| 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. |
Related skills
More from zc277584121/marketing-skills and the wider catalog.

image-generation
Generate illustration images for articles and documentation with Codex-first, OpenAI, and Gemini fallback support.

jupyter-notebook-writing
Write Milvus Jupyter notebooks using Markdown-first workflow with jupyter-switch conversion.

md-to-feishu
Convert Markdown files to Feishu documents with automatic image uploading and Mermaid diagram rendering.

mermaid-to-gif
Convert Mermaid diagrams to animated GIFs with context-aware animation styles (progressive, highlight-walk, pulse-flow, wave).

mermaid-to-image
Convert Mermaid diagram code blocks to PNG images using mermaid.ink API.

raw-video-processing
Remove silent segments and speed up raw screen recordings with FFmpeg-based post-processing.