diff --git a/AGENTS.md b/AGENTS.md index cec01cc..d1af12b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,7 +42,8 @@ only skills; commands, agents or hooks may follow. Apache-2.0, ...). List any local edit to a copied skill in `NOTICE`. Before adding, read the whole skill: no hidden instructions, no `curl | sh`, no unexpected hosts. - **Skills written here** (`github-pages`, `github-apps`, `repo-badges`, - `github-mcp-config`, `security-advisories`, `workflows-actions-reuse`): only for a topic with + `github-mcp-config`, `security-advisories`, `workflows-actions-reuse`, + `github-markdown`): only for a topic with no upstream skill worth copying. They are MIT under the repo's `LICENSE`, so they have no `LICENSE.txt`, `metadata.upstream` or `NOTICE` entry, and the upstream sync skips them. Before merging a new one or a large change, test it the superpowers `writing-skills` way: give the same tasks diff --git a/README.md b/README.md index 5fed702..83c4b63 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ may follow. | `pull-request-code-review` | Reviewing someone else's PR: reading the diff in context, a batched pending review with line comments, choosing the verdict (GitHub MCP tools) | [github/github-mcp-server](https://github.com/github/github-mcp-server) | | `pull-request-review-feedback` | Working through review threads on your PR: decide, reply, resolve only what is settled (GitHub MCP tools) | [github/github-mcp-server](https://github.com/github/github-mcp-server) | | `repo-badges` | README badges: GitHub status badges, shields.io static badges and logos (Simple Icons, svgl fallback), and badges rendered in CI with a pinned renderer onto an orphan `badges` branch, with no badge service | this repo | +| `github-markdown` | GitHub-only Markdown: when to use it vs plain Markdown, alerts, footnotes, heading anchors, where `#123` and SHAs autolink, mentions, closing keywords, stripped HTML, `
`, ``, Mermaid and math | this repo | | `github-mcp-config` | Adding GitHub's official MCP server when a skill needs its tools and none is configured: check for an existing one, remote (PAT, or OAuth on Copilot hosts) vs local (OAuth without a token), per-harness token syntax, toolsets and read-only | this repo | | `security-advisories` | Handling vulnerabilities on GitHub: private vulnerability reporting, SECURITY.md, editing the reported draft advisory, temporary private fork, CVE request, credits, publishing, when Dependabot alerts, reporting upstream | this repo | | `gh-attach` | Uploading screenshots and files to PRs, issues and comments, and downloading attachments, with the `gh attach` extension | [sudosubin/gh-attach](https://github.com/sudosubin/gh-attach) | diff --git a/skills.sh.json b/skills.sh.json index b54dc2b..54e2b4a 100644 --- a/skills.sh.json +++ b/skills.sh.json @@ -50,10 +50,11 @@ }, { "title": "Repositories and hosting", - "description": "Pages, README badges and Codespaces.", + "description": "Pages, README writing and badges, and Codespaces.", "skills": [ "github-pages", "repo-badges", + "github-markdown", "github-codespaces-efficiency" ] } diff --git a/skills/github-markdown/SKILL.md b/skills/github-markdown/SKILL.md new file mode 100644 index 0000000..3975e24 --- /dev/null +++ b/skills/github-markdown/SKILL.md @@ -0,0 +1,58 @@ +--- +name: github-markdown +description: 'Use only when a GitHub-specific Markdown question comes up, usually while editing a repo''s root README.md, an issue or PR template, or an issue, PR or comment body: alerts, footnotes, task lists, heading anchors, #123 and SHA autolinks, @mentions, closing keywords,
, for dark mode, raw HTML that GitHub strips, Mermaid, math. Not needed for plain Markdown.' +metadata: + version: "0.2.2" +--- + +# GitHub Markdown + +Plain CommonMark is assumed knowledge. This covers only what github.com adds or changes. + +## GFM or plain Markdown? + +Go down the list and stop at the first match: + +1. The user, AGENTS.md or CLAUDE.md says which to use: do that. +2. The repo's root `README.md`: use GitHub features where they help. +3. Text shown only on github.com (issue and PR bodies, comments, discussions, release notes, + `.github/ISSUE_TEMPLATE/*`, `.github/pull_request_template.md`): use GitHub features. +4. Any other Markdown file (`docs/`, `CHANGELOG.md`, `AGENTS.md`, `SKILL.md`, anything a site + generator or another tool renders): tables, strikethrough, task lists and bare URLs only. + No alerts, footnotes, Mermaid, math, `
` or other github.com-only features. + +Creating a new README or template under rule 2 or 3 with nothing under rule 1: write it with +GitHub features and ask the user in one line whether that is OK. + +## Quick reference (github.com only unless noted) + +| Feature | Syntax and gotchas | +|---|---| +| Alerts | `> [!NOTE]`, `[!TIP]`, `[!IMPORTANT]`, `[!WARNING]`, `[!CAUTION]` on the first quote line. One or two per page, not nested. | +| Footnotes | `text[^1]` and `[^1]: note` anywhere; rendered at the bottom. Not in wikis. | +| Heading anchors | Lowercase; **every word kept**; each space becomes `-`; other punctuation dropped (so ` & ` leaves `--`); formatting markers removed; non-ASCII letters kept; repeats get `-1`, `-2`. `## Use a _CLI_ & the API, v2!` is `#use-a-cli--the-api-v2`. | +| Line breaks | In `.md` files a single newline is not a break: end the line with `\` (visible). Avoid two trailing spaces, which work but are invisible in most editors. In issues, PRs and comments a newline is a break. | +| Links | Write `[label](url)`. Use `` only when the label should be the URL itself. Never leave a bare URL, even where GitHub would autolink it. | +| Underline, sub, sup | ``, ``, `` | +| Relative links | Resolve against the current branch; `/` starts at the repo root. Prefer them for repo files and images. | +| Task lists (all renderers) | `- [ ]`, `- [x]`; escape a leading paren: `- [ ] \(Optional)`. | +| Tables (all renderers) | Blank line before; `---` per column; escape `\|`, even inside code spans. | + +## References, mentions and keywords + +- `#26`, `GH-26`, `owner/repo#26`, a full SHA and `owner/repo@sha` autolink **only in issues, + PRs, discussions and comments**. In repo files and wikis they are plain text: write explicit + links. +- `@name` and `@org/team` notify people. Put non-user `@` text (`@types/node`, npm scopes) in + backticks. +- `Closes #N` (also close/fix/resolve in any tense) in a PR body closes the issue on merge. + +## More detail + +- Raw HTML, what github.com strips, `
`, ``, centering and image sizing: + [references/html.md](references/html.md) +- Mermaid, maps, STL, math, code fences: [references/diagrams-math.md](references/diagrams-math.md) +- All autolink forms, unfurling, backlinks, label chips, color chips: + [references/autolinks.md](references/autolinks.md) +- Color, styled text, multi-column layout or animation without CSS (MathJax, Mermaid, + animated SVG): [references/fancy-tricks.md](references/fancy-tricks.md) diff --git a/skills/github-markdown/references/autolinks.md b/skills/github-markdown/references/autolinks.md new file mode 100644 index 0000000..61231fb --- /dev/null +++ b/skills/github-markdown/references/autolinks.md @@ -0,0 +1,45 @@ +# Autolinks, references and mentions on GitHub + +## Where they work + +Issue, PR, discussion and commit-message text. **Not** in repo files (README.md included) or +wikis, which only autolink bare URLs (`https://...`, `www....`): there, write explicit links. +Everywhere, write URLs as `[label](url)` or ``, not bare (see the Links row in SKILL.md). + +## Forms + +| Write | Links to | +|---|---| +| `#26`, `GH-26` | issue or PR 26 in this repo | +| `owner/repo#26` | issue or PR in another repo | +| full 40-char SHA, or a 7+ char prefix | commit in this repo | +| `user@sha`, `owner/repo@sha` | commit in a fork or another repo | +| issue, PR or commit URL | shortened to the forms above | +| `https://github.com/o/r/labels/name` | label chip (same repo only; not if the name has a `.`) | +| `` `#0969DA` ``, `` `rgb(9,105,218)` ``, `` `hsl(212,92%,45%)` `` | color swatch (issues, PRs, discussions only; no spaces inside the backticks) | + +Only these forms link: prefixed forms such as `pr#3` or `issue#1` stay plain text. +Custom autolinks (JIRA keys and so on) work only if a repo admin configured them. + +**Create the target first.** A reference links only if the issue or PR (in that repo, for +`owner/repo#N`) already exists when the comment is posted or the commit is pushed. Creating it +later does not link the earlier text, so open the issue before writing `#N` or `Closes #N`. + +## Behavior to expect + +- A reference that is the whole text of a list item unfurls to the title and state. +- Linking an issue or PR creates a backlink on the target. Use + `https://redirect.github.com/...` instead of `https://github.com/...` to avoid it (not on + `ghe.com` data-residency hosts). +- `@user` and `@org/team` notify them (only if they can read the repo); editing a mention into + a comment also notifies. Backtick any `@` text that is not a person to notify. + +## Keywords + +- In a PR body, a commit message in the PR, or a commit pushed to the default branch: `close`, `closes`, `closed`, `fix`, + `fixes`, `fixed`, `resolve`, `resolves`, `resolved` + `#N` or `owner/repo#N` closes the issue + on merge. One keyword covers a comma-separated list on the same line: `Closes #1, #2` (spaces + around the comma are fine). + Anything else ends the list: `Closes #1 and #2` closes only #1, a doubled comma drops the + next issue, and a keyword after the references (`#1, #2 closes them`) closes none. +- `Duplicate of #N` as a comment marks a duplicate. diff --git a/skills/github-markdown/references/diagrams-math.md b/skills/github-markdown/references/diagrams-math.md new file mode 100644 index 0000000..eacb41a --- /dev/null +++ b/skills/github-markdown/references/diagrams-math.md @@ -0,0 +1,27 @@ +# Diagrams, math and code fences on GitHub + +All of these render in `.md` files, issues, PRs, discussions and wikis. Other renderers mostly +show them as plain code blocks. + +## Diagrams and maps (fence language decides) + +| Fence | Renders | +|---|---| +| `mermaid` | Mermaid diagram (flowchart, sequence, pie, ...). A block holding only `info` shows the Mermaid version GitHub runs. | +| `geojson`, `topojson` | Interactive map | +| `stl` | 3D model viewer (ASCII STL) | + +## Math (MathJax) + +- Inline: `$x^2$`, or `` $`x_1 * y_1`$ `` when the expression contains Markdown characters. +- Block: `$$...$$` on its own line(s), or a ```` ```math ```` fence (no `$$` needed). +- A literal `$` inside an expression: `\$`. Outside one but on the same line: + `$`. +- In `.md` files, text right before an inline-started `$$` block needs a line break (`\`). + +## Code fences + +- Highlighting uses Linguist language names (`ruby`, `sh`, `powershell`). Use lower-case names + if the file also builds on GitHub Pages (Jekyll). +- Show a fence inside a fence by using a longer one outside (four backticks around three). +- Indented (non-fenced) code inside a list item needs eight spaces. diff --git a/skills/github-markdown/references/fancy-tricks.md b/skills/github-markdown/references/fancy-tricks.md new file mode 100644 index 0000000..658e974 --- /dev/null +++ b/skills/github-markdown/references/fancy-tricks.md @@ -0,0 +1,54 @@ +# Fancy tricks: color, layout and motion without CSS + +For when someone asks for a "hack": colors, styled text, multi-column layout or animation in a +README or comment. github.com strips CSS, `class`, `style` and all script (see +[html.md](html.md)), so every trick here goes through something GitHub renders itself: +images, MathJax, Mermaid or plain HTML attributes. Prefer plain Markdown unless the user asks. +Each trick costs accessibility or portability; say which when you use it. + +## Color + +| Want | Trick | Notes | +|---|---|---| +| Colored text | `$\color{red}{\text{warning}}$` (MathJax) | Renders as math: not searchable, odd spacing, read as math by screen readers. Also `\color{#0969DA}`. `\colorbox` is blocked ("macros are not allowed"), so there is no background color. | +| Red and green lines | a ```` ```diff ```` block; lines starting with `+` or `-` | Code-block font; meant for diffs. | +| Colored boxes and blocks | a Mermaid diagram with `style A fill:#f9f,stroke:#333` or `classDef` | A diagram, not text; fine for charts and status boards. | +| Colored callouts | the five alerts (`> [!NOTE]` ...) | The only text color GitHub supports directly. | +| Highlight | `text` | GitHub's highlight color only: bright yellow in light mode, a dim tint in dark mode. | +| Color swatch | `` `#ff0000` `` | Issues, PRs and discussions only. | +| Any color, any font | an image (PNG or SVG banner, a shields.io badge) | Give it `alt` text. Use `` for separate dark and light versions. | + +## Fonts and type + +- No font family or size control in HTML. Built in: headings, ``, ``, ``, + bold, italic, strikethrough, and monospace from ``, ``, ``, ``. +- MathJax fonts and sizes inside `$...$`: `\mathbb{R}`, `\mathcal{A}`, `\mathfrak{g}`, + `\texttt{x}`, `\mathsf{x}`, `\large` up to `\Huge`. +- Unicode styled letters (𝓼𝓬𝓻𝓲𝓹𝓽, π”£π”―π”žπ”¨π”±π”²π”―, 𝙒𝙀𝙣𝙀) are plain text and always render, but + screen readers spell them out or skip them and search cannot find them. Avoid them for + anything important. + +## Layout + +- **Columns and grids**: an HTML `` (tables nest inside `
`), with `width`, `align`, + `valign`, `colspan`, `rowspan`. GitHub's stylesheet always draws borders and striping; + borderless tables are not possible. +- **Side-by-side image and text**: `` (see "Floating an image" in html.md). +- **Menus and accordions**: nested `
` blocks. +- **Centered hero section**: `
` around an image, a heading and badges. + +## Motion and live content + +- **Animated SVG** in an `` (or `![]()`): CSS and SMIL animation inside the SVG file play; + its scripts never run. This is how "typing" banners work. Keep the file small. +- **Animated GIF, WebP or APNG**: work as images. Mind file size and motion sensitivity. +- **Live images** from an outside server (stats cards, "now playing", counters): GitHub fetches + images through its caching image proxy, so updates show up late and every reader's request + hides their IP from the server. +- **Theme-aware art**: `` with `prefers-color-scheme` sources swaps images between + dark and light mode. + +## Never possible + +JavaScript, forms, `