plugins/svelte-skills/skills/svelte-template-directives/SKILL.md
Svelte template directives ({@attach}, {@html}, {@render}, {@const}, {@debug}). Use for DOM manipulation, third-party libs, tooltips, canvas, dynamic HTML. @attach replaces use: actions.
npx skillsauth add spences10/svelte-skills-kit svelte-template-directivesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The reactive alternative to use: actions. Re-runs when dependencies
change, passes through components via spread, supports cleanup functions.
<script>
import ImageZoom from 'js-image-zoom';
function useZoom(options) {
return (element) => {
new ImageZoom(element, options);
return () => console.log('cleanup');
};
}
</script>
<!-- Re-runs if options changes (use: wouldn't!) -->
<figure {@attach useZoom({ width: 400 })}>
<img src="photo.jpg" alt="zoomable" />
</figure>
| Directive | Purpose | Reactive? |
| ---------------- | ------------------------------ | --------- |
| {@attach} | DOM manipulation, 3rd-party | Yes |
| {@html} | Render raw HTML strings | Yes |
| {@render} | Render snippets | Yes |
| {@const} | Local constants in blocks | N/A |
| {@debug} | Pause debugger on value change | N/A |
| {#each (key)} | Keyed iteration (always key!) | Yes |
| <svelte:window> | Window event listeners | N/A |
| Feature | use: | @attach |
| --------------------- | ------- | ------------------- |
| Re-runs on arg change | No | Yes |
| Composable | Limited | Fully |
| Pass through props | Manual | Auto via spread |
| Convert legacy | N/A | fromAction() |
@attach requires Svelte 5.29+fromAction from svelte/attachments to convert legacy actions<svelte:window>/<svelte:document> for global events, not $effecttools
SvelteKit structure guidance. Use for routing, layouts, error handling, SSR, or svelte:boundary. Covers file naming, nested layouts, error boundaries, pending UI, and hydration.
databases
SvelteKit remote functions guidance. Use for query(), form(), command(), and prerender() patterns in .remote.ts files.
tools
SvelteKit data flow guidance. Use for load functions, form actions, server/client data, and invalidation. Covers +page.server.ts vs +page.ts, serialization, fail(), redirect(), error(), invalidateAll().
development
Svelte CSS styling patterns. Use for scoped styles, CSS custom properties, style: directive, :global, or styling child components.