Index of every page on this site: llms.txt
All skills
fubits1 avatar

/code-style

@a024d57
by Iljafubits1/svelte-skills11 stars
2
Run it yourself

Code style rules for all languages: variable naming, brace style, HTML data attributes, markup, forms and locale formatting, CSS nesting. Auto-invoke when editing code files, writing new functions or markup, or naming variables.

Use this Skill: https://skilld.dev/gh/fubits1/svelte-skills/code-style

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈60 tokens for metadata: the name and description. ≈1.3k when used: this file.

Description uses 3.0% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈241 characters, or 3.0%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Code Style

REQUIRED SUB-SKILLS:

  • When Svelte is involved (.svelte, .svelte.ts, .svelte.js), invoke svelte-5:code-style-svelte. If the svelte-5 plugin isn't installed, stop and ask the user to install it.
  • When CSS is involved (CSS or SCSS files, <style> blocks, inline style attributes, style: directives), invoke frontend:code-style-css.

Brace Style

Single-line if without braces is OK only when the entire statement fits on one line:

// OK — fits on one line. But then we need an empty line after the statement, except there is another if, then we need an empty line after the last if.
if (x) doThing();

//OK
if (x) doThing();
if (y) doThingY();
if (z) doThingZ();

let x = 1

//NOT OK
if (x) doThing();
let x = 1

// NOT OK — body wraps to the next line, needs braces
if (x)
  doThing();

// Correct
if (x) {
  doThing();
}

HTML Data Attributes

Always use key-value syntax. Never use bare/boolean data attributes.

<!-- BAD -->
<div data-active></div>

<!-- GOOD -->
<div data-active="true"></div>

Markup and Locale

  • A native <button> activates on Enter and Space, an <a href> on Enter only. Use <button> for actions and <a href> for navigation to a real URL; only a non-semantic element with a role needs its own key handler.
  • Give inputs a meaningful name, the matching type (email, tel, url, number) and inputmode, and turn off spellcheck on emails, codes and usernames (spellcheck="false").
  • Give every field that collects information about the user its autocomplete token (name, email, tel, street-address, one-time-code), which WCAG 1.3.5 requires. Use autocomplete="off" only on a field that must never be autofilled.
  • Wrap a checkbox or radio and its text in one <label>, so the whole row is a single hit target with no dead zone.
  • Keep a submit button enabled until the request starts, then show a spinner while it runs.
  • Warn before the user leaves with unsaved changes: beforeunload on plain pages, beforeNavigate on SvelteKit (svelte-5:code-style-svelte).
  • Never disable zoom with user-scalable=no or maximum-scale=1. Match <meta name="theme-color"> to the page background.
  • During a drag, put inert on the content that isn't a drop target, not on the dragged element (text selection: frontend:code-style-css).
  • Format dates, times, numbers and currency with Intl.DateTimeFormat and Intl.NumberFormat. Detect the language from Accept-Language or navigator.languages, not the IP. Mark brand names, code and identifiers with translate="no".

Variable Naming

Use semantic, human-readable names. The name should say what the thing IS, not save keystrokes.

Don't Do
ctx context
c, cb callback
obj object or something more specific
val value
tmp temporary or something more specific
res result or response
el element

Exceptions: Loop variables (i, j) and lambda params where meaning is obvious from context ((item) => item.id) are fine.

Function Naming

Functions are verbs. Past-participle nouns (mountedPopup) lie about lifecycle, wrong for a factory that mounts lazily. Use createComponentPopup.

Conventions: createX/buildX (factory), getX (sync read), loadX/fetchX (async), isX/hasX (predicate), toX (transform), attachX/detachX (lifecycle), onX/handleX (event).

One word, not two: toggle already means open-if-closed/close-if-open. Don't write toggleOrShow. Same for closeAndReset, getOrCreate.

Plural follows the work: if a function grows to handle N where it handled 1, rename. detachPopup that now detaches info + context popups is detachPopups.

TypeScript

type over interface

Use type for object shapes. Never use interface unless extending a third-party interface.

// BAD
interface Milestone {
  date: string
  label: string
}

// GOOD
type Milestone = {
  date: string
  label: string
}

Private members in classes

Private class members (fields and methods) should be prefixed with #, never private. # is enforced at runtime; private is compile-time only.

CSS Nesting

Always nest CSS with &. Never write flat selectors as separate rules.

/* BAD — flat selectors */
.parent .child { ... }
.parent:hover { ... }

/* GOOD — nested with & */
.parent {
  & .child { ... }
  &:hover { ... }
  &[data-active="true"] { ... }
}

This applies to all CSS, component styles, global stylesheets, everywhere. For the full nesting workflow (specificity analysis, block ordering, stylelint compliance), use frontend:css-nesting.

Related Skills

  • frontend:editing: File editing discipline, refactoring safety.
  • frontend:comments: Which comments survive, comment format, protected comments.
  • svelte-5:code-style-svelte: Svelte-specific style rules (component docs, reactivity patterns).
  • frontend:css-nesting: Full CSS nesting workflow with specificity analysis and stylelint compliance.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides code style guidelines for multiple programming and styling languages. No security issues were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at a024d57. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated last month
user-invocable
true

README badge

README badge for fubits1/svelte-skills/code-style