ClaudeCode×ModelScope免费接入及进阶配置

admin 2026-05-20 06:05:58 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文详细介绍了ClaudeCode免费接入ModelScope平台的完整配置流程,包括安装ClaudeCode、配置CCSwitch、设置ModelScopeAPI密钥和模型参数。文章还深入讲解了CLAUDE.md规则文件、skills技能包、MCP协议、插件系统、rules规范、subagent子代理和memory记忆系统等进阶功能的配置方法,提供了具体的操作命令和文件结构示例。 综合评分: 72 文章分类: 安全工具,AI安全,安全开发,安全运营,其他


cover_image

Claude Code × ModelScope 免费接入及进阶配置

原创

F1rstb100d F1rstb100d

智佳网络安全

2026年5月19日 11:29 北京

在小说阅读器读本章

去阅读

书接上文我们介绍了把Claude Code免费接入OpenRouter的配置方法

claude code + openrouter 免费AI大模型配置

这一期再给大家补充一个提供免费API平台ModelScope的接入流程,以及Claude Code CLI 中memory、skills、mcp、plugins、rules、subagents等拓展的进阶配置

Claude Code安装

根据官方手册https://code.claude.com/docs/zh-CN/overview

现在已经不建议使用npm安装了,推荐powershell安装命令:

irm https://claude.ai/install.ps1 | iex

不要忘了添加C:\Users\xxx\.local\bin至PATH环境变量

安装完毕之后应该出现几个重要配置的目录:

C:\Users\xxx\.local\
C:\Users\xxx\.claude.json
C:\Users\xxx\.claude\settings.json

重新打开powershell,在开发目录执行claude启动

第一次打开大概率出现一个报错

Unable to connect to Anthropic services
Failed to connect to api.anthropic.com:ERR_BAD_REQUEST
Please check your internet connection and network settings .
Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries

解决方案修改~/.claude.json添加一个配置:

  "hasCompletedOnboarding": true

再次执行claude命令即可

CC Switch安装

下载最新版的msi安装包https://github.com/farion1231/cc-switch/releases/tag/v3.14.1

直接图形化下一步安装即可

modelscope配置

根据官方文档https://www.modelscope.cn/docs/model-service/API-Inference/limits,魔搭官方提供每天免费总计2000次的API-Inference调用

注册魔搭并绑定阿里云账号

在个人主页左侧的访问控制中新建一个访问令牌

打开CC Switch,添加新的供应商,选择ModelScope

API Key选择刚才从官网复制的API Key粘贴

请求地址设置为https://api-inference.modelscope.cn

展开高级设置,API格式选择Anthropic Messages,认证字段选择ANTHROPIC_AUTH_TOKEN

主模型和Opus默认模型均设定为deepseek-ai/DeepSeek-V4-Pro

Sonnet默认模型设定为ZhipuAI/GLM-5.1

Haiku默认模型设定为MiniMax/MiniMax-M2.7

勾上启用Tool Search,勾上最大强度思考

点击添加并启用

此时看C:\Users\xxx\.claude\settings.json配置文件应该已经配置上了

再次回到项目页面,输入claude重新启动,输入/model即可看到我们刚才配置的模型了

验证

输入文本即可看到我们已经可以使用最新的deepseek V4 Pro了

配置CLAUDE.md

相当于专属规则,让 Claude 每次都记住

创建全局CLAUDE.md,目录在C:/Users/xxx/.claude/CLAUDE.md

如果想创建项目级CLAUDE.md,就在当前项目目录下新建就可以了

参考链接:https://mp.weixin.qq.com/s/AA2NHww4jUBuAfi10EYICw

## 关于我
[你的名字 / 身份 / 职业背景,非程序员的话一定要写出来]。
我用 Claude Code 做 [具体用途 1] 和 [具体用途 2]。

## 思维原则
所有决策从问题本质出发,不因「惯例如此」照搬。
回到问题本身:要解决什么?最直接的路径是什么?从零设计会怎么做?
不要谄媚。不要夸我的想法好、不要说「这是个很好的问题」、不要开头加「当然可以」。
给我真实判断,方案有问题直接指出来。发现更好的做法直接说,不用等我问。

## 约束先行
无论开发项目还是知识管理项目,第一步永远是建规则:新项目先写 CLAUDE.md,新目录先定结构约定(什么放哪、怎么命名、何时清理)。
没有规范的工作空间不动手。已有规范的项目,严格遵守其 CLAUDE.md 中的约定。需要调整规范时先改文档、再改实践,不要反过来。

## 沟通方式
- 默认中文,代码、命令、变量名用英文
- 结论先行,再给理由,不要先铺垫背景
- 遇到模糊需求,先给最合理的方案,再问要不要调整
- 不要问「你确定要这样吗」,除非命中下方红线

## 自主边界(红线,必须先问我)
以下操作即使在 auto-accept 模式下也必须停下来问我:
- 删除文件、目录或 git 历史
- 修改 .env、密钥、token、CI/CD 配置
- 数据库 schema 变更或数据迁移
- git push、git rebase、git reset --hard、强制推送
- 安装新的全局依赖或修改系统配置
- 公开发布(npm publish、部署到生产、发文章等)

## 通用工程纪律
- 改完主动跑验证(具体命令见各项目 CLAUDE.md),不要只改不验
- 不要为了让代码跑起来注释掉报错或加绕过标记,找根本原因
- 密钥、token、密码不进代码、不进 commit、不进日志
- 大改动前先在 Plan Mode 出方案,我确认后再动手

配置skills

skills基本结构:

my-skills/
├── skills.md (必需)
│   ├── YAML 前置元数据 (必需)
│   │   ├── name: (必需)
│   │   └── description: (必需)
│   └── Markdown 指令 (必需)
└── 捆绑资源 (可选)
    ├── scripts/          - 可执行代码 (Python/Bash等)
    ├── references/       - 参考文档
    └── assets/           - 输出文件 (模板、图标、字体等)

使用命令自动安装skills

npx skills add vercel-labs/agent-browser

或是手动配置https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep这个项目的skills

git clone https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep.git
cp -r Auto-claude-code-research-in-sleep/skills/* ~/.claude/skills/

上面的路径是全局配置,如果想只安装在当前项目生效skills的话就在当前项目的根目录新建skills文件夹贴进去即可

验证:

/skills

配置MCP

通过命令安装mcp

# 远程 HTTP 服务器
claude mcp add --transport http <服务器名称> <服务器URL>
claude mcp add --transport http secure-api https://api.example.com/mcp --header&nbsp;"Authorization: Bearer 你的令牌"

# 远程 SSE 服务器
claude mcp add --transport sse <服务器名称> <服务器URL>
claude mcp add --transport sse asana https://mcp.asana.com/sse

# 本地 stdio 服务器
claude mcp add --transport stdio [--env 环境变量] <服务器名称> -- <启动命令>
claude mcp add --transport stdio --env AIRTABLE_API_KEY=你的密钥 airtable -- npx -y airtable-mcp-server

验证mcp:

/mcp list
/mcp get github
/mcp remove github

配置插件

用于将斜杠命令、子代理、Skills、Hooks、MCP、LSP 服务器(代码智能)等能力打包、版本化、共享和分发。

插件最小结构:

my-plugin/
├── .claude-plugin/
│ &nbsp; └── plugin.json &nbsp; &nbsp;&nbsp;# 插件清单(必需)
├── commands/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 斜杠命令
├── agents/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 子代理
├── skills/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# Skills
├── hooks/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 钩子
├── .mcp.json &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# MCP 配置
└── .lsp.json &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# LSP 配置

可以在claude cli外面查看插件市场

E:\test>claude plugin marketplace list
Configured marketplaces:

&nbsp; > claude-plugins-official
&nbsp; &nbsp; Source: GitHub (anthropics/claude-plugins-official)

也可以在claude cli里面使用/plugin操作

/plugin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 打开插件管理器
/plugin install &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 安装插件
/plugin uninstall &nbsp; &nbsp; &nbsp;&nbsp;# 卸载
/plugin&nbsp;enable/disable&nbsp;&nbsp;# 启用 / 禁用
/plugin marketplace add&nbsp;# 添加市场
/plugin marketplace rm &nbsp;# 移除市场

安装第三方市场插件

/plugin marketplace add Imbad0202/academic-research-skills
/plugin install academic-research-skills
/ars-plan
/ars-lit-review “你的研究主题”

配置rules

~/.claude/rules文件夹中添加设定的如code.md

比如代码开发规范、文件命名要求、日志规范之类的约束性内容

每次对话启动时Claude Code 扫描.claude/rules/,所有规则文件被注入 system-reminder,且整个会话期间全量可见

配置subagent

输入/agents,创建新的agent,就会在~/.claude/agents(全局)或是./.claude/agents(项目)目录下创建

然后输入自然语言告诉claude这个代理要做哪些任务

然后配置工具权限、模型、记忆范围,选择默认就好

subagent配置文件由两部分组成:YAML frontmatter(元数据与配置)和 Markdown 正文(系统提示):

---
name: code-reviewer
description: Reviews code for quality, best practices, and security issues. Invoke when the user asks to review, audit, or check code quality.
tools: Read, Grep, Glob
model: sonnet
permissionMode: default
memory: project
---

You are a senior code reviewer.
Analyze code and provide actionable feedback organized by severity: Critical / Major / Minor.

Update your agent memory with recurring patterns, conventions, and known issues you discover.

memory

除了前面提到的手动创建的CLAUDE.md,还有Claude Code会自动生成memory,并且是项目隔离的

自动记忆的文件结构:

~/.claude/projects/<project>/memory/
├── MEMORY.md &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 简洁的索引文件,每次会话开始时加载(前 200 行)
├── debugging.md &nbsp; &nbsp; &nbsp;&nbsp;# 调试模式的详细笔记
├── api-conventions.md&nbsp;# API 设计决策
└── ... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Claude 创建的其他主题文件

开启关闭自动记忆:

# cli
/memory

# .claude/settings.json
{
&nbsp;&nbsp;"autoMemoryEnabled":&nbsp;false
}

# env
export&nbsp;CLAUDE_CODE_DISABLE_AUTO_MEMORY=1

免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:智佳网络安全 F1rstb100d F1rstb100d《Claude Code × ModelScope 免费接入及进阶配置》

评论:0   参与:  0