/swcode-base:swcode-basefrom swcode-base
The user's coding rules, with a check of your own diff before you deliver. Load before writing, editing, refactoring, reviewing or exploring code in any project or language, and keep applying it to every later code change in the session. Covers reading before writing, named constants, SOLID applied without speculative abstraction, frontend business rules kept in services apart from atomic components, guard clauses and exhaustive mappers instead of if/else and switch, function size limits, error handling, TypeScript types in a types/ directory, the mistakes coding agents tend to make, and verification. Run its self-check on your own after writing or changing code, before presenting or committing; don't wait to be asked. Also keeps the project's AGENTS.md, the notes every session starts from, without being asked, going by them before exploring, creating them when the project has none and adding what each task found out, so the next session does not find it all out again. Not for conceptual questions, git workflow, CI configuration, prose or data analysis.
Ships in swcode-base. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
These are the user's rules for code. Follow them while writing, then check your own diff against them before you show it. Once loaded, they apply to every later code change in the session, not only the first one.
The design comes from SOLID, applied to the code that exists today. The rest exists because coding agents tend to write more than the task needs: extra guards, extra options, extra layers, extra comments. When in doubt, ask whether the task needs this line today. If not, leave it out.
Code examples in the references declare types inline to stay short; in real code they live in types/ (rule 25).
CLAUDE.md, AGENTS.md), and the conventions written in its README or CONTRIBUTING.services/ folder), follow the codebase and mention the difference. Never mix two styles in one codebase.Each rule has a short name. Use the name, not the number, when you mention a rule in code or in a review.
data, result, item, value, info, temp, obj, helper, manager and utils need a qualifier (parsedInvoice, rawCsv), and so do handle…, process… and do… when a vague word follows (processData, handleItem).<name>.constants.ts file next to its module, or in src/shared.constants.ts when several modules share it. Name constants after their module (BUTTON_EVENT, not EVENT). CSS class names stay plain strings. When two languages need the same value (a field name in the form and in the PHP handler), keep one source both read, or a test that fails when they drift; never comments alone. What may stay literal, and how to name lookups and lists: references/constants.md.Each principle fixes a problem the code has today; none is a reason to build structure in advance. Reasons and examples: references/solid.md.
is…/has… predicates never change state.Pick<Workflow, 'id' | 'name'>), and expose only what callers need. Split an interface whose users each use a different part of it.locale parameter beside i18n.locale). Dependencies point toward the rules, never back. An effectful helper does one operation and returns a structured result; its caller coordinates.…Mode parameter without a caller today. Settings that change per deployment (a sender address, a server path, a key) belong in configuration and aren't speculative. SOLID alone never justifies an abstraction.The UI must be able to change without touching a business rule, and the rules must be testable without a DOM. The split is what matters, not the folder names: follow the project's folders. Layers, examples and tests: references/frontend.md.
services/, with pure calculations in lib/. Every server call goes through one gateway module: services/api.ts in an app; a site with a single call keeps it in one module. A service never imports a component or reaches into the DOM; app-wide UI it needs (a toast, a confirm dialog, navigation) goes through a function.if is for guard clauses. Use if to return or throw early on invalid input, errors and exceptional cases, and never write else. Choose a value with a simple ternary, an exhaustive mapper, or a named predicate or function, never with an if that assigns. A side effect that depends on a condition is a ternary when there are two branches (open ? show() : hide()); a lone side effect, with nothing to do otherwise, may sit in a single if. Never nest ternaries: needing more branches means the function does too much, so split it.switch. Case-based logic uses a typed map, const icons: Record<OrderStatus, IconName> = {…}, so adding a case to the type fails to compile until the map handles it.render(invoice, true)) becomes two functions; a boolean that is the value being set (setBusy(busy), toggle(force)) is fine. Aim for 20 lines per function and split above 40; the markup of a JSX template doesn't count, the logic around it does. Extract any loop or callback nested more than two levels deep.const. When a value would be assigned across a try or several branches, extract a function that returns it, or returns a Result. Don't keep a mutable variable only to carry context between branches (a currentPath for error messages): pass the context in, or return it with the result.Reasons and examples for rule 8 and group E: references/functions.md.
catch that returns undefined or a default, ?? '' on a call whose undefined means it failed, PHP's (string) on a function that returns false. Record that something happened only after it did: a message counts as sent once the mail went out, not before. A deliberate fallback is fine when the function's doc comment says so and nothing is lost.typeof checks for cases the types already rule out.any, no casts on outside data. Use unknown only at boundaries and narrow it with a type guard or validator. Never as Foo on outside data; as const and satisfies are fine.interface for object shapes and type for unions and intersections; undefined for absent values, not null, unless an outside contract requires null.types/. Code files hold only code. Every named interface and type goes in a flat types/ directory, in a file named after its code file (form.service.ts → types/form.service.types.ts). Zod schemas, and types derived from a runtime value, stay beside that value. A short anonymous type used once inline (in satisfies or a generic argument) may stay; name it in types/ once it's reused or grows past a line. Which types/ directory and how to name shared types: references/types.md.lib/ functions directly, services with a fake gateway. For ranges and counts, list the edge cases (empty, one, many, exactly at the limit, just past it) and give each one a test, not a comment.Rules 2, 13, 22 and 27 remove code. These stay, whatever a simplification suggests. Removing one changes behaviour, so keep it or ask. In a review, a removed or missing floor item is filed as Floor: <name>.
When a rule is wrong for a specific case, keep the code and add a comment that names the rule, the reason, and when to look at it again:
// style exception: size limits — mirrors the payment API's 6 required fields; revisit if we wrap that API.
On a later pass, a comment like this means the case is settled: don't flag it again. A style exception comment with no "revisit" condition is itself a finding.
Walk your diff once before you show it. Fix every "no", or say why it stays, then re-check only the lines you changed. Two passes at most: whatever is left after that goes in the report as flagged.
lib/, do atoms and molecules take data in and send events out, and does no component use a higher layer?if a guard clause or a lone side effect, with no else, no switch, no nested ternary, and new cases added as mapper entries?catch or fallback value that hides it, and is success recorded only after it happened? Is outside data validated where it enters, with no checks inside for cases the types rule out?any, no cast on outside data, no null without an outside contract, and is every named type in types/?Then report the pass, so the user can see it ran. List each fix as <file>:<line> — <what changed> (leave out the line if it isn't stable), and each thing you noticed but didn't change as flagged: <file> — <what and why>. End with one line:
coding-style: 3 fixed, 1 flagged
or coding-style: clean when nothing came up. Count only what you actually did; never give a quality score or a percentage. Flagged means not fixed: anything outside the request is flagged, never changed.
The task is done when the request is met, the checks have run and the report is written. Then stop: the report is the last thing you do.
flagged: line. Don't fix it.references/agent-mistakes.md (opens in a new tab)references/constants.md (opens in a new tab)references/frontend.md (opens in a new tab)references/functions.md (opens in a new tab)references/other-languages.md (opens in a new tab)references/project-notes.md (opens in a new tab)references/review.md (opens in a new tab)references/solid.md (opens in a new tab)references/types.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub bioleyl/swcode --plugin swcode-base