RuleSync CLI: Manage Rules from Your Terminal
RuleSync CLI: the command-line tool for syncing AI coding rules across repositories. It connects to the RuleSync dashboard (where rulesets are managed), pulls the latest rules to your local project, pushes local rule changes back to the dashboard, and generates tool-specific rule files (CLAUDE.md, .cursorrules, copilot-instructions.md) from your centralized rulesets. The CLI: designed for developers who prefer the terminal over the web dashboard.
The RuleSync workflow: create and manage rulesets in the RuleSync dashboard (or via CLI). Assign rulesets to projects. The CLI (or CI/CD integration) pulls the assigned rulesets and generates the rule files in each project. When rulesets are updated: pull again to get the latest version. The CLI: the bridge between the centralized dashboard and the distributed repositories.
Who uses the CLI: individual developers (pull rules to their local project), CI/CD pipelines (automated rule sync on every build), and platform teams (manage rules across many repos from the terminal). The dashboard: for browsing rulesets, managing teams, and visual management. The CLI: for automated workflows and terminal-native developers.
Step 1: Install and Authenticate (2 Minutes)
Installation: npm install -g rulesync (or pnpm add -g rulesync). Verify: rulesync --version. The CLI: a Node.js package, works on macOS, Linux, and Windows. For project-local installation: pnpm add -D rulesync (use via pnpm exec rulesync or in package.json scripts). AI rule: 'Global install for developer workflow. Project-local install for CI/CD (ensures the CLI version is locked with the project).'
Authentication: rulesync login. This opens a browser window for authentication (OAuth with GitHub, GitLab, or email). After login: the CLI stores an authentication token locally. For CI/CD: use an API key instead of interactive login. Generate an API key in the RuleSync dashboard (Settings โ API Keys). Set as an environment variable: RULESYNC_API_KEY. The CLI uses the API key automatically when the environment variable is set.
Verify authentication: rulesync whoami. This displays: your username, organization, and the projects you have access to. If the output is correct: authentication is working. If it shows an error: re-run rulesync login or check the API key environment variable.
Global: npm install -g rulesync. The developer runs rulesync pull from any project directory. Convenient for daily use. Local: pnpm add -D rulesync. The CLI version is locked in package.json. CI/CD uses the exact same version every time. No 'it works locally but CI uses a different version' issues. For most teams: global for developer machines, local (in devDependencies) for CI pipelines.
Step 2: Connect and First Sync (3 Minutes)
Connect a project: navigate to your project directory. Run: rulesync init. The CLI: detects the project (from package.json, go.mod, etc.), asks which organization and ruleset to assign, and creates a .rulesyncrc configuration file in the project root. The config file: specifies which rulesets this project uses and which output formats to generate (CLAUDE.md, .cursorrules, or both).
First pull: rulesync pull. The CLI: fetches the assigned rulesets from the dashboard, composes them (if multiple rulesets are assigned โ organization rules + technology rules), and writes the output files (CLAUDE.md, .cursorrules). The generated files: committed to the repository so they are available to all developers. The pull: can be run manually or automated in CI/CD.
Verify the output: open the generated CLAUDE.md (or .cursorrules). The file: contains the composed rules from all assigned rulesets, with a header showing the ruleset versions and the generation timestamp. Test: start a Claude Code session in the project and verify the AI follows the rules. If it does: the setup is complete. If not: check the generated file for correctness or update the rulesets in the dashboard.
rulesync pull generates CLAUDE.md and .cursorrules. These files: should be committed to the repository. Why? Developers who do not have the RuleSync CLI installed: still get the rules (the files are in the repo). The AI tools: read the files from the repo, not from RuleSync. The CLI: is the delivery mechanism. The generated files: are the product. Commit them so every developer benefits, even those who never run the CLI.
Step 3: CLI Command Reference
Core commands: rulesync login (authenticate), rulesync init (connect a project to a ruleset), rulesync pull (fetch latest rules from dashboard and generate output files), rulesync push (push local rule changes back to the dashboard โ for ruleset authors), rulesync status (show current ruleset versions and sync status), and rulesync diff (show differences between local rules and the dashboard version).
Workflow commands: rulesync pull --format claude (generate only CLAUDE.md), rulesync pull --format cursor (generate only .cursorrules), rulesync pull --format all (generate all formats โ default), rulesync pull --dry-run (show what would change without writing files), and rulesync pull --check (exit with error if local rules are outdated โ useful in CI). AI rule: 'rulesync pull --check in CI: fails the build if rules are outdated. This ensures every build uses current rules.'
CI/CD integration: add rulesync pull --check to the CI pipeline. If the rules are current: the command exits successfully and the build continues. If the rules are outdated: the command exits with an error, failing the build with a message: 'AI rules are outdated. Run rulesync pull to update.' This ensures: every deployed version has current rules. The CI check: the automated equivalent of the pre-commit validation. AI rule: 'rulesync pull --check is the CI command. rulesync pull is the developer command. The --check flag: validates without writing files.'
Without --check: a developer forgets to run rulesync pull after a ruleset update. They push code with outdated rules. The build succeeds. The AI-generated code: follows old conventions. With --check in CI: the build fails with 'AI rules are outdated. Run rulesync pull to update.' The developer: runs rulesync pull, commits the updated files, and pushes again. Total delay: 2 minutes. Benefit: every deployed version has current rules. Always.
RuleSync CLI Summary
Complete RuleSync CLI setup.
- Install: npm install -g rulesync (global) or pnpm add -D rulesync (project-local for CI)
- Auth: rulesync login (interactive) or RULESYNC_API_KEY env var (CI/CD)
- Init: rulesync init in project directory. Selects org, ruleset, and output formats
- Pull: rulesync pull fetches rules and generates CLAUDE.md/.cursorrules
- Push: rulesync push sends local changes to the dashboard (for ruleset authors)
- Status: rulesync status shows current versions and sync status
- CI: rulesync pull --check fails if rules are outdated. Ensures every build has current rules
- Formats: --format claude, --format cursor, --format all (default)