github-traffic
Fetch, store, and visualize GitHub repository traffic data (views, clones, referrers, stars) with trend charts. Requires repo push access.
What this skill does
# 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:**
> - `gh` CLI 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
> - `matplotlib` is 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:
```bash
# Daily snapshot via cron (no output, just stores data)
0 9 * * * python /path/to/scripts/github_traffic.py owner/repo --snapshot
```
---
## Default Workflow
```bash
python /path/to/skills/github-traffic/scripts/github_traffic.py <owner/repo>
```
This will:
1. Fetch current traffic data via `gh api`
2. Save a snapshot to `~/.github-traffic/` for historical tracking
3. Display a formatted summary (views, clones, referrers, popular pages)
---
## Generating Charts
```bash
# 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:
1. **Page Views** — total views and unique visitors (area chart)
2. **Git Clones** — total clones and unique cloners (bar + line chart)
3. **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
```bash
# 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 in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.