Allow running bare claude unwrapped alongside ug claude (opt out of OS-managed settings)

Abierto
#1,282 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
backend, cli

Línea de trabajo

Start with src/ucode/agents/claude.py and src/ucode/managed_files.py, then read “Claude Subscription Relay” in docs/os-managed-settings-design.md to understand the local-only path and managed-settings behavior. Trace how ug claude reconciles settings and how ug status reports them; define and test the opt-out, repeated launches, and a documented non-destructive cleanup path for existing managed settings.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

After running ug claude once from an interactive terminal, a bare claude
invocation is permanently routed through the Databricks AI Gateway. There is
currently no supported way to keep the two separate, i.e.:

• ug claude -> Databricks AI Gateway (Unity Gateway models)
• claude -> the user's own native configuration (e.g. personal subscription)

Current behavior

Every interactive ug claude launch calls write_tool_config(), which writes
the gateway overlay (ANTHROPIC_BASE_URL, ANTHROPIC_CUSTOM_HEADERS,
apiKeyHelper, ANTHROPIC_DEFAULT_*_MODEL, ...) to two places
(src/ucode/agents/claude.py):

  1. ~/.claude/ucode-settings.json (passed explicitly via claude --settings ...)
  2. /etc/claude-code/managed-settings.json (Linux) — the OS-managed,
    machine-wide, highest-precedence scope

The managed file is what captures bare claude: it reads the managed scope
without any flags (managed > --settings > user), and _reconcile_managed_settings
is explicit that this is intentional ("so a bare claude uses the gateway").

Why this can't be worked around today

• claude --setting-sources only accepts user,project,local; the managed
scope always applies and cannot be excluded via CLI flags.
• Interactive ug claude re-reconciles the managed file on every launch
(recreates it when absent, overwrites drifted values), so manually deleting
it only lasts until the next run.
• managed_writes_allowed() keys off stdin.isatty() only
(src/ucode/managed_files.py) — there is no flag or env var to stay local-only.
• ug revert restores everything and clears state, so it is not usable as a
toggle between the two modes.

Use case

Developers who use both their own Claude subscription and the Databricks
gateway (e.g. personal vs. work contexts, or comparing native vs. gateway
behavior) currently have to choose one: after the first ug claude run, the
native claude experience is gone machine-wide until a full revert.

(Related: subscription-relay mode is already intentionally local-only for the
same class of reason — a persisted gateway address would break bare claude.
See "Claude Subscription Relay" in docs/os-managed-settings-design.md.)

Proposal

Add a supported local-only opt-out so ug claude uses only the
--settings injection (~/.claude/ucode-settings.json) and never touches the
OS-managed file. For example, one of:

• ug claude --local-only / ug configure --no-managed-settings, or
• UCODE_NO_MANAGED_SETTINGS=1 env var

Suggested semantics:

• When opted out, skip _reconcile_managed_settings (same path as the
non-interactive local fallback) instead of writing the managed file.
• If the managed file already contains ug-owned gateway values, either warn
that bare claude is still captured (with a remediation hint), or offer to
clean just the ug-owned keys — without a full ug revert/state wipe
(e.g. ug revert --managed-only or per-agent revert).
• ug status already reports managed state (current, compatible (local settings), ...), so the opted-out state stays observable.

Acceptance criteria

• [ ] With the opt-out set, ug claude launches through the gateway while
bare claude keeps working against the user's native configuration.
• [ ] Repeated opted-out launches never create or modify the OS-managed file.
• [ ] A user who previously ran without the opt-out has a documented,
non-destructive path back to a clean managed file.

Environment

• ug --version: 0.2.0+53.g3076da9
• OS: Ubuntu
• Claude Code version (claude --version): 2.1.310 (Claude Code)

Lenguaje dominante
Python
Estrellas
122
Forks
101
Merge medio
1 d 18 h
PR fusionados (30 d)
228

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de databricks/unity-gateway

Todos los issues de databricks/unity-gateway

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.