Uncle Bob Sets Rules for AI-Written Code: First Make It Run, Then Make It Right, Then Practice
Uncle Bob has open-sourced ub-mode, a skill that turns Clean Code discipline into hard checks for AI coding agents. A three-step process plus four tools—he says it works well for him.
Uncle Bob is Robert C. Martin, author of Clean Code. He posted a tweet saying he wrote a skill and it works well for him. His grokbots (AI coding agents) use this skill when writing code.
The skill is called ub-mode and is open-sourced on GitHub. An Agent skill is a set of external rules: a SKILL.md file placed in the AI assistant's skills directory, automatically loaded before the AI starts working.
Three-Step Process
ub-mode breaks the coding process into three steps.
First make it run. This stage requires basic thinking, TDD, and redesigning from first principles. Question assumptions first; if you can avoid adding something, don't add it. Architecturally, model the domain, guard boundaries, respect the type system, ensure operations are idempotent, and separate shared state first.
Then make it correct. Fix root causes, break work into verifiable units, and test behavior, not implementation. Then run three deterministic quality tools: crapper checks cyclomatic complexity and CRAP scores, dryer eliminates duplication, and mutator performs mutation testing. Finally, refactor.
Practice. Keep logs, guard the context window, clean the workspace, and commit and push in small steps.
Companion Tools
crapper calculates each function's cyclomatic complexity, test coverage, and CRAP score, with a threshold of 10. dryer detects structural duplication; duplicate blocks with similarity greater than or equal to 0.8 are removed. mutator runs mutation testing to find uncovered code and mutants that tests fail to kill. uml-viewer visualizes components, coverage, CRAP, mutation scores, and dependency direction.
Installation
Installation is not complicated. Copy SKILL.md into the AI assistant's skills directory, name it ub-mode/SKILL.md, and then invoke /ub-mode. For example: ~/.grok/skills/ub-mode/SKILL.md, ~/.claude/skills/ub-mode/SKILL.md, or ~/.cursor/skills/ub-mode/SKILL.md.
Some Reactions
A commenter asked whether cramming rules into a skill would blow up the context. Uncle Bob said: You're an engineer; you have to watch the AI and not let them forget the rules. He has already compressed this set of rules quite small, so it has little impact on most models.
He also explained why he wrote this skill. Previously he had to manually direct the AI through a process: after the task ran, run crap, run dry, run mutate. Now the AI does them in order by itself.
In the comments, someone posted a screenshot of game programmer Casey Muratori's Unclean Code skill. It was deliberately written in reverse: functions should be as large as possible, the whole system should share one global state, a function's sole responsibility is to run the entire application, duplicate code should be copied freely, variable names should be p, n, i, all abstraction should be eliminated, and performance problems should be optimized immediately. The most brutal part is the first rule: ensure that Bob Martin is never correct under any circumstances, even by accident.
Uncle Bob replied with only a video, laughing happily.
A commenter said these are the first batch of junior developers who have actually read Clean Code from cover to cover. Another asked: since there is Clean Architecture, could you make another skill that lets AI check whether architectural principles are violated? Uncle Bob did not respond, but ub-mode is already heading in that direction.
Project link: github.com/unclebob/ub-mode
发布时间: 2026-10-26 03:48