Claude Code 加 DeepSeek 配置实战:如何让非顶级模型也可用
Claude Code 加 DeepSeek 配置实战如何让非顶级模型也可用用不起 Claude Opus配置到位效果不差。前提本文目标读者用不了 Claude Opus API只能用 DeepSeek 的程序员核心问题DeepSeek 输出不够稳定怎么通过配置让 Claude Code 达到可用状态核心认知Claude Code 官方文档里有一句话容易被忽略CLAUDE.md content is delivered as a user message, not as part of the system prompt. Claude reads it and tries to follow it.这意味着模型不是全部配置能补偿。官方文档把 Claude Code 的记忆机制分两种机制谁写什么时候加载CLAUDE.md你写每次会话开始Auto MemoryClaude 自己写每次会话开始只读前200行关键点你写的东西会直接影响模型行为。配置越具体模型越靠谱。配置一CLAUDE.md 怎么写才有用官方文档明确说了Specific, concise, well-structured instructions work best.1.1 写什么把每次都要解释的东西写进去# 项目配置 ## 项目结构 - src/api/ - API 路由 - src/core/ - 核心逻辑 - tests/ - 测试 ## 构建命令 - npm run dev - 启动开发服务器 - npm run test - 运行测试 - npm run lint - 代码检查 ## 代码规范 - 使用 2 空格缩进 - 必须加类型提示 - 函数必须有 docstring - 提交前运行 lint1.2 别写什么模糊的规则“代码写得好一点” —— 没用矛盾的规则“用 2 空格” “用 4 空格” —— 模型随便选太长“目标 200 行” —— 越长 adherence 越低1.3 进阶按文件类型加载规则官方文档说可以用.claude/rules/目录让规则只在相关文件被打开时才加载.claude/ ├── CLAUDE.md └── rules/ ├── api.md # 只在打开 API 文件时加载 ├── testing.md # 只在打开测试文件时加载 └── security.md # 安全相关规则api.md内容示例--- paths: - src/api/**/*.ts --- # API 开发规则 - 所有端点必须有输入验证 - 使用标准错误响应格式 - 包含 OpenAPI 注释1.4 路径规则怎么写官方文档支持的 glob 模式模式匹配*.ts根目录所有 TS 文件src/**/*.jssrc 下所有 JS 文件tests/*.{ts,tsx}tests 下 TS 和 TSX配置二settings.json 怎么配官方文档说 settings.json 有四个作用域作用域位置谁能用User~/.claude/settings.json自己所有项目Project.claude/settings.json团队提交 gitLocal.claude/settings.local.json自己当前项目ManagedIT 部署整个组织2.1 最实用permissions 权限控制这是官方文档的核心例子{permissions:{allow:[Bash(npm run test *),Bash(npm run lint *),Bash(git *),Read,Edit,Write],deny:[Bash(rm -rf *),Bash(curl *),Read(./.env*),Read(./secrets/**)]}}为什么有用限制危险操作让模型更谨慎。DeepSeek 模型能力弱更需要安全边界。2.2 环境变量{env:{NODE_ENV:development,LOG_LEVEL:debug}}配置三Skills 自定义命令官方文档说当你每次都复制同样的流程时用 Skill。3.1 创建一个代码审查 Skillmkdir-p~/.claude/skills/code-review~/.claude/skills/code-review/SKILL.md---name:code-reviewdescription:按团队规范审查代码disable-model-invocation:trueallowed-tools:Bash(git*)Bash(ruff*)Read---## 审查流程1. 运行 git diff--stat 看改了多少 2. 运行 ruff check . 检查代码 3. 读改动文件找问题 4. 输出报告## 报告格式## 问题-[file:line]问题描述## 总结-严重问题数-建议3.2 调用方式# 直接调用/code-review# 带参数/code-review src/api/user.py配置四MCP 扩展工具官方文档MCP (Model Context Protocol) 让 Claude 连接外部工具。4.1 什么时候用官方文档说Connect a server when you find yourself copying data into chat from another tool比如想让 Claude 查数据库→ 接 PostgreSQL MCP想让 Claude 查 GitHub→ 接 GitHub MCP4.2 怎么配项目级 MCP 在.mcp.json{mcpServers:{filesystem:{command:npx,args:[-y,modelcontextprotocol/server-filesystem,/path/to/project]},github:{command:uvx,args:[mcp-server-github]}}}实战一步步配好 DeepSeekStep 1创建 CLAUDE.md# 项目根目录touchCLAUDE.md内容# 项目配置 ## 项目 Python FastAPI 项目。 ## 命令 - pytest - 运行测试 - ruff check . - 代码检查 - ruff format . - 格式化 ## 规范 - 4 空格缩进 - 类型提示必须有 - docstring 用 Google 风格Step 2配置 permissionsmkdir-p.claudetouch.claude/settings.json{permissions:{allow:[Bash(pytest *),Bash(ruff *),Bash(git *),Read,Edit,Write],deny:[Bash(rm -rf *),Bash(curl *),Read(./.env*),Read(./secrets/**)]}}Step 3创建代码审查 Skillmkdir-p.claude/skills/reviewtouch.claude/skills/review/SKILL.md---name:reviewdescription:审查代码质量disable-model-invocation:trueallowed-tools:Bash(git*)Bash(ruff*)Read---请审查当前改动 1. 运行 git diff--stat 看改了多少 2. 运行 ruff check . 检查代码 3. 输出审查报告 格式## 问题-[file:line]问题## 总结Step 4使用# 启动 Claude Code指定 DeepSeekclaude--modeldeepseek# 或者在对话中用/review效果怎么样官方文档说The more specific and concise your instructions, the more consistently Claude follows them.配置到位后输出更稳定规则明确模型不用猜错误更少权限限制防止危险操作效率更高Skill 自动化重复流程还有啥可以配官方文档里还有这些我没展开Auto Memory让 Claude 自己记住调试心得Subagents创建专门的子 AgentHooks自动化工具调用前后的事件官方文档值得一读https://docs.anthropic.com/en/docs/claude-code/总结配置作用难度CLAUDE.md项目规范⭐settings.json权限控制⭐⭐Skills自动化流程⭐⭐MCP外部工具⭐⭐⭐记住模型不够配置来凑。配置越具体输出越靠谱。