Idea: `rulesync run` to create rules for target agent without persisting
Problem
Rulesync's generate flow is great when you want generated agent config files to exist on disk (committed or ignored). However, there are scenarios where users want the agent to see the generated files but don't want those files persisted into the working tree:
- Keep repo completely clean (no ignored generated outputs, no "dirty" working tree, no editor/watch reload churn)
- Run agents in CI, ephemeral dev shells, or read-only checkouts
- Avoid writing/deleting files in a monorepo root just to run an agent in one package
- Use Rulesync as the single source of truth while treating generated files as a pure build artifact
rulesync gitignore and .local patterns help, but still write files into the repo.
Proposal
Add a new command: rulesync run
rulesync run generates the requested targets/features into a temporary workspace (or overlay)
and runs the target agent (or arbitrary command) there, then cleans up.
Key idea: agent gets correct tool-native files, but the project directory remains untouched.
Suggested UX
Wrap an agent invocation (primary use-case)
rulesync run --targets claudecode --features "*" -- claude
rulesync run --targets codexcli --features rules -- codex
rulesync run --targets geminicli --features rules,mcp -- gemini
- Everything after
--is executed withcwdset to the ephemeral workspace - Exit code is forwarded
- Temp workspace is deleted on exit (including SIGINT/SIGTERM handling)
"Prepare only" mode (optional)
# Print temp dir path without executing
rulesync run --targets claudecode --features rules,mcp --print-path
# Or specify output directory explicitly
rulesync run --targets claudecode --features rules,mcp --output-dir /tmp/rulesync-run-xyz
Acceptance Criteria
- [ ] Zero changes in the original project directory (
git statusstays clean) - [ ] Generated outputs in ephemeral workspace identical to
rulesync generatefor same inputs - [ ] Supports existing generation options (
--simulate-commands,--simulate-subagents,--simulate-skills,--modular-mcp, etc.) - [ ] Works across platforms (macOS/Linux/Windows)
- [ ] Robust cleanup (normal exit + signals)
Implementation Sketch
- Create a temp dir
- Materialize an "overlay workspace":
- Option A: Copy repo (costly for big repos)
- Option B: Symlink/junction the repo into temp, then write only generated config files into temp root
- Option C: Use
git worktree add --detach <temp-dir>to create a lightweight linked working tree, generate configs there, run the agent, thengit worktree remove
- Run the existing generator targeting the temp workspace as
baseDir(or introduce an internal "output root" override), then exec the command
Git Worktree Considerations
Option C has some nice properties:
- Native git support, no custom symlink logic needed
- Worktree shares
.gitobjects with main repo (space-efficient) - Clean separation — worktree is a real checkout that tools understand
git worktree listprovides visibility into active ephemeral sessions
Potential flags:
rulesync run --targets claudecode --strategy worktree -- claude
rulesync run --targets claudecode --strategy symlink -- claude # default?
rulesync run --targets claudecode --strategy copy -- claude # fallback for non-git dirs
Caveats:
- Requires the project to be a git repo (fallback to symlink/copy for non-git)
- Worktree creation has some overhead (~100-500ms), though still faster than full copy
- Need to handle cleanup on SIGKILL (orphaned worktrees can be pruned with
git worktree prune)
Alternatives Considered
rulesync generate+ ignore patterns +git clean -fdX— workable but still touches the working tree and can trigger watch-based tooling/editor refresh- Adding
--output-dirtogenerate— lighter, butrunis nicer as a wrapper for "generate then immediately invoke agent" - Manual
git worktreemanagement — possible, butrulesync runencapsulates the generate+exec+cleanup lifecycle
Why This Fits Rulesync
Rulesync already supports many tools/targets and features (rules/ignore/mcp/commands/subagents/skills). run would make Rulesync usable in "no-footprint" workflows without changing the underlying unified rules model.
@Guria It seems a interesting and convenient feature. On the other hand, file synchronization to realize it seems pretty complex. If we can use env vars to set agent's configs, the work will become simple.
I just had an idea that was bothering me, and your project was the best place to share. I hope it can spark some ideas, since we definitely still have a pain with all those folders present even if they ignored and symlinked.
I really liked this idea. I would love to be able to share a rulesync setup with others so they can use on any project without having to either add it globally or commit to the repo. +1
Re-validated against the current codebase and current upstream configuration mechanisms. The use case is still valid, but the execution model is not defined tightly enough to implement safely yet.
Some agents now let Rulesync isolate user-level configuration without copying a repository: Claude Code supports CLAUDE_CONFIG_DIR (official environment-variable reference), Gemini CLI supports GEMINI_CLI_HOME (official configuration reference), and Copilot CLI supports COPILOT_HOME (official configuration-directory reference). Those variables do not relocate each tool’s project-scoped files, however; project rules/settings are still discovered at fixed paths under the workspace.
The proposed temporary copy/worktree strategies also introduce an unresolved correctness issue: an agent launched inside that temporary checkout edits the temporary checkout. Rulesync would need a defined way to propagate the agent’s code changes back to the original working tree without also propagating generated configuration, while preserving uncommitted files, ignored files, submodules, worktrees, permissions, and concurrent edits. A symlink tree avoids copying code but does not provide a portable cross-platform overlay for fixed project-config paths.
A maintainer therefore still needs to choose the contract before implementation:
- Is
runlimited to agents that can load all requested config through environment/CLI overrides, or must it support fixed project paths? - Do agent edits apply directly to the original tree, get copied back afterward, or remain in a worktree for manual integration?
- What happens to untracked/ignored files, nested repositories, submodules, and an already-dirty source tree?
- Is the initial scope a single target/strategy, or the full target × feature matrix in the acceptance criteria?
Leaving this open as inconclusive under its existing considering status.
Closing as not planned after re-validating the proposal against the current upstream configuration models.
User-level state can be isolated for some agents (CLAUDE_CONFIG_DIR, GEMINI_CLI_HOME, and COPILOT_HOME), but their project-scoped instructions and settings are still discovered from fixed paths under the active workspace. Official references:
- https://code.claude.com/docs/en/env-vars
- https://code.claude.com/docs/en/claude-directory
- https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md
- https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-config-dir-reference
A temporary copy or worktree therefore changes the agent's editing target as well as its config target. Safely copying code edits back while preserving an already-dirty tree, untracked and ignored files, submodules, permissions, nested repositories, and concurrent edits would require a workspace synchronization/overlay system rather than a Rulesync generation feature. A symlink tree does not provide a portable writable overlay on macOS, Linux, and Windows.
Because the acceptance criteria require the full target × feature matrix and cross-platform behavior, narrowing this silently to the few user-level config overrides would not implement the requested command. This can be reconsidered if the supported agents expose complete project-config path overrides, or if a future proposal defines a deliberately limited execution/edit-propagation contract.