Brand Voice

io.github.zoharbabin由 GitHub 账号 zoharbabin 发布v0.1.8更新于 Oct 24, 2026

Enforce brand writing guidelines in Claude Code — PostToolUse hook + MCP server

已验证STDIO仅桌面效率与工作流开发者工具

概览

AI 生成的概览

本地 MCP 服务器兼 Claude Code 钩子,按品牌规范文件检查 Markdown 文案,标出或修正违规内容。

可以做什么
  • 按品牌规范分析 Markdown 文件或内联文本,返回违规项与可读性评分
  • 对禁用词和避免用词执行安全的词级替换,可先用 dryRun 预览差异
  • 检查禁用词、避免用词、句长、被动语态和可读性等级,跳过代码块、行内代码和表格行
  • 配合 PostToolUse 钩子在写入不合规时阻断并让 Claude 修正重试,另提供 CLI 用于 CI 检查
适用场景
适合在 Claude Code 撰写或修改 Markdown 时,自动执行品牌用词、语气和可读性规则,而不必每次提示都粘贴规范。也适合希望把同样检查接入 CI 流水线的团队。
运行要求
以 Node.js 本地进程运行(需 Node.js 18 及以上),通过 npm 或 npx 安装。需要项目、用户主目录或上级目录中存在 brand-guidelines.md。Vale 为可选项,仅 vale-sync 命令需要。未声明账号、API 密钥或环境变量。
安装前请注意
安装流程会改动项目文件:写入 brand-guidelines.md、向 CLAUDE.md 注入内容,并在 .claude/settings.json 注册钩子、在 .mcp.json 注册服务器。钩子会阻断写入并触发重试,apply_suggestions 在未设 dryRun 时会改写文件。可选的引导式设置会通过网络检索品牌信息。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Brand Voice,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

brand-voice

Brand writing enforcement for Claude Code — automatic, configurable, zero-friction.

[npm version] [npm downloads] [CI] [License: MIT] [Node.js 18+]

Every time Claude writes or edits a Markdown file, brand-voice checks it against your brand guidelines and signals Claude to fix violations before the file saves. No manual review. No rule reminders in every prompt.

[brand-voice demo]

Claude reads the violation list, corrects the file, and retries the write — automatically.


Why brand-voice?

Your brand guidelines live in a doc somewhere. Claude doesn't read them unless you paste them into every prompt. Even then, the rules drift over time.

brand-voice makes the rules structural:

  • Works for any company — configure your own vocabulary, voice, and visual identity
  • Auto-corrects, doesn't just report — the PostToolUse hook blocks bad writes and triggers a retry
  • Covers the full stack — hook for Claude Code, MCP server for on-demand checks, CLI for CI pipelines
  • Smart about code — ignores fenced blocks, indented code, inline code spans, and table cells
  • Escape hatches — .brand-voice-ignore for whole files, <!-- brand-voice-disable-line --> for individual lines
  • Visual identity included — colors, fonts, logo URLs live in the same guidelines file

Install

sh
npm install -g brand-voice

Or run without installing:

sh
npx brand-voice@latest check

Requires Node.js 18+.


Quick Start

Option A — Guided setup in Claude Code (recommended)

Run the setup skill inside any Claude Code session:

/brand-voice-setup

The skill does everything:

  1. Asks whether you have existing brand docs or want to answer four questions
  2. Optionally researches your brand automatically via web
  3. Writes brand-guidelines.md to your project
  4. Injects a summary block into CLAUDE.md
  5. Registers the PostToolUse hook in .claude/settings.json
  6. Registers the MCP server in .mcp.json

After setup, every .md and .mdx file Claude touches is checked automatically.

Option B — Manual setup

sh
# 1. Installnpm install -g brand-voice
# 2. Create brand-guidelines.md in your project root (see schema below)
# 3. Register the hookbrand-voice setup

How It Works

Three components work together:

ComponentWhat it does
PostToolUse hook (brand-voice-check)Runs after every Write/Edit/MultiEdit on .md/.mdx; exits 2 with violations so Claude auto-corrects, exits 0 when clean
MCP server (brand-voice-mcp)Exposes analyze_readability and apply_suggestions for on-demand analysis and word-level fixes
CLI (brand-voice)Standalone checker for CI pipelines, ratchet baselines, and GitHub PR annotations

What gets checked

RuleSeverityDescription
Forbidden termserrorWhole-word, case-insensitive match — blocks the write
Avoid termswarningSame matching — signals a preferred alternative
Sentence lengthwarningConfigurable max words per sentence (default: 25)
Passive voicewarningAuxiliary + past-participle pattern detection
Readability gradewarningFlesch-Kincaid grade per sentence vs. your target

Code blocks, inline code, indented blocks, and table rows are never checked — only prose.

Never checked: physical line length or line breaks. The CLAUDE.md injection always includes a formatting rule telling Claude to write continuous paragraphs and let the renderer word-wrap, but the analyzer itself has no line-width rule and never will — sentence length is measured in words, not characters or lines, so hard-wrapped and unwrapped prose score identically.

PostToolUse hook exit codes

CodeMeaning
0No violations — file accepted
2Violations found — Claude reads output, corrects, and retries

Exit 1 is never used (it aborts the session rather than triggering a retry).


brand-guidelines.md

One Markdown file holds your entire brand configuration. Keep it under 600 words so it fits cleanly in context.

markdown
# Brand Guidelines
## PersonaWho 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 claims]
## On-Tone Examples> Connect your data in minutes — Acme handles the routing.
## Off-Tone Examples> Leverage our cutting-edge platform to seamlessly integrate.
## 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- Heading font: Inter- Body font: Source Sans Pro
## Formatting Rules- Heading style: sentence case- Oxford comma: yes- Readability target: 8th grade
## Quick ReferenceRepeat your top 5 rules here. This section appears last —where LLM attention is highest — to reinforce critical rulesagainst context-window attention drop-off.

See example/brand-guidelines.md for a complete working example.

Section aliases

## On-Brand Examples and ## Off-Brand Examples are accepted as aliases for ## On-Tone Examples / ## Off-Tone Examples. All other section names are case-insensitive exact matches.

Search path

The hook and CLI search for brand-guidelines.md in this order:

  1. Current working directory
  2. ~/.claude/brand-guidelines.md (user scope — enforces rules across all your projects)
  3. Parent directories up to the git root

Suppressing Violations

Skip files or directories — .brand-voice-ignore

Create a .brand-voice-ignore file in your project root. Uses gitignore-style patterns:

# Auto-generated contentdist/CHANGELOG.md
# Agent prompt files — intentional brand vocabulary exceptionsdata/prompts/**
# Vendor docsvendor/

Skip a single line — inline comment

markdown
<!-- brand-voice-disable-line -->

Add this comment anywhere on a line to suppress all violations on that line. Useful for one-off exceptions where the violation is intentional.


MCP Server

analyze_readability

Check a file or inline text for violations and readability scores.

Inputs:

FieldTypeRequiredDescription
filestringone of file/textAbsolute or relative path to a .md/.mdx file
textstringone of file/textInline Markdown to analyze
cwdstringnoWorking directory for locating brand-guidelines.md

Returns: { filePath, passed, violations[], readabilityScores, visualIdentity }

apply_suggestions

Apply safe word-level substitutions for forbidden/avoid terms. Does not fix sentence length, passive voice, or grade — those need human judgment.

Inputs:

FieldTypeRequiredDescription
filestringyesPath to the file to fix
dryRunbooleannoPreview diff without writing (default: false)

Returns: diff + change list (dry run) or confirmation + change list (live)

Tip: Run dryRun: true first to preview, then apply.


CI Integration

brand-voice works independently of Claude Code — add it to any pipeline.

Check all .md files:

sh
npx brand-voice@latest check

Check only files changed in the current branch:

sh
npx brand-voice@latest check --changed-only

GitHub Actions inline annotations (PR diff comments):

sh
npx brand-voice@latest check --reporter github-pr-review

Ratchet enforcement — block regressions without requiring a clean slate:

sh
# Run once, commit the filenpx brand-voice@latest baseline --save
# In CI: fail only if violations increase above baselinenpx brand-voice@latest check --baseline .brand-voice-baseline.json

Example GitHub Actions workflow:

yaml
name: Brand Voiceon:  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 0 = clean or within baseline. Exit 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 in Claude Code  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

ts
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); // ReadabilityScores  console.log(result.passed);            // false if any error-severity violations}

See src/types.ts for full type definitions.


Distribution Patterns

ScenarioWhat to do
Solo developerRun /brand-voice-setup once per project; commit brand-guidelines.md
TeamCommit brand-guidelines.md, .claude/settings.json, and .mcp.json; teammates get enforcement on git pull
Global (all projects)Run /brand-voice-setup with the global flag; writes to ~/.claude/brand-guidelines.md
claude.ai (browser)Setup skill outputs a paste block for Claude Project instructions — no hook or MCP needed
Enterprise / CIUse brand-voice check in pipelines; commit .brand-voice-baseline.json for ratchet enforcement

Requirements

  • Node.js 18+
  • brand-guidelines.md — created by /brand-voice-setup or written manually
  • Vale — optional; only required for vale-sync

Contributing

Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md for setup instructions, key invariants to preserve, and code style guidance.


License

MIT — see LICENSE.

来源:README.md,提交 0aa31e3

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.8最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分