← All guides Automate

Run cursor-doctor in CI with GitHub Actions

Lint your Cursor rules automatically to catch broken frontmatter and invalid globs.

Why lint rules in CI

Rules with broken frontmatter or invalid globs fail silently. Cursor won't tell you the rule is broken, it just won't load. Running cursor-doctor check in CI catches these issues before they reach your team.

The check command

The check command scans your .cursor/rules/ directory and returns an exit code based on what it finds:

npx cursor-doctor check

Exit codes:

Any issue causes the build to fail, which is what you want in CI. If something is wrong with your rules, you'll know before merging.

GitHub Actions workflow

Add this workflow to .github/workflows/lint-cursor-rules.yml to check rules on every push:

name: Lint Cursor Rules

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  lint-rules:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      
      - name: Check Cursor rules
        run: npx cursor-doctor check

This workflow runs on every push and PR to main. If npx cursor-doctor check exits with code 2, the workflow fails and blocks the merge.

Tip: Add paths to only run the workflow when rules files change. This saves CI minutes.

Using lint for more detail

The check command gives a pass/fail health grade. For a detailed breakdown of every issue in every file, use lint instead:

- name: Lint Cursor rules
  run: npx cursor-doctor lint

The lint command exits with code 1 if any errors are found, 0 otherwise. It shows each issue with file path, severity, and a hint for fixing it.

What the check command catches

The linter validates frontmatter structure, glob syntax, and rule quality:

Errors

Warnings

Running locally before committing

Run the same check locally to catch issues before pushing:

npx cursor-doctor check

Fix any errors or warnings, then commit. Your CI workflow will pass on the first try.

Other CI platforms

The check command works in any CI environment that supports Node.js. For GitLab CI, CircleCI, or Jenkins, install Node and run npx cursor-doctor check the same way. The exit code behavior is identical.

Related guides

Add rule checking to CI

Run npx cursor-doctor check in your CI pipeline to catch broken rules before they reach production.

npx cursor-doctor check