Skip to content

feat(cli): add --no-activate flag to auth login#45

Open
tak848 wants to merge 2 commits intoanthropics:mainfrom
tak848:feat/auth-login-no-set-active
Open

feat(cli): add --no-activate flag to auth login#45
tak848 wants to merge 2 commits intoanthropics:mainfrom
tak848:feat/auth-login-no-set-active

Conversation

@tak848
Copy link
Copy Markdown

@tak848 tak848 commented May 6, 2026

Problem

ant auth login --profile <name> unconditionally writes <name> to active_config, which is the resolution surface shared between this CLI, the Anthropic Go SDK, Claude Code, and the Claude Agent SDK (WIF reference). Bootstrapping a profile for a separate automation tool therefore silently retargets the active profile used by every other consumer of that surface, with no opt-out today.

For comparison, other CLIs handle the "login also activates" question differently:

  • aws-cli does not maintain a separate active-profile pointer at all — every command resolves through --profile <name> / AWS_PROFILE, falling back to the literal default profile.
  • gcloud auth login activates the new account by default (same shape as ant today) but provides --no-activate as an explicit opt-out for users who want to log in without changing the active account.
  • kubectl separates auth from activation: switching the active context is an explicit kubeconfig operation, canonically kubectl config use-context <name>.

The current default is the right one for single-tool users — most do want the just-logged-in profile to become the new active one — and this PR does not change it. It just adds an opt-out flag, both for users hit by the shared-surface footgun above and for users who prefer to manage activation manually (closer to the aws-style "always pass --profile" model).

Change

Add a --no-activate flag (default false) to ant auth login. When set, auth login writes configs/<profile>.json and credentials/<profile>.json as usual but does not create or retarget active_config. When the flag would otherwise have skipped a retarget, auth login prints → active profile unchanged (still "<prev>"; --no-activate in effect) to stderr; first-login or no-op cases stay silent.

The flag name follows ant's existing profile activate verb and the --no-<verb> pattern used by --no-browser on the same command. The patch is one flag plus one AND condition on the existing activation guard — no SDK-side change, no migration.

Compatibility

No breaking change. Default behavior with the flag unset is identical to today; the existing TestAuthLoginActivatesExplicitProfile regression test still passes unchanged.

Tests

New TestAuthLoginNoActivate (3 subtests via the existing mock-token-server harness) covers: --profile B --no-activate with prior active_config=A keeps A; first login with --no-activate leaves active_config absent silently; --no-activate is honored when the profile resolves via ANTHROPIC_PROFILE. ./scripts/test passes locally.

Related future work

A symmetric ant profile deactivate (or equivalent flag on profile activate) for clearing active_config is a natural follow-up — --no-activate is the write-side opt-out, but there is no first-class way to remove an existing pointer today. Out of scope here; happy to file a separate PR if there is interest.

Process note

Filing this as a regular PR rather than an issue because GitHub Issues are not enabled on this repo. Happy to redirect to a different channel if there is a preferred path for CLI feature requests.

tak848 added 2 commits May 7, 2026 07:49
Allow `ant auth login` to skip writing the logged-in profile to
active_config. Default behavior is unchanged.

Use case: bootstrapping a profile for an external tool without
retargeting the active profile used by Claude Code and Claude Agent
SDK consumers, which share the same active_config resolution per
the WIF reference.

Covered by an end-to-end test (TestAuthLoginNoSetActive) that
exercises the active_config write path against the existing
token-server harness, including the ANTHROPIC_PROFILE env-source
path. No SDK-side change is required.
Match `ant`'s existing `profile activate` verb and the `--no-<verb>`
flag pattern used elsewhere in this CLI (e.g. `--no-browser`). The
previous name leaked the internal `active_config` filename into the
public flag surface; the operation users already think in is
"activate".

No behavior change. Renames the flag, the corresponding stderr
message, and TestAuthLoginNoActivate.
@tak848 tak848 marked this pull request as ready for review May 7, 2026 00:14
@tak848 tak848 requested a review from a team as a code owner May 7, 2026 00:14
tak848 added a commit to tak848/ccgate that referenced this pull request May 7, 2026
…5.0+

- README + ja/README: third union branch, profile snippet, active_config
  caveat, link to upstream PR anthropics/anthropic-cli#45.
- docs/api-key-helper + ja: new "Profile-based authentication" section
  (Quick start, Auto-login bootstrap Beta, env-var migration), updated
  field table, 401/403 matrix gains a profile column, Recovery
  checklist gains every profile_load + auto_login error_class label.
- docs/configuration + ja: profile credential_source value, profile_load
  reason row.
- defaults.jsonnet (claude / codex): auth example block now lists the
  profile shape with the [Beta] auto_login variant.
- examples/{claude,codex}/ccgate.jsonnet: commented-out profile + Beta
  variants alongside the existing provider block.

All copy is honest about the Beta scope: ccgate does not save / restore
active_config in this release; root fix is upstream.

Refs #69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant