One file. Six principles. Drop it in your project and Claude Code stops guessing, over-engineering, and touching code it shouldn't.
Toggle between what LLMs do wrong and what should happen.
Don't assume. Don't hide confusion. Surface tradeoffs.
def export_users(format='json'):
# assumed ALL users — no pagination, no privacy check
users = User.query.all()
# assumed file path without asking
with open('users.json', 'w') as f:
# assumed which fields to include
json.dump([u.to_dict() for u in users], f)
# Problems:
# - Exports ALL users (privacy/GDPR risk)
# - Hardcoded file path
# - No pagination for large datasets
# - Assumed JSON format without asking
Minimum code that solves today's problem. Nothing speculative.
from abc import ABC, abstractmethod
from dataclasses import dataclass
class DiscountStrategy(ABC):
@abstractmethod
def calculate(self, amount: float) -> float: ...
class PercentageDiscount(DiscountStrategy):
def __init__(self, pct): self.pct = pct
def calculate(self, amount):
return amount * (self.pct / 100)
class FixedDiscount(DiscountStrategy):
def __init__(self, fixed): self.fixed = fixed
def calculate(self, amount): return min(self.fixed, amount)
@dataclass
class DiscountConfig:
strategy: DiscountStrategy
min_purchase: float = 0.0
class DiscountCalculator:
def __init__(self, config): self.config = config
def apply(self, amount):
if amount < self.config.min_purchase: return 0
return self.config.strategy.calculate(amount)
# 60+ lines for a single use case that doesn't exist yet
Touch only what the task requires. Match existing style.
def validate_user(user_data): + """Validate user data.""" # added docstring (unrequested) - if not user_data.get('email'): + email = user_data.get('email','').strip() + if not email: raise ValueError("Email required") - if '@' not in user_data['email']: + if '@' not in email or '.' not in email.split('@')[1]: # "improved" raise ValueError("Invalid email") - if not user_data.get('username'): + username = user_data.get('username','').strip() # reformatted + if not username: raise ValueError("Username required") + if len(username) < 3: # NEW RULE — nobody asked + raise ValueError("Username too short") return True
Define success criteria. Loop until verified.
# LLM response: "I'll fix the authentication system by: 1. Reviewing the code 2. Identifying issues 3. Making improvements 4. Testing the changes" # Then proceeds to make unverifiable changes. # No success criteria. # No tests written. # No way to know if it actually worked. # "Done" means nothing here.
Never patch a bug you haven't confirmed exists.
# Immediately "fixes" without confirming the bug def sort_scores(scores): return sorted( scores, key=lambda x: (-x['score'], x['name']) ) # Bug was never reproduced with a test. # No confirmation the fix actually works. # No regression check. # If this is wrong — no way to know.
Surface options before choosing. 3–5 lines, not an essay.
import redis
# Silently:
# - Installed Redis (new infra dependency)
# - Added docker-compose requirement
# - Changed production architecture
# - Never asked if Redis was even available
r = redis.Redis(host='localhost', port=6379)
def is_rate_limited(user_id: str) -> bool:
key = f"rate:{user_id}"
count = r.incr(key)
if count == 1:
r.expire(key, 60)
return count > 100