Fetch a matching XKCD comic and generate validated Markdown or HTML embed output for docs or terminal use.
You help users find one relevant XKCD comic and turn it into something immediately usable in a document or terminal. Your role is to resolve the comic request, validate the result, and generate clean Markdown or HTML output without dragging in complex dependencies.
Return one validated comic with a clear selection rationale, and reject fancy extras that need heavyweight tooling.
Use this skill when the user wants to:
https://c.xkcd.com/random/comic/README.md or another Markdown fileDefault behavior:
README.mdClassify the request — Determine whether the user wants latest, random, a numeric comic id, a direct XKCD URL, or an archive-based match from a phrase or description. Also determine the requested output mode: Markdown edit, terminal HTML, or both.
Resolve one comic — Use scripts/fetch_xkcd.py to retrieve the comic metadata and output snippets:
latest should use https://xkcd.com/info.0.jsonrandom should resolve through https://c.xkcd.com/random/comic/https://xkcd.com/archive/ and choose the nearest title match conservativelyValidate the result — Confirm that the comic page URL and image URL resolve with HTTP 200 before editing a document or presenting the HTML snippet. If validation fails, surface the failure explicitly instead of pretending the embed worked.
Generate the requested output — Use the returned snippets to produce one of:
Edit the target document when needed — If the user wants the comic embedded in Markdown:
README.mdHandle ASCII requests conservatively — Do not promise ASCII rendering by default. Reject it unless a relatively simple shell or Python script with only standard tooling can do the job. In this skill, ASCII output is intentionally rejected because rendering arbitrary PNG images reliably requires image-decoding or terminal-rendering dependencies that are outside the allowed simplicity bar.
Report the outcome — Summarize which comic was selected, why it was selected, what output was produced, what file was changed if any, and what validation succeeded.
scripts/fetch_xkcd.pyResolve a comic request, emit reusable snippets, and optionally validate the page and image URLs.
python3 skills/xkcd-says-what/scripts/fetch_xkcd.py latest --format json --validate
python3 skills/xkcd-says-what/scripts/fetch_xkcd.py random --format markdown-linked
python3 skills/xkcd-says-what/scripts/fetch_xkcd.py "subduction ocean crust" --format html-anchor --validate
python3 skills/xkcd-says-what/scripts/fetch_xkcd.py https://xkcd.com/2057/ --format html-image
Prefer --format json when the agent needs both the metadata and the ready-to-use snippets.
User: "Add a random XKCD comic to the README and also show me the HTML anchor."
Your approach:
python3 skills/xkcd-says-what/scripts/fetch_xkcd.py random --format json --validateREADME.md200Problem: Pretending archive search covers comic transcripts, alt text, or semantic understanding far beyond the archive title list.
Fix: Be explicit that archive-based search is title-driven and approximate. If confidence is low, say so.
Problem: Inserting Markdown or HTML before checking whether the comic page and image URL actually resolve.
Fix: Validate first, then edit the file or print the snippet.
Problem: Pulling in Pillow, ImageMagick, chafa, or other special clients just to force an ASCII output mode.
Fix: Reject ASCII rendering under this skill's constraints and explain that the feature exceeds the allowed complexity budget.
Use extended reasoning for:
| Task | Agent Type | When to Spawn |
|---|---|---|
| Repository doc update | general-purpose | When the embed needs to be inserted into multiple docs |
| Codebase exploration | explore | When the correct target Markdown file is unclear |
scripts/fetch_xkcd.py only when the request needs exact arguments or output formats| Source Skill | Source State | Leads to State |
|---|---|---|
| writing-skills | Workflow Step 6: Add reference assets | XSW1: Need a runnable helper for repeatable comic lookup |
| This State | Leads to Skill | Target State |
|---|---|---|
| XSW4: Need a polished Markdown destination after embedding | shields-badges | README polish after comic insertion |
| Skill | Relationship |
|---|---|
| writing-skills | Similar authoring conventions for maintaining the skill itself |
| do-nothing-scripting | Useful fallback when the user wants a manual script outline instead of immediate automation |
| shields-badges | Helps refine README presentation after the comic embed is added |
https://xkcd.com/<num>/info.0.json and the latest comic at https://xkcd.com/info.0.json.