AI Rules Sync (AIS) - Synchronize, manage, and share your AI agent rules across projects and teams.
Stop copying .mdc files around. Manage your rules in Git repositories and sync them via symbolic links.
Supports: Cursor (rules, commands, skills, agents), Copilot (instructions), Claude (skills, agents), Trae (rules, skills), OpenCode (agents, skills, commands, tools), and universal AGENTS.md.
- Why AIS?
- Quick Start
- Installation
- Supported Tools
- Core Concepts
- Basic Usage
- Tool-Specific Guides
- Advanced Features
- Configuration Reference
- Architecture
- 🧩 Multi-Repository: Mix rules from company standards, team protocols, and open-source collections
- 🔄 Sync Once, Update Everywhere: One source of truth, automatic updates across all projects
- 🤝 Team Alignment: Share coding standards instantly, onboard new members with one command
- 🔒 Privacy First: Keep sensitive rules local with
ai-rules-sync.local.json - 🛠️ Git Integration: Manage repositories directly through CLI (
ais git) - 🔌 Extensible: Plugin architecture for adding new AI tools
You have a rules repository and want to use its rules in your project.
# 1. Install AIS
npm install -g ai-rules-sync
# 2. Go to your project
cd your-project
# 3. Add a rule (IMPORTANT: specify repository URL the first time)
ais cursor add react -t https://github.com/your-org/rules-repo.git
# Done! The rule is now linked to your projectWhat just happened?
- AIS cloned the repository to
~/.config/ai-rules-sync/repos/ - Set it as your current repository
- Created a symlink:
rules-repo/.cursor/rules/react→your-project/.cursor/rules/react - Saved the configuration to
ai-rules-sync.json
Next time, you can omit the -t flag:
ais cursor add vue
ais cursor add testingYou have rules in your project and want to share them via a repository.
# 1. Install AIS
npm install -g ai-rules-sync
# 2. Create a rules repository (or use existing one)
# Option A: Create new repository
git init ~/my-rules-repo
ais use ~/my-rules-repo
# Option B: Use existing repository
ais use https://github.com/your-org/rules-repo.git
# 3. Import your existing rule
cd your-project
ais cursor rules import my-custom-rule
# Done! Your rule is now in the repository and linked to your projectWhat just happened?
- AIS copied
your-project/.cursor/rules/my-custom-ruleto the repository - Created a git commit
- Replaced the original with a symlink
- Saved the configuration to
ai-rules-sync.json
Optional: Push to remote
ais cursor rules import my-rule --push
# or manually:
ais git pushnpm install -g ai-rules-syncVerify installation:
ais --versionOptional: Enable tab completion
ais completion install| Tool | Type | Mode | Default Source Directory | File Suffixes | Documentation |
|---|---|---|---|---|---|
| Cursor | Rules | hybrid | .cursor/rules/ |
.mdc, .md |
Docs |
| Cursor | Commands | file | .cursor/commands/ |
.md |
Docs |
| Cursor | Skills | directory | .cursor/skills/ |
- | Docs |
| Cursor | Agents | directory | .cursor/agents/ |
- | Docs |
| Copilot | Instructions | file | .github/instructions/ |
.instructions.md, .md |
Docs |
| Claude | Skills | directory | .claude/skills/ |
- | Docs |
| Claude | Agents | directory | .claude/agents/ |
- | Docs |
| Trae | Rules | file | .trae/rules/ |
.md |
Website |
| Trae | Skills | directory | .trae/skills/ |
- | Website |
| OpenCode | Agents | file | .opencode/agents/ |
.md |
Website |
| OpenCode | Skills | directory | .opencode/skills/ |
- | Website |
| OpenCode | Commands | file | .opencode/commands/ |
.md |
Website |
| OpenCode | Tools | file | .opencode/tools/ |
.ts, .js |
Website |
| Universal | AGENTS.md | file | . (root) |
.md |
Standard |
Modes:
- directory: Links entire directories (skills, agents)
- file: Links individual files with automatic suffix resolution
- hybrid: Links both files and directories (e.g., Cursor rules)
A rules repository is a Git repository containing your rules, organized by tool:
my-rules-repo/
├── .cursor/
│ ├── rules/
│ │ ├── react.mdc
│ │ └── typescript.mdc
│ ├── commands/
│ │ └── deploy.md
│ └── skills/
│ └── code-review/
├── .claude/
│ └── skills/
│ └── debug-helper/
└── ai-rules-sync.json # Optional: customize source paths
Repository Locations:
- Global:
~/.config/ai-rules-sync/repos/(managed by AIS) - Local: Any local path (for development)
Managing Repositories:
# Set current repository
ais use https://github.com/your-org/rules-repo.git
# List all repositories
ais list
# Switch between repositories
ais use company-rules
ais use personal-rules# First time: specify repository
ais cursor add react -t https://github.com/org/rules.git
# After that: use current repository
ais cursor add vueWhen to use: You want to use existing rules from a repository.
# Import existing rule from your project
ais cursor rules import my-custom-rule
# With options
ais cursor rules import my-rule --message "Add my rule" --pushWhen to use: You have rules in your project and want to share them.
# Install all rules from ai-rules-sync.json
ais install
# Install specific tool
ais cursor installWhen to use: You cloned a project with ai-rules-sync.json and want to set up all rules.
ai-rules-sync.json - Project configuration (committed to git)
{
"cursor": {
"rules": {
"react": "https://github.com/org/rules.git"
}
}
}ai-rules-sync.local.json - Private rules (NOT committed to git)
{
"cursor": {
"rules": {
"company-secrets": "https://github.com/company/private-rules.git"
}
}
}Option 1: Use an existing repository
ais use https://github.com/your-org/rules-repo.gitOption 2: Create a new local repository
# Create directory and initialize git
mkdir ~/my-rules-repo
cd ~/my-rules-repo
git init
# Set as current repository
ais use ~/my-rules-repo
# Create rules structure
mkdir -p .cursor/rules
echo "# React Rules" > .cursor/rules/react.mdc
git add .
git commit -m "Initial commit"Option 3: Clone and use
git clone https://github.com/your-org/rules-repo.git ~/my-rules-repo
ais use ~/my-rules-repoBasic add:
cd your-project
# First time: specify repository
ais cursor add react -t https://github.com/org/rules.git
# Subsequent adds
ais cursor add vue
ais cursor add typescriptAdd with alias:
# Add 'react' rule but name it 'react-18' in your project
ais cursor add react react-18Add from different repository:
# Add from company repository
ais cursor add coding-standards -t company-rules
# Add from personal repository
ais cursor add my-utils -t personal-rulesAdd as private (local) rule:
# Won't be committed to git (saved in ai-rules-sync.local.json)
ais cursor add company-secrets --localImport a rule from your project to repository:
cd your-project
# Import rule
ais cursor rules import my-custom-rule
# Import with custom commit message
ais cursor rules import my-rule -m "Add custom rule"
# Import and push to remote
ais cursor rules import my-rule --push
# Force overwrite if exists in repository
ais cursor rules import my-rule --forceWhat happens during import:
- Copies rule from project to repository
- Creates a git commit
- Replaces original with symlink
- Updates
ai-rules-sync.json
# Remove a rule (deletes symlink and config entry)
ais cursor remove react
# Remove from specific tool
ais cursor commands remove deploy
ais cursor skills remove code-reviewWhen cloning a project:
# Clone project
git clone https://github.com/team/project.git
cd project
# Install all rules from ai-rules-sync.json
ais installReinstall all rules:
# Remove and recreate all symlinks
ais cursor install
ais copilot install
ais install # All tools# Add a .mdc file
ais cursor add react
ais cursor add coding-standards.mdc
# Add a .md file
ais cursor add readme.md
# Add a rule directory
ais cursor add my-rule-dir
# Remove
ais cursor remove react# Add command
ais cursor commands add deploy-docs
# Remove command
ais cursor commands remove deploy-docs# Add skill (directory)
ais cursor skills add code-review
# Remove skill
ais cursor skills remove code-review# Add agent (directory)
ais cursor agents add code-analyzer
# Remove agent
ais cursor agents remove code-analyzer# Add instruction
ais copilot add coding-style
# Suffix matching (if both exist, you must specify)
ais copilot add style.md # Explicit
ais copilot add style.instructions.md # Explicit
# Remove
ais copilot remove coding-style# Add skill
ais claude skills add code-review
# Add agent
ais claude agents add debugger
# Remove
ais claude skills remove code-review
ais claude agents remove debugger# Add rule
ais trae rules add project-rules
# Add skill
ais trae skills add adapter-builder
# Remove
ais trae rules remove project-rules
ais trae skills remove adapter-builder# Add agent
ais opencode agents add code-reviewer
# Add skill
ais opencode skills add refactor-helper
# Add command
ais opencode commands add build-optimizer
# Add tool
ais opencode tools add project-analyzer
# Remove
ais opencode agents remove code-reviewer# Add from root
ais agents-md add .
# Add from directory
ais agents-md add frontend
# Add with alias (to distinguish multiple AGENTS.md files)
ais agents-md add frontend fe-agents
ais agents-md add backend be-agents
# Remove
ais agents-md remove fe-agentsUse the -t flag to specify which repository to use:
# Add from company repository
ais cursor add coding-standards -t company-rules
# Add from open-source repository
ais cursor add react-best-practices -t https://github.com/community/rules.git
# Add from personal repository
ais cursor add my-utils -t personal-rulesView current repository:
ais list
# * company-rules (current)
# personal-rules
# community-rulesSwitch default repository:
ais use personal-rulesAll commands support:
-t, --target <repo>: Specify repository (name or URL)-l, --local: Save toai-rules-sync.local.json(private)
Examples:
ais cursor add react -t company-rules --local
ais copilot add coding-style -t https://github.com/org/rules.gitAutomatically discover and install ALL available rules:
# Install everything from current repository
ais add-all
# Install all Cursor rules
ais cursor add-all
# Install specific type
ais cursor rules add-all
# Preview before installing
ais add-all --dry-run
# Filter by tool
ais add-all --tools cursor,copilot
# Interactive mode (confirm each)
ais cursor add-all --interactive
# Force overwrite existing
ais add-all --force
# Skip existing
ais add-all --skip-existing
# Save as private
ais cursor add-all --localOutput example:
Discovering entries from repository...
cursor-rules: 5 entries
cursor-commands: 3 entries
Total: 8 entries discovered
Installing entries:
[1/8] cursor-rules/react → .cursor/rules/react ✓
[2/8] cursor-rules/vue → .cursor/rules/vue ✓
...
Summary:
Installed: 7
Skipped: 1 (already configured)
For third-party repositories with non-standard structure:
# Simple format (in context)
ais cursor rules add-all -s custom/rules
# Dot notation format (explicit)
ais add-all -s cursor.rules=custom/rules -s cursor.commands=custom/cmds
# Preview first
ais cursor rules add-all -s custom/rules --dry-run# Set custom source directory
ais config repo set-source third-party cursor.rules custom/rules
# View configuration
ais config repo show third-party
# Clear configuration
ais config repo clear-source third-party cursor.rules
ais config repo clear-source third-party # Clear all
# List all repositories
ais config repo listPriority system:
CLI Parameters > Global Config > Repository Config > Adapter Defaults
Change where rules are linked in your project:
# Add to custom directory
ais cursor add my-rule -d docs/ai/rules
# Monorepo: different packages
ais cursor add react-rules frontend-rules -d packages/frontend/.cursor/rules
ais cursor add node-rules backend-rules -d packages/backend/.cursor/rulesIMPORTANT: Adding same rule to multiple locations requires aliases:
# First location (no alias needed)
ais cursor add auth-rules -d packages/frontend/.cursor/rules
# Second location (alias REQUIRED)
ais cursor add auth-rules backend-auth -d packages/backend/.cursor/rulesCustomize source paths in repository:
Create ai-rules-sync.json in your rules repository:
{
"rootPath": "src",
"sourceDir": {
"cursor": {
"rules": ".cursor/rules",
"commands": ".cursor/commands",
"skills": ".cursor/skills",
"agents": ".cursor/agents"
},
"copilot": {
"instructions": ".github/instructions"
},
"claude": {
"skills": ".claude/skills",
"agents": ".claude/agents"
},
"trae": {
"rules": ".trae/rules",
"skills": ".trae/skills"
},
"opencode": {
"agents": ".opencode/agents",
"skills": ".opencode/skills",
"commands": ".opencode/commands",
"tools": ".opencode/tools"
},
"agentsMd": {
"file": "."
}
}
}Manage repository directly from CLI:
# Check repository status
ais git status
# Pull latest changes
ais git pull
# Push commits
ais git push
# Run any git command
ais git log --oneline
ais git branch
# Specify repository
ais git status -t company-rulesAutomatic installation (recommended):
On first run, AIS will offer to install tab completion.
Manual installation:
ais completion installOr add to shell config manually:
Bash/Zsh (~/.bashrc or ~/.zshrc):
eval "$(ais completion)"Fish (~/.config/fish/config.fish):
ais completion fish | sourceUsage:
ais cursor add <Tab> # Lists available rules
ais cursor commands add <Tab> # Lists available commands
ais copilot add <Tab> # Lists available instructionsProject configuration file (committed to git):
{
"cursor": {
"rules": {
"react": "https://github.com/user/repo.git",
"react-v2": {
"url": "https://github.com/user/another-repo.git",
"rule": "react"
}
},
"commands": {
"deploy-docs": "https://github.com/user/repo.git"
},
"skills": {
"code-review": "https://github.com/user/repo.git"
},
"agents": {
"code-analyzer": "https://github.com/user/repo.git"
}
},
"copilot": {
"instructions": {
"general": "https://github.com/user/repo.git"
}
},
"claude": {
"skills": {
"code-review": "https://github.com/user/repo.git"
},
"agents": {
"debugger": "https://github.com/user/repo.git"
}
},
"trae": {
"rules": {
"project-rules": "https://github.com/user/repo.git"
},
"skills": {
"adapter-builder": "https://github.com/user/repo.git"
}
},
"opencode": {
"agents": {
"code-reviewer": "https://github.com/user/repo.git"
},
"skills": {
"refactor-helper": "https://github.com/user/repo.git"
},
"commands": {
"build-optimizer": "https://github.com/user/repo.git"
},
"tools": {
"project-analyzer": "https://github.com/user/repo.git"
}
}
}Format types:
-
Simple string: Just the repository URL
"react": "https://github.com/user/repo.git"
-
Object with alias: Different name in project vs repository
"react-v2": { "url": "https://github.com/user/repo.git", "rule": "react" }
-
Object with custom target directory:
"docs-rule": { "url": "https://github.com/user/repo.git", "targetDir": "docs/ai/rules" }
Use ai-rules-sync.local.json for private rules:
# Add private rule
ais cursor add company-secrets --localThis file:
- Has same structure as
ai-rules-sync.json - Should be in
.gitignore(AIS adds it automatically) - Merges with main config (local takes precedence)
Location: ~/.config/ai-rules-sync/config.json
{
"currentRepo": "company-rules",
"repos": {
"company-rules": {
"name": "company-rules",
"url": "https://github.com/company/rules",
"path": "/Users/user/.config/ai-rules-sync/repos/company-rules",
"sourceDir": {
"cursor": {
"rules": "rules/cursor",
"commands": "commands/cursor"
}
}
},
"personal-rules": {
"name": "personal-rules",
"url": "https://github.com/me/rules",
"path": "/Users/user/.config/ai-rules-sync/repos/personal-rules"
}
}
}Old cursor-rules.json format is still supported:
- If
ai-rules-sync.jsondoesn't exist butcursor-rules.jsondoes, AIS will read it - Running any write command (add/remove) will migrate to new format
- Only Cursor rules are supported in legacy format
AIS uses a plugin-based adapter architecture:
CLI Layer
↓
Adapter Registry & Lookup (findAdapterForAlias)
↓
Unified Operations (addDependency, removeDependency, link, unlink)
↓
Sync Engine (linkEntry, unlinkEntry)
↓
Config Layer (ai-rules-sync.json)
Key Design Principles:
- Unified Interface: All adapters implement the same operations
- Auto-Routing: Automatically finds correct adapter based on config
- Generic Functions:
addDependencyGeneric()andremoveDependencyGeneric()work with any adapter - Extensible: Easy to add support for new AI tools
1. Create adapter file (src/adapters/my-tool.ts):
import { createBaseAdapter, createSingleSuffixResolver, createSuffixAwareTargetResolver } from './base.js';
// Directory mode (skills, agents)
export const myToolSkillsAdapter = createBaseAdapter({
name: 'my-tool-skills',
tool: 'my-tool',
subtype: 'skills',
configPath: ['myTool', 'skills'],
defaultSourceDir: '.my-tool/skills',
targetDir: '.my-tool/skills',
mode: 'directory',
});
// File mode (single suffix)
export const myToolRulesAdapter = createBaseAdapter({
name: 'my-tool-rules',
tool: 'my-tool',
subtype: 'rules',
configPath: ['myTool', 'rules'],
defaultSourceDir: '.my-tool/rules',
targetDir: '.my-tool/rules',
mode: 'file',
fileSuffixes: ['.md'],
resolveSource: createSingleSuffixResolver('.md', 'Rule'),
resolveTargetName: createSuffixAwareTargetResolver(['.md']),
});2. Register adapter (src/adapters/index.ts):
import { myToolSkillsAdapter, myToolRulesAdapter } from './my-tool.js';
// In DefaultAdapterRegistry constructor:
this.register(myToolSkillsAdapter);
this.register(myToolRulesAdapter);3. Update ProjectConfig (src/project-config.ts):
export interface ProjectConfig {
// ... existing fields ...
myTool?: {
skills?: Record<string, RuleEntry>;
rules?: Record<string, RuleEntry>;
};
}Done! Your adapter now supports all operations through the unified interface.
# New team member clones project
git clone https://github.com/team/project.git
cd project
# Install AIS
npm install -g ai-rules-sync
# Install all rules
ais install
# Done! All rules are now linked# Pull latest rules
ais git pull
# Rules are automatically updated (symlinks point to repository)# 1. Create repository
mkdir company-rules
cd company-rules
git init
# 2. Create structure
mkdir -p .cursor/rules .cursor/commands .claude/skills
# 3. Add rules
echo "# Company Coding Standards" > .cursor/rules/coding-standards.mdc
echo "# React Best Practices" > .cursor/rules/react.mdc
# 4. Commit
git add .
git commit -m "Initial company rules"
# 5. Push to remote
git remote add origin https://github.com/company/rules.git
git push -u origin main
# 6. Team members can now use
ais cursor add coding-standards -t https://github.com/company/rules.git# 1. Set up repository
ais use https://github.com/team/rules.git
# 2. Import all existing rules
cd your-project
ais cursor rules import rule1
ais cursor rules import rule2
ais cursor commands import deploy
ais claude skills import code-review
# 3. Push to remote
ais git push
# 4. Team can now install
# In ai-rules-sync.json, share the config
# Team members run: ais install# Verify installation
npm list -g ai-rules-sync
# Reinstall
npm install -g ai-rules-sync
# Check PATH
echo $PATH# Remove all symlinks and recreate
ais cursor install
# Or manually
rm .cursor/rules/*
ais cursor install# List repositories
ais list
# Set repository
ais use <repo-name-or-url># Zsh: ensure completion is initialized
# Add to ~/.zshrc before ais completion line:
autoload -Uz compinit && compinit- Documentation: https://github.com/lbb00/ai-rules-sync
- Issues: https://github.com/lbb00/ai-rules-sync/issues
- NPM: https://www.npmjs.com/package/ai-rules-sync
Unlicense - Free to use, modify, and distribute.