Skip to content
Agentmart
Submit a tool

lit

Rules and patterns for writing Lit Web Components correctly in this project.

Skill by IgorAIvanov

IndexedMIT★ 1
Write a review

Chalk Labs

Need help deploying lit?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/igoraivanov-lit

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Rules and patterns for writing Lit Web Components correctly in this project. Trigger this skill whenever writing or editing any Lit component (.ts files with @customElement, @property, LitElement, html``, css``), when adding new properties to existing components, or when debugging why an attribute isn't working from HTML. Always use this skill before writing any @property decorator — getting the attribute name wrong is a silent bug that's very hard to trace.

Use cases: frontend, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/lit

What's inside

Skill name
lit
Description
Rules and patterns for writing Lit Web Components correctly in this project. Trigger this skill whenever writing or editing any Lit component (.ts files with @customElement, @property, LitElement, html``, css``), when adding new properties to existing components, or when debugging why an attribute isn't working from HTML. Always use this skill before writing any @property decorator — getting the attribute name wrong is a silent bug that's very hard to trace.
License
MIT
Metadata
audience: app
Instructions
169 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Lit Web Components — правила цього проекту

## Критичне правило: атрибути camelCase → kebab-case

**Проблема:** Lit за замовчуванням перетворює camelCase назви властивостей на lowercase без дефісів:
- `showClear` → атрибут `showclear` (НЕ `show-clear`)
- `displayField` → атрибут `displayfield` (НЕ `display-field`)
- `listSize` → атрибут `listsize` (НЕ `list-size`)

Це мовчазна помилка — компонент просто ігнорує атрибут, без попереджень.

**Рішення:** Для будь-якої camelCase властивості завжди вказувати `attribute` явно:

```ts
// Правильно
@property({ type: String, attribute: "label-position" }) labelPosition: "top" | "left" = "top";
@property({ type: Boolean, attribute: "show-clear" }) showClear = false;
@property({ type: Number, attribute: "list-size" }) listSize = 10;
@property({ type: String, attribute: "display-field" }) displayField = "name";
@property({ type: String, attribute: "id-field" }) idField = "id";
@property({ type: Object, attribute: "picker-params" }) pickerParams = {};
@property({ type: Object, attribute: "fetch-params" }) fetchParams = {};

// Однословні — attribute не потрібний (lowercase вже збігається)
@property({ type: String }) label = "";
@property({ type: String }) placeholder = "";
@property({ type: Boolean }) disabled = false;
@property({ type: String }) url = "";
@property({ type: String }) width = "";
@property({ type: Boolean }) visible = true;
```

**Правило:** якщо назва властивості містить велику літеру — обов'язково додай `attribute: "kebab-case-name"`.

## Boolean атрибути в Lit-шаблонах

Для boolean властивостей використовувати `?` прив'язку:

```ts
// Правильно
html`<ui-picker ?show-clear=${this.readonly}></ui-picker>`
html`<button ?disabled=${!this.canSave}>Зберегти</button>`

// Неправильно — передає рядок "show-clear", не true/false
html`<ui-picker show-clear></ui-picker>`
```

Виняток: статичний boolean атрибут без виразу (завжди true) — можна без `?`:
```ts
html`<input required>`  // OK — завжди true
```

## `<select>`: вибране позначає ПУНКТ, а не `.value` на списку

`.value=${…}` на `<select>` у шаблоні лита **не працює** — і мовчки.

```ts
// Неправильно — показує ПЕРШИЙ пункт, що б не лежало у value
html`<select .value=${this.accountType} @change=${…}>
  <option value="active">Активний</option>
  <option value="passive">Пасивний</option>
</select>`

// Правильно — вибране на самому пункті, від порядку не залежить
html`<select @change=${…}>
  <option value="active"  ?selected=${this.accountType === "active"}>Активний</option>
  <option value="passive" ?selected=${this.accountType === "passive"}>Пасивний</option>
</select>`
```

**Чому.** Лит комітить прив'язки елемента раніше, ніж додає його дітей, тож
`.value` присвоюється, коли жодного `<option>` ще немає. Браузер таке значення
відкидає — вибирати нема з чого, — а щойно пункти з'являються, стає на перший.
На наступних рендерах лит `.value` уже не чіпає: воно дорівнює тому, що він сам
поставив минулого разу. Контрол лишається на першому пункті назавжди.

**Чому це помічають пізно і не тим боком.** Помилка видна ЛИШЕ коли збережене
значення не збігається з першим пунктом, а в половини списків перший пункт —
найчастіший («20%», «покупка», «активний»). Тобто екран виглядає правильним,
доки хтось не вибере інше; а коли вибере — побачить не «показано не те», а **«не
збереглося»**: після взаємодії контрол тримає вибране, і різниця вилазить аж
після перезаходу. Шукати підуть у праві доступу, payload і SQL — усе справне.

**У власному компоненті** з програмною зміною значення (кнопка очищення,
перезавантаження запису) `?selected` мало: атрибут діє, лише доки в `<option>`
не зведено прапорець «брудності», а взаємодія його зводить. Там значення
доставляють властивістю після рендера — див. `ui-select` у ядрі:

```ts
protected override updated(changed: Map<string, unknown>) {
  super.updated?.(changed);
  const select = this.renderRoot.querySelector("select");
  if (select && select.value !== this.value) select.value = this.value;
}
```

Порядок властивостей у ВИКЛИКУ (`.options` перед `.value`) не рятує: значення
виставляє сам компонент у своєму шаблоні.

## Shadow DOM та Tailwind CSS

Компоненти, що наслідують `GlobalStyledLitElement`, отримують зібраний Tailwind через
спільний `CSSStyleSheet` (`tw` із `@client/shared/styles.ts`), який адоптується в кожен
shadow root. Аркуш порожній, доки застосунок його не заповнить — це робить
`app/styles/app-styles.ts`.  
Але Tailwind генерує тільки класи, що використовуються у файлах зі списку `@source`.

Збірка одна, і вона в застосунку: `app/styles/tailwind.css`. Бібліотека Tailwind не
компілює — вона віддає тему плоским CSS, а дописує її `setAppStyles()` сам, уже після
зібраного Tailwind: правила теми безшарові й мусять перебивати utilities, і код це
гарантує надійніше за порядок рядків.

Якщо додаєш Tailwind-класи в новий каталог — додай `@source` до `app/styles/tailwind.css`.
Шлях там реальний, не аліас і не ім'я пакета: сканер Tailwind читає директиву з диска,
повз бандлер.
```css
@source "../../vendor/jsr.io/@altera";   /* ← вже додано: класи з шаблонів ui-kit */
```
Авто-детекція сканує сам застосунок, але `vendor/` виключає — звідси цей рядок.

From IgorAIvanov/altera03, MIT.

More from IgorAIvanov/altera03

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Aug 13, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from IgorAIvanov

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get lit running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying lit?

CallGet help
Cite this page

lit skill. Agent Mart. https://agentmart.dev/skills/igoraivanov-lit (last updated 2026-10-24)