thedotmack/claude-mem · info
API key prompt cancelled — leaving existing configuration un
Error message
API key prompt cancelled — leaving existing configuration untouched.
What it means
In the interactive Claude-access flow, when an Anthropic API key is already configured the installer asks keep-or-rotate. Pressing Esc or Ctrl-C at that select prompt (p.isCancel) triggers this warning and the function returns with the existing configuration completely untouched — nothing is read, overwritten, or cleared.
Source
Thrown at src/npx-cli/commands/install.ts:1039
ANTHROPIC_BASE_URL: '',
ANTHROPIC_AUTH_TOKEN: '',
});
log.info('Configured claude-mem to use your logged-in Claude SDK account.');
};
const configureDirectApiKey = async (): Promise<void> => {
const existing = loadClaudeMemEnv().ANTHROPIC_API_KEY || '';
if (existing.trim().length > 0) {
const choice = await p.select<'keep' | 'replace'>({
message: 'An Anthropic API key is already configured. Keep it or enter a new one?',
options: [
{ value: 'keep', label: 'Keep existing key' },
{ value: 'replace', label: 'Enter a new key (rotate)' },
],
initialValue: 'keep',
});
if (p.isCancel(choice)) {
log.warn('API key prompt cancelled — leaving existing configuration untouched.');
return;
}
if (choice === 'keep') {
saveClaudeMemEnv({
ANTHROPIC_API_KEY: existing.trim(),
ANTHROPIC_BASE_URL: '',
ANTHROPIC_AUTH_TOKEN: '',
});
persistClaudeProvider('api-key');
return;
}
}
const apiKeyResult = await p.password({
message: 'Paste your Anthropic API key:',
mask: '*',
validate: (v?: string) => (!v || v.trim().length === 0) ? 'API key required' : undefined,
});View on GitHub (pinned to e2d1df569a)
Solutions
- Nothing is broken — rerun `npx claude-mem install` and make a selection to change the key.
- To rotate without prompts, edit ~/.claude-mem/.env directly (ANTHROPIC_API_KEY) or rerun and choose 'replace'.
- To keep the current key permanently, no action is needed: cancellation already preserved it.
Defensive patterns
Strategy: validation
Validate before calling
// Scripting the installer? Treat cancel as a first-class outcome: // (user-facing flows: check p.isCancel on EVERY prompt result before use)
Type guard
// clack's own guard — always narrow before using the value: import * as p from '@clack/prompts'; const isCancelled = (r: unknown): r is symbol => p.isCancel(r);
Prevention
- Check p.isCancel immediately after every prompt and return early — never let a cancel symbol flow into string handling.
- In automation, pre-set values (env/settings) instead of driving interactive prompts.
- Remember cancellation here is safe by design: existing config is never modified.
When it happens
Trigger: User presses the cancel key (Esc / Ctrl-C in the clack prompt) on the 'Keep existing key / Enter a new key (rotate)' select. This is the designed graceful-exit branch, not an exception.
Common situations: Users who entered the provider flow by accident and want out; muscle-memory Esc while tabbing through prompts; CI harnesses that send Ctrl-C bytes to stdin.
Related errors
- Gateway setup cancelled — leaving existing configuration unt
- Claude Code is not installed. Claude-mem works best in Claud
- No supported IDEs detected — pick the one(s) you plan to use
- Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DAT
- Provider=${options.provider} requested non-interactively. AP
AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20).
Data as JSON: /api/errors/fc1fc044e2307ce3.
Report an issue: GitHub.