punctuation-fix

A command that standardizes punctuation in Markdown files, which are plain-text documents commonly used for project notes and documentation. It converts specified Chinese punctuation to English punctuation and adjusts spacing.

In plain words
What is it for?
Use it on a file, directory, or project to normalize punctuation in Markdown documentation.
Why use it?
It removes the need to fix punctuation and spacing manually across many Markdown files while leaving code, links, URLs, and HTML tags untouched.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/linfee/spec-kit-cn/punctuation-fix
Clone the repo
git clone --depth 1 https://github.com/Linfee/spec-kit-cn

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,201 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01201
Opus 5 $0.00000 $0.00600
Sonnet 5 $0.00000 $0.00240
Haiku 4.5 $0.00000 $0.00120

Measured 3d ago against content hash f176833d1b93, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

punctuation-fix scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/punctuation-fix.md · 144 lines

How it starts

The opening of the file, as written. The whole thing — 144 lines — stays where its author put it; the contents beside it link to each section on GitHub.

标点符号规范化命令

自动批量修复 Markdown 文件中的标点符号,确保符合项目翻译标准。

使用方式

/punctuation-fix [路径]

参数:

  • 路径 (可选): 要处理的文件或目录路径,默认为项目根目录下所有 .md 文件

执行步骤

1. 确定处理范围

根据参数确定要处理的文件:

  • 如果未指定路径,处理项目根目录下所有 .md 文件(排除 .git/, spec-kit/, node_modules/ 等目录)
  • 如果指定的是文件,仅处理该文件
  • 如果指定的是目录,处理该目录下所有 .md 文件

2. 执行标点符号规范化

使用 sedperl 进行批量替换,处理以下规则:

中文标点 → 英文标点:

中文标点 英文标点 说明
, 逗号后添加空格
. 句号后添加空格
: 冒号后添加空格
; 分号后添加空格
! 感叹号后添加空格
? 问号后添加空格
, 顿号替换为逗号并添加空格

空格处理规则:

  • 标点后如果是中文字符,添加一个空格
  • 标点后如果是英文/数字,检查是否已有空格,避免重复
  • 标点后如果是换行符,不添加空格
  • 标点后如果已经是空格,不重复添加

保护特殊内容 (不处理):

  • 代码块 (```...```)
  • 行内代码 (`...`)
  • URL 和链接
  • HTML 标签

3. 生成执行脚本

生成并执行 shell 脚本,示例:

#!/bin/bash

# 标点符号规范化脚本
# 处理指定目录下的 Markdown 文件

TARGET_DIR="${1:-.}"

# 使用 perl 进行替换(更好的 Unicode 支持)
find "$TARGET_DIR" -name "*.md" \
  -not -path "*/.git/*" \
  -not -path "*/spec-kit/*" \
  -not -path "*/node_modules/*" \
  -not -path "*/.venv/*" \
  -type f -exec perl -CSD -i -pe '
    # 保护代码块(先替换为占位符)
    # ... 保护逻辑 ...

    # 中文标点转英文标点(后跟非空白字符时添加空格)
    s/,(\S)/, $1/g;    # 逗号
    s/。(\S)/. $1/g;    # 句号
    s/:(\S)/: $1/g;    # 冒号
    s/;(\S)/; $1/g;    # 分号
    s/!(\S)/! $1/g;    # 感叹号
    s/?(\S)/? $1/g;    # 问号
    s/、(\S)/, $1/g;    # 顿号

    # 标点后已经是空白的情况(只替换标点)
    s/,(\s)/,$1/g;
    s/。(\s)/.$1/g;
    s/:(\s)/:$1/g;
    s/;(\s)/;$1/g;
    s/!(\s)/!$1/g;
    s/?(\s)/?$1/g;
    s/、(\s)/,$1/g;

    # 恢复代码块
    # ... 恢复逻辑 ...
  ' {} \;

echo "标点符号规范化完成"

4. 验证和报告

执行完成后:

  1. 显示处理的文件数量
  2. 显示修改的统计信息
  3. 如果有无法自动处理的情况,列出需要人工检查的位置

注意事项

  • 执行前会自动创建备份(可选)
  • 不会处理代码块内的内容
  • 不会处理 URL 中的标点
  • 建议在执行后进行 diff 检查

示例

处理前:

这是一个示例,包含中文标点。包括:冒号、顿号等!

处理后:

这是一个示例, 包含中文标点. 包括: 冒号, 顿号等!

输出格式

执行完成后输出:

📝 标点符号规范化报告

处理文件: 42 个
修改文件: 15 个

修改统计:
  ,→ ,   : 128 处
  。→ .   : 86 处
  :→ :   : 34 处
  ;→ ;   : 12 处
  !→ !   : 8 处
  ?→ ?   : 5 处
  、→ ,   : 23 处

✅ 标点符号规范化完成

Read the full file on GitHub · 144 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 144 lines · 0 tokens per session scan A f176833d1b93

Subscribe to this mod's changes

punctuation-fix is a command published in the GitHub repository Linfee/spec-kit-cn (695 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,201 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.