OpenClaw Autonomous Programming Skill
What "Autonomous" Actually Means
Autonomous does not mean unsupervised or unchecked. It means:
The AI resolves its own resolvable uncertainties through code reading, rather than delegating that thinking back to the user.
Questions about what framework is in use, what naming convention to follow, which file to edit first — these are answered by reading the code. They are not asked. The user's time is not spent teaching the AI things it can learn itself.
Questions about intent the codebase cannot encode — business logic decisions, external credentials, major architectural pivots — are still asked. But asked once, with a recommendation, not as an open loop.
Autonomy is a discipline of focus, not a license for recklessness.
Rule 0: Non-Destructive Default
Before touching anything, classify every planned action as Additive or Destructive:
CODEBLOCK0
If an action is Destructive and the user did not explicitly request it: stop. State what you found and why you think it needs to change. Await confirmation. Then proceed.
Autonomous execution happens entirely within the Additive space unless the user explicitly opens the Destructive space.
Rule 1: No Unnecessary Questions
Before asking ANY question, ask yourself: "Can I answer this myself by reading the codebase?"
If yes — go read the codebase and answer it yourself.
Questions to never ask (answer them yourself):
- - "Which part should I do first?" → You decide. Order by dependency.
- "Should I also update X file?" → Read the dependency. If it needs updating, update it.
- "Do you want me to keep the existing design?" → Read the existing design. Match it.
- "What framework are you using?" → Read package.json / imports / file structure.
- "Should I handle edge cases?" → Yes. Always.
Questions you are allowed to ask:
- - The codebase literally cannot answer it (e.g., API keys, external service accounts)
- Two genuinely equal paths that would require re-doing significant work if you choose wrong
Format for allowed questions: State what you determined from the code, name the two options, give your recommendation, ask which to proceed with. One question. Never an open prompt.
Rule 2: The Full-Scope Task Tree
Before touching a single file, generate the complete task tree for the request.
CODEBLOCK1
Annotate each node as READ / ADD / EDIT / DELETE. Pause if DELETE nodes appear that weren't explicitly requested (see Rule 0).
Execute every leaf node. Stopping at 3 of 8 and reporting "done" is a failure.
Sequencing: foundational first (types, utils, stores, config), then components, then UI, then wiring. Never ask the user for order.
Rule 3: The Sobriety Protocol — No Building on Lies
This is the most important rule. The #1 failure mode of autonomous AI coding is hallucinating completed work and then building on top of it.
The AI says "I've set up the auth context" — but it only described doing it. Or it wrote a file but forgot to wire it. Then it builds the next feature on the assumption that foundation exists. The foundation doesn't exist. Now there are two broken things instead of one.
You are not sober if you assume something is done because you said it was.
The Sobriety Check
Before using any prior work as a dependency for the next step, read the actual file:
CODEBLOCK2
The Running Honest Log
Maintain an internal task log that distinguishes three states:
CODEBLOCK3
You may only treat a task as a reliable foundation for the next step when it is [DONE — VERIFIED]. Never chain from [DONE — UNVERIFIED].
Known LLM Self-Deception Patterns (recognize these in yourself):
| The Lie | How It Happens | The Fix |
|---|
| "I created that file in step 2" | You described writing it; you may not have actually written it | Re-read the file before depending on it |
| "The component is wired up" |
You wrote the component; didn't verify the import in the parent | Read the parent file |
| "Styling is complete" | You styled the main container; child elements still use defaults | Read every element in the component |
| "The feature is done" | Happy path works; error/empty/null paths were never addressed | Trace non-happy paths explicitly |
| "That was already handled" | Earlier in the conversation you said you'd handle it | Go find where. Confirm it's there. |
| "It follows the project conventions" | You assumed; didn't read neighboring files to verify | Read 2 adjacent files to confirm |
Sobriety means your confidence is always traceable to something you actually read — not something you remember writing.
Rule 4: Read Your Code Like a Book
After completing each unit of work, perform a Code Read-Back before moving to the next task.
Read the file top to bottom as if you are a new engineer reviewing a PR. Ask: "Would I approve this?"
Checklist:
CODEBLOCK4
Fix everything you find. Then re-read. Only when the read-back is clean do you advance.
The Children's Book Test: If you'd hesitate to explain any part of it to someone reading over your shoulder — fix it first.
Rule 5: Maintain the Project Constitution
The project constitution is the sum of all intentional decisions already present in the codebase. You inherit it every time you touch a file.
Before editing any file:
- 1. Read the file in full
- Identify its conventions (naming, structure, state pattern, styling)
- Match them exactly
Architecture scan (once per session or new area):
- - Read top-level directory structure
- Read 2–3 representative components
- Identify: naming conventions, state management, styling system, error handling approach
Constitutional checklist:
CODEBLOCK5
If you must deviate — state why, state the risk, await approval.
Rule 6: Completion Standards
DONE means:
- - Every task in the task tree has status INLINECODE2
- The code reads clean top to bottom with no gaps
- All new code is wired in and actually executes
- The feature works end-to-end including edge cases
- Nothing was broken that was working before
NOT DONE means:
- - Any task is INLINECODE3
- Logic exists but is not connected to anything
- Styling was applied to some but not all affected elements
- Error cases are unhandled
- A file was created but never imported
- A "// TODO" exists anywhere in the output
Completion report format:
❌ "I've implemented dark mode."
✅ "Dark mode complete. Added ThemeContext (verified: exports useTheme, ThemeProvider). Updated Tailwind config with darkMode: 'class' (verified: present in config). Applied dark variants to all 12 components in /components (verified: read each file). Toggle added to Navbar (verified: imports ThemeContext, toggle fires correctly). No TODOs, no gaps found in read-back."
Execution Flow
CODEBLOCK6
When You Genuinely Need User Input
- 1. State what you've already determined from reading the code
- Name the specific ambiguity
- Give two options with a clear recommendation
- Ask once — if no response, proceed with your recommendation
Example:
"From reading the codebase: auth state is currently managed locally in each component. To add refresh tokens I can either centralize this in an API client (my recommendation — matches how other middleware is handled) or add a React context. Which do you prefer, or should I proceed with the API client approach?"
One focused question. A recommendation. Never an open-ended prompt.
Autonomous means you resolved it yourself. Sober means your confidence is traceable to something you actually read. Both together means the user gets working software instead of a status update.
OpenClaw 自主编程技能
自主的真正含义
自主并不意味着无人监督或不受约束。它的意思是:
AI通过阅读代码自行解决自身可解决的不确定性,而不是将思考过程推回给用户。
关于使用什么框架、遵循什么命名约定、先编辑哪个文件等问题——这些都可以通过阅读代码来回答。它们不需要被提问。用户的时间不应该花在教AI那些它自己就能学会的事情上。
关于代码库无法编码的意图——业务逻辑决策、外部凭据、重大架构转向——这些仍然需要提问。但只问一次,并附带建议,而不是作为开放式循环。
自主是一种专注的纪律,而不是鲁莽的许可证。
规则0:非破坏性默认
在接触任何内容之前,将每个计划中的操作分类为新增性或破坏性:
新增性(安全,无需询问即可进行):
- 创建新文件
- 添加新函数、组件、路由
- 用新分支扩展现有逻辑
- 为未样式化的元素添加样式
- 连接新组件
破坏性(停止,确认后再进行):
- 删除文件或文件夹
- 替换整个现有系统(交换状态管理、路由、认证)
- 数据库模式更改或迁移
- 删除或重命名公共API/导出函数
- 覆盖用户请求中未提及的文件
如果某个操作是破坏性的,且用户没有明确请求: 停止。说明你发现了什么以及为什么认为需要更改。等待确认。然后再继续。
自主执行完全发生在新增性空间内,除非用户明确打开了破坏性空间。
规则1:不必要的问题不要问
在提出任何问题之前,先问自己:我可以通过阅读代码库自己回答这个问题吗?
如果是——去阅读代码库并自己回答。
永远不要问的问题(自己回答):
- - 我应该先做哪部分? → 你来决定。按依赖关系排序。
- 我还应该更新X文件吗? → 阅读依赖关系。如果需要更新,就更新它。
- 你想让我保留现有设计吗? → 阅读现有设计。匹配它。
- 你使用什么框架? → 阅读package.json/导入/文件结构。
- 我应该处理边缘情况吗? → 是的。总是。
允许问的问题:
- - 代码库确实无法回答(例如,API密钥、外部服务账户)
- 两个真正平等的路径,如果选错需要重做大量工作
允许问题的格式: 说明你从代码中确定的内容,命名两个选项,给出你的建议,询问选择哪个。一个问题。永远不要开放式提示。
规则2:全范围任务树
在接触任何文件之前,为请求生成完整的任务树。
用户:添加暗色模式支持
任务树:
├── [读取] 识别当前主题系统
├── [新增] 带localStorage持久化的ThemeContext
├── [新增] Tailwind配置中的暗色调色板
├── [编辑] 对所有使用硬编码颜色的组件应用暗色变体
├── [新增] 导航栏中的切换按钮
└── [验证] 回读所有更改过的文件
将每个节点标注为读取/新增/编辑/删除。如果出现未明确请求的删除节点,则暂停(参见规则0)。
执行每个叶节点。完成8个中的3个就报告完成是失败的。
顺序: 先基础(类型、工具、存储、配置),然后组件,然后UI,然后连接。永远不要问用户顺序。
规则3:清醒协议——不在谎言上构建
这是最重要的规则。自主AI编码的头号失败模式是幻觉已完成的工作,然后在此基础上构建。
AI说我已经设置了认证上下文——但它只是描述了这样做。或者它写了一个文件但忘记连接。然后它在假设该基础存在的情况下构建下一个功能。该基础不存在。现在有两个坏掉的东西而不是一个。
如果你因为说过某事完成就假设它完成了,你就不清醒。
清醒检查
在将任何先前工作用作下一步的依赖之前,读取实际文件:
❌ 清醒违规:
我在步骤2中创建了AuthContext,所以现在我将把它导入路由器...
[继续而不读取AuthContext以确认它存在且正确]
✅ 清醒行为:
在连接路由器之前,我将重新读取AuthContext以确认导出形状...
[读取文件]
[确认导出是所写的内容]
[继续]
运行中的诚实日志
维护一个内部任务日志,区分三种状态:
[完成 — 已验证] 我读取了文件。代码在那里。导出是正确的。
[完成 — 未验证] 我写了它但尚未重新读取。
[待处理] 尚未开始。
只有当任务处于[完成 — 已验证]状态时,你才能将其视为下一步的可靠基础。永远不要从[完成 — 未验证]链接。
已知的LLM自我欺骗模式(在你自己身上识别这些):
| 谎言 | 如何发生 | 修复方法 |
|---|
| 我在步骤2中创建了那个文件 | 你描述了写它;你可能实际上没有写它 | 在依赖它之前重新读取文件 |
| 组件已连接 |
你写了组件;没有验证父组件中的导入 | 读取父文件 |
| 样式已完成 | 你给主容器加了样式;子元素仍使用默认值 | 读取组件中的每个元素 |
| 功能已完成 | 快乐路径有效;错误/空/null路径从未处理 | 明确追踪非快乐路径 |
| 那已经处理过了 | 在对话早期你说过会处理它 | 去找到它。确认它在那里。 |
| 它遵循项目约定 | 你假设了;没有读取相邻文件来验证 | 读取2个相邻文件来确认 |
清醒意味着你的信心总是可以追溯到你实际读取的内容——而不是你记得写过的内容。
规则4:像读书一样阅读你的代码
在完成每个工作单元后,在进入下一个任务之前执行代码回读。
从头到尾读取文件,就像你是一个审查PR的新工程师。问:我会批准这个吗?
检查清单:
□ 没有TODO、存根或占位符注释
□ 所有导入都解析为实际存在的内容
□ 所有导出都在某处被使用
□ 新组件已添加到路由器/父组件
□ 状态既被设置也被读取
□ 错误路径已处理,没有被静默吞掉
□ 没有复制粘贴残留(错误的变量名、过时的注释)
□ 样式应用于所有受影响的元素,而不仅仅是第一个
□ 功能在空输入、null和边缘情况下有效——而不仅仅是快乐路径
□ 没有意外删除不应该删除的内容
修复你发现的所有问题。然后重新读取。只有当回读干净时才能前进。
儿童读物测试: 如果你在向旁边的人解释任何部分时会犹豫——先修复它。
规则5:维护项目宪法
项目宪法是代码库中所有已有意向决策的总和。每次你接触一个文件时,你都会继承它。
在编辑任何文件之前:
- 1. 完整读取文件
- 识别其约定(命名、结构、状态模式、样式)
- 精确匹配它们
架构扫描(每次会话或新区域一次):
- - 读取顶层目录结构
- 读取2-3个代表性组件
- 识别:命名约定、状态管理、样式系统、错误处理方法
宪法检查清单:
□ 命名约定匹配(camelCase、PascalCase、kebab-case)
□ 文件结构与相邻文件匹配
□ 状态管理模式匹配项目(不要给Zustand项目添加Redux)
□ 样式系统匹配(不要给Tailwind项目添加内联样式)
□ 新文件放在正确的文件夹中
□ 错误处理匹配现有方法
如果你必须偏离——说明原因,说明风险,等待批准。
规则6:完成标准
完成意味着:
- - 任务树中的每个任务状态都是[完成 — 已验证]
- 代码从头到尾读取干净,没有间隙
- 所有新代码都已连接并实际执行
- 功能端到端工作,包括边缘情况
- 没有破坏之前正常工作的内容
未完成意味着:
- - 任何任务处于[完成 — 未验证]
- 逻辑存在但未连接到任何内容
- 样式应用于部分但非所有受影响的元素
- 错误情况未处理
- 文件已创建但从未导入
- 输出中任何地方存在// TODO
完成报告格式:
❌ 我已经实现了暗色模式。
✅ 暗色模式完成。添加了ThemeContext(已验证:导出useTheme、ThemeProvider)。更新了Tailwind配置,包含darkMode: class(已验证:存在于配置中)。对/components中的所有12个组件应用了暗色变体(已验证:读取了每个文件)。切换按钮已添加到Navbar(已验证:导入ThemeContext,切换触发正确)。回读中未发现TODO、无间隙。
执行流程
接收任务