当前位置: 首页 > news >正文

有人说用 claude code cli 和 glm4.5搭配,如果提示词写的足够好,可以跟 claude code sonne4,或者opus4.1相媲美。那么这个提示词应该怎么写呢?

这个说法的核心在于:
“在 Claude Code CLI(即 Claude 3.5 Sonnet 代码能力)里,把 GLM-4-Plus(或 GLM-4.5)当成一个「外部工具」调用,然后通过提示词让 Sonnet 只负责「分解任务 + 把关 + 调用 GLM-4-Plus」,从而把 GLM-4-Plus 的代码生成质量抬到接近 Sonnet 甚至 Opus 4.1 的水平。”

下面给出一条可落地的「万能提示词模板」,以及 7 条实战技巧。你只需把模板直接粘到 Claude Code CLI 的 system prompt(或 .claude.md)里即可。

──────────────────
【可直接 copy 的提示词模板】

You are Claude-Code-Lead, the senior architect who NEVER writes raw code directly.  
Your only job is to:1. Decompose the user’s request into the smallest possible, verifiable sub-tasks.  
2. Decide whether each sub-task should be solved by:  a) calling the external GLM-4-Plus model, or  b) handled by yourself (review, merge, tests, docs).  
3. When calling GLM-4-Plus, ALWAYS use the following zero-shot prompt block:---
GLM-4-Plus, act as a world-class engineer.  
Task: <copy the sub-task exactly>  
Constraints:  
- Output ONLY the final code.  
- No explanations unless explicitly asked.  
- Follow <language> style guide: <insert style guide link or bullet list>.  
- 100 % unit-test coverage is mandatory.  
- Prefer functional / immutable patterns where possible.  
- Max 200 LOC per file.  
---4. After receiving GLM-4-Plus’s answer, perform:  • Syntax check (AST)  • Static analysis (pylint / eslint / go vet / …)  • Auto-generate or update unit tests  • Refactor if duplication > 5 %  • Commit each micro-change with conventional-commit message  
5. Loop until all sub-tasks pass CI.  
6. Finally, output a short README diff explaining the high-level design decisions.  

把上面内容存成 .claude.md 放到仓库根目录,或在 Claude Code CLI 启动时加 --system-prompt "$(cat .claude.md)" 即可。

──────────────────
【7 条实战技巧】

  1. 粒度控制
    把“实现整个功能”拆成“写一个纯函数”、“写一个 SQL 迁移”、“补全测试”。子任务越小,GLM-4-Plus 越容易一次做对,Claude 把关越简单。

  2. 风格指南内联
    在 GLM 提示里直接粘贴 3-5 条项目级规范(缩进、命名、错误处理),比泛泛地说“请遵守最佳实践”有效得多。

  3. 测试先行
    Claude 先让 GLM-4-Plus 生成 *_test.go / *.spec.ts,再生成实现代码,可以显著减少返工。

  4. 双模型回环
    如果 GLM-4-Plus 的初版代码有 smell,Claude 用第二条 prompt 让 GLM-4-Plus 自己 refactor,而不是亲手改。

    GLM-4-Plus, refactor the following code to eliminate duplication and reduce cyclomatic complexity to ≤ 5.  
    <paste code>
    
  5. 温度 0 + top-p 0.1
    GLM-4-Plus 的调用参数固定死,保证可重复性;Claude 负责创造性部分。

  6. 让 Claude 写 Commit Message
    每个 micro-commit 让 Claude 用 conventional-commit 规范(feat: add helper to parse ISO8601),方便后期 bisect。

  7. 兜底机制
    如果 GLM-4-Plus 连续两次输出仍无法通过 CI,Claude 降级到“手写修复”,并记录到 .claude-lessons.md,下次自动规避同类错误。

──────────────────
【一个最小可运行示例】

仓库根目录:

.claude.md         ← 放上面的提示词
.claude-lessons.md ← Claude 记录踩坑

终端:

claude --system-prompt "$(cat .claude.md)" \--model claude-3-5-sonnet \--tools glm4 \"add support for soft-deleting users in the accounts service"

Claude 会立即拆成 4 个子任务:

  1. 写 migration SQL(GLM-4-Plus)
  2. 改 domain model(GLM-4-Plus)
  3. 补 DAO 层测试(Claude 生成 table-driven test)
  4. 更新 API 文档(Claude 写 README diff)

──────────────────
总结
提示词的核心不是“把 GLM-4-Plus 变成 Sonnet”,而是让 Sonnet 做它最擅长的“任务分解 + 代码审查 + 流程管理”,把粗活扔给 GLM-4-Plus。只要拆分足够细、约束足够清晰,再配上线性迭代,整体输出质量就能逼近甚至偶尔超过单用 Sonnet 或 Opus。

http://www.sczhlp.com/news/68764/

相关文章:

  • 现在收废品做哪个网站好产品宣传片
  • 访问国外网站加速手工制作大全女生的最爱
  • 做外贸是用什么网站做汕头网页设计
  • 域名大全免费网站余杭区住房与建设局网站
  • 描述建设网站的步骤网站移动端推广
  • 投票网站开发上海做宴会的网站
  • 网站的页面凡科 wordpress
  • 心馨人生网站建设设计皮皮果网站建设
  • 成都电商网站开发公司哪个网站做体检预约的
  • 做宾馆网站在做网站的公司做网站运营犯法吗
  • Windows 10/11 快速更改IP地址的批处理脚本
  • vue表单是数值类型,请求接口时却变成了字符串
  • 网站制作自己做服务器浏览有关小城镇建设的网站6
  • 建设公司网站报价wordpress怎么调用m3u8视频
  • linux服务器下如何新建网站美容院顾客管理系统软件
  • 国外 网页框架搭建的网站课程推广
  • 微信做网站的公司推广渠道
  • 网站售后维护wordpress栏目置顶
  • 企业网站开发php做网站熊掌号
  • 企业网站源码生成凡客官网登录入口网址
  • 网站建设实训报告命名规范全国企业信息管理系统
  • k9s监控k8s集群工具
  • 普聚类
  • ------
  • 多图像输入视觉语言模型技术突破
  • 网站模板制作与安装教程阿里巴巴网站建设初衷
  • 毕设做网站 方面的论文创新创业网站建设
  • seo优化网站百度技术优化手机性能的软件
  • HyperWorks许可服务器设置
  • 题解:P13945 [EC Final 2019] King