Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)33k · #8855

star-history-chart

Skill này làm gì

Skill này thiết lập biểu đồ lịch sử sao trong README của kho mã, không phụ thuộc vào dịch vụ biểu đồ bên ngoài. Skill dành cho người duy trì mã nguồn mở muốn cho thấy sự phát triển của dự án.

Khi nào nên dùng

  • ✓Khi bạn muốn có biểu đồ số sao theo thời gian hiển thị trong README GitHub.
  • ✓Khi ảnh biểu đồ sao của bên thứ ba không còn tải được cho kho mã của bạn.
  • ✓Khi bạn muốn biểu đồ được làm mới tự động mỗi tuần bằng GitHub Action.

Liên kết skill

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/git/star-history-chart/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/git/star-history-chart/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thêm biểu đồ lịch sử sao vào README của dự án tôi, để nó tự cập nhật mỗi tuần.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent sao chép một script và một file workflow GitHub vào kho mã của bạn. Workflow dùng token của chính kho để lấy số sao, vẽ SVG theme sáng và tối, rồi commit lại hằng tuần.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Star History Chart (self-hosted, never breaks)

Add a "Stargazers over time" chart that renders from a static SVG committed to the repo and refreshes itself weekly — no external chart service, no broken images.

Why this exists

GitHub now restricts the /stargazers endpoint to a repository's own admins and collaborators. Unauthenticated requests return {"message":"Requires authentication"}, which breaks every third-party live-chart service (star-history.com free tier, starchart.cc, etc.) for all repos. The only reliable fix is to generate the chart yourself with an authenticated token and commit a static image. Inside GitHub Actions, the repo's own GITHUB_TOKEN can read its own stargazers, so the whole thing runs with zero secrets to configure.

What this skill sets up

  1. scripts/generate_star_history.py — fetches stargazers (authenticated), renders a clean, light/dark-adaptive SVG.
  2. .github/workflows/star-history.yml — weekly cron + manual trigger that regenerates and commits docs/star-history.svg.
  3. A README section pointing at the local SVG.

Workflow

Step 1: Copy the script and workflow into the repo

mkdir -p scripts .github/workflows docs
cp skills/git/star-history-chart/scripts/generate_star_history.py scripts/generate_star_history.py
cp skills/git/star-history-chart/assets/star-history.yml .github/workflows/star-history.yml

The script needs the requests package: pip install requests. It resolves the repo from STAR_HISTORY_REPO, then GITHUB_REPOSITORY (set automatically in Actions), then the origin git remote — so no edits are required for it to work in a different repo.

Step 2: Generate the SVG once, locally

Use a token that can read the repo's stargazers (as owner/collaborator). The GitHub CLI provides one:

GITHUB_TOKEN=$(gh auth token) python scripts/generate_star_history.py

This writes docs/star-history.svg. For a repo with many thousands of stars the first run paginates the whole stargazer list and can take a couple of minutes.

Verify it rendered (optional, macOS): qlmanage -t -s 800 -o . docs/star-history.svg

Step 3: Add it to the README

Add or replace the star chart section. Point the image at the local SVG. Set the link target to wherever you want clicks to go (the repo, a docs page, or your own site):

## Stargazers over time
[![Stargazers over time](docs/star-history.svg)](https://github.com/OWNER/REPO/stargazers)

If replacing a broken star-history.com / starchart.cc embed, swap only the image URL to docs/star-history.svg and keep or update the link target.

Step 4: Commit

git add scripts/generate_star_history.py .github/workflows/star-history.yml docs/star-history.svg README.md
git commit -m "feat(readme): self-hosted stargazers chart with weekly auto-refresh"
git push

Step 5: (Optional) Trigger the auto-refresh now

The workflow runs every Monday at 04:00 UTC. To refresh immediately without waiting: GitHub → Actions → "Update Star History" → Run workflow.

Customization

  • Output path — set STAR_HISTORY_OUTPUT (default docs/star-history.svg).
  • Different repo — set STAR_HISTORY_REPO=owner/name.
  • Colors / size — edit the .line, .area, .dot CSS and WIDTH/HEIGHT constants near the top of generate_star_history.py. The chart is theme-aware via a prefers-color-scheme: dark block, so it looks right in both GitHub light and dark modes.
  • Refresh cadence — edit the cron expression in the workflow.

Notes

  • No secrets to add: the workflow uses the automatic GITHUB_TOKEN.
  • Private repos work too, as long as the token can read the repo.
  • The script uses only requests plus the Python standard library.
Câu hỏi thường gặp

Tại sao không dùng trang biểu đồ trực tuyến?

Skill giải thích rằng GitHub hiện chỉ cho quản trị viên kho xem dữ liệu người đánh dấu sao, nên nhiều dịch vụ biểu đồ bên ngoài bị lỗi với mọi người.

Có cần thêm khóa bí mật không?

Skill cho biết workflow chạy bằng token của chính kho trong GitHub Actions, nên không cần cấu hình thêm bí mật nào.

Những gì được thêm vào dự án của tôi?

Một script, một file workflow hằng tuần, một file SVG được tạo trong thư mục docs, và một phần README trỏ đến biểu đồ.

Chi tiết

Mô tả gốc của tác giả

Add a self-hosted "Stargazers over time" chart to any GitHub repo's README. GitHub now restricts the stargazers endpoint to a repo's own admins/collaborators, so third-party live services (star-history free tier, starchart.cc) return "Requires authentication" for everyone. This generates a static, theme-aware SVG in-repo and auto-refreshes it weekly with a GitHub Action using the repo's own GITHUB_TOKEN. Use when the star chart in a README is broken, shows "Requires authentication", or you want a star history that never breaks.

repo: davila7/claude-code-templates

Độ phổ biến

Sao GitHub
33k
Vị trí xếp hạng
#8855
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự