svelte5-inspect
暂无简介
- License 许可
- MIT
- 所属仓库
- dibstern/conduit
- 最近更新
- 2026-10-29
- Stars
- ★ 15
- Forks
- 2
03 SKILL.md 正文
Svelte 5: Debugging with $inspect()
The Svelte DevTools browser extension does NOT support Svelte 5. Do not recommend installing it.
$inspect(...values)
Built-in Svelte 5 rune that logs reactive values to the console whenever they change. Dev-mode only — automatically stripped from production builds.
<script>
let count = $state(0);
let user = $state({ name: 'Alice' });
$inspect(count); // logs: "init" 0, then "update" 1, 2...
$inspect(user); // deep-tracks object mutations
$inspect(count, user); // multiple values in one call
</script>
Custom handling with .with()
Replace the default console.log with any callback:
$inspect(count).with((type, ...values) => {
// type is "init" or "update"
if (type === 'update') debugger; // break on change
});
Common patterns:
$inspect(val).with(() => { debugger })— breakpoint on any change$inspect(val).with(console.trace)— log with stack trace
Rules
- Only works inside reactive contexts (component
<script>,$effect,$derived) - Only runs in dev mode — zero cost in production
- Tracks deeply: mutating a property on a
$stateobject triggers it - Cannot be used in
.tsfiles — Svelte compiler rune only
When to ask the developer to add $inspect()
You can read every .svelte file, but you cannot see runtime state. When the bug lives in the gap between what the code says and what actually happens in the browser, ask the developer to add $inspect() and report back what the console shows.
Ask when:
- Reactive chain not propagating — you see
$derived→$effect→ render but the UI isn't updating.$inspect()pinpoints which link in the chain breaks. - Stale or unexpected values — a
$statevariable should be X but the UI shows Y. Static analysis can't distinguish timing issues, overwrites from elsewhere, or deep reactivity misses. - Component receiving wrong props — you suspect the parent passes stale data but can't prove it without runtime evidence.
- Effect firing too often or not at all —
$effectdependencies are implicit in Svelte 5, so you can't always predict the trigger pattern from code alone. - After your first fix attempt didn't work — if you patched the code and the user says it's still broken, don't guess again. Ask for
$inspect()output to get evidence.
How to ask:
Be specific. Don't say "add some inspect calls." Say exactly what to inspect and where:
Add
$inspect(messages, isLoading)insideChatPanel.svelteand tell me what the console shows when you send a message.
This gives you the runtime evidence to diagnose instead of guess.
04 同仓库更多 Skills
release-notes
Drafts release notes. Fixture skill for conduit's recorded skill-loads-turn trace.
changelog-style
House style for changelog entries. Fixture skill for conduit's recorded skill-loads-turn trace.
typescript-advanced-types
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.
sveltekit-svelte5-tailwind-skill
Comprehensive integration skill for building sites with SvelteKit 2, Svelte 5, and Tailwind CSS v4
playwright-cli
Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
modern-javascript-patterns
Master ES6+ features including async/await, destructuring, spread operators, arrow functions, promises, modules, iterators, generators, and functional programming patterns for writing clean, efficient JavaScript code. Use when refactoring legacy code, implementing modern patterns, or optimizing JavaScript applications.