Skip to content
Skills Library
Programming · Building & coding

code-style

/code-style

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.

Licence
MIT
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
2
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • SKILL.md zawiera komentarze HTML (2). Nie widać ich w podglądzie Markdown, a model je czyta.

What it does and when to use it

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.

Original author description

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.

How it works

  1. Brace Style
  2. HTML Data Attributes
  3. Markup and Locale
  4. Variable Naming
  5. Function Naming
  6. TypeScript
  7. CSS Nesting
  8. Related Skills
Original SKILL.md headings · 137 lines, 757 words
SKILL.md preview
---
name: code-style
description: "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."
user-invocable: true
---

# 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:

```js
// 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.

```html
<!-- 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.

```ts
// 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.

```css
/* 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.

Versions

RepositoryScoreLicence
This page · fubits1/svelte-skills100MIT
automattic/wordpress-activitypub100MIT
bastidood/skills100MPL-2.0
microsoft/semantic-link-labs100MIT
Casper-Studios/casper-marketplace100MPL-2.0
avsm/ocaml-claude-marketplace100ISC
railtownai/railtracks96MIT
LemurDaniel/claude-code-storyline-style95MIT

Database snapshot: 13.11.2026 · package version 08dd8bb55cc4 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90code-style-css
    Use when editing CSS, SCSS, or style blocks in .svelte files. Covers CSS-specific code style rules. Auto-invoke when writing or modifying styles.
  • 100python-code-style
    Python code style, linting, formatting, naming conventions, and documentation standards. Use when writing new code, reviewing style, configuring linters, writing docstrings, or establishing project standards.
  • 100rs-style
    Use when asking about Rust code style or best practices. Keywords: naming, formatting, comment, clippy, rustfmt, lint, code style, best practice, P.NAM, G.FMT, code review, naming convention, variable naming, function naming, type naming
  • 100google-cpp-style
    Google C++ Style Guide rules for writing clean, maintainable C++ code. Use when writing C++, reviewing code, discussing naming conventions, formatting, class design, or any C++ best practices. Covers headers, scoping, classes, functions, naming, comments, and formatting.
  • 95yapyak-css
    CSS: `[Role]ElementType` class naming, DOM-mirrored nesting, design tokens, cascade, units, layout. Use when editing `*.css` files or component styles.
  • 100go-style-core
    Use when working with Go formatting, line length, nesting, naked returns, semicolons, or core style principles. Also use when a style question isn't covered by a more specific skill, even if the user doesn't reference a specific style rule. Does not cover domain-specific…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.