Enforce brand writing guidelines in Claude Code — PostToolUse hook + MCP server
Enforce brand writing guidelines in Claude Code — PostToolUse hook + MCP server
Valid MCP server (2 strong, 4 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry.
6 files analyzed · 1 issue found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
This plugin requests these system permissions. Most are normal for its category.
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-zoharbabin-brand-voice": {
"args": [
"-y",
"brand-voice"
],
"command": "npx"
}
}
}From the project's GitHub README.
Enforce brand writing guidelines in Claude Code.
A PostToolUse hook checks every Markdown file Claude writes or edits against your brand guidelines and signals Claude to correct violations before saving. Visual identity — colors, fonts, logo URLs — lives in the same guidelines file so Claude can reference them when generating any brand-compliant asset. Includes an MCP server for on-demand analysis and a /brand-voice-setup skill for guided onboarding.
npm install -g brand-voice
Or use without installing:
npx brand-voice@latest check
Requires Node.js 18+.
Step 1 — Run the setup skill in Claude Code
/brand-voice-setup
The skill either reads an existing brand guidelines file you provide or asks four questions to create one. It writes brand-guidelines.md, injects a summary into CLAUDE.md, and registers the hook and MCP server in .claude/settings.json and .mcp.json.
Step 2 — Write Markdown as normal
Every time Claude uses Write, Edit, or MultiEdit on a .md or .mdx file, the PostToolUse hook runs brand-voice-check against the result. If violations are found, the hook exits with code 2 and outputs the violation list — Claude reads this feedback, corrects the violations, and retries the write automatically.
Step 3 — Iterate on your guidelines
Edit brand-guidelines.md whenever your rules change. No reinstall needed — the hook reads the file on every invocation.
| Component | What it does |
|---|---|
/brand-voice-setup skill | Guided setup: reads or interviews for brand rules, writes brand-guidelines.md, injects a summary into CLAUDE.md, registers the hook and MCP server |
PostToolUse hook (brand-voice-check) | Runs after every Write/Edit/MultiEdit on .md/.mdx files; exits 2 with a violation report to trigger automatic correction, exits 0 when clean |
MCP server (brand-voice-mcp) | Exposes analyze_readability and apply_suggestions for on-demand checking and automated term fixes |
CLI (brand-voice) | Standalone checker for CI pipelines, ratchet baseline enforcement, and git-diff-aware checks |
Readability scores (Flesch Reading Ease, Flesch-Kincaid grade, sentence/word counts) are returned by analyze_readability.
| Code | Meaning |
|---|---|
0 | No violations — file accepted |
2 | Violations found — Claude retries and corrects |
Exit 1 is never used by the hook (it would abort the session rather than signal a retry).
Brand Voice violations in quickstart.md:
Line 12: Forbidden term: "simply"
Line 23: Avoid term: "utilize"
Line 31: Sentence too long: 34 words (max 25). Sentence: "Our platform..."
Line 45: Possible passive voice: "is configured"
Fix these violations, then the file will be saved.
brand-guidelines.md is a plain Markdown file in your project root (or ~/.claude/ for user-scope). Keep it under 600 words / ~750 tokens so it fits cleanly in CLAUDE.md context.
# Brand Guidelines
## Persona
Who you are and who you write for.
## Tone & Voice
- Direct, honest, clear
- Person: second ← "first" | "second" | "third"
- Voice: active ← "active" | "passive"
- Sentences: max 25 words
- Contractions: yes ← "yes" | "no"
- Exclamation marks: no
## Vocabulary
**Always use:** Acme, Acme Platform, APIs
**Avoid:** leverage, utilize, synergy, seamless
**Forbidden:** [competitor names, unverified performance claims]
## On-Tone Examples
> Connect your data in minutes — Acme handles the routing, you handle the insights.
## Off-Tone Examples
> Leverage our cutting-edge platform to seamlessly integrate your workflows.
## Visual Identity
- Primary color: #006EFA
- Secondary color: #0050C3
- Accent color: #FF9DFF
- Background color: #FFFFFF
- Text color: #282828
- Logo (light): https://cdn.example.com/logo-light.svg
- Logo (dark): https://cdn.example.com/logo-dark.svg
- Icon / mark: https://cdn.example.com/icon.svg
- Heading font: Inter
- Body font: Source Sans Pro
## Formatting Rules
- Heading style: sentence case
- Oxford comma: yes
- Readability target: 8th grade
## Quick Reference
Repeat your top 5 rules here. This section appears at the end of the
file where LLM attention is highest — restating key rules here counters
"Lost in the Middle" degradation in long context windows.
The ## Quick Reference section is required. It restates the most critical rules at the end of the file, where attention is strongest, to reinforce them against context-window attention drop-off.
Section name aliases: ## On-Brand Examples and ## Off-Brand Examples are accepted as aliases for ## On-Tone Examples and ## Off-Tone Examples. All other section names are case-insensitive exact matches.
See example/brand-guidelines.md for a complete working example.
The hook and CLI search for brand-guidelines.md in this order:
~/.claude/brand-guidelines.md (user scope)If you have a brand-guidelines.md that already follows the schema above, brand-voice import re-parses and normalizes it into the current directory:
brand-voice import /path/to/brand-guidelines.md
For a document with different section headings or prose narrative, use /brand-voice-setup instead — the skill uses Claude to translate any format into the schema.
The brand-voice-mcp server exposes two tools:
analyze_readabilityCheck a file or inline text for violations and get readability scores.
Inputs:
| Field | Type | Required | Description |
|---|---|---|---|
file | string | one of | Absolute or cwd-relative path to a .md/.mdx file |
text | string | one of | Inline Markdown text to analyze |
cwd | string | no | Working directory for locating brand-guidelines.md |
Returns: { filePath, passed, violations[], readabilityScores, visualIdentity }
apply_suggestionsApply safe word-level substitutions to fix common violations (forbidden/avoid terms). Does not fix sentence length, passive voice, or readability — those require manual editing.
Inputs:
| Field | Type | Required | Description |
|---|---|---|---|
file | string | yes | Path to the file to fix |
dryRun | boolean | no | Return a diff without writing (default: false) |
Returns: { dryRun: true, diff, changes[] } (dryRun) or { filePath, changes[], message } (live)
Tip: Call apply_suggestions with dryRun: true first to preview changes, then again without dryRun to apply them.
| Scenario | How |
|---|---|
| Solo developer | Run /brand-voice-setup once per project; commit brand-guidelines.md |
| Team | Commit brand-guidelines.md, .claude/settings.json (hook), and .mcp.json (MCP server); teammates get enforcement automatically on git pull |
| claude.ai (browser) | The setup skill outputs a paste block for Claude Project instructions — no hook or MCP server required |
| Enterprise / CI | Use brand-voice check in pipelines; commit .brand-voice-baseline.json for ratchet enforcement |
brand-voice includes a standalone CLI for pipelines, independent of Claude Code.
Check all .md files:
npx brand-voice check
Check only files changed in the current branch:
npx brand-voice check --changed-only
GitHub Actions annotations (inline PR diff comments):
npx brand-voice check --reporter github-pr-review
Ratchet enforcement — prevent regressions without requiring a clean slate:
# Save current violation count as baseline (run once, commit the file)
npx brand-voice baseline --save
# In CI: fail only if violations increase above baseline
npx brand-voice check --baseline .brand-voice-baseline.json
Example GitHub Actions workflow:
name: Brand Voice
on:
pull_request:
paths: ['**.md', '**.mdx']
jobs:
prose:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: npx brand-voice@latest check --changed-only --reporter github-pr-review
Exit code 0 = clean or within baseline. Exit code 1 = errors found or baseline exceeded.
brand-voice <command> [options]
Commands:
check [file] Check a file or all .md files in cwd
setup Print instructions to run /brand-voice-setup
import <file> Normalize a brand-guidelines.md into cwd
baseline --save Save current violation count as ratchet baseline
vale-sync Check that the Vale binary is available
Check options:
--changed-only Only check files changed in git (requires git)
--baseline <file> Compare against a baseline JSON file (ratchet check)
--reporter github-pr-review Emit GitHub Actions annotation format
import { parseGuidelines, analyzeText, loadGuidelines } from 'brand-voice';
const guidelines = loadGuidelines(process.cwd());
if (guidelines) {
const result = analyzeText(markdownString, 'doc.md', guidelines);
console.log(result.violations); // Violation[]
console.log(result.readabilityScores);
}
See src/types.ts for the full type definitions.
brand-guidelines.md — required for enforcement; created by /brand-voice-setupvale-sync command; not required for the hook, MCP server, or CLI checknpm install && npm run buildnpm test — runs the Jest suite under src/npm run typecheck — strict TypeScript via tsc --noEmitBug reports and guideline schema improvements are welcome via GitHub Issues.
MIT — see LICENSE.
Be the first to review this server!
by Modelcontextprotocol · Developer Tools
Read, search, and manipulate Git repositories programmatically
by Modelcontextprotocol · Developer Tools
Web content fetching and conversion for efficient LLM usage
by Toleno · Developer Tools
Toleno Network MCP Server — Manage your Toleno mining account with Claude AI using natural language.