# svelte-core-bestpractices

> Claude/Codex skill by [@sveltejs](https://omgskills.com/library/sveltejs/index.md) · 334 stars · Updated 2026-10-18

Guidance on writing fast, robust, modern Svelte code. Load this skill whenever in a Svelte project and asked to write/edit or analyze a Svelte component or module. Covers reactivity, event handling, styling, integration with libraries and more.

## Install

```sh
git clone https://github.com/sveltejs/ai-tools /tmp/ai-tools && ln -s /tmp/ai-tools/tools/skills/svelte-core-bestpractices ~/.claude/skills/svelte-core-bestpractices
```

## From README

$state Only use the $state rune for variables that should be reactive — in other words, variables that cause an $effect, $derived or template expression to update. Everything else can be a normal variable. Objects and arrays ($state({...}) or $state(\[...\])) are made deeply reactive, meaning mutation will trigger updates. This has a trade-off: in exchange for fine-grained reactivity, the objects must be proxied, which has performance overhead. In cases where you're dealing with large objects that are only ever reassigned (rather than mutated), use $state.raw instead. This is often the case with API responses, for example. $derived To compute something from state, use $derived rather than $effect: \[!NOTE\] $derived is given an expression, not a function. If you need to use a function (because the expression is complex, for example) use $derived.by. Deriveds are writable — you can assign to them, just like $state, except that they will re-evaluate when their expression changes.

## Links

- HTML page: https://omgskills.com/skills/sveltejs/ai-tools/svelte-core-bestpractices/
- GitHub: https://github.com/sveltejs/ai-tools
- Author: [@sveltejs](https://omgskills.com/library/sveltejs/index.md)

## More from this repo

- [svelte-code-writer](https://omgskills.com/skills/sveltejs/ai-tools/svelte-code-writer/index.md) — CLI tools for Svelte 5 documentation lookup and code analysis.
   - [@sveltejs](https://omgskills.com/library/sveltejs/index.md) · 334 stars

## More skills by this author

- [performance-investigation](https://omgskills.com/skills/sveltejs/svelte/performance-investigation/index.md) — Investigate performance regressions and find opportunities for optimization
   - [@sveltejs](https://omgskills.com/library/sveltejs/index.md) · 88k stars
