sync-gate

A command-line tool for managing a project’s sync-gate configuration, which checks whether related files are updated together. The configuration can define file patterns that require matching updates elsewhere.

In plain words
What is it for?
Use it to initialize, inspect, validate, add, remove, or locate sync-gate rules, including checks suitable for continuous integration.
Why use it?
It exposes broken or ineffective synchronization rules that might otherwise fail silently.

Command

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/skymanbp/cc-enforcer/sync-gate
Clone the repo
git clone --depth 1 https://github.com/skymanbp/cc-enforcer
Per session 53 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,333 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.00053 $0.01333
Opus 5 $0.00026 $0.00666
Sonnet 5 $0.00011 $0.00267
Haiku 4.5 $0.00005 $0.00133

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

Security

Grade A, and why

sync-gate 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 2d 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.

commands/sync-gate.md · 81 lines

How it starts

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

/cc-enforcer:sync-gate

rule 12 的被动半区.claude/cc-enforcer/sync-gate.toml 驱动:某组的 when glob 命中了本会话编辑过的文件,而 require 侧一个都没动 → Stop layer (i) 拦下完成声明(除非回复里有 同步核对: / sync-check: 标记)。 本命令调用 hooks/scripts/manage_sync_gate.py。 机制说明见 rules/12-repo-wide-sync.md

为什么必须有 check

sync_gate.load()故意 failing-open 的:配置解析失败、某个组缺 when/require、某个 glob 打不中任何文件 —— 这些情况下它都不报错,只是 静默地不再守护,外加一行没人看的 stderr。

后果是:一道你以为在守着、其实早就失效的门,比没有门更坏,因为你不会再去 看它。check 就是唯一能戳破这层的东西。

子命令

子命令 作用
check 打印 loader 实际解析出的组 + 被丢弃的组(写在文件里但 loader 不认)+ 打不中任何文件的 glob。有任何问题 → 退出码 1,因此可以直接进 CI。
list 只打印实际加载的组(check 的安静版)。
init 生成带注释的模板(0 个组)。已存在则拒绝覆盖。
add 追加一组,写前双重校验(见下)。
remove 按名字删一组。
path 打印解析到的配置路径。

你(receiving agent)要做的

python "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/manage_sync_gate.py" check
python "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/manage_sync_gate.py" init
python "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/manage_sync_gate.py" \
    add rules-fanout --when 'rules/*.md' --require 'docs/RULES.md' \
    --note '改规则要同步索引'
python "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/manage_sync_gate.py" remove rules-fanout

参数:

  • --when GLOB / --require GLOB:可重复。对项目相对路径做 fnmatch, * 跨路径分隔符(所以 rules/*.md 也覆盖 rules/zh/)。
  • --allmode = "all"每一个 require glob 都必须有编辑命中。用于 锁步不变量(例:plugin.json 改了,marketplace.jsonCHANGELOG.md 必须双双跟上——只跟一个正是 v0.22.1 的翻车形态)。不加则是 any-of。
  • --note:为什么这几个文件必须一起动。会出现在 layer (i) 的拦截理由里, 所以写给"三个月后的自己"看。

写入契约

add / remove重写整个文件,落盘前过两道:

  1. 能不能解析回来tomlio.dumps_check)—— 序列化 bug 不许把配置写坏。
  2. loader 认不认(用真正的 sync_gate.load_file 回读)—— 一个 require = [] 的组是合法 TOML,但会被 loader 静默丢弃。只做第 1 道的话,CLI 会报告 "已添加",而那一组什么也不守。任何一组回读不到 → 拒写并原样还原文件。

写入目标由 CLAUDE_PROJECT_DIR → 带 .git/.claude 标记的 cwd 确定性解析, 不会去搜索"哪里已经有一个配置文件"。没有 --global:glob 是仓库相对的, 一个组离开它的仓库就没有意义。

Read the full file on GitHub · 81 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. 2d ago First seen · 81 lines · 53 tokens per session scan A 0cb33eb6abc1

Subscribe to this mod's changes

sync-gate is a command published in the GitHub repository skymanbp/cc-enforcer (5 stars, last pushed 7d ago), licensed MIT. It adds 53 tokens to every session and 1,333 once invoked, about $0.0003 per session on Opus 5. 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-31.