-
Notifications
You must be signed in to change notification settings - Fork 106
feat: add --rulesync-dir flag to decouple source rules from output directory #1514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0f83522
fb61dd9
e1eff88
f39b126
0c43acc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Separate Rulesync Directory | ||
|
|
||
| The `--rulesync-dir <path>` flag lets you point `rulesync generate` at a `.rulesync/` source directory that is different from the current working directory. This decouples where your rule definitions live from where the generated tool configuration files are written. | ||
|
|
||
| ## Primary use case: centralized rules across all repos | ||
|
|
||
| A common workflow is to keep a single set of AI rules in a shared directory (e.g. `~/.aiglobal`) and apply them to every project without switching directories: | ||
|
|
||
| ```bash | ||
| # In any project directory — rules are read from ~/.aiglobal/.rulesync/ | ||
| rulesync generate --rulesync-dir ~/.aiglobal --targets "*" --features rules | ||
| ``` | ||
|
|
||
| Without `--rulesync-dir`, you would have to `cd ~/.aiglobal && rulesync generate` and then `cd -` back, and the output files would land in `~/.aiglobal` instead of the current project. | ||
|
|
||
| ## Step-by-step setup | ||
|
|
||
| 1. Create and initialize a shared rules directory: | ||
|
|
||
| ```bash | ||
| mkdir -p ~/.aiglobal | ||
| cd ~/.aiglobal | ||
| rulesync init | ||
| ``` | ||
|
|
||
| 2. Edit your shared rules (`~/.aiglobal/.rulesync/rules/overview.md`, etc.) to your preferences. | ||
|
|
||
| 3. From any project, generate configurations using the shared rules: | ||
|
|
||
| ```bash | ||
| # In your project directory | ||
| rulesync generate --rulesync-dir ~/.aiglobal --targets claudecode --features rules | ||
| ``` | ||
|
|
||
| 4. (Optional) Add `--rulesync-dir ~/.aiglobal` to a shell alias or your project's Makefile/taskfile so you do not need to type it every time. | ||
|
|
||
| ## Comparison with `--global` | ||
|
|
||
| These two flags serve different but complementary purposes: | ||
|
|
||
| | | `--rulesync-dir` | `--global` | | ||
| | ------------ | ------------------------------------------------- | ---------------------------------------------------------------------- | | ||
| | **Changes** | Source location (where `.rulesync/` is read from) | Output location (writes to user-scope config paths, e.g. `~/.claude/`) | | ||
| | **Use when** | Your rule definitions live in a non-CWD directory | You want the output to go to the tool's global (user-scope) config | | ||
|
|
||
| They can be combined. For example, to read rules from `~/.aiglobal` and write them to Claude Code's global settings: | ||
|
|
||
| ```bash | ||
| rulesync generate --rulesync-dir ~/.aiglobal --global --targets claudecode --features rules | ||
| ``` | ||
|
|
||
| > **Note:** Passing `--rulesync-dir` does not automatically enable `--global`. When `--rulesync-dir` is explicitly provided, Rulesync reads `.rulesync/` from that directory, but output scope still follows the CLI flags: use `--global` for user-scope output, and omit it for project-scope output. A `"global": true` setting in the `rulesync.jsonc` under `--rulesync-dir` is not applied unless you also pass `--global`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,7 +195,7 @@ const main = async () => { | |
| ) | ||
| .option("--delete", "Delete all existing files in output directories before generating") | ||
| .option( | ||
| "-b, --base-dir <paths>", | ||
| "-b, --base-dirs <paths>", | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming |
||
| "Base directories to generate files (comma-separated for multiple paths)", | ||
| parseCommaSeparatedList, | ||
| ) | ||
|
|
@@ -215,6 +215,10 @@ const main = async () => { | |
| "--simulate-skills", | ||
| "Generate simulated skills. This feature is only available for copilot, cursor and codexcli.", | ||
| ) | ||
| .option( | ||
| "--rulesync-dir <path>", | ||
| "Path to the directory containing .rulesync/ (parent of .rulesync/)", | ||
| ) | ||
| .option("--dry-run", "Dry run: show changes without writing files") | ||
| .option("--check", "Check if files are up to date (exits with code 1 if changes needed)") | ||
| .action( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page isn't registered in
docs/.vitepress/config.tssidebar, so two things follow: (1) the page won't appear in the docs site navigation, and (2)scripts/sync-skill-docs.tsiterates the sidebar, soskills/rulesync/separate-rulesync-dir.mdwill never be generated. That breaks the repo'sdocs/↔skills/rulesync/sync invariant. Please add an entry under the Guide section and re-run the sync script.Also: the "global is not applied" note at the end of this file is load-bearing behaviour — worth promoting it out of a blockquote into a
::: warningadmonition so readers don't miss it.