Skip to content

Config writes destroy existing Claude Code, Codex, and Gemini CLI settings #10

@datasciencemonkey

Description

@datasciencemonkey

Problem

When running coding-gateway configure or launching a tool, the CLI fully overwrites the config files for all three supported tools:

  • Claude Code (~/.claude/settings.json): Overwrites the entire file with just apiKeyHelper + env. This destroys mcpServers, permissions, hooks, allow rules, enabledPlugins, and all other user settings.
  • Codex (~/.codex/config.toml): Replaces the entire file with a single Databricks profile, destroying any user-defined profiles or model providers.
  • Gemini CLI (~/.gemini/.env): Replaces the entire file with 4 gateway variables. The token refresh thread also re-overwrites the file every 30 minutes.

This happens on every launch, not just during explicit configuration.

Impact

  • Users lose MCP server configurations, permission rules, hooks, plugin settings, and custom env vars
  • The backup mechanism only captures the config from the very first run and is never updated
  • Users who have customized their Claude Code setup will have everything silently destroyed

Expected Behavior

The tool should read-merge-write: read existing config, deep-merge only the keys it manages, and write back — preserving everything else. On logout, it should surgically remove only its managed keys.

Acceptance Criteria

  • Claude settings.json merge: only apiKeyHelper and gateway env vars are written; all other keys preserved
  • Gemini .env merge: only 4 gateway vars are updated; other env vars preserved
  • Logout surgically removes gateway-managed keys instead of restoring stale backups
  • Unit tests verify merge/unmerge round-trips preserve user settings
  • Tested against a real Claude Code settings file with MCP servers, hooks, plugins

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions