Ruler Rules Migration
Overview
Migrate a repository to a reusable Ruler rules structure with a safe audit/apply workflow. Keep default templates in English and avoid overwriting existing repository-specific content unless explicitly forced. Support different project types through preset-based template selection.
Inputs
Collect these inputs before applying changes:
- Target repository root path.
- Whether to run in
auditorapplymode. - Template preset:
auto,base,nextjs,monorepo, ornode-lib(default:auto). - Whether to include optional
skills:sync:claudeintegration. - Whether overwrite is allowed for differing files (
--force).
Presets
Presets control the content of project-specific template files (10-project-context.md, 20-dev-commands.md, 30-coding-conventions.md). Universal files (ruler.toml, AGENTS.md, 00-core-principles.md) are always sourced from the base directory.
| Preset | Auto-detect Signal | Use Case |
|---|---|---|
base | Fallback | Any project, minimal with placeholders |
nextjs | next.config.* exists | Next.js App Router projects |
monorepo | turbo.json or pnpm-workspace.yaml exists | Turborepo / pnpm workspace |
node-lib | package.json has main or exports, no next.config.* | Node.js libraries |
Preset Selection Priority
- Explicit
--preset <name>flag (highest priority). - Auto-detection from target repo files (when
--preset autoor omitted). - Falls back to
baseif no signals match.
Workflow
- Run the bootstrap script in
auditmode. - Review missing files, differences, and manual actions.
- Run in
applymode to create missing files and safe defaults. - Re-run
applyto confirm idempotency. - Run
ruler:applyin the target repo to generate root rule outputs.
Decision Tree
-
Need only Ruler integration: Use default behavior (do not pass
--with-optional-sync). -
Need optional Claude skills sync as well: Pass
--with-optional-syncto includeskills:sync:claudesuggestions. -
Targeting a specific project type: Pass
--preset nextjs,--preset monorepo, or--preset node-lib. Or let auto-detection choose the right preset. -
Existing files differ from templates:
- Keep defaults safe: do not override without
--force. - Use
--forceonly when intentional template replacement is required.
Commands
Use these commands from this skill directory:
# Audit (default preset auto-detection)
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode audit
# Apply with auto-detected preset
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply
# Apply with explicit preset
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply --preset nextjs
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply --preset monorepo
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply --preset node-lib
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply --preset base
# With optional sync and force
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply --preset nextjs --with-optional-sync
node ./scripts/bootstrap-ruler.mjs --target /path/to/repo --mode apply --force
Validation Checklist
After applying, verify:
.ruler/ruler.tomlexists and definescodex+claudeoutputs.- Required
.ruler/*.mdtemplates exist. .gitignorecontains the Ruler generated-files block.package.jsoncontainsruler:apply.- If
is-cistyle guard is used,is-ciis installed (pnpm add -D is-ci). postinstallfollows the CI-skip recommendation or an explicit local alternative (preserve existing setup commands by chaining with&& (...)).- Running
ruler:applysucceeds in the target repository.
Resources
-
Script:
scripts/bootstrap-ruler.mjs -
References:
references/migration-playbook.mdreferences/applyto-patterns.md -
Templates:
assets/templates/base/.ruler/(universal + fallback)assets/templates/presets/nextjs/.ruler/(Next.js overlay)assets/templates/presets/monorepo/.ruler/(monorepo overlay)assets/templates/presets/node-lib/.ruler/(Node.js library overlay)