prettier-markdown-hook

productivity v1.0.0 by Terry Li

Automatically format markdown files with prettier when Claude stops responding, with configurable organization and path exclusions

MIT License
Free Pricing

Installation

Open Claude Code and run this command:

/plugin install prettier-markdown-hook@claude-code-plugins-plus

Use --global to install for all projects, or --project for current project only.

What It Does

This Claude Code plugin provides a Stop hook that automatically formats markdown files in your workspace using prettier. It runs asynchronously in the background after every conversation, ensuring consistent markdown formatting without interrupting your workflow.

Features

  • Zero-Config Default: Works immediately after installation with sensible defaults
  • Organization Exclusions: Skip formatting for specific GitHub organizations (e.g., company repos)
  • Path Exclusions: Exclude specific directories or file patterns
  • AI Commit Messages: Optional AI-generated commit messages (opt-in)
  • Fire-and-Forget: Async execution (<10ms hook exit time)
  • XDG Compliant: Cross-platform default paths
  • Comprehensive Logging: All operations logged for debugging

How It Works

  1. Stop Hook: Triggers after Claude finishes responding
  2. Workspace Check: Verifies you're in a git workspace
  3. Exclusion Check: Skips excluded organizations/paths
  4. Format Files: Runs prettier on modified markdown files
  5. Auto Commit: Creates a conventional commit (optional AI message)
  6. Background Execution: All processing happens asynchronously

Components

1 hook

How It Works

Automatic Formatting (Default)

No action required! The hook runs automatically after every conversation:

  1. You interact with Claude
  2. Claude finishes responding (Stop event)
  3. Hook executes in background
  4. Markdown files formatted
  5. Changes committed (if any modifications)

Monitoring Hook Execution

Check log file:


tail -20 ~/.local/state/prettier-hook/format-markdown.log

tail -f ~/.local/state/prettier-hook/format-markdown.log

grep -i error ~/.local/state/prettier-hook/format-markdown.log

Example log output:


[2025-11-15 18:30:42] Starting prettier markdown formatting
[2025-11-15 18:30:42] Workspace: /Users/terry/projects/my-app
[2025-11-15 18:30:42] Remote: git@github.com:myuser/my-app.git
[2025-11-15 18:30:42] Exclusion check: NOT excluded (no matching org)
[2025-11-15 18:30:43] Found 5 modified markdown files
[2025-11-15 18:30:45] Formatted 5 files successfully
[2025-11-15 18:30:46] Created commit: style: format markdown files with prettier
[2025-11-15 18:30:46] Prettier formatting completed successfully

Disabling the Hook

Temporary disable (per workspace):


cd /path/to/workspace

/plugin disable prettier-markdown-hook

Permanent uninstall:


/plugin uninstall prettier-markdown-hook

Manual Formatting (Alternative)

While the plugin uses the Stop hook (automatic), you can manually run the script:


~/.claude/plugins/prettier-markdown-hook/scripts/format-markdown.sh

export PATH="$PATH:~/.claude/plugins/prettier-markdown-hook/scripts"
format-markdown.sh

FAQ

Ready to use prettier-markdown-hook?