SSkilltecabyclaudinhocode
Enviar skill
← Voltar para o catálogo

claude-model-launcher

Desenvolvimento

Configure Claude Code to launch third-party LLM backends (GLM / DeepSeek / Qwen / Kimi / etc.) via their Anthropic-compatible endpoints. Creates per-provider launcher scripts (`~/.claude/claude-<name>.sh` and `.ps1`) plus matching shell aliases so the user can run `glm`, `ds`, `qwen`, etc. to start Claude Code with that backend. Trigger on: "add <provider> to claude code", "配一个 <模型> 启动器", "加一个 <模型

1estrelas
Ver no GitHub ↗Autor: Frog1205Licença: MIT

Claude Code Multi-Model Launcher

This file is agent-facing instructions consumed by Claude Code at runtime. If you are a human looking for install / usage docs, read README.md instead (Chinese).

Claude Code reads the env vars ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL (plus per-slot overrides) at startup. Many third-party providers (z.ai, DeepSeek, Alibaba Bailian, Moonshot, etc.) expose an Anthropic-compatible endpoint, so pointing those env vars at the provider + launching claude is all it takes to route every request through that backend.

This skill installs one launcher per provider so the user can switch backends by typing a short command (glm, ds, qwen, ...).

Workflow

  1. Confirm what the user wants. Ask (if unclear):

    • Which provider? (GLM / DeepSeek / Qwen / Kimi / custom)
    • API key.
    • Preferred alias name (default: short provider abbreviation).
    • OS / shell — see the Platform Matrix table below. Common cases: Windows native (Git Bash + PowerShell), macOS (Zsh default), Linux (Bash/Zsh/Fish), WSL2 (Linux inside Windows).
    • Auto-detect WSL2: run grep -qi microsoft /proc/version 2>/dev/null && echo wsl2 — if it prints wsl2, treat as WSL2 (Linux rules apply; no .ps1 needed).
  2. Look up the endpoint. Use the Known Endpoints table below. If the provider is not listed, ask the user for the doc URL and use WebFetch / WebSearch. Do not guess endpoint URLs.

  3. Create the launcher script(s). Location: ~/.claude/claude-<alias>.{sh,ps1}. Platform rules:

    • Windows native: create both .sh (for Git Bash) and .ps1 (for PowerShell).
    • macOS / Linux / WSL2: create only .sh. After writing, run chmod +x ~/.claude/claude-<alias>.sh.
    • WSL2 users do not need a .ps1 — they run claude inside the Linux layer.
  4. Wire up shell aliases. Choose the section that matches the user's environment:

    Bash (Linux / WSL2 / Git Bash on Windows):

    echo "alias <alias>='~/.claude/claude-<alias>.sh'" >> ~/.bashrc
    

    Then remind the user to open a new terminal (or run source ~/.bashrc).

    Zsh (macOS default since Catalina 10.15; also common on Linux):

    echo "alias <alias>='~/.claude/claude-<alias>.sh'" >> ~/.zshrc
    

    Then open a new terminal (or run source ~/.zshrc).

    Fish (Linux/macOS):

    echo "alias <alias> '~/.claude/claude-<alias>.sh'" >> ~/.config/fish/config.fish
    

    Fish alias syntax omits =. Open a new terminal to reload.

    PowerShell (Windows native — PowerShell 5.1 or 7):

    # Create profile dir if missing, then append
    if (!(Test-Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force }
    Add-Content $PROFILE "`nfunction <alias> { & `"`$env:USERPROFILE\.claude\claude-<alias>.ps1`" @args }"
    

    Note: Windows PowerShell 5.1 ($PROFILE under Documents\WindowsPowerShell) and PowerShell 7 (Documents\PowerShell) use different profile paths. Write to the one the user actually runs.

    macOS Bash (users who switched back or use older macOS pre-Catalina): Append to ~/.bash_profile (macOS does not auto-source ~/.bashrc in login shells):

    echo "alias <alias>='~/.claude/claude-<alias>.sh'" >> ~/.bash_profile
    
  5. Tell the user to open a NEW shell window (aliases/functions do not load into existing sessions) and run <alias> to test. Warn that a 403 usually means a wrong BASE_URL or a key from the wrong plan tier.

  6. Never embed the user's API key in chat output after the fact. If the user has pasted a key into conversation, remind them once to rotate if they are worried about shoulder-surfing or screenshot leaks — do not nag on every turn.

Platform Matrix

Quick reference — choose the row that matches the user's OS + shell:

EnvironmentScripts to createShell config fileAlias syntax
Windows + Git Bash.sh + .ps1~/.bashrcalias ds='~/.claude/claude-ds.sh'
Windows + PowerShell 5.1.ps1 (+ .sh optional)$PROFILE (WindowsPowerShell)function ds { & "..." @args }
Windows + PowerShell 7.ps1 (+ .sh optional)$PROFILE (PowerShell)same as above
WSL2 (Bash).sh only~/.bashrcalias ds='~/.claude/claude-ds.sh'
WSL2 (Zsh).sh only~/.zshrcalias ds='~/.claude/claude-ds.sh'
macOS (Zsh, default ≥ Catalina).sh only~/.zshrcalias ds='~/.claude/claude-ds.sh'
macOS (Bash, pre-Catalina / custom).sh only~/.bash_profilealias ds='~/.claude/claude-ds.sh'
Linux (Bash).sh only~/.bashrcalias ds='~/.claude/claude-ds.sh'
Linux (Zsh).sh only~/.zshrcalias ds='~/.claude/claude-ds.sh'
Linux (Fish).sh only~/.config/fish/config.fishalias ds '~/.claude/claude-ds.sh'

WSL2 detection: grep -qi microsoft /proc/version 2>/dev/null && echo wsl2

Script Templates

~/.claude/claude-<alias>.sh (Unix shell):

#!/bin/bash
# Launch Claude Code with <Provider> backend
export ANTHROPIC_AUTH_TOKEN="<API_KEY>"
export ANTHROPIC_BASE_URL="<BASE_URL>"
export ANTHROPIC_MODEL="<DEFAULT_MODEL>"
export ANTHROPIC_DEFAULT_OPUS_MODEL="<OPUS_SLOT_MODEL>"
export ANTHROPIC_DEFAULT_SONNET_MODEL="<SONNET_SLOT_MODEL>"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="<HAIKU_SLOT_MODEL>"
# Optional: small/fast background model, subagent model, provider-specific tuning
claude "$@"

Make it executable via chmod +x.

~/.claude/claude-<alias>.ps1 (PowerShell):

# Launch Claude Code with <Provider> backend
$env:ANTHROPIC_AUTH_TOKEN = "<API_KEY>"
$env:ANTHROPIC_BASE_URL = "<BASE_URL>"
$env:ANTHROPIC_MODEL = "<DEFAULT_MODEL>"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "<OPUS_SLOT_MODEL>"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "<SONNET_SLOT_MODEL>"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "<HAIKU_SLOT_MODEL>"
claude @args

PowerShell execution policy must allow local scripts (RemoteSigned or Unrestricted for CurrentUser). Check with Get-ExecutionPolicy -Scope CurrentUser; if it is Restricted, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.

Known Endpoints

These values were verified against official provider docs. Keep this table updated.

ProviderANTHROPIC_BASE_URLKey prefixTypical model names
z.ai (GLM)https://api.z.ai/api/anthropicregularglm-5.1
DeepSeekhttps://api.deepseek.com/anthropicsk-...deepseek-v4-pro (Opus/Sonnet), deepseek-v4-flash (Haiku)
Alibaba Bailian — Coding Plan (monthly subscription)https://coding.dashscope.aliyuncs.com/apps/anthropicsk-sp-...qwen3.6-plus, qwen3.6-flash, qwen3-coder-next
Alibaba Bailian — pay-as-you-gohttps://dashscope.aliyuncs.com/apps/anthropicsk-...same as above
Moonshot / Kimihttps://api.moonshot.cn/anthropicsk-...kimi-k2-... (confirm current name from Moonshot docs)

Slot-mapping guidance

Claude Code requests different model slots depending on the task. Ask the provider's docs for their recommendation; if none, default to:

  • OPUS / SONNET → the provider's strongest coding model.
  • HAIKU / SMALL_FAST → the provider's cheapest/fastest model (used for summarization, titling, background work).
  • CLAUDE_CODE_SUBAGENT_MODEL → same as Opus/Sonnet (subagents do heavy work).

Provider-specific gotchas

  • Alibaba Bailian Coding Plan keys (sk-sp-...) MUST use the coding.dashscope.aliyuncs.com subdomain. Mixing a sk-sp- key with the generic dashscope.aliyuncs.com endpoint (or vice versa) returns 403 invalid-key. The Coding Plan also only works in coding tools (Claude Code, Qwen Code) — curl / Postman will be rejected.
  • DeepSeek recommends CLAUDE_CODE_EFFORT_LEVEL=max, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1, `CLAUDE_CO

Como adicionar

/plugin marketplace add Frog1205/claude-code-model-launcher

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Comentários · Nenhum comentário

Entre para comentar. Entrar

  • Ainda não há comentários. Seja o primeiro.