Skip to content

starinzlob/ruleferry

Repository files navigation

RuleFerry

一套项目规则,同步到 Codex、Claude Code、Cursor、GitHub Copilot、Gemini CLI 和 OpenCode。
One set of project rules, synchronized across Codex, Claude Code, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

中文 · English

中文

RuleFerry 使用 .ruleferry/rules.md 保存唯一的规范来源,检查各平台指令文件中的冲突和敏感数据,再把共享规则同步到带有清晰标记的托管区块中。原本由人工编写的平台专属指令会保持不变。

快速开始

npx --yes ruleferry init
npx --yes ruleferry check
npx --yes ruleferry diff
npx --yes ruleferry sync

init 会导入现有指令文件中内容最多的一份;使用 --from 时,会优先采用指定的适配器。它不会覆盖已经存在的 RuleFerry 或旧版 AgentRules 配置。

npx --yes ruleferry init --from agents

先检查 .ruleferry/rules.md,再用 diff 预览目标文件的精确变更,确认后运行 sync

支持的文件

适配器 托管目标
Codex AGENTS.md
Claude Code CLAUDE.md
Cursor .cursor/rules/ruleferry.mdc
GitHub Copilot .github/copilot-instructions.md
Gemini CLI GEMINI.md
OpenCode .opencode/rules.md

.ruleferry.json 中配置要启用的目标:

{
  "version": 1,
  "source": ".ruleferry/rules.md",
  "targets": ["agents", "claude", "cursor", "copilot", "gemini", "opencode"]
}

审计检查

npx --yes ruleferry check --strict
npx --yes ruleferry check --format json
npx --yes ruleferry check --format github

当前 MVP 可以发现:

  • 多个指令文件中完全重复的规则;
  • 围绕同一主题可能存在的肯定/否定冲突;
  • 嵌入的 API Key、令牌和私钥;
  • 让规则无法移植的用户专属绝对路径;
  • 缺失的规范来源文件。

冲突检测刻意保持为提示性质。请人工审查警告,不要让工具自动改写规则语义。

安全同步

生成的规则会放在以下标记之间:

<!-- ruleferry:start -->
共享规则会出现在这里。
<!-- ruleferry:end -->

后续运行时,RuleFerry 只替换这个区块。可以使用 --target cursor 单独预览或同步某个适配器。由 AgentRules 0.1.0 创建的项目仍然可以读取;下一次同步会升级旧标记,同时保留所有非托管内容。

GitHub Actions

examples/github-workflow.yml 复制到你的仓库中。该工作流会直接从这个 GitHub 仓库安装 RuleFerry,--format github 会输出 GitHub 原生注释。

Agent Skill

仓库在 skills/ruleferry 中提供了可安装的 Skill。它会指导 Agent 先审计、再检查差异,最后在不删除平台专属指令的前提下完成同步。

开发

npm install
npm test

需要 Node.js 20 或更高版本。

许可

MIT


English

RuleFerry keeps a canonical .ruleferry/rules.md, audits instruction files for conflicts and sensitive data, and ferries shared rules into clearly marked managed blocks. Existing hand-written platform-specific instructions stay intact.

Quick start

npx --yes ruleferry init
npx --yes ruleferry check
npx --yes ruleferry diff
npx --yes ruleferry sync

init imports the largest existing instruction file, preferring the adapter selected with --from. It never overwrites an existing RuleFerry or legacy AgentRules setup.

npx --yes ruleferry init --from agents

Review .ruleferry/rules.md, preview the exact target files with diff, then run sync.

Supported files

Adapter Managed target
Codex AGENTS.md
Claude Code CLAUDE.md
Cursor .cursor/rules/ruleferry.mdc
GitHub Copilot .github/copilot-instructions.md
Gemini CLI GEMINI.md
OpenCode .opencode/rules.md

Configure enabled targets in .ruleferry.json:

{
  "version": 1,
  "source": ".ruleferry/rules.md",
  "targets": ["agents", "claude", "cursor", "copilot", "gemini", "opencode"]
}

Audit checks

npx --yes ruleferry check --strict
npx --yes ruleferry check --format json
npx --yes ruleferry check --format github

The MVP detects:

  • exact rules duplicated across instruction files;
  • likely positive/negative conflicts about the same subject;
  • embedded API keys, tokens, and private keys;
  • user-specific absolute paths that make rules non-portable;
  • a missing canonical source.

Conflict detection is intentionally advisory. Review warnings instead of applying automatic semantic rewrites.

Safe synchronization

Generated rules live between markers:

<!-- ruleferry:start -->
Shared rules appear here.
<!-- ruleferry:end -->

RuleFerry replaces only this block on subsequent runs. Use --target cursor to preview or synchronize a single adapter. Projects created with AgentRules 0.1.0 remain readable; the next sync upgrades legacy markers while preserving unmanaged content.

GitHub Actions

Copy examples/github-workflow.yml into your repository. The workflow installs RuleFerry directly from this GitHub repository and --format github emits native annotations.

Agent Skill

The repository includes an installable Skill at skills/ruleferry. It teaches an agent to audit first, review the diff, and synchronize without erasing platform-specific instructions.

Development

npm install
npm test

Requires Node.js 20 or newer.

License

MIT

About

Safely audit and synchronize coding-agent instruction files across Codex, Claude Code, Cursor, Copilot, Gemini CLI, and OpenCode.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages