← ClaudeAtlas

ai-coding-disciplinelisted

Mandatory coding discipline rules that prevent common AI coding anti-patterns. MUST be loaded for ALL code writing, editing, reviewing, bug fixing, and testing tasks. Trigger on: writing code, editing code, fixing bugs, writing tests, implementing features, refactoring, code review, creating functions, adding error handling, debugging. This skill enforces fail-fast principles, proper error propagation, meaningful tests, and disciplined debugging workflows. Always active when Claude writes or modifies code.
satbirbhbc-ux/ai-coding-principles · ★ 1 · AI & Automation · score 74
Install: claude install-skill satbirbhbc-ux/ai-coding-principles
# AI Coding Discipline > These rules override default AI coding tendencies. Follow them in ALL code you write or modify. --- ## Rule 1: No Silent Fallbacks **Never use fallback values to mask data that should not be missing.** ```typescript // FORBIDDEN — hides upstream bugs const price = product?.price ?? 0; const userName = user?.name || "Unknown"; // CORRECT — fail fast when data contract is violated if (product.price == null) { throw new Error(`Product ${product.id} is missing price`); } const price = product.price; ``` **When fallbacks ARE acceptable:** - User-facing display with explicit design intent (e.g., avatar placeholder) - Optional configuration with documented defaults - External input parsing where absence is a valid state **Checklist before writing `??`, `||`, or `?.`:** 1. Can this value legitimately be null/undefined at this point? 2. If it is null, will the fallback produce a correct result downstream? 3. Would a thrown error help me find a bug faster? If the answer to #3 is yes, throw instead of falling back. --- ## Rule 2: No Catch-All try/catch in Business Logic **Business logic functions must NOT wrap everything in try/catch. Let errors propagate naturally.** ```typescript // FORBIDDEN — swallows all errors into a useless null async function createOrder(data: OrderInput) { try { const user = await getUser(data.userId); const coupon = await validateCoupon(data.couponCode); const order = await saveOrder({ ...data, discount: co