SuperAPI AI Directory

doc-sync-tool

Office & productivity

View repository

Updated 10-24 16:15

About this skill

Doc Sync Tool

Feature Description

This tool is used to automatically sync AI Agent configuration documents in the project, ensuring that Agents.md、claude.md and gemini.md three files keep consistent content.

Core Features

  1. Auto Discovery: Recursively scans all folders under the current directory to find these three documents
  2. Smart Sync: When any one document is found, automatically creates/updates the other two
  3. File Watching: Monitors file changes in real time and automatically syncs the latest content
  4. Manual Trigger: Supports manual sync execution via command line

Use Cases

  • Share the same project configuration across multiple AI Agents
  • Automatically keep the work instructions of different AIs consistent
  • Avoid the hassle of manually maintaining multiple identical documents

Usage

Install dependencies

cd /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool
pnpm install

Manual sync (single run)

# 在项目根目录执行
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/sync.js

# 或者使用 npm script
pnpm run sync

Auto watch (continuous running)

# 启动文件监听服务
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js

# 或者使用 npm script
pnpm run watch

Run in background (recommended)

# 使用 PM2 在后台运行
pm2 start /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js --name doc-sync

# 查看状态
pm2 status

# 停止服务
pm2 stop doc-sync

How It Works

  1. Scanning phase: Recursively traverses the specified directory to find Agents.md、claude.md、gemini.md files
  2. Grouping phase: Groups these three files in the same folder into one group
  3. Sync phase:
    • If a group has only one file, copy its content to create the other two
    • If a group has multiple files, select the most recently modified one as the source and sync it to the other files
  4. Watch phase (watch mode): Continuously monitors file changes and triggers sync

Configuration Options

You can modify the following configurations in sync.js :

const CONFIG = {
  targetFiles: ['Agents.md', 'claude.md', 'gemini.md'],  // 目标文件列表
  scanPath: process.cwd(),                                // 扫描路径(默认当前目录)
  excludeDirs: ['node_modules', '.git', '.next', 'dist'] // 排除目录
};

Notes

  • The tool automatically skips directories such as node_modules、.git、.next、dist and other directories
  • The original format and content of files are preserved during sync
  • It is recommended to use it in a Git repository for easy tracking of file changes
  • Watch mode runs continuously; it is recommended to use PM2 to manage the process

Troubleshooting

Permission issues

chmod +x sync.js watch.js

Node.js version requirement

Requires Node.js 14+

Dependency installation failure

rm -rf node_modules package-lock.json
pnpm install