core/capabilities/execution/coding-principles/SKILL.md
Seven universal coding principles applied during implementation. Language-agnostic quality standards that shape every line of code as it's written. Loaded by build-loop before each task. Not a review checklist — a mindset active during implementation.
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.
development
Branch-per-initiative git discipline for all delivery workflows. Defines branch naming by workflow, the propose-confirm creation protocol, dirty-tree and detached-HEAD handling, the always user-gated merge protocol, worktree support for parallel sessions, and abandonment cleanup. Activates only in git repositories — silently inactive everywhere else. Use when starting /build, /fix, /architect, or /build-x at Standard+ scope, when resuming an initiative, when offering a merge at a completion checkpoint, or when the user wants a second concurrent initiative.
development
Drives task-by-task execution from an approved plan with quality gates between each task. Reads the plan, finds the next incomplete task, dispatches implementation, validates, updates progress, and continues. Use after a plan is approved and the user says "go", "start building", "execute the plan", or "implement the feature".
testing
Preserves and restores context across agent sessions using plan file checkboxes as source of truth. Use when starting a new session, resuming previous work, ending a session, or when the user says "continue from last time", "what was I doing", or "save progress".
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).