AI 默认使用其训练数据的通用平均值,因此要获得您的风格,您必须通过示例、明确的规则文件和 linter 循环来展示和强制执行它 — linter 循环可以捕捉漏掉的东西。不要指望它猜测您的标准(WordPress Coding Standards、PSR-12 等)。
AI 默认使用其训练数据的通用平均值,因此要获得您的风格,您必须通过示例、明确的规则文件和 linter 循环来展示和强制执行它 — linter 循环可以捕捉漏掉的东西。不要指望它猜测您的标准(WordPress Coding Standards、PSR-12 等)。
.eslintrc、phpcs.xml 或 .editorconfig。这些规则是机器可检查的形式,AI 可以读取它们。CLAUDE.md 或系统提示,明确说明标准:"此项目遵循 PSR-12。使用 4 个空格缩进,函数的大括号放在下一行,hooks 使用 snake_case。" 常设说明比每次提示中重复自己更有效。# 1. AI generates the change, then you run the project linter on it:
phpcs --standard=phpcs.xml src/NewClass.php
# => src/NewClass.php 12 | ERROR | Expected 1 space after FUNCTION keyword; 0 found
# src/NewClass.php 14 | ERROR | Line indented incorrectly; expected 4 spaces, found 2
# 2. Paste those exact errors back to the AI: "Fix these phpcs errors."
# 3. Re-run until clean. The linter — not the AI's claim — is the source of truth.
这个循环收敛很快,因为 linter 提供精确的行级反馈,AI 可以直接作用,而不是您用散文描述风格。
忽视项目规范的代码即使在功能上正确也会造成审查摩擦和不一致 — 审查者浪费时间在格式上,代码库也会漂移。AI 在您提供规范之前对您的风格没有任何认识,因此工作是使规则明确和可检查:用规则文件表达意图,用代表性代码表达习语,用 linter 作为循环中的执行者。相同的纪律(配置 + 示例 + 自动化检查)也是您如何让人类队友适应您的规范的方式。