svelte-component — команда Claude Code: что делает и как установить
Команда создаёт компоненты Svelte с типизацией и тестами прямо под структуру каталогов вашего проекта.
npx claude-code-templates@latest --command svelte/svelte-componentЧто делает svelte-component
Ассистент считывает конфигурацию проекта через Read, проверяя файлы svelte.config.js и tsconfig.json. Новые файлы сохраняются в src/components/ или src/lib/. Разметка сразу получает семантические теги HTML и ARIA-атрибуты для доступности.
Шаблон формирует строгую структуру. Скрипт объявляет типизированные пропсы и реактивные переменные $bindable, а разметка изолируется блоком <style>. Если в проекте настроен Vitest или Jest, агент создаёт файл тестов и обновляет экспорт в индексе.
Команде нужны инструменты Read, Write и Edit. Без файлов конфигурации Svelte в корне ассистент не сможет определить целевую папку для компонентов.
Какие задачи решает
- сгенерировать компонент Svelte со слотами и типизированными пропсами
- добавить ARIA-атрибуты и доступную разметку по умолчанию
- создать модульные тесты для Vitest или Jest вместе с компонентом
- подготовить историю Storybook для визуального тестирования
Примеры запросов агенту
- /svelte-component Modal --typescript --story
- /svelte-component Button --typescript
- Создай компонент формы UserForm с валидацией ввода и тестами
Как установить svelte-component
1Через claude-code-templates
npx claude-code-templates@latest --command svelte/svelte-component2Вручную: положить файлы
.claude/commands/svelte-component.mdВызов — /svelte-component. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/svelte-component.mdВызов — /prompts:svelte-component. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/svelte-component.prompt.mdВручную: положить файлы
.gemini/commands/svelte-component.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о svelte-component
Как установить svelte-component в Claude Code?
Выполните в терминале npx claude-code-templates@latest --command svelte/svelte-component. Команда запишется в .claude/commands/svelte-component.md.
Что делает команда svelte-component?
Она сканирует структуру проекта и создаёт каркас компонента Svelte с тестами, типами TypeScript и доступной разметкой.
Какие флаги принимает svelte-component?
Команда принимает имя компонента, а также опциональные флаги --typescript для строгой типизации и --story для генерации файла Storybook.
Исходный текст
svelte-component.md · MIT
---
allowed-tools: Read, Write, Edit
argument-hint: "[component-name] [--typescript] [--story]"
description: Create new Svelte components with best practices, TypeScript support, and testing
---
# Create Svelte Component
Create new Svelte component: $ARGUMENTS
## Current Svelte Project
- Svelte config: @svelte.config.js or @vite.config.js (if exists)
- Components directory: @src/components/ or @src/lib/ (if exists)
- TypeScript config: @tsconfig.json (detect TypeScript usage)
- Testing setup: @vitest.config.js or @jest.config.js (if exists)
## Task
Create Svelte component with best practices. When creating components:
1. **Gather Requirements**:
- Component name and purpose
- Props interface
- Events to emit
- Slots needed
- State management requirements
- TypeScript preference
2. **Component Structure**:
```svelte
<script lang="ts">
// Imports
// Type definitions
// Props
// State
// Derived values
// Effects
// Functions
</script>
<!-- Markup -->
<style>
/* Scoped styles */
</style>
```
3. **Best Practices**:
- Use proper prop typing with TypeScript/JSDoc
- Implement $bindable props where appropriate
- Create accessible markup by default
- Add proper ARIA attributes
- Use semantic HTML elements
- Include keyboard navigation support
4. **Component Types to Create**:
- **UI Components**: Buttons, Cards, Modals, etc.
- **Form Components**: Inputs with validation, custom form controls
- **Layout Components**: Headers, Sidebars, Grids
- **Data Components**: Tables, Lists, Data visualizations
- **Utility Components**: Portals, Transitions, Error boundaries
5. **Additional Files**:
- Create accompanying test file
- Add Storybook story if applicable
- Create usage documentation
- Export from index file
## Example Usage
User: "Create a Modal component with customizable header, footer slots, and close functionality"
Assistant will:
- Create Modal.svelte with proper structure
- Implement focus trap and keyboard handling
- Add transition effects
- Create Modal.test.js with basic tests
- Provide usage examples
- Suggest accessibility improvements
© davila7 · MIT · davila7/claude-code-templates