Skip to content

fix: fall back to well-known path when CLAUDE_PLUGIN_DATA is not injected#14

Merged
Turtle-Hwan merged 1 commit into
mainfrom
fix/api-key-plugin-data-fallback
May 12, 2026
Merged

fix: fall back to well-known path when CLAUDE_PLUGIN_DATA is not injected#14
Turtle-Hwan merged 1 commit into
mainfrom
fix/api-key-plugin-data-fallback

Conversation

@Turtle-Hwan
Copy link
Copy Markdown
Contributor

@Turtle-Hwan Turtle-Hwan commented May 12, 2026

Problem

/clone:api-key import-env and set failed with an error when CLAUDE_PLUGIN_DATA was not set:

Error: CLAUDE_PLUGIN_DATA is not set, so the plugin config token cannot be stored.

status also fell through to demo fallback even when a token was already saved, because without CLAUDE_PLUGIN_DATA the script had no idea where to look.

Root cause

CLAUDE_PLUGIN_DATA is only injected by the Claude Code harness when the skill runs inside a session. Running the script outside the harness (or when the env var is missing for any reason) left the storage path completely unknown.

Changes

  • pluginDataDir() now falls back to ~/.claude/plugins/data/clone-clone-labs when CLAUDE_PLUGIN_DATA is not set
  • Removed the unnecessary throw from writePluginConfigToken() — a fallback path is always available
  • status output labels the path as (fallback path — CLAUDE_PLUGIN_DATA not injected) so users can tell the difference
  • Test isolation: runHook in stop-hook-v2.test.mjs now always sets CLAUDE_PLUGIN_DATA to a temporary workdir-local path instead of deleting it, preventing the developer's saved token from leaking into test assertions

Verification

  • 26/26 tests pass
  • import-env succeeds without CLAUDE_PLUGIN_DATA — token saved to fallback path
  • status correctly reports source: plugin config after saving

…cted

Previously, /clone:api-key import-env and set failed with an error when
CLAUDE_PLUGIN_DATA was not set by the Claude Code harness. status also
fell through to demo fallback even when a token was already saved.

Now pluginDataDir() returns ~/.claude/plugins/data/clone-clone-labs as
a fallback so token reads and writes work regardless of whether the
harness injects the env var. status output labels the path as a fallback
when CLAUDE_PLUGIN_DATA is not present so users can tell the difference.

Test isolation: runHook in stop-hook-v2.test.mjs now always sets
CLAUDE_PLUGIN_DATA to a temporary workdir-local path instead of
deleting it, preventing the developer's saved token from leaking into
test assertions.
@Turtle-Hwan Turtle-Hwan merged commit 2ae5676 into main May 12, 2026
@Turtle-Hwan Turtle-Hwan deleted the fix/api-key-plugin-data-fallback branch May 12, 2026 18:00
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