Skip to content

fix(setup-skill): validate Claude token immediately after it is written to .env#1044

Open
mikegcoleman wants to merge 8 commits intoqwibitai:mainfrom
mikegcoleman:fix/validate-credentials-on-setup
Open

fix(setup-skill): validate Claude token immediately after it is written to .env#1044
mikegcoleman wants to merge 8 commits intoqwibitai:mainfrom
mikegcoleman:fix/validate-credentials-on-setup

Conversation

@mikegcoleman
Copy link

@mikegcoleman mikegcoleman commented Mar 13, 2026

Fixes #1045

Summary

Adds inline credential validation to the setup skill's step 4 (Claude Authentication). After the user writes their token to .env, a self-contained node one-liner POSTs a minimal request to the Anthropic API to confirm the token actually works — before channel setup begins.

No source files changed. Validation logic lives entirely in .claude/skills/setup/SKILL.md as a node one-liner, consistent with the skills-first contribution philosophy.

What the inline check does

  • Reads ANTHROPIC_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_AUTH_TOKEN from .env (handles quoted values)
  • POSTs to api.anthropic.com/v1/messages with max_tokens: 1 — just enough to get an HTTP status
  • CREDENTIAL_CHECK: ok → continue
  • CREDENTIAL_CHECK: invalid_token (401) → prompt user to re-run claude setup-token and paste a fresh token
  • CREDENTIAL_CHECK: network_error → warn, let user decide whether to continue
  • CREDENTIAL_CHECK: no_token → no recognised credential found, re-run step 4

Test plan

  • Valid API key → CREDENTIAL_CHECK: ok, setup continues
  • Valid OAuth token → CREDENTIAL_CHECK: ok, setup continues
  • Expired/wrong token → CREDENTIAL_CHECK: invalid_token, user prompted to retry
  • No credentials in .envCREDENTIAL_CHECK: no_token
  • Network unreachable → CREDENTIAL_CHECK: network_error with option to continue

🤖 Generated with Claude Code

gavrielc and others added 7 commits March 10, 2026 23:59
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Docker build: forward proxy env vars and disable npm strict-ssl for MITM proxies
- WhatsApp: use HttpsProxyAgent for WebSocket, fetch client revision from sw.js
- Container runner: forward proxy/CA env vars, add host.docker.internal to NO_PROXY,
  use empty file instead of /dev/null for .env shadow mount
- Credential proxy: route upstream requests through HTTPS proxy agent
- Tests: clear proxy env vars in vi.hoisted() to use mocked Baileys path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes node_modules before npm install in setup step 5 to avoid
conflicts between old and newly merged channel dependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cleanupOrphans() filters containers by `name=nanoclaw-`, which also
matches the sandbox container (e.g. `nanoclaw-docker-sandbox`). This
caused the process to kill its own host container on startup.

Filter out the current hostname so the sandbox is never stopped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…aved

Adds a new `validate-credentials` setup step that makes a minimal live
API call (POST /v1/messages, max_tokens=1) right after the user writes
their token to .env — before channel setup begins. A 401 response fails
fast with a clear error, catching invalid or expired tokens immediately
instead of surfacing as a confusing agent failure on first WhatsApp message.

Supports both auth modes (ANTHROPIC_API_KEY and CLAUDE_CODE_OAUTH_TOKEN).
Updates the setup skill to call this step and handle all three outcomes:
valid, invalid token, and network error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…en to .env

Adds an inline node credential check to the setup skill's step 4. After
the user writes their token to .env, a minimal POST to the Anthropic API
(max_tokens=1) confirms the token works before channel setup begins.

A 401 response fails fast with a clear message, catching invalid or
expired tokens immediately rather than surfacing as a confusing agent
error on the first WhatsApp/Telegram message.

No source files changed — validation logic lives entirely in the skill
as a self-contained node one-liner.

Fixes qwibitai#1045

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mikegcoleman mikegcoleman changed the title feat(setup): validate Claude credentials immediately after token is saved fix(setup-skill): validate Claude token immediately after it is written to .env Mar 13, 2026
@Andy-NanoClaw-AI Andy-NanoClaw-AI added Status: Needs Review Ready for maintainer review PR: Fix Bug fix labels Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fix Bug fix Status: Needs Review Ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setup: no validation of Claude token — invalid tokens only surface on first message

3 participants