DEV Community

Cover image for Why an AI Agent Config Sync CLI Needs Drift-Aware Undo (and Atomic Writes)
Abdelmomen
Abdelmomen

Posted on

Why an AI Agent Config Sync CLI Needs Drift-Aware Undo (and Atomic Writes)

If you run a config sync CLI across AI coding agents—writing to CLAUDE.md, AGENTS.md, or opencode.json—the scary part is not the first sync.

The scary part is what happens after you make a quick manual edit in one of those files, and later decide to roll back the last sync.

A blind undo restores the pre-sync backup and wipes out the manual rule you added in between. Worse, a crash mid-write without atomic replacement can leave a real developer config half-written.

When I built one-setup-all-agents (v0.1.0 pre-alpha, MIT, Python >= 3.11 standard library only), I designed the safety engine before adding more adapters. Here is how it works—and where its current boundaries are.

Five safety layers before touching real configs

  1. Dry-run and explicit plan before writing
    all-agents sync builds and prints the full change plan first, then waits for confirmation. In non-interactive mode without --yes, it stops as a dry-run (Dry run only: not interactive; pass --yes to apply). When conflicts exist and no changes can be executed safely, it exits with code 3.

  2. Pre-write backups and atomic replacement
    Every target file is backed up before modification. File writes go to temporary sibling files first and replace the target atomically, so an interrupted write does not corrupt your existing config.

  3. Append-only unified write-ahead journal
    File edits, links, and external CLI calls are recorded with exact inverse actions in an append-only write-ahead journal. On POSIX systems, the state directory uses 0700 permissions and journal/backup files use 0600.

  4. Drift-aware undo (revert refused due to drift)
    When you run all-agents undo, it checks whether the target file still matches what the tool wrote. If you edited CLAUDE.md, AGENTS.md, or opencode.json manually after sync, undo refuses to overwrite your changes:

revert refused due to drift: ...; use --force to override

Your manual work stays intact unless you explicitly pass --force.

  1. Secrets as environment-variable references only API keys and auth headers are referenced strictly by environment-variable name (for example ${GITHUB_TOKEN}). all-agents never reads secret values from your environment, prints them, or writes them into managed configs. (Note: init snapshots and pre-write backups copy existing tool files byte-for-byte into the private 0700/0600 state directory, so any pre-existing literal secrets in those files stay in the backups.)

Honest v0.1.0 pre-alpha boundaries

This is still pre-alpha software, and the limits are documented explicitly:

  • Global user scope only: Project-level configs are not supported in v0.1.0.
  • External changes and interrupted CLI calls: External edits made outside all-agents cannot be anticipated, and if a process terminates abruptly during an external CLI call (such as claude mcp), you must inspect that tool's config manually.
  • Per-tool capability differences: Tools do not expose identical capabilities. For example, Antigravity does not expand environment variables in HTTP headers, so remote HTTP MCP servers requiring auth headers are flagged as unsupported and skipped; Codex flags a conflict if a non-empty AGENTS.override.md is present.
  • OS verification scope: Live tool binaries were verified on Windows; Linux (Ubuntu WSL2) and macOS (macos-latest) CI run the test suite against fixtures, with live Linux/macOS tool binaries still unverified.

Try it read-only

If you have uv installed, you can inspect what one-setup-all-agents detects without writing any file:

uvx one-setup-all-agents init --dry-run
Enter fullscreen mode Exit fullscreen mode

Links

Top comments (0)