Skip to content

Idea: rulesync run to create rules for target agent without persisting #902

@Guria

Description

@Guria

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 with cwd set 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 status stays clean)
  • Generated outputs in ephemeral workspace identical to rulesync generate for 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

  1. Create a temp dir
  2. 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, then git worktree remove
  3. 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 .git objects with main repo (space-efficient)
  • Clean separation — worktree is a real checkout that tools understand
  • git worktree list provides 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-dir to generate — lighter, but run is nicer as a wrapper for "generate then immediately invoke agent"
  • Manual git worktree management — possible, but rulesync run encapsulates 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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions