Writing GitHub READMEs with badges, alerts, and Mermaid
Use Shields.io badges, GitHub Markdown alerts, and small Mermaid diagrams to make project status, setup requirements, and architecture easy to find.
A README has to answer different questions quickly. I put status in a few badges, call attention to setup hazards with GitHub alerts, and keep a small architecture diagram alongside the code.
The examples use GitHub Flavored Markdown and the Shields.io v1 static badge endpoint as of December 2024.
Decide what belongs in the README
When I open a repository, I look for the runtime, what the project does, and how to run it. A wall of prose makes these details hard to find. Screenshots of the architecture also fall behind the code if every change requires someone to re-export an image.
Three small additions solve different problems.
- Badges show state at a glance. Useful examples include the runtime version, license, and CI status.
- Alerts separate operational caveats from ordinary setup steps. A missing environment variable or a destructive reset command deserves a distinct treatment.
- Mermaid describes the system in source text. The diagram can change in the same pull request as the implementation.
I keep each addition focused. A badge should answer a question, and a diagram should help a reader follow one workflow.
Add static and dynamic badges
Shields.io static badges accept a label, message, and color in the URL. The style parameter selects a rendering style such as flat, flat-square, or for-the-badge. Use the logo parameter for a Simple Icons identifier and logoColor if you need a specific contrast.
1
2
3



In a path-based badge, a single hyphen separates fields and a single underscore represents a space. Double a hyphen or underscore when you need it to appear literally. The /static/v1 query format can be easier to read if the label or message contains several special characters.
1
2
3
4
5
6
<!-- Escape hyphens (--) and underscores (__) -->


<!-- Use the query format for punctuation-heavy labels -->

I use static badges when the value changes alongside the README, as with a runtime version or license. For CI status or an image tag, an external result is the source of truth. A dynamic badge can show that result as the underlying job or registry changes.
| Badge | Updates | Useful for | Detail to check |
|---|---|---|---|
| Shields.io static | Manually | Runtime and license | Update after a version change |
| GitHub Actions | Per workflow run | Build and test status | Select the branch with ?branch= |
| SonarCloud | After analysis | Quality gate | Supply the project key and metric |
| Docker Hub via Shields.io | After data becomes visible through the cache | Tag and image size | Registry updates may take a few minutes to appear |
1
2
3
4
5
6
7
8
9
<!-- GitHub Actions workflow badge -->
[](https://github.com/OWNER/REPO/actions/workflows/ci.yml)
<!-- SonarCloud quality gate badge -->
[](https://sonarcloud.io/summary/new_code?id=PROJECT_KEY)
<!-- Docker Hub version and image size badges -->


An external badge service cannot fetch a private repository without suitable access. For private CI status, use GitHub’s native workflow badge and verify what authenticated collaborators see.
When a badge is tied to a workflow, I link the image to the workflow run list. The small badge tells me whether to investigate, and the link takes me to the logs. Check the branch query as part of review. A badge for a deployment branch and a badge for the default branch can both be valid while answering different questions.
Reserve Markdown alerts for information that needs it
GitHub offers five alert types. I choose the marker that describes what a reader should do with the message.
| Marker | Intention | Example |
|---|---|---|
[!NOTE] | Provide helpful background | Supported runtime |
[!TIP] | Offer an optional shortcut | Starting services with Docker Compose |
[!IMPORTANT] | State a prerequisite | Required JDK or environment file |
[!WARNING] | Prevent a foreseeable problem | A setting restricted to the local profile |
[!CAUTION] | Explain a serious risk | A script that deletes database volumes |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
> [!NOTE]
> Tested with Java 21 and virtual threads enabled.
> [!TIP]
> Start PostgreSQL and Redis together with `docker compose up -d`.
> [!IMPORTANT]
> Copy `.env.example` to `.env` and fill in the required values before starting.
> [!WARNING]
> Use `ddl-auto=create` only in the local profile.
> [!CAUTION]
> Running `scripts/reset-db.sh` deletes all existing volume data.
Alerts cannot be nested. Outside GitHub, a Markdown renderer may display the marker as plain quote text, including on package pages. Keep the sentence clear enough to stand on its own there. GitHub documentation on alerts
Keep architecture diagrams in the diff
A Mermaid fence keeps the diagram’s source in the same Markdown file as the rest of the README. GitHub renders it in the page, and reviewers can see the text change when a component moves or an edge is added. A short vertical flow is also easier to read in narrow viewports.
flowchart TD
Client["Client (Web / Mobile)"] --> Gateway["API Gateway (/api/v1)"]
Gateway -->|"Validate JWT"| App["Spring Boot App"]
App --> Cache["Redis (Session / Cache)"]
App --> DB["PostgreSQL (Primary DB)"]
Characters such as parentheses, brackets, slashes, colons, and ampersands can be mistaken for Mermaid syntax. Quote labels that contain them. GitHub’s bundled Mermaid version may differ from the one in your editor, so I check the pull request preview instead of assuming both renderers behave identically.
Describe the edge when it carries information a reader needs. In this example, the label marks where JWT validation happens. Keeping that label short leaves room to read the actual component names on a phone.
Review the rendered README
I start with three to five badges that answer questions about the project, one or two alerts for setup or operational risks, and a diagram with four to six nodes. Preview the Markdown on GitHub. Check that badge links open their source, alerts are readable as plain quotes, and the diagram fits on a narrow screen. Add details where onboarding questions recur.