Skip to content

chore: add OpenAI-powered prose check pre-commit hook#501

Open
larkiny wants to merge 2 commits intomainfrom
chore/openai-grammar-precommit
Open

chore: add OpenAI-powered prose check pre-commit hook#501
larkiny wants to merge 2 commits intomainfrom
chore/openai-grammar-precommit

Conversation

@larkiny
Copy link
Collaborator

@larkiny larkiny commented Feb 5, 2026

Summary

Adds a pre-commit hook that reviews Markdown documentation for grammar and style issues using the OpenAI API.

Features:

  • Configurable model, sensitivity level, and fail/warn mode
  • Rich terminal UI with spinner and diff-style output
  • Graceful handling when API key is missing (warns, doesn't block)
  • External prompt file (scripts/prose-review-instructions.md) for easy customization

Configuration via .env.local:

OPENAI_API_KEY=sk-...           # Required
PROSE_CHECK_MODE=warn           # warn (default) or fail
PROSE_CHECK_MODEL=gpt-4o-mini   # Any OpenAI chat model
PROSE_CHECK_SENSITIVITY=medium  # low, medium (default), or high

Test plan

  • Clone repo without .env.local → should warn and allow commit
  • Set up .env.local with API key → should check staged .md/.mdx files
  • Verify issues display with diff-style formatting
  • Test warn mode allows commits with issues
  • Test fail mode blocks commits with issues

Adds a pre-commit hook that reviews Markdown documentation for grammar
and style issues using the OpenAI API. Features:

- Configurable model, sensitivity level, and fail/warn mode
- Rich terminal UI with spinner and diff-style output
- Graceful handling when API key is missing (warns, doesn't block)
- External prompt file for easy customization

Configuration via .env.local (not committed):
- OPENAI_API_KEY (required)
- PROSE_CHECK_MODE: warn (default) or fail
- PROSE_CHECK_MODEL: gpt-4o-mini (default)
- PROSE_CHECK_SENSITIVITY: low, medium (default), or high
- PROSE_CHECK_ENABLED: disable hook entirely (default: true)
- PROSE_CHECK_EXCLUDE: comma-separated paths to skip
- npm scripts: prose:check (staged files), prose:check:all (all docs)
- .env.prose-precommit.example template for contributors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant