scientific-skills/markdown-mermaid-writing/references/markdown_style_guide.md
For AI agents: Read this file for all core formatting rules. When creating any markdown document, follow these conventions for consistent, professional output. When a template exists for your document type, start from it โ see Templates.
For humans: This guide ensures every markdown document in your project is clean, scannable, well-cited, and renders beautifully on GitHub. Reference it from your
AGENTS.mdor contributing guide.
Target platform: GitHub Markdown (Issues, PRs, Discussions, Wikis, .md files)
Design goal: Clear, professional documents that communicate effectively through consistent structure, meaningful formatting, proper citations, and strategic use of diagrams.
| # | Principle | Rule |
|---|---|---|
| 1 | Answer before they ask | Anticipate reader questions and address them inline. A great document resolves doubts as they form โ the reader finishes with no lingering "but what about...?" |
| 2 | Scannable first | Readers skim before they read. Use headings, bold, and lists to make the structure visible at a glance. |
| 3 | Cite everything | Every claim, statistic, or external reference gets a footnote citation with a full URL. No orphan claims. |
| 4 | Diagrams over walls of text | If a concept involves flow, relationships, or structure, use a Mermaid diagram alongside the text. |
| 5 | Generous with information | Don't hide the details โ surface them. Use collapsible sections for depth without clutter, but never omit information because "they probably don't need it." If it's relevant, include it. |
| 6 | Consistent structure | Same heading hierarchy, same formatting patterns, same emoji placement across every document. |
| 7 | One idea per section | Each heading should cover one topic. If you're covering two ideas, split into two headings. |
| 8 | Professional but approachable | Clean formatting, no clutter, no decorative noise โ but not stiff or academic. Write like a senior engineer explains to a colleague. |
Everything is code. PRs, issues, kanban boards โ they're all markdown files in your repo, not data trapped in a platform's database.
grep beats gh api every time.| What | Where it lives | What GitHub does |
|---|---|---|
| Pull requests | docs/project/pr/pr-NNNNNNNN-short-description.md | GitHub PR is a thin pointer โ humans go there to comment on diffs, approve, and watch CI. The record of what changed, why, and what was learned lives in the file. |
| Issues | docs/project/issues/issue-NNNNNNNN-short-description.md | GitHub Issues is a notification and comment layer. Bug reports, feature requests, investigation logs, and resolutions live in the file. |
| Kanban boards | docs/project/kanban/{scope}-{id}-short-description.md | No external board tool needed. Modify the board in your branch, merge it with your PR. The board evolves with the codebase. |
| Decision records | docs/decisions/NNN-{slug}.md | Not tracked in GitHub at all โ purely repo-native. |
๐ Don't capture information in GitHub's UI that should be captured in a file. Approve PRs in GitHub. Watch CI in GitHub. Comment in GitHub. But the actual content โ the description, the investigation, the decision โ lives in a committed file. If it's worth writing down, it's worth committing.
See File conventions for directory structure and naming.
Every document starts with exactly one H1 title, followed by a brief context line and a separator:
# Document Title Here
_Brief context โ project name, date, or purpose in one line_
---
| Level | Syntax | Use | Max per document |
|---|---|---|---|
| H1 | # Title | Document title | 1 (exactly one) |
| H2 | ## Section | Major sections | 4โ10 |
| H3 | ### Topic | Topics within a section | 2โ5 per H2 |
| H4 | #### Subtopic | Subtopics when needed | 2โ4 per H3 |
| H5+ | Never use | โ | 0 |
Rules:
## ๐ Project Overview## ๐ Project overview not ## ๐ Project Overview (exception: proper nouns)### Authentication flow not ### Details| Format | Syntax | When to use | Example |
|---|---|---|---|
| Bold | **text** | Key terms, important concepts, emphasis | Primary database handles writes |
| Italic | *text* | Definitions, titles, subtle emphasis | The process is called sharding |
Code | `text` | Technical terms, commands, file names, values | Run npm install to install |
~~text~~ | Deprecated content, corrections |
Rules:
***text***) โ pick oneREADME.md), commands (git push), config values (true), environment variables (NODE_ENV)Use blockquotes for definitions, callouts, and important notes:
> **Definition:** A _load balancer_ distributes incoming network traffic
> across multiple servers to ensure no single server bears too much demand.
For warnings and callouts:
> โ ๏ธ **Warning:** This operation is destructive and cannot be undone.
> ๐ก **Tip:** Use `--dry-run` to preview changes before applying.
> ๐ **Note:** This requires admin permissions on the repository.
>>)| List type | Syntax | Use when |
|---|---|---|
| Bullet | - item | Items have no inherent order |
| Numbered | 1. step | Steps must happen in sequence |
| Checkbox | - [ ] item | Tracking completion (agendas, checklists) |
โ
Good โ parallel structure, concise:
- Configure the database connection
- Run the migration scripts
- Verify the schema changes
โ Bad โ mixed structure, verbose:
- You need to configure the database
- Migration scripts
- After that, you should verify that the schema looks correct
See the [Mermaid Style Guide](mermaid_style_guide.md) for diagram conventions.
[Mermaid Style Guide] not [click here] or [link][Guide](./README.md) not absolute URLshttps://Every claim, statistic, or reference to external work MUST have a footnote citation. This is non-negotiable for credibility.
Markdown was created by John Gruber in 2004 as a lightweight
markup language designed for readability[^1]. GitHub adopted
Mermaid diagram support in February 2022[^2].
[^1]: Gruber, J. (2004). "Markdown." _Daring Fireball_. https://daringfireball.net/projects/markdown/
[^2]: GitHub Blog. (2022). "Include diagrams in your Markdown files with Mermaid." https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/
Citation format:
[^N]: Author/Org. (Year). "Title." *Publication*. https://full-url
Rules:
[^1], [^2], [^3] in order of appearance## References section or at the very endWhen the same URL appears multiple times, use reference-style links to keep the text clean:
The [official docs][mermaid-docs] cover all diagram types.
See [Mermaid documentation][mermaid-docs] for the full syntax.
[mermaid-docs]: https://mermaid.js.org/ 'Mermaid Documentation'

_Figure 1: System architecture showing the three-tier deployment model_
Rules:
![Three-tier architecture diagram] not ![image] or ![screenshot]*Figure N: What this image shows*images/file.png not absolute paths{document-slug}_{description}.{ext}
Examples:
auth_flow_overview.png
deployment_architecture.svg
api_response_example.png
If the content could be expressed as a Mermaid diagram, prefer that over a static image:
| Scenario | Use |
|---|---|
| Architecture diagram | Mermaid flowchart or architecture-beta |
| Sequence/interaction | Mermaid sequenceDiagram |
| Data model | Mermaid erDiagram |
| Timeline | Mermaid timeline or gantt |
| Screenshot of UI | Image (Mermaid can't do this) |
| Photo / real-world image | Image |
| Complex data visualization | Image or Mermaid xychart-beta |
See the Mermaid Style Guide for diagram type selection and styling.
| Feature | Free Tier | Pro Tier | Enterprise |
| ------- | --------- | -------- | ---------- |
| Users | 5 | 50 | Unlimited |
| Storage | 1 GB | 100 GB | Custom |
| Support | Community | Email | Dedicated |
Rules:
|---| (default)|---:| when appropriateUse backticks for technical terms within prose:
Run `git status` to check for uncommitted changes.
The `NODE_ENV` variable controls the runtime environment.
Always specify the language for syntax highlighting:
```python
def calculate_average(values: list[float]) -> float:
"""Return the arithmetic mean of a list of values."""
return sum(values) / len(values)
```
Rules:
```python, ```bash, ```json, etc.```text for plain output โ not ``` with no language# Configure the database connection at the top of the blockUse HTML <details> for supplementary content that shouldn't clutter the main flow โ speaker notes, implementation details, verbose logs, or optional deep-dives.
<details>
<summary><strong>๐ฌ Speaker Notes</strong></summary>
- Key talking point one
- Transition to next topic
- **Bold** emphasis works inside details
- [Links](https://example.com) work too
</details>
---
Rules:
<details> tag collapses automatically<strong>๐ฌ Speaker Notes</strong> or <strong>๐ Implementation Details</strong><summary> tag โ required for markdown to render inside the block--- โ horizontal rule after every </details> for visual separation| Summary label | Use for |
|---|---|
| ๐ฌ Speaker Notes | Presentation talking points, timing, transitions |
| ๐ Details | Extended explanation, verbose context |
| ๐ง Implementation | Technical details, code samples, config |
| ๐ Raw Data | Full output, logs, data tables |
| ๐ก Background | Context that helps but isn't essential |
Use --- (three hyphens) for visual separation:
---
When to use:
</details> block โ mandatory, creates clear separationWhen NOT to use:
One emoji per H2 heading, at the start. Use sparingly in body text for callouts and emphasis only.
| Emoji | Use for |
|---|---|
| ๐ | Overview, summary, agenda, checklist |
| ๐ฏ | Goals, objectives, outcomes, targets |
| ๐ | Content, documentation, main body |
| ๐ | Resources, references, links |
| ๐ | Agenda, navigation, current position |
| ๐ | Housekeeping, logistics, announcements |
| โ๏ธ | Tasks, assignments, action items |
| Emoji | Meaning |
|---|---|
| โ | Success, complete, correct, approved |
| โ | Failure, incorrect, avoid, rejected |
| โ ๏ธ | Warning, caution, important notice |
| ๐ก | Tip, insight, idea, best practice |
| ๐ | Important, key point, remember |
| ๐ซ | Prohibited, do not, blocked |
| Emoji | Meaning |
|---|---|
| โ๏ธ | Configuration, settings, process |
| ๐ง | Tools, utilities, setup |
| ๐ | Analysis, investigation, review |
| ๐ | Data, metrics, analytics |
| ๐ | Growth, trends, improvement |
| ๐ | Cycle, refresh, iteration |
| โก | Performance, speed, quick action |
| ๐ | Security, authentication, privacy |
| ๐ | Web, API, network, global |
| ๐พ | Storage, database, persistence |
| ๐ฆ | Package, artifact, deployment |
| Emoji | Meaning |
|---|---|
| ๐ค | User, person, individual |
| ๐ฅ | Team, group, collaboration |
| ๐ฌ | Discussion, comments, speaker notes |
| ๐ | Learning, education, knowledge |
| ๐ค | Question, consideration, reflection |
## ๐ Overview> โ ๏ธ **Warning:**) and key markers onlyWhenever content describes flow, structure, relationships, or processes, consider whether a Mermaid diagram would communicate it better than prose alone. Diagrams and text together are more effective than either alone.
Any time your text describes flow, structure, relationships, timing, or comparisons, there's a Mermaid diagram that communicates it better. Scan the table below to identify the right type, then follow this workflow:
| Your content describes... | Add a... | Type file |
|---|---|---|
| Steps in a process, workflow, decision logic | Flowchart | flowchart.md |
| Who talks to whom and when (API calls, messages) | Sequence diagram | sequence.md |
| Class hierarchy, type relationships, interfaces | Class diagram | class.md |
| Status transitions, entity lifecycle, state machine | State diagram | state.md |
| Database schema, data model, entity relationships | ER diagram | er.md |
| Project timeline, roadmap, task dependencies | Gantt chart | gantt.md |
| Parts of a whole, proportions, distribution | Pie chart | pie.md |
| Git branching strategy, merge/release flow | Git Graph | git_graph.md |
| Concept hierarchy, brainstorm, topic map | Mindmap | mindmap.md |
| Chronological events, milestones, history | Timeline | timeline.md |
| User experience, satisfaction scores, journey | User Journey | user_journey.md |
| Two-axis comparison, prioritization matrix | Quadrant chart | quadrant.md |
| Requirements traceability, compliance mapping | Requirement diagram | requirement.md |
| System architecture at varying zoom levels | C4 diagram | c4.md |
| Flow magnitude, resource distribution, budgets | Sankey diagram | sankey.md |
| Numeric trends, bar charts, line charts | XY Chart | xy_chart.md |
| Component layout, spatial arrangement, layers | Block diagram | block.md |
| Work item tracking, status board, task columns | Kanban board | kanban.md |
| Binary protocol layout, data packet format | Packet diagram | packet.md |
| Cloud infrastructure, service topology, networking | Architecture diagram | architecture.md |
| Multi-dimensional comparison, skills, radar analysis | Radar chart | radar.md |
| Hierarchical proportions, budget breakdown | Treemap | treemap.md |
๐ก Pick the right type, not the easy type. Don't default to flowcharts for everything โ a timeline is better than a flowchart for chronological events, a sequence diagram is better for service interactions, an ER diagram is better for data models. Scan the table above and match your content to the most specific type. If you catch yourself writing a paragraph that describes a visual concept, stop and diagram it.
Place the diagram inline with the related text, not in a separate section:
### Authentication Flow
The login process validates credentials, checks MFA status,
and issues session tokens. Failed attempts are logged for
security monitoring.
โ```mermaid
sequenceDiagram
accTitle: Login Authentication Flow
accDescr: User login sequence through API and auth service
participant U as ๐ค User
participant A as ๐ API
participant S as ๐ Auth Service
U->>A: POST /login
A->>S: Validate credentials
S-->>A: โ
Token issued
A-->>U: 200 OK + session
โ```
The token expires after 24 hours. See [Authentication flow](#authentication-flow)
for refresh token details.
Always follow the Mermaid Style Guide for diagram styling โ emoji, color classes, accessibility (accTitle/accDescr), and type-specific conventions.
</details> blockaccTitle/accDescr)<details> blocks have descriptive <summary> labels<summary> tag (for markdown rendering)--- after every </details> blockTemplates provide pre-built structures for common document types. Copy the template, fill in your content, and follow this style guide for formatting. Every template enforces the principles above โ citations, diagrams, collapsible depth, and self-answering structure.
| Document type | Template | Best for |
|---|---|---|
| Presentation / briefing | presentation.md | Slide-deck-style documents with speaker notes, structured sections, and visual flow |
| Research paper / analysis | research_paper.md | Data-driven analysis, literature reviews, methodology + findings with heavy citations |
| Project documentation | project_documentation.md | Software/product docs โ architecture, getting started, API reference, contribution guide |
| Decision record (ADR/RFC) | decision_record.md | Recording why a decision was made โ context, options evaluated, outcome, consequences |
| How-to / tutorial guide | how_to_guide.md | Step-by-step instructions with prerequisites, verification steps, and troubleshooting |
| Status report / executive brief | status_report.md | Progress updates, risk summaries, decisions needed โ for leadership and stakeholders |
| Pull request record | pull_request.md | PR documentation with change inventory, testing evidence, rollback plan, and review notes |
| Issue record | issue.md | Bug reports (reproduction steps, root cause) and feature requests (acceptance criteria, user stories) |
| Kanban board | kanban.md | Sprint/release/project work tracking with visual board, WIP limits, metrics, and blocked items |
Some templates produce documents that accumulate over time. Use these directory conventions:
| Document type | Directory | Naming pattern | Example |
|---|---|---|---|
| Pull requests | docs/project/pr/ | pr-NNNNNNNN-short-description.md | docs/project/pr/pr-00000123-fix-auth-timeout.md |
| Issues | docs/project/issues/ | issue-NNNNNNNN-short-description.md | docs/project/issues/issue-00000456-add-export-filter.md |
| Kanban boards | docs/project/kanban/ | {scope}-{identifier}-short-description.md | docs/project/kanban/sprint-2026-w07-agentic-template-modernization.md |
| Decision records | docs/decisions/ | NNN-{slug}.md | docs/decisions/001-use-postgresql.md |
| Status reports | docs/status/ | status-{date}.md | docs/status/status-2026-02-14.md |
## ๐๐๐ Content Topics โ Too many
โ Fix: One emoji per H2
## ๐ Content topics
Studies show 73% of developers prefer Markdown. โ Where's the source?
โ Fix: Add footnote
Studies show 73% of developers prefer Markdown[^1].
[^1]: Stack Overflow. (2024). "Developer Survey Results." https://survey.stackoverflow.co/2024
The system handles authentication by first checking the JWT token
validity, then verifying the user exists in the database, then
checking their permissions against the requested resource...
โ Fix: Use a list, heading, or diagram
### Authentication flow
1. Validate JWT token signature and expiration
2. Verify user exists in the database
3. Check user permissions against the requested resource
## Content
[paragraphs of text]
## Screenshots
[all images grouped here] โ Disconnected from context
โ Fix: Place images inline where relevant
</details>
### Next Topic โ Runs together visually
โ
Fix: Always add --- after </details>
</details>
---
### Next topic โ Clear separation