You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03_guidelines/common/ai-coding.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,7 +164,38 @@ If AI consistently fails to follow a specific guideline:
164
164
3. Add the rule to the project's checklist template
165
165
4. If still failing, consider adding a pre-commit hook or linter rule for automated enforcement
166
166
167
-
## 5.4 Rule Suppression (Escape Hatch)
167
+
## 5.4 How to Write Effective Guidelines (Benchmark-Validated)
168
+
169
+
[Benchmark data](https://github.com/yunbow/ai-dev-os-benchmark) shows that guideline **specificity** — not quantity — determines AI compliance. Vague rules are ignored; specific rules achieve 100% compliance.
170
+
171
+
### Rules for writing rules:
172
+
173
+
| Principle | Bad (0% compliance) | Good (100% compliance) |
|**Name the exact method**| "Validate date ranges" | "MUST use `.refine()` to check `dueDate > new Date()`" |
176
+
|**Name the exact pattern**| "Use exhaustive checks" | "MUST use `default: { const _exhaustive: never = status; }`" |
177
+
|**Provide decision criteria**| "Use dynamic imports" | "SHOULD use `next/dynamic` for components with dependencies > 50KB: charts, editors, modals" |
178
+
|**Show the anti-pattern**| "Use proper naming" | "❌ `handleDelete` ✅ `handleTaskDelete` (MUST include noun)" |
179
+
|**Use MUST/SHOULD keywords**| "Consider using..." | "MUST validate on BOTH client and server using `zodResolver`" |
180
+
181
+
### What NOT to include in guidelines:
182
+
183
+
* General best practices the AI already knows (basic error handling, standard naming, RESTful API design)
184
+
* Large Before/After code sections (benchmark shows no improvement, +55% tokens wasted)
185
+
* YAML frontmatter or structured metadata (benchmark shows no improvement, +33% tokens wasted)
186
+
* Abstract principles without concrete implementation guidance
187
+
188
+
### The "generate → check → fix" workflow:
189
+
190
+
Guidelines alone produce near-zero improvement in total code quality scores. The primary quality mechanism is **post-generation verification** via `/ai-dev-os-check`:
191
+
192
+
1. Load 3-5 project-specific guideline files in CLAUDE.md (~8K tokens)
193
+
2. AI generates code
194
+
3. Run `/ai-dev-os-check` with a specific checklist
195
+
4. AI reviews its own code and fixes violations
196
+
5. This workflow scores 96.9/100 in benchmarks
197
+
198
+
## 5.5 Rule Suppression (Escape Hatch)
168
199
When a specific guideline rule is not applicable to a particular module or file, suppress it explicitly rather than ignoring it silently:
169
200
170
201
***Project-level suppression**: Add a `project-specific/` guideline that overrides the rule for specific directories or modules. The Specificity Cascade ensures project-specific rules take precedence over common rules.
0 commit comments