core/capabilities/execution/coding-principles/SKILL.md
Use during implementation — loaded by build-loop before each task — whenever code is being written and should hold to universal quality standards, regardless of language or stack. Active while writing, not a post-hoc review checklist.
npx skillsauth add xoai/sage coding-principlesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Seven universal principles for writing production-quality code. Apply these to every line, in every language. They are not a post-hoc checklist — they shape decisions AS you write.
Stack skills (react, flutter, nextjs, etc.) add language-specific idioms on top. These principles are the foundation.
Write code a stranger can read without asking you what it does.
Do:
fetchActiveUsers(), isExpired,
MAX_RETRY_ATTEMPTSif (user.role === "admin") not
if (checkAccess(user, 2)).Don't:
if (retries > 3) → if (retries > MAX_RETRIES)data, temp, flag2, processStuff, handleIt.Every external call can fail. Handle it explicitly. Never swallow errors. Give the caller something useful when things go wrong.
Do:
fetch, query, read, parse has error handling.Don't:
console.log(err) as the only error handling.Validate at every entry point. Don't trust input from users, APIs, files, or even your own internal modules.
Do:
response?.data?.user?.id not response.data.user.id.Don't:
Variables close to where they're used. Functions close to what calls them. Reduce the blast radius of every change.
Do:
Don't:
Design APIs and interfaces so correct usage is obvious and misuse requires effort.
Do:
Don't:
null to mean both "failed" and "empty."any or untyped dictionaries for structured data.Match the existing codebase. Consistency across the project matters more than your personal preference.
Do:
camelCase, use camelCase.Don't:
Write tests that catch bugs, not tests that inflate coverage numbers.
Do:
test_expired_token_returns_401.Don't:
test_1, test_auth_3, test_new.Build-loop loads this capability at Step 3, before each task:
Sage: Loading coding principles for implementation.
Following: clarity, error handling, boundary guards, minimal scope,
safe APIs, consistency, behavior testing.
These principles are active for every line written during the task. They are NOT a post-hoc checklist — they shape the code as it's written.
The announcement Loading coding principles for implementation. is the
compliance marker: it MUST appear before each task's implementation, making the
standard active and observable rather than assumed.
Derived from the RED baseline in TESTS.md — the excuses for skipping the load
step and just coding. The marker must appear on every task, no size exception.
| The excuse (observed) | Why it's wrong | The rule | |---|---|---| | "It's a tiny change, principles don't matter." | Small changes are exactly where magic numbers and swallowed errors slip in unnoticed. | Principles load before every task — there is no size exception. | | "I know clean code by heart." | The load isn't a reminder for you; it makes the standard active and observable for the task. | Announce and apply on every task, not only when you feel you need it. | | "I'll clean it up in review." | Principles shape code as it's written; review only catches what shaping would have prevented. | They are a mindset during implementation, not a post-hoc checklist. | | "The stack skill already covers quality." | Stack idioms sit on top of the universal foundation — they don't replace it. | Both apply; principles are the foundation. |
testing
Root cause diagnosis with evidence, Reproducing test, Minimal patch
tools
Session resumption with context
tools
Configure Sage preset and project settings. Switch between base, startup, enterprise, or opensource constitution presets. Use when the user says "configure sage", "change preset", or "sage settings".
development
Brief (medium+ tasks), Spec, Implementation plan