Uses a Claude Code (Claude Pro/Max) sign-in as a DSH anthropic model provider, keeping the pi-ai credential record and the Claude Code keychain on the same rotating OAuth chain.
Install
# from npm (prebuilt)
dsh plugin --profile web add @trmquang93/dsh-claude-code-account
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:trmquang93/dsh-claude-code-account
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
Use a Claude Code sign-in (Claude Pro/Max subscription) as a DSH model provider.
Claude Code keeps its OAuth grant in the login keychain, one item per
CLAUDE_CONFIG_DIR. DSH's pi-ai adapter keeps its own copy of that grant in the
credential record llm-pi-ai/<provider> and refreshes it when it expires. This
plugin keeps both sides on the same rotating chain, so
- the account keeps powering DSH model requests (through the
anthropicroute) with no second OAuth sign-in, and - the Claude Code CLI login keeps working after DSH refreshes the token, because the rotated grant is written back to the keychain.
It refreshes once when neither side holds a usable access token, and mirrors whichever side already holds the fresher valid grant (so a refresh DSH performed itself is repaired back into the keychain instead of being spent twice).
Install
dsh plugin --profile <name> add @trmquang93/dsh-claude-code-account
The package ships prebuilt JavaScript, so the install runs no build script and
needs no permission. It declares a bundle: dsh appends it to the profile's
dsh.profile.bundles and applies its patch on the next boot. Signing in to
Claude Code first is optional — the plugin reports a missing login instead of
failing the boot.
Prerequisite: the provider route
The route is configuration, not code. DSH's last patch layer — the profile's
own $DSH_HOME/profiles/<profile>/cordis.patch.yml — must list anthropic
under llm-pi-ai.providers. Keep the route key equal to the plugin's
provider:
- id: llm-pi-ai
name: '@deepseek-ai/dsh-llm-pi-ai'
config:
providers:
opencode-go:
apiKeyEnv: OPENCODE_GO_API_KEY
openrouter:
apiKeyEnv: OPENROUTER_API_KEY
anthropic:
displayName: Claude Code (personal)
The plugin ships its own Claude model list (models.json) and serves it on the
route, so new models appear without waiting for the app's bundled pi-ai. A
models list set on the route in the profile wins over it.
Set the route's displayName to the account it is wired to; the plugin writes
the credential and never the route.
Configuration
- id: claude-code-account
name: '@trmquang93/dsh-claude-code-account'
config:
account: default # default/work → ~/.claude, personal → ~/.claude-personal
provider: anthropic # pi-ai route whose record this plugin owns
accounts: # optional: extra name → config-dir map
personal: .claude-personal
work: .claude
configDir: /abs/dir # optional: an absolute CLAUDE_CONFIG_DIR instead
refreshLeadMs: 600000 # refresh when the access token is this close
intervalMs: 300000 # how often the timer re-checks
writeBack: true # write rotated tokens back into the keychain
claudeCommand: claude # used for `claude auth status --json` metadata
The account name selects the Claude Code config directory, and the directory selects the keychain item:
| account | config dir | keychain service |
|---|---|---|
default, work |
~/.claude |
Claude Code-credentials |
personal |
~/.claude-personal |
Claude Code-credentials-<sha256(absolute dir)[:8]> |
any configDir |
that directory | Claude Code-credentials, or the suffix above for a non-default directory |
That is exactly how Claude Code namespaces several logins in one keychain, so a
second login at ~/.claude-personal resolves to its own suffixed item
(sha256("<home>/.claude-personal")[:8]).
Use
- Sign in to Claude Code for the chosen account:
claude auth login, orCLAUDE_CONFIG_DIR=~/.claude-personal claude auth loginfor a second one. - Make sure the
anthropicroute is in the profile patch (above). DSH applies patch changes live with HMR. - Pick a Claude model in the model selector. The plugin has already mirrored
the account's grant into
llm-pi-ai/anthropic. - Ask
claude_code_account(tool) or read the startup log line for the account email, plan and access-token expiry.
The tool returns no secret values:
{
"account": "personal",
"configDir": "/Users/quangtran/.claude-personal",
"keychainService": "Claude Code-credentials-6195afbc",
"provider": "anthropic",
"providerRegistered": true,
"email": "trmquang@icloud.com",
"subscriptionType": "pro",
"accessExpiresAt": "2026-11-10T19:10:43.114Z",
"accessExpiresInMinutes": 469,
"source": "keychain",
"recordConfigured": true
}
action: "sync" forces a reconcile pass (refreshing when needed).
What can go wrong
- The plugin owns
llm-pi-ai/<provider>. Signing out or signing in to the same route from the Models page writes the same record; the next timer pass restores the Claude Code account's grant. Use another route key (and anotherproviderin this plugin's config) if the two must coexist. - A keychain write can be refused when the login keychain's access control
does not allow
securityto update the item; the sync then still updates DSH but the CLI keeps its old chain. The record reports the failure vialastError; re-enable the CLI by runningclaude auth loginfor the account. - An account that was never signed in fails with an actionable
run "claude auth login"message instead of silently leaving DSH keyless. - macOS only for the keychain read. Other platforms fall back to
<configDir>/.credentials.json, which is where Claude Code stores its grant on Linux. Nothing else is platform-specific. - Claude Code must keep working with the account. The plugin writes rotated
tokens back, but if the account's refresh token has expired, both sides need a
fresh
claude auth login.
Release
npm test
npm publish # publishConfig sets access:public and the public registry
Bump version first; files limits the tarball to the entry points, the patch,
the README and the LICENSE.
Tests
node --test test/ covers the decision logic (which side wins, when a network
refresh happens, write-back), the keychain-service naming, document merging, and
the record shape, all with injected fakes.
Verify a mounted account
claude_code_account(tool) or the startup log line reports the account email, plan and access-token expiry;action: "sync"forces a reconcile.- The composer model menu (or
/model) lists a Claude Code (personal) group once theanthropicroute is configured. - Send a short prompt with a Claude model selected — the answer comes from the subscription, not an API key.
CLAUDE_CONFIG_DIR=~/.claude-personal claude auth statusand a one-shotclaude -p "ok"must still work: that proves the write-back preserved the CLI login.
Links
More in this category
Ebony-Vinyl/dsh-our-free-model★ 77208
Adds free model lanes to DeepSeek Harness — DeepSeek V4.1 Flash, Kimi K3 and others — with no login, sign-up or API key, plus a local OpenAI-compatible gateway, fallback routing and a usage dashboard.
dingminhua/dsh-connect-workbuddy★ 1681
Connects locally signed-in WorkBuddy models, CN and international alike, to DSH, reading each model's credit multiplier from the upstream catalog on every refresh, with per-model image input toggles, account switching backed by an auto-failing-over pool, manual daily check-in, and read-only credit overviews shown as compact pills on the card and in the composer.
Alice-Marx/dsh-model-router★ 966
Routes DeepSeek Harness work across configured model APIs and supported vendor CLIs with dependency-aware packages and cost previews.
V1ki/dsh-plugin-subscriptions★ 618
Use ChatGPT (Codex), Claude, and Grok subscriptions as DeepSeek Harness LLM providers, with Settings login, model catalogs, usage, plus image_generate, video_generate, and x_search tools.
XDTrees/dsh-workbuddy-xdpool★ 541
Merge every locally signed-in WorkBuddy account into DeepSeek Harness as one auto-failing-over model pool (multi-account rotation, live credits, and a model catalog showing per-model credit multipliers and free/night-discount tags).
XDTrees/dsh-xdpool★ 541
Merge every locally signed-in WorkBuddy account into DeepSeek Harness as one auto-failing-over model pool: multi-account rotation, 429 cooldowns, live credits, a model catalog with per-model credit multipliers and free/night-discount tags, QR-code login for 13 vendors, and aggregate free-tier channels. Accounts persist across restarts.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.