Feature Description
This tool is used to automatically sync the AI Agent configuration documents in the project, ensuring that Agents.md、claude.md and gemini.md the three files remain consistent in content.
Core Features
- Automatic Discovery: recursively scan all folders under the current directory to find these three documents
- Smart Sync: when any one document is found, automatically create/update the other two
- File Watching: monitor file changes in real time and automatically sync the latest content
- Manual Trigger: supports manually executing sync from the 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
How to Use
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
Automatic watching (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 the 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
- Scanning Phase: recursively traverse the specified directory to find
Agents.md、claude.md、gemini.mdfiles - Grouping Phase: group these three files in the same folder together
- Sync Phase:
- If a group has only one file, copy its content to create the other two
- If a group has multiple files, choose the most recently modified as the source and sync it to the other files
- Watching Phase (watch mode): continuously monitor file changes and trigger sync
Configuration Options
You can modify the following configuration in sync.js :
const CONFIG = {
targetFiles: ['Agents.md', 'claude.md', 'gemini.md'], // 目标文件列表
scanPath: process.cwd(), // 扫描路径(默认当前目录)
excludeDirs: ['node_modules', '.git', '.next', 'dist'] // 排除目录
};
Notes
- The tool will automatically skip
node_modules、.git、.next、distand other directories - During sync, the original format and content of the files will be preserved
- It is recommended to use it in a Git repository to make it easier to track file changes
- Watch mode will run continuously; it is recommended to use PM2 to manage the process
Troubleshooting
Permission issues
chmod +x sync.js watch.js
Node.js version requirements
Requires Node.js 14+
Dependency installation failed
rm -rf node_modules package-lock.json
pnpm install