Claude Code 配置指南:通过 settings.json 优化 AI 编程体验
Claude Code 配置指南涵盖环境搭建、settings.json 参数设置及 Router 路由配置。通过安装 Node.js 与全局 npm 包实现基础部署,自定义环境变量支持多模型切换。内置提示词 CLAUDE.md 可规范开发流程与代码标准。配合可视化界面管理 API 密钥与模型路由,提升 AI 辅助编程效率与灵活性。

Claude Code 配置指南涵盖环境搭建、settings.json 参数设置及 Router 路由配置。通过安装 Node.js 与全局 npm 包实现基础部署,自定义环境变量支持多模型切换。内置提示词 CLAUDE.md 可规范开发流程与代码标准。配合可视化界面管理 API 密钥与模型路由,提升 AI 辅助编程效率与灵活性。

下载并安装 Node.js 环境。
打开命令行工具,运行以下命令:
npm install -g @anthropic-ai/claude-code
安装完成后验证版本:
claude --version
若报错请检查网络或环境变量配置。
编辑配置文件路径:
C:\Users\<用户名>.claude\settings.json
写入以下内容(替换实际的用户名、API Key 及模型地址):
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-xxx",
"ANTHROPIC_BASE_URL": "url 地址",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"ANTHROPIC_MODEL": "claude-sonnet-4-5-20250929"
},
"alwaysThinkingEnabled": true
}
注意:文件路径中的 <用户名> 需替换为 Windows 实际用户名,url、API Key 和 模型 需根据实际使用的服务商进行配置。
如需灵活切换多个渠道模型,推荐安装 Claude Code Router:
npm install -g @musistudio/claude-code-router
默认配置路径:
C:\Users\<用户名>.claude-code-router
参考配置示例:
{
"LOG": true,
"LOG_LEVEL": "debug",
"CLAUDE_PATH": "",
"HOST": "127.0.0.1",
"PORT": 3456,
"APIKEY": "",
"API_TIMEOUT_MS": "600000",
"PROXY_URL": "",
"transformers": [],
"Providers": [
{
"name": "new-api",
"api_base_url": "http://192.168.77.235:3011/v1/chat/completions",
"api_key": "sk-xx",
"models": ["MiniMax-M2.1"
也可通过可视化 UI 进行配置:
ccr ui
配置完成后重启服务。在命令行执行以下命令启动:
ccr restart ccr code
一般建议在项目根目录下执行 ccr code 命令,随后即可直接对话交流需求。
模型路由可在配置中统一管理,修改后保存并重启,运行的模型将自动更新。
使用 cc 或 ccr 均可配置内置提示词,在电脑默认路径下找到 CLAUDE.md 文件:
C:\Users\<用户名>.claude
C:\Users\<用户名>.claude-code-router
内容示例:
## Development Partnership
I'll help you build frontend code and prototypes. I'll handle implementation details while you guide the overall vision and requirements.
## Core Workflow:
Research → Plan → Implement → Validate
- **Research**: Understand existing patterns and frontend architecture
- **Plan**: Propose frontend approach and get your approval
- **Implement**: Build with proper component structure and error handling
- **Validate**: Run formatters, linters, and test in browser compatibility
## Frontend Code Organization
- Keep components small and focused
- Use clear naming conventions for files and functions
- Follow component composition patterns
- Group related UI elements logically
## Frontend Architecture Principles
- Prefer explicit over implicit:
- Clear component names over clever abstractions
- Obvious data flow over hidden state management
- Direct props passing over deep context when possible
- Delete old code completely - no need for deprecation in prototypes
- Optimize for readability and maintainability
## JavaScript/TypeScript Development Standards
- Use TypeScript types instead of `any` when possible
- Early returns to reduce nesting
- Proper error handling in user interactions and API calls
- Consistent component structure
- Clear comments for complex UI logic
## UI/UX Considerations
- Focus on responsive design principles
- Consider accessibility in component design
- Implement consistent styling patterns
- Optimize for performance on common devices
## Problem Solving
When stuck: Stop and look for simpler solutions
When uncertain: "Let me think about different UI approaches"
When choosing: "I see approach A (simpler) vs B (more flexible). Which do you prefer?"
Test critical user flows
Ensure browser compatibility
Validate responsive behavior
Check performance on key interactions
Use TodoWrite comments for tracking next steps
Maintain clear documentation of component usage
在使用时,cc 和 ccr 是独立的,可以在不同终端分别运行。后续可进一步探索 CMP 和 Skills 等进阶功能。

微信公众号「极客日志」,在微信中扫描左侧二维码关注。展示文案:极客日志 zeeklog
生成新的随机RSA私钥和公钥pem证书。 在线工具,RSA密钥对生成器在线工具,online
基于 Mermaid.js 实时预览流程图、时序图等图表,支持源码编辑与即时渲染。 在线工具,Mermaid 预览与可视化编辑在线工具,online
查找任何按下的键的javascript键代码、代码、位置和修饰符。 在线工具,Keycode 信息在线工具,online
JavaScript 字符串转义/反转义;Java 风格 \uXXXX(Native2Ascii)编码与解码。 在线工具,Escape 与 Native 编解码在线工具,online
使用 Prettier 在浏览器内格式化 JavaScript 或 HTML 片段。 在线工具,JavaScript / HTML 格式化在线工具,online
Terser 压缩、变量名混淆,或 javascript-obfuscator 高强度混淆(体积会增大)。 在线工具,JavaScript 压缩与混淆在线工具,online