gh-attach
Skill này làm gì
Công cụ này cho phép bạn tải lên và tải xuống file (như hình ảnh, PDF hoặc video) trên GitHub. Nó biến một file cục bộ thành liên kết có thể chia sẻ và xem trực tiếp trên GitHub, hoặc tải một file từ liên kết có sẵn.
Khi nào nên dùng
- ✓Khi bạn cần thêm hình ảnh hoặc tài liệu vào pull request (PR), issue hoặc bình luận trên GitHub.
- ✓Khi muốn nhúng hình ảnh so sánh trước và sau trong một dự án.
- ✓Khi bạn nhận được liên kết đến một tệp đính kèm trên GitHub và cần tải file đó về.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/gh-attach/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Đính kèm hình ảnh này từ máy tính của tôi vào issue #123.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ dùng một chương trình tên “gh-attach” để gửi file của bạn lên GitHub, tạo ra một liên kết. Liên kết này sau đó được thêm vào pull request, issue hoặc bình luận của bạn. Để tải xuống, bạn cung cấp liên kết và công cụ sẽ lưu file vào máy tính của bạ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 and download GitHub user-attachments (gh-attach)
GitHub has no public API for user-attachments. The web UI uses an internal
endpoint that mints github.com/user-attachments URLs whose visibility follows the
repository they belong to. gh-attach
(MIT, sudosubin) replicates that drag-and-drop flow as a gh CLI extension, so an
agent can upload a local file from the terminal, get a URL back, and later download
an attachment URL to a file.
Overview
This skill drives gh-attach to turn a local file (screenshot, image, PDF, zip,
log, or video) into a hosted GitHub user-attachments URL, then embeds that URL
into a pull request, issue, or comment. It also downloads an existing attachment
URL back to a local file. GitHub auto-renders the URL as an image, video, or file
wherever it is pasted, and the URL inherits the repository's visibility, so a
private-repo upload stays private. It works against GitHub Cloud and GitHub
Enterprise Server.
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"
- "Attach this file (PDF, zip, log, video) to the issue or comment"
- "Embed before/after screenshots" in a PR, issue, or README
- "Download this GitHub attachment" from a
user-attachmentsURL
How It Works
Step 1: Verify prerequisites
gh auth status # gh installed and authenticated
gh extension install sudosubin/gh-attach --pin v0.4.2 --force
gh extension list | grep -F 'sudosubin/gh-attach' # require the reviewed v0.4.2 release
Uploads use a GitHub user_session browser cookie, not the gh token (that
endpoint rejects tokens). By default gh must be authenticated so gh-attach can
select the matching browser account (Chromium family, Firefox family, or Safari).
If the wrong account is selected, add --browser <name> --profile <name>. Obtain
explicit approval before allowing the pinned extension to access that interactive
browser profile. Headless and CI uploads are intentionally unsupported: never export,
store, or pass a raw user_session cookie to the extension.
Step 2: Upload
# Use an absolute quoted path; -R is optional inside a repo working dir.
URL=$(gh attach "/abs/path/screenshot.png" -R <owner>/<repo>)
gh attach prints the URL on one line to stdout. For GitHub Enterprise Server,
use -R host/owner/repo. Capture the output; it is the embeddable reference.
Step 3: Embed into the PR / issue / comment
printf '## Screenshots\n\n%s\n' "$URL" \
| gh pr comment <pr> -R <owner>/<repo> --body-file -
Use gh pr edit, gh issue comment, or gh issue edit with --body-file - for
other targets. Always pass --body-file - (not inline --body) so multi-line
bodies and special characters cannot break shell quoting. GitHub auto-renders the
URL, so paste it as-is.
Step 4: Download
# Specify the destination explicitly.
gh attach download "$URL" -O "/abs/path/out.png"
Downloads of private attachments use the active gh token, with browser cookies as
an authorization fallback.
Examples
- Attach a screenshot to PR #42: upload the file, then append the URL under a
## Screenshotsheading in the PR body withgh pr edit ... --body-file -. - Embed before/after screenshots in a README: upload both files, paste the two URLs into the README at the relevant section.
- Download an attachment for review: run
gh attach download "$URL" -O out.zipto fetch auser-attachmentsfile locally.
Best Practices
- Resolve globs to absolute paths first, and quote paths that contain spaces or Unicode.
- For display sizing, embed an HTML tag instead of the bare URL:
<img width="800" src="$URL">. - Keep uploads interactive. Do not place a GitHub browser session in CI, an environment variable, a secret store consumed by this extension, or an agent log.
gh-attachcan upload multiple files concurrently and emit Markdown or JSON output with jq-style filtering when you need to script around the result.
Limitations
- Interactive session cookie required. A
user_sessioncookie grants full account access and is not scoped like a PAT. The supported path is the reviewed, pinned extension reading an explicitly approved local browser profile; CI and headless cookie injection are out of scope.
…
Câu hỏi thường gặp
File hiển thị trên GitHub như thế nào?
GitHub tự động hiển thị liên kết dưới dạng hình ảnh, video hoặc file, tùy thuộc vào loại nội dung. Nếu file nằm trong kho lưu trữ riêng tư, liên kết chỉ hoạt động với những người có quyền truy cập kho đó.
Tôi có cần cài GitHub trên máy tính không?
Có, bạn cần cài đặt chương trình “gh” và thiết lập để dùng công cụ này, vì nó hoạt động cùng với “gh”.
Tải file lên có an toàn không?
Có, miễn là bạn chỉ tải lên các file bạn định chia sẻ. File tải lên kho riêng tư vẫn ở chế độ riêng tư. Điều quan trọng là không bao giờ chia sẻ “user session cookie” mà công cụ dùng nội bộ, vì nó cấp toàn quyền truy cập vào tài khoản của bạn.
Chi tiết
Mô tả gốc của tác giả
Upload and download GitHub user-attachments (screenshots, PDFs, zips, videos) from the terminal; use when asked to attach or embed a file in a PR, issue, or comment, or download an attachment URL.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #6276
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
obsidian-vault-maintainer
394kGiúp agent của bạn giữ gọn kho ghi nhớ kiểu Obsidian, với liên kết wiki hoạt động tốt, thuộc tính nhất quán và các phần tự tạo an toàn.
wiki-maintainer
394kGiúp agent của bạn duy trì wiki bộ nhớ OpenClaw với các trang có thể lặp lại, khối được quản lý an toàn và kiểm tra mâu thuẫn hoặc thiếu sót.
obsidian
394kCho phép agent của bạn đọc, tìm, tạo và sửa ghi chú, công việc, liên kết và thuộc tính trong Obsidian bằng dòng lệnh Obsidian chính thức.