- Home
- Plugins
- Models & Providers
- dsh-claude-code-account
dsh-claude-code-account
trmquang93/dsh-claude-code-account
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
dsh plugin --profile web add github:trmquang93/dsh-claude-code-accountREADME
@trmquang93/dsh-claude-code-account
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.
Related plugins
dsh-our-free-model
ebony-vinyl/dsh-our-free-model
dsh-routing-suite
yjh051108/dsh-routing-suite
dsh-connect-workbuddy
dingminhua/dsh-connect-workbuddy
dsh-workbuddy-connect
corrinehu/dsh-workbuddy-connect