Learn-skills.dev ruler-rules-init
Migrate and bootstrap Ruler-based AI rules across repositories with English-first templates, preset-based project detection, and safe, idempotent setup. Use when creating or standardizing `.ruler/*` files, generating `AGENTS.md`/`CLAUDE.md`, wiring `ruler:apply` into `package.json`, adding generated-file ignores in `.gitignore`, and designing `applyTo` scoping patterns such as `**` and `web/**`.
git clone https://github.com/NeverSight/learn-skills.dev
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/adonis0123/adonis-skills/ruler-rules-init" ~/.claude/skills/neversight-learn-skills-dev-ruler-rules-init && rm -rf "$T"
data/skills-md/adonis0123/adonis-skills/ruler-rules-init/SKILL.mdRuler 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
oraudit
mode.apply - Template preset:
,auto
,base
,nextjs
, ormonorepo
(default:node-lib
).auto - Whether to include optional
integration.skills:sync:claude - 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 |
|---|---|---|
| Fallback | Any project, minimal with placeholders |
| exists | Next.js App Router projects |
| or exists | Turborepo / pnpm workspace |
| has or , no | Node.js libraries |
Preset Selection Priority
- Explicit
flag (highest priority).--preset <name> - Auto-detection from target repo files (when
or omitted).--preset auto - Falls back to
if no signals match.base
Workflow
- Run the bootstrap script in
mode.audit - Review missing files, differences, and manual actions.
- Run in
mode to create missing files and safe defaults.apply - Re-run
to confirm idempotency.apply - Run
in the target repo to generate root rule outputs.ruler:apply
Decision Tree
-
Need only Ruler integration: Use default behavior (do not pass
).--with-optional-sync -
Need optional Claude skills sync as well: Pass
to include--with-optional-sync
suggestions.skills:sync:claude -
Targeting a specific project type: Pass
,--preset nextjs
, or--preset monorepo
. Or let auto-detection choose the right preset.--preset node-lib -
Existing files differ from templates:
- Keep defaults safe: do not override without
.--force - Use
only when intentional template replacement is required.--force
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:
exists and defines.ruler/ruler.toml
+codex
outputs.claude- Required
templates exist..ruler/*.md
contains the Ruler generated-files block..gitignore
containspackage.json
.ruler:apply- If
style guard is used,is-ci
is installed (is-ci
).pnpm add -D is-ci
follows the CI-skip recommendation or an explicit local alternative (preserve existing setup commands by chaining withpostinstall
).&& (...)- Running
succeeds in the target repository.ruler:apply
Resources
-
Script:
scripts/bootstrap-ruler.mjs -
References:
references/migration-playbook.mdreferences/applyto-patterns.md -
Templates:
(universal + fallback)assets/templates/base/.ruler/
(Next.js overlay)assets/templates/presets/nextjs/.ruler/
(monorepo overlay)assets/templates/presets/monorepo/.ruler/
(Node.js library overlay)assets/templates/presets/node-lib/.ruler/