GitHub Packages · MIT · Node ≥ 18

readme-gauge

Lint READMEs for missing sections, broken badges, stale install commands and missing usage examples.

  1. 1 Point the @mrlouiswright scope at GitHub Packages in .npmrc

    @mrlouiswright:registry=https://npm.pkg.github.com
  2. 2 Install

    npm i -D @mrlouiswright/readme-gauge
Installing from GitHub Packages needs a token

Published to GitHub Packages, not npmjs.com. GitHub Packages needs a GitHub token with read:packages to install, even for public packages: add //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} to .npmrc or run npm login --registry=https://npm.pkg.github.com.

~/project — zsh
$ npx readme-gaugereadme-gauge — README.md98 words, 6 heading(s), 4 badge(s), 7 link(s) MEDIUM   README.md:3 badge uses travis-ci.org (travis-ci.org shut down in 2021) [broken-badge]         ↳ fix: Replace it with a GitHub Actions badge or remove it.MEDIUM   README.md:5 badge references workflow missing.yml, which does not exist in .github/workflows [broken-badge]         ↳ fix: Point the badge at an existing workflow file.MEDIUM   README.md:15 "npm install --save acme-widget@2.0.0" installs "acme-widget" but this package is "acme-widgets" [stale-install-command]         ↳ fix: Use "acme-widgets".MEDIUM   README.md:20 "Usage" section has no code example [missing-usage-example]         ↳ fix: Add a fenced code block showing a minimal, copy-pasteable example.LOW      README.md:10 link to #options-list matches no heading [broken-anchor]         ↳ fix: Fix the anchor or add the heading.
Sample output from the readme-gauge README.

Why it exists

readme-gauge reads your README the way a new user does. It flags what is missing or wrong: no install or usage section, a usage section without a code example, an install command for a package that was renamed (“npm i acme-widget” when the package is acme-widgets), a pinned old major, a Travis badge for a service that shut down in 2021, an npm badge for a different package, a workflow badge pointing at a file that no longer exists, relative links and “#anchors” that go nowhere, placeholder text (TODO, “lorem ipsum”), and a License section that disagrees with package.json. Every finding has a line number and a concrete fix.

CLI, library and GitHub Action. Node.js 18+, zero runtime dependencies. By Louis Wright.

Features

Sections

required sections (install, usage, license by default) found by heading text with sensible aliases ("Getting started", "Licence", "Examples"…), plus empty sections, a missing # title and skipped heading levels.

Install commands

parses npm/pnpm/yarn/bun/npx commands in code blocks and inline code. Flags the wrong or misspelled package name, pinned majors older than package.json, global installs of packages without a bin, --save, Bower, and a CLI that's never shown.

Badges

shields.io / npm / packagephobia / bundlephobia badges naming another package, GitHub badges for another repository, Actions badges for a workflow file that doesn't exist, dead services (Travis CI .org, David DM, Greenkeeper, Gemnasium).

Links

relative link and image targets are checked on disk; #anchors are checked against GitHub's heading slugs (including duplicates and Unicode). --check-links also fetches external links and badge images.

Output

text, JSON, SARIF 2.1.0 and Markdown; --fail-on; exit codes 0/1/2; allowlist entries with expiry dates.

Usage

# lint ./README.md against ./package.json

 npx readme-gauge

# Example

 npx readme-gauge packages/core --fail-on medium

# Example

 npx readme-gauge --require install,usage,api,license,contributing

# also fetch external links and badges

 npx readme-gauge --check-links

CI / GitHub Action

permissions:
  contents: read
  security-events: write   # only needed for the SARIF upload
jobs:
  readme-gauge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with: { persist-credentials: false }
      - uses: MrLouisWright/readme-gauge@v1
        with:
          fail-on: high
          sarif: readme-gauge.sarif
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with: { sarif_file: readme-gauge.sarif }

Options & flags

FlagDescription
README
--file <path>README to lint (default: README.md / readme.* in dir)
--require <list>Required sections, comma-separated (default: install,usage,license;
--min-words <n>Minimum word count before too-short (default: 80)
--check-linksAlso fetch external links and badge images (HEAD, then GET)
--timeout <ms>Per-URL timeout for --check-links (default: 8000)
Common
-c, --config <file>JSON config (default: .readme-gauge.json or "readmeGauge" in package.json)
-f, --format <fmt>text (default) | json | sarif | markdown
--json <file>Also write a JSON report
--sarif <file>Also write SARIF 2.1.0
--markdown <file>Also write Markdown (e.g. for a job summary)
--fail-on <sev>critical | high | medium | low | info | none (default: high)
--list-rulesPrint rules and default severities
--no-fixesHide fix suggestions in text output
--no-colorDisable colours

Full reference, config file format and API in the README.

Support this project

Support open-source security tools

I build free, open-source tools that help developers ship safer websites. Every coffee helps keep them maintained, documented and free for everyone.

Buy me a coffee (opens Stripe in a new tab)

Secure checkout by Stripe

Portrait of Louis Wright

About the author

Louis Wright

Cyber security researcher and software engineer based in the UK.

More tools by Louis Wright

58 tools

Sentinels security scanners & CI gates · 20