Skip to content

Programmatic API

Rulesync can be used as a library in your Node.js/TypeScript projects. The generate and importFromTool functions are available as named exports.

typescript
import { generate, importFromTool } from "rulesync";

// Generate configurations
const result = await generate({
  targets: ["claudecode", "cursor"],
  features: ["rules", "mcp"],
});
console.log(`Generated ${result.rulesCount} rules, ${result.mcpCount} MCP configs`);

// Import existing tool configurations into .rulesync/
const importResult = await importFromTool({
  target: "claudecode",
  features: ["rules", "commands"],
});
console.log(`Imported ${importResult.rulesCount} rules`);

generate(options?)

Generates configuration files for the specified targets and features.

OptionTypeDefaultDescription
targetsToolTarget[]from config fileTools to generate configurations for
featuresFeature[]from config fileFeatures to generate
baseDirsstring[][process.cwd()]Base directories for generation
configPathstringauto-detectedPath to rulesync.jsonc
verbosebooleanfalseEnable verbose logging
silentbooleantrueSuppress all output
deletebooleanfrom config fileDelete existing files before generating
globalbooleanfalseGenerate global (user scope) configurations
simulateCommandsbooleanfalseGenerate simulated commands
simulateSubagentsbooleanfalseGenerate simulated subagents
simulateSkillsbooleanfalseGenerate simulated skills
dryRunbooleanfalseShow changes without writing files
checkbooleanfalseExit with code 1 if files are not up to date

importFromTool(options)

Imports existing tool configurations into .rulesync/ directory.

OptionTypeDefaultDescription
targetToolTarget(required)Tool to import configurations from
featuresFeature[]from config fileFeatures to import
configPathstringauto-detectedPath to rulesync.jsonc
verbosebooleanfalseEnable verbose logging
silentbooleantrueSuppress all output
globalbooleanfalseImport global (user scope) configurations

Released under the MIT License.