Claude Code CommandSvelte14 installs

Svelte Optimize

Install with the Claude Code Templates CLI
$ npx claude-code-templates@latest --command="svelte/svelte-optimize" --yes

Requires Claude Code. The command adds this command to your project's .claudedirectory — nothing runs on ToolZip's servers.

What's inside this command

Component source

/svelte:optimize

Optimize Svelte/SvelteKit applications for performance, including bundle size reduction, rendering optimization, and loading performance.

Instructions

You are acting as the Svelte Development Agent focused on performance optimization. When optimizing:

  • Performance Analysis:
- Analyze bundle size with rollup-plugin-visualizer

- Profile component rendering

- Measure Core Web Vitals

- Identify performance bottlenecks

- Check network waterfall

  • Bundle Optimization:

Code Splitting:

// Dynamic imports
   const HeavyComponent = await import('./HeavyComponent.svelte');
   
   // Route-based splitting
   export const prerender = false;
   export const ssr = true;

Tree Shaking:

- Remove unused imports

- Optimize library imports

- Use production builds

- Eliminate dead code

  • Rendering Optimization:

Reactive Performance:

// Use $state.raw for large objects
   let data = $state.raw(largeDataset);
   
   // Optimize derived computations
   let filtered = $derived.lazy(() => 
     expensiveFilter(data)
   );

Component Optimization:

- Minimize re-renders

- Use keyed each blocks

- Implement virtual scrolling

- Lazy load components

  • Loading Performance:
- Implement preloading strategies

- Optimize images (lazy loading, WebP)

- Use resource hints (preconnect, prefetch)

- Enable HTTP/2 push

- Implement service workers

  • SvelteKit Optimizations:
// Prerender static pages
   export const prerender = true;
   
   // Optimize data loading
   export async function load({ fetch, setHeaders }) {
     setHeaders({
       'cache-control': 'public, max-age=3600'
     });
     
     return {
       data: await fetch('/api/data')
     };
   }

  • Optimization Checklist:
- [ ] Enable compression (gzip/brotli)

- [ ] Optimize fonts (subsetting, preload)

- [ ] Minimize CSS (PurgeCSS/Tailwind)

- [ ] Enable CDN/edge caching

- [ ] Implement critical CSS

- [ ] Optimize third-party scripts

- [ ] Use WebAssembly for heavy computation

Example Usage

User: "My SvelteKit app is loading slowly, optimize it"

Assistant will:

  • Run performance analysis
  • Identify largest bundle chunks
  • Implement code splitting
  • Optimize images and assets
  • Add preloading for critical resources
  • Configure caching headers
  • Implement lazy loading
  • Optimize server-side rendering
  • Provide performance metrics comparison
Type
Command
Category
Svelte
Installs
14
Source
GitHub ↗

Related Claude Code Commands

Catalog data and component content are sourced from the open-source davila7/claude-code-templates project (MIT license). ToolZip curates the listing and writes original descriptions; every component links back to its original source. Claude Code is a product of Anthropic. ToolZip is an independent catalog and is not affiliated with or endorsed by Anthropic.