brand-voice-mcp
Enforces brand writing guidelines in Claude Code by analyzing Markdown files for violations and offering on-demand readability analysis and automated term fixes through MCP tools.
README
brand-voice
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.
Install
npm install -g brand-voice
Or use without installing:
npx brand-voice@latest check
Requires Node.js 18+.
Quick Start
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.
How It Works
| 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 |
Violation types checked
- Forbidden terms — whole-word, case-insensitive match; severity: error
- Avoid terms — same matching; severity: warning
- Sentence length — configurable max words per sentence (default: 25)
- Passive voice — auxiliary + past-participle pattern detection
- Readability grade — Flesch-Kincaid grade per sentence checked against your target
Readability scores (Flesch Reading Ease, Flesch-Kincaid grade, sentence/word counts) are returned by analyze_readability.
PostToolUse hook exit codes
| 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).
Example hook output
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 File
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.
Schema
# 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.
Guidelines search path
The hook and CLI search for brand-guidelines.md in this order:
- Current working directory
~/.claude/brand-guidelines.md(user scope)- Parent directories up to the git root
Importing from an existing document
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.
MCP Server
The brand-voice-mcp server exposes two tools:
analyze_readability
Check 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_suggestions
Apply 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.
Distribution
| 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 |
CI Integration
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.
CLI Reference
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
Programmatic API
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.
Requirements
- Node.js 18+ — required runtime
brand-guidelines.md— required for enforcement; created by/brand-voice-setup- Vale (optional) — only needed for
vale-synccommand; not required for the hook, MCP server, or CLI check
Contributing
- Fork the repository and create a branch.
npm install && npm run buildnpm test— runs the Jest suite undersrc/npm run typecheck— strict TypeScript viatsc --noEmit- Open a pull request with a clear description of the change.
Bug reports and guideline schema improvements are welcome via GitHub Issues.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。