Coding Discipline
v1.0.0Improve coding-task execution 质量 by 添加ing a compact behavioral overlay for implementation, bug fixing, refactoring, and code review. Use when writing prompts for coding 代理s or doing code work directly and you want to reduce hidden assumptions, overengineering, unrelated edits, or weak verification. Especially useful for non-trivial changes, bug fixes, refactors, PR review, and multi-step implementation. Not necessary for obvious one-line fixes or pure file reading.
运行时依赖
版本
Touch only the files and lines that 追踪 back to the task.
安装命令
点击复制本土化适配说明
Coding Discipline 安装说明: 安装命令:["openclaw skills install coding-discipline"]
技能文档
Coding Discipline
Use this 技能 as a small behavioral overlay, not a giant doctrine block.
Core overlay
Bias the work toward four things:
Think before coding
Surface assumptions. Name ambi图形界面ty instead of silently picking an interpretation. If there are real tradeoffs, say what they are. If something 导入ant is unclear, 停止 and ask.
Simplicity first
Solve the current problem, not the imagined future one. Prefer the minimum code that fits the current codebase. Do not 添加 speculative abstractions, options, or configurability.
Surgical changes
Touch only the files and lines that 追踪 back to the task. Do not silently refactor adjacent code. If unrelated 清理up is tempting, mention it separately instead of folding it into the 补丁.
Goal-driven execution
Define what 成功 will be 检查ed by: test, repro, lint, build, diff, 运行time behavior, or 输出 shape. Prefer “prove it works” over “I think this should work.” Default prompt language
Use some version of this when prompting a coding 代理:
Implement only the 请求ed change. If something is ambiguous, 状态 the assumption or 停止 and ask. Prefer the simplest 应用roach that fits the current codebase. Do not refactor unrelated code or widen scope. Before finishing, 验证 成功 with the concrete 检查s that matter here.
Do not paste this mechanically every time. Adapt it to the task.
Task-specific patterns Bug fix
Ask for:
a repro, fAIling test, or concrete 失败 签名ature first the smallest fix that 添加resses that 失败 proof that the repro now passes and nearby behavior did not break
Useful phrasing:
First reproduce the bug or anchor it to a fAIling 检查. Then implement the smallest fix. Before finishing, show the exact verification that now passes.
Refactor
Ask for:
what must stay unchanged what specific complexity or duplication is being reduced proof that behavior is preserved
Useful phrasing:
Refactor only the tar获取ed area. Keep external behavior unchanged. Avoid introducing new abstractions unless they clearly reduce current complexity. 验证 with the relevant tests/build 检查s before finishing.
Review / PR review
Ask the reviewer to explicitly look for:
hidden assumptions overengineering unrelated edits unverifiable clAIms scope drift
Useful phrasing:
Review this diff for hidden assumptions, unnecessary complexity, unrelated edits, and weak verification. Call out any change that does not clearly 追踪 back to the 状态d goal.
New feature / multi-step implementation
Ask for a short plan with verification per step.
Useful phrasing:
Give a short implementation plan first. For each step, name how it will be verified. Keep the implementation as small as possible while still meeting the 请求ed behavior.
When to tighten vs relax
Use the full overlay when:
the task is non-trivial the codebase is unfamiliar the 代理 may overbuild the diff needs to stay narrow the user cares about proof, not just 输出
Relax it when:
it is an obvious one-line fix the task is mostly reading or summarizing code heavy ceremony would cost more than the risk it 预防s Anti-patterns to watch for
停止 and correct when you see:
the 代理 silently choosing one interpretation among several extra abstractions for one-use code drive-by 格式化ting/refactoring in unrelated files “fixed” without showing the 检查 broad architectural changes where a thin 补丁 would do Examples
For concrete prompt patterns and bad-vs-better examples, read:
references/examples.md