-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
Description
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-xyzAcceptance 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 dirsCaveats:
- 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.
Reactions are currently unavailable