AGENT SKILL

gh-attach-image

Upload local image or video files (screenshots, rendered diagrams, before/after comparisons, walkthrough recordings) so they render inline in a GitHub PR description, issue description, or PR/issue comment — without committing the files to the repo and without a browser session. Use this whenever a task calls for attaching, embedding, or including a screenshot/image/diagram/video in a GitHub PR or issue via `gh`, or when asked to "show" or "visually verify" a change and the result needs to land in a PR/issue body. Also use this if you're about to commit screenshot or video files into a repo just so they can be referenced by a raw.githubusercontent.com URL in a PR description, or about to create a gist for the same purpose — this skill is the correct, lighter-weight alternative to both of those workarounds. Also use this when an uploaded github.com/user-attachments URL returns 404 or looks broken: the upload usually did not fail, the URL only resolves once a saved PR/issue body or comment references it.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 1
Forks
0

01 前言 Front Matter

name
gh-attach-image
license
MIT
metadata
{ "version": "1.1.0" }
description
Upload local image or video files (screenshots, rendered diagrams, before/after comparisons, walkthrough recordings) so they render inline in a GitHub PR description, issue description, or PR/issue comment — without committing the files to the repo and without a browser session. Use this whenever a task calls for attaching, embedding, or including a screenshot/image/diagram/video in a GitHub PR or issue via `gh`, or when asked to "show" or "visually verify" a change and the result needs to land in a PR/issue body. Also use this if you're about to commit screenshot or video files into a repo just so they can be referenced by a raw.githubusercontent.com URL in a PR description, or about to create a gist for the same purpose — this skill is the correct, lighter-weight alternative to both of those workarounds. Also use this when an uploaded github.com/user-attachments URL returns 404 or looks broken: the upload usually did not fail, the URL only resolves once a saved PR/issue body or comment references it.

02 资源文件 9

03 SKILL.md 正文

Attaching images to GitHub PRs/issues via gh

The problem this solves

The official gh CLI has no flag for attaching images to a PR or issue body (gh pr create --image doesn't exist — it's an open, unimplemented feature request: cli/cli#12960, cli/cli#12788). Without this skill, the natural-seeming fallbacks are all worse:

  • Committing the image to the repo and linking its raw.githubusercontent.com URL — pollutes repo history with binary files that have nothing to do with the actual change, and doesn't work at all for private repos unless the viewer already has read access via git (still doesn't work for raw.githubusercontent.com on a private repo without a token in the URL).
  • Creating a Gist — works, but publishes the images to an external, separately-managed resource for what should be a self-contained PR.
  • Driving a real browser to paste/drag-drop the image — the actual mechanism GitHub's web UI uses, but it needs a real authenticated browser session; a computer-use-style browser tool that only clicks/types on page elements can't feed it real local file data.

GitHub's actual drag-and-drop upload hits an internal endpoint that turns out to accept a plain bearer token — no browser, no cookies, no session. That's what this skill uses.

Quick path: use the bundled script

node ${CLAUDE_SKILL_DIR}/scripts/ts/upload.ts implements the whole flow. Prefer it over reconstructing the curl calls by hand — it already handles content-type detection, URL encoding, and the two usage patterns below.

# Default: upload and print markdown lines — use this when the images need
# to go in a specific spot in a hand-crafted body (a table, a particular
# section) rather than a simple append.
node ${CLAUDE_SKILL_DIR}/scripts/ts/upload.ts --repo OWNER/NAME before.png after.png
# -> ![before](https://github.com/user-attachments/assets/<uuid>)
#    ![after](https://github.com/user-attachments/assets/<uuid>)

# Convenience: upload AND append to an existing PR/issue body under a heading
node ${CLAUDE_SKILL_DIR}/scripts/ts/upload.ts --repo OWNER/NAME --pr 42 screenshot.png

# Or post as a new comment instead of editing the body
node ${CLAUDE_SKILL_DIR}/scripts/ts/upload.ts --repo OWNER/NAME --issue 7 --comment diagram.png

Run node ${CLAUDE_SKILL_DIR}/scripts/ts/upload.ts with no arguments (or read the top of the file) for the full flag list — it also documents itself inline.

If the default mode is used (no --pr/--issue), the script prints the markdown lines and stops — you're then responsible for placing them into the body (e.g. building a full body file with Write, then gh pr edit N --repo OWNER/NAME --body-file file.md) and saving it. See the gotcha below for why the save step isn't optional.

Video works too — .mp4, .mov, and .webm are all recognized alongside the image extensions. For video the script prints a bare URL instead of ![alt](url), since that's what GitHub needs to render an inline <video> player (image markdown around a video URL shows a broken-image icon instead).

The mechanics, if you need to do this by hand

TOKEN="$(gh auth token)"
REPO_ID="$(gh api repos/OWNER/NAME --jq .id)"

# Write the auth header to a temp file — keeps the token out of process args.
AUTH_HDR="$(mktemp)"
printf 'Authorization: Bearer %s\n' "$TOKEN" > "$AUTH_HDR"

curl -s "https://uploads.github.com/user-attachments/assets?name=<filename>&content_type=<mime-type>&repository_id=${REPO_ID}" \
  -X POST \
  --header @"$AUTH_HDR" \
  -H "Accept: application/json" \
  --data-binary "@<local-file-path>"
rm -f "$AUTH_HDR"
# -> {"url":"https://github.com/user-attachments/assets/<uuid>"}

content_type is a standard MIME type: image/png, image/jpeg, image/gif, image/webp, image/svg+xml, image/apng for images, or video/mp4, video/quicktime, video/webm for video. Match it to the actual file — verified working for PNG and MP4; the others follow the same upload path GitHub's own UI uses so there's no reason to expect them to differ. For video, put the returned URL on its own line in the body rather than wrapping it in ![alt](url) — see the "Quick path" section above.

The one gotcha that looks like a bug but isn't

The returned URL 404s immediately after upload. This is not a failure — it's the same behavior as GitHub's own drag-and-drop: the asset is only "claimed" once something references its URL inside a PR/issue/comment body that actually gets saved. Upload alone leaves it in limbo.

The fix is always the same: make sure the markdown line (![alt](that url)) ends up inside a body you save via gh pr edit --body-file, gh issue edit --body-file, gh pr comment, or gh issue comment — then the URL starts resolving (302 → signed S3 URL → the actual image). Don't re-upload or try a different endpoint if the first check 404s; save the body first, then check again.

If you want to confirm it worked, don't just check for a 404 going away — follow the redirect and confirm the content type matches what you sent:

curl -sI -L "<the url>" | grep -i content-type

What NOT to do

Don't fall back to committing the images to the repo or creating a Gist "just to be safe" if this upload flow seems to fail — the 404-before-save behavior above is the most likely reason it looks broken, not an actual failure. If gh auth token errors, that means the caller isn't logged in (gh auth login) — don't paper over it by switching to a workaround; surface the actual error so it gets fixed at the source.

Testing note

This was empirically verified (curl request/response shape, the upload-then-404-until-claimed behavior, and the final resolved image content-type) against a real GitHub repo in August 2026. The endpoint is undocumented and internal to GitHub, so if it stops working entirely (not just the claim-behavior gotcha above), that's a sign GitHub changed something — fall back to telling the user to attach the image manually in the GitHub web UI rather than guessing at a new endpoint shape.

04 同仓库更多 Skills

dfadler
dfadler/agent-config

youtube-transcript

ALWAYS invoke before fetching a transcript, captions or description for a YouTube video, even when only asked how you would get them. Given a YouTube URL (youtube.com/watch, youtu.be, shorts), save the video's English auto-captions as plain text and its description to files with `yt-dlp`, and print the title, channel and duration. Use when asked to "get the transcript for this video", "grab the captions", "summarize this YouTube video", "put these videos' transcripts in an artifact", or when a YouTube link is pasted and its spoken content is needed. Do not drive the browser's transcript panel or try `youtube-transcript-api` first: both were tried and are slower or empty.

★ 1
dfadler
dfadler/agent-config

git-worktree-usage

Load this before pushing to, or opening a PR from, a branch whose earlier PR already merged (a squash merge leaves its commits off the default branch, so a new PR from it shows stale history), even when only advising: it defines the fresh-branch and cherry-pick fix. Create worktrees with the `EnterWorktree` tool, never raw `git worktree add`. Git worktree and branch mechanics for isolating non-trivial work: locking and the stale-worktree sweep, picking what to parallelize by file surface, the repo-wide `git stash` collision hazard and its `git restore` alternative, branch naming, catching a branch up to a moved `main` via merge (not rebase), CI/coverage gotchas after a merge, conflict-resolution escalation levels, and PR-splitting sequencing. Also ships two SessionStart hooks that self-heal a project's own symlinked-worktree-directory convention and auto-prune merged worktrees, and a commit-branch guard hook that asks before a git commit lands on the default or an unrelated checked-out branch. Use when creating, entering, or cleaning up a git worktree, including before starting work in an existing worktree that another session may be using; deciding how to parallelize agent sessions across a repo; hitting a `git stash` collision between sessions; resolving a merge/rebase conflict; splitting an already-written diff into multiple PRs; or a stale or wrongly-linked worktree directory needs diagnosing. Do not use for a plain `git stash` in a single clone with no other worktrees or sessions, for rewriting an unpushed branch's history, or for running commands in a worktree the user just created.

★ 1
dfadler
dfadler/agent-config

url-to-audio

ALWAYS invoke before answering any request to narrate or convert a URL or article to audio, even when only asked what you would do or which backend you would use (including when `OPENAI_API_KEY` is unset and the fallback is `say`). Turn a web article into a narrated audio file: fetch the page, extract the clean reading text, and synthesize it with macOS `say` by default (free, local, already installed, no API key) or OpenAI TTS optionally (when `OPENAI_API_KEY` is set and a `say` voice isn't good enough). Voice and speed are configurable per call, with env var defaults. Produces a `.m4a`/`.mp3` file at a predictable path and prints it. Use when asked to "read this article to me", "convert this page/URL to audio", "make an audio version of this link", or "text-to-speech this article" — including when asked only for the commands or plan, or when `OPENAI_API_KEY` is unset.

★ 1
dfadler
dfadler/agent-config

subagent-orchestration

Use FIRST, before answering or planning, whenever the user hands over a list of two or more separate tasks ("do A, B and C", numbered or in no order) that each need real exploration, even if they only ask how you would tackle them: it triages which can run as parallel sub-agents and which must stay serial. Also use when asked how to configure a sub-agent already chosen for a large search or exploration (agent type, model tier), and when about to spawn a sub-agent, fan out with the Workflow tool, or run a task that would put large tool output (more than ~50 lines, or ~3 file reads) into the main context. Routes the work to the main context, a single Agent call, or a Workflow; defines the compact handback a delegated agent should return; and picks the model tier. Use for "should I delegate this", "which agent do I use", or "keep my context small".

★ 1
dfadler
dfadler/agent-config

config

Internal primitive that reads YAML frontmatter from vault config files via mcp__obsidian__* tools, and returns it as merged key-value data. Not a user-facing slash command — this skill is never triggered by a user request directly; other agent-config skills (screen-capture, and second-brain's own capture/query skills) invoke it to load their own settings. Degrades to an empty config, never a hard failure, when the Obsidian MCP is disconnected or the config file doesn't exist. Parse `$ARGUMENTS` as `<skill-name> [project-name]`.

★ 1
dfadler
dfadler/agent-config

lighthouse

Run a Lighthouse CLI pass (mobile + desktop) against a URL and store the results in the second-brain vault under knowledge/lighthouse/<project>/. ALWAYS invoke this skill first when asked to run, repeat or script a Lighthouse pass or performance/accessibility audit against a URL, before writing any `lighthouse` command, including when the config disables it (it defines the no-op behaviour). Complements, not replaces, a manual responsive resize-and-look pass. Not for advice about fixing a Lighthouse finding. Config-driven: which form factors run, whether the skill runs at all, and where results land are all controlled by lighthouse_enabled, lighthouse_form_factors, and lighthouse_output_dir.

★ 1