Chuyển đến nội dung
Skillpedia
Hình ảnh và biểu tượng48k · #6277

gh-image

Skill này làm gì

Công cụ này tải hình ảnh từ máy tính của bạn lên GitHub và tạo liên kết để có thể xem ở bất cứ đâu. Nó hữu ích để thêm ảnh chụp màn hình hoặc hình ảnh vào các dự án trên GitHub.

Khi nào nên dùng

  • ✓Khi bạn muốn thêm hình ảnh vào một pull request (PR) trên GitHub.
  • ✓Khi muốn đưa hình ảnh vào một issue hoặc bình luận trên GitHub.
  • ✓Khi muốn thể hiện trạng thái trước và sau của một thứ trong file README.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/gh-image/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/sickn33/agentic-awesome-skills/blob/main/skills/gh-image/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

“Đính kèm ảnh chụp màn hình này vào PR của tôi.”

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

Cách hoạt động

Công cụ tải hình ảnh lên GitHub và trả về một liên kết đặc biệt. Liên kết này sau đó được chèn vào nơi bạn muốn, như mô tả PR hoặc bình luậ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.

Upload images to GitHub (gh-image)

GitHub has no public API for image uploads — the web UI uses an internal endpoint that mints user-attachments URLs scoped to the repo's visibility. gh-image (MIT, © drogers0) replicates that flow as a gh CLI extension, so an agent can upload a local image from the terminal and get a ready-to-embed Markdown image line back.

Overview

This skill drives gh-image to turn a local image file into a hosted GitHub user-attachments URL, then embeds that URL into a pull request, issue, or comment. It is the missing "attach a screenshot" capability for terminal agents.

When to Use This Skill

Use this skill when asked to:

  • "Attach a screenshot to the PR" or "add an image to the PR description"
  • "Put this image in the issue" / "comment with these screenshots"
  • "Show the test results / before-and-after in the PR"
  • Embed any local image into GitHub Markdown without leaving the terminal

How It Works

Step 1: Verify prerequisites

gh auth status                                   # gh installed & authenticated
gh extension list | grep -q 'drogers0/gh-image' \
  || gh extension install drogers0/gh-image      # review/pin the extension source first

gh-image does not use the gh token for the upload (that endpoint rejects tokens). It needs a GitHub user_session cookie, resolved in this order: --token <value> flag → GH_SESSION_TOKEN env var (use in CI/headless) → a logged-in browser's cookie store (default for local use).

Step 2: Upload

# Use an absolute path; --repo is optional inside a repo working dir.
gh image "/abs/path/screenshot.png" --repo <owner>/<repo>

gh image prints Markdown to stdout, one line per image:

![screenshot.png](https://github.com/user-attachments/assets/<uuid>)

Capture that output — it is the embeddable reference.

Step 3: Embed into the PR / issue / comment

MD="$(gh image "/abs/path/shot.png" --repo owner/repo)"
BODY="$(gh pr view <pr> --repo owner/repo --json body -q .body)"
printf '%s\n\n## Screenshots\n\n%s\n' "$BODY" "$MD" \
  | gh pr edit <pr> --repo owner/repo --body-file -

Use gh pr comment, gh issue edit, or gh issue comment with --body-file - for other targets. Always pass --body-file - (not inline --body) so multi-line bodies and special characters can't break shell quoting.

Step 4: Verify

gh pr view <pr> --repo owner/repo --json body -q .body   # confirm URL present

Examples

  • Attach a CleanShot screenshot to PR #42: upload the file, append it under a ## Screenshots heading in the PR body.
  • Embed before/after images in a README: upload both, paste the two Markdown lines into the README at the relevant section.

Best Practices

  • Resolve globs to absolute paths first; quote paths with spaces/Unicode.
  • For display sizing, embed an HTML tag instead of bare Markdown: <img width="800" src="https://github.com/user-attachments/assets/<uuid>" />.
  • In CI, set GH_SESSION_TOKEN from a dedicated bot account.

Limitations

  • Session cookie required. A user_session cookie grants full account access (not scoped like a PAT) — treat it like a password; use a bot account in CI.
  • Write access to the target repo is required; orgs that enforce SAML SSO need the session authorized at https://github.com/orgs/<org>/sso first.
  • Private-repo images stay private: the user-attachments URL inherits repo visibility, so an anonymous fetch on a private repo returns 404/403 by design.
  • Windows + Chrome 127+ cannot read cookies (library limitation) — use another browser or GH_SESSION_TOKEN.
  • The skill embeds the Markdown itself; gh-image only prints the URL.
Câu hỏi thường gặp

Tôi có cần cài GitHub trên máy tính không?

Có, bạn cần cài đặt công cụ “gh” và cấu hình để dùng GitHub từ terminal.

Công cụ biết tải hình ảnh nào lên bằng cách nào?

Bạn cung cấp đường dẫn chính xác của hình ảnh trên máy tính khi đưa ra yêu cầu.

Hình ảnh được lưu trữ ở đâu?

Hình ảnh được tải lên GitHub và gắn với chế độ hiển thị của kho lưu trữ của bạn.

Chi tiết

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

Upload local images to GitHub and get canonical user-attachments embed URLs; use when asked to attach a screenshot to a PR, issue, or comment, or to embed before/after images in a README.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#6277
Giấy phép
MIT
Cập nhật
15/10/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ự