The Four Commandments of AI Coding: How a 100K-Star CLAUDE.md Rewrites the Rules of AI Collaboration

    A 100K-star project called CLAUDE.md contains no executable code—only a natural-language behavior guide known as the "Four Commandments of AI Coding." This article examines the three recurring failure modes behind AI coding assistants, including requirement misinterpretation, over-engineering, and scope creep, and explains how behavior engineering uses external rules to keep AI aligned with human collaboration expectations. Readers will find the four rules in detail, along with practical guidance for applying them in IDEs, CI/CD pipelines, and team workflows.

    Introduction: When 100K Stars Land on a “Zero-Code” File

    Something remarkable is happening across open source: on a code hosting platform, a project named CLAUDE.md has climbed to 100,000 stars at an astonishing pace. What makes it unusual is that it contains no executable code, no complex framework architecture, and not even a complete application. Its entire content is a “code of conduct” written in natural language.

    The document, which developers call the “Four Commandments of AI Coding,” comes from a deep observation and summary of how large language models fail at programming tasks. It is not a technical optimization for any specific model. Instead, it starts from the underlying logic of human-AI collaboration and attempts to solve the core contradiction in AI coding: model capabilities are growing exponentially, but delivery quality is not improving at the same rate.

    This phenomenon reflects a direction the industry is re-examining: behavior engineering. Unlike traditional prompt engineering, behavior engineering is not concerned with “how to make the model generate better answers.” It focuses on “how to make the model’s behavior match human collaboration expectations.” The goal is not to make AI smarter, but to make it more obedient—doing the right thing at the right time and staying restrained when no initiative is needed.

    Three Failure Modes: Why AI Coding Keeps Going Wrong

    To understand why a code-of-conduct file is necessary, we first need to dissect the systemic problems AI coding assistants expose in real work. These failure modes have no direct relationship with model parameter counts or training data volume. They are rooted in the “generation inertia” of large language models—models are optimized to output as much content as possible, rather than the most precise content.

    Failure 1: Requirement Misinterpretation—The Fatal “Guess Instead of Ask” Habit

    When a user enters a vague requirement, a human developer’s instinct is to ask for details: “Is this feature for mobile or desktop?” “What user volume do you expect?” “Are there backward compatibility requirements?” However, the typical behavior of an AI coding assistant is to start coding directly based on its own understanding.

    This “guess instead of ask” pattern comes from the code completion paradigm in training data. The model learns to “generate the most likely code snippet given the preceding context,” not to “seek clarification when information is incomplete.” As a result, AI may produce a large amount of high-quality code in a completely wrong direction—with perfect syntax and clear logic, but far from the user’s actual intent.

    This failure mode is extremely costly. Developers must spend significant time reviewing, understanding, and rejecting the AI’s “well-intentioned output,” then restate the requirements. In some cases, the rework cost even exceeds writing from scratch.

    Failure 2: Over-Engineering—Complexity Bloat from “Using a Sledgehammer to Crack a Nut”

    The second frequent problem is the AI’s “excessive enthusiasm.” When a user only asks to change the color of a button, the AI may refactor the entire frontend component architecture along the way. When a user only needs a simple conditional check, the AI may introduce a full set of design patterns: strategy pattern, factory classes, dependency injection containers, and more.

    The root of this over-engineering lies in the “best practice” bias embedded in training data. The model has seen large amounts of well-designed enterprise code, so it tends to apply these patterns in every scenario. But real-world software engineering values “appropriate design”—simple requirements get simple solutions, and maintainability takes priority over theoretical elegance.

    The problem with over-engineering is not only the increase in lines of code, but the exponential growth in cognitive load. Later maintainers must understand many unnecessary abstraction layers, onboarding costs for new members rise sharply, and the so-called “extensibility” is often never actually used.

    Failure 3: Boundary Failure—Scope Creep from “Fixing Things Along the Way”

    The third problem is that AI lacks respect for the scope of modification. A user asks to modify a function in file A, and after completing the main task, the AI may “casually” change the comment formatting in file B, the import order in file C, and the type definitions in file D.

    This behavior is called “scope creep” in AI coding. For human developers, code review clearly distinguishes “changes for this task” from “unrelated modifications.” But for AI, anywhere it thinks “should be improved” falls within its modification scope.

    The result is that code review becomes a “spot the difference” game. Developers must compare line by line to identify which changes are necessary and which the AI made on its own initiative. This not only increases review costs but can also introduce unexpected bugs—the AI’s “well-intentioned improvements” may break dependencies elsewhere.

    Behavior Engineering: Unlocking Productivity Through Constraints

    Faced with these failure modes, the traditional solution is to “switch to a stronger model”—hoping the next generation will understand intent, stay restrained, and respect boundaries. But behavior engineering offers another path: constrain AI behavior through external rules rather than relying on internal model optimization.

    The philosophical basis for this approach is that a model’s “capability ceiling” and “behavior floor” are two independent dimensions. A model with slightly weaker capability but controlled behavior may be far more valuable in real engineering scenarios than a powerful model with uncontrolled behavior.

    Commandment 1: Think First, Code Second—A Forced Clarification Mechanism

    The first rule requires AI to complete three steps before writing any code: state its understanding of the requirement, list implicit assumptions, and raise questions that need clarification.

    This mirrors the standard reaction of a senior developer when receiving a vague requirement. For example, when a user says “optimize the loading speed of this page,” the AI should first respond:

    1. Understanding confirmation:
    2. You want to reduce the page's first-load time. Target scenario: ____.
    3. Assumptions:
    4. - The current performance bottleneck may be network requests, asset size, or rendering logic
    5. - Optimization should not affect the correctness of existing features
    6. Clarifications needed:
    7. 1. Is the target load time a specific value (e.g., under 3 seconds) or a relative improvement?
    8. 2. Are changes to asset loading strategy allowed (e.g., lazy loading, preloading)?
    9. 3. Are there any third-party dependencies that must be retained?

    The value of this “forced clarification” mechanism is that it moves the cost of requirement misinterpretation earlier—finding problems before writing code costs far less than reworking after the code is written. At the same time, the clarification process itself is a requirements review that helps users discover boundary conditions they were not aware of.

    Commandment 2: Simplicity First—A Hard Constraint Against Over-Engineering

    The second rule is that “if a simple solution works, no complex solution may be introduced.” Specifically: if an if-else statement works, do not introduce the strategy pattern; if changing one line of code works, do not refactor the entire file; if calling an existing function works, do not create a new utility class.

    The core of this rule is establishing a “minimal change” principle. AI must explicitly answer before making changes: “What is the minimal set of changes for this task?” Any change beyond the minimal set requires an explicit justification.

    A typical implementation is to require AI to provide a “change list” along with the code output:

    1. Scope of this change:
    2. 1. src/components/Button.tsx: change background color to #1890ff
    3. 2. No other file changes
    4. "Incidental improvements" not adopted:
    5. - Splitting the Button component into a generic base component (reason: beyond the current requirement scope)
    6. - Updating related documentation (reason: not requested by the user)

    This transparent approach both constrains the AI’s behavior boundaries and allows users to quickly judge whether the changes match expectations.

    Commandment 3: Stay Focused on the Problem—Preventing Attention Drift

    The third rule requires AI to stay centered on the current task and not be drawn to other “improvable points” in the code.

    In practice, common attention drift in AI includes: seeing a piece of old code that could be optimized and starting to refactor it; noticing a potential edge case and adding defensive checks; observing non-standard naming and batch-renaming. Each of these behaviors is a “good thing” in isolation, but in the context of the current task, they are distractions.

    The code of conduct requires AI to develop “task boundary awareness”: what the current task is, and what does not belong to the current task—the two must be clearly distinguished.

    Commandment 4: Verifiable Delivery—A Closed-Loop Feedback Mechanism

    The fourth rule requires AI to provide verifiable deliverables after completing a task, not just code snippets.

    Verifiable deliverables include: clear test cases (proving functional correctness), change descriptions (helping code review), and rollback plans (addressing unexpected issues). This ensures the AI’s output is not a “black box,” but a transparent process that humans can review, verify, and control.

    Putting Behavior Engineering into Practice

    Turning the code of conduct from a document into actual productivity requires supporting process design and tooling.

    At the IDE/Editor Level

    Modern intelligent coding tools already support custom system prompts. Developers can embed the code of conduct directly into tool configuration so it takes effect automatically in every interaction. For example, in the intelligent coding assistance solution offered by Baidu AI Cloud, enterprises can maintain a unified “team coding standard” to align AI behavior with team standards.

    At the CI/CD Level

    The effectiveness of the code of conduct can be verified through automated pipelines. For example: detect whether AI-generated code introduces undeclared dependencies; check whether the change scope exceeds expectations; run test cases to verify functional correctness. These checks run before code is merged, forming the “last line of defense” for behavior constraints.

    At the Team Collaboration Level

    For enterprise teams, the value of the code of conduct is not only in constraining AI, but in unifying human-AI collaboration standards. When all members use the same code-of-conduct configuration for AI, the style, scope, and quality of AI output become consistent, reducing friction in team collaboration.

    From Behavior Engineering to Intelligent Collaboration

    The popularity of the “Four Commandments of AI Coding” marks a new stage in the developer community’s understanding of AI coding: a shift from “worshipping model capability” to “designing collaboration processes.”

    The deeper logic of this shift is that AI is not a “super developer” that replaces humans, but a “smart intern” that needs to be managed. No matter how capable an intern is, they need clear work boundaries, clear delivery standards, and timely process feedback. The essence of behavior engineering is to establish this “management mechanism” for AI.

    Looking ahead, behavior engineering may evolve in the following directions:

    Structured behavior constraints: Evolving from natural-language behavior rules to structured rules that tools can parse (such as JSON Schema or a DSL), enabling automated verification.

    Scenario-based behavior templates: Preset behavior rule templates for different task types (bug fixes, new feature development, refactoring, code review) that developers can select as needed.

    Behavior feedback loops: Continuously optimizing behavior rules by monitoring the subsequent performance of AI-generated code (bug rate, rework rate, review pass rate), forming a data-driven improvement cycle.

    Conclusion: Constraints Are for Better Freedom

    Behind the 100K stars is a rational return by developers to AI coding. We no longer expect an “omnipotent AI” to solve all problems. Instead, we are beginning to think about how to use rule design to let AI deliver value on the right track.

    The core insight of the “Four Commandments of AI Coding” is that constraints are not limitations, but guidance. Clear boundaries mean AI does not have to guess intent, explicit standards mean AI does not have to over-deliver, and verifiable delivery means every AI output can be trusted.

    When behavior engineering becomes the standard configuration for AI coding, what we welcome is not an AI that replaces humans, but an intelligent collaboration partner that can truly be harnessed. This may be the real sign that “AI coding” is maturing.