tauri-svelte-typescript-guide — правило Cursor для Tauri, Svelte
Правило для Cursor, которое задаёт агенту стиль работы с десктопными приложениями на Tauri: Svelte во фронтенде, TypeScript для типов.
.cursor/rules/tauri-svelte-typescript-guide-cursorrules-prompt-f.mdcЧто делает tauri-svelte-typescript-guide-cursorrules-prompt-f
Файл описывает, как ассистент должен писать код в проекте на Tauri с Svelte и TypeScript. Внутри — набор принципов: типизация через TypeScript, компонентный подход Svelte, обращение к нативным API Tauri для файловой системы и системного трея, состояние через Svelte stores. Отдельно разобрана работа с внешним бэкендом: HTTP-запросы через Axios, обработка ошибок сети, интерфейсы TypeScript под структуры данных.
Есть блоки про безопасность и производительность. Агент будет напоминать про allowlist Tauri, валидацию ввода на фронтенде и HTTPS для внешних сервисов. Из оптимизаций — ленивая загрузка компонентов и маршрутов, кэширование часто запрашиваемых данных. Тесты описаны так: юнит-тесты компонентов на Jest и Testing Library, end-to-end на Playwright или Cypress.
Правило ссылается на внешний Python-бэкенд, поэтому в промпте заложены повторные попытки при сбоях и сериализация сложных структур. Если у вас бэкенд на другом языке, эти разделы придётся переписать. Сборка идёт через Vite, упаковка — через CLI Tauri. В зависимостях перечислены Tauri, Svelte, TypeScript, Vite и Axios, так что проект без Axios получит советы, которые к нему не подходят.
Какие задачи решает
- задать агенту единый стиль кода в проекте на Tauri и Svelte
- получить типизированные интерфейсы для ответов внешнего API
- не забыть про allowlist и валидацию ввода при работе с нативными API
- настроить ленивую загрузку компонентов и маршрутов Svelte
- описать тесты компонентов и критичных пользовательских сценариев
Примеры запросов агенту
- Добавь экран настроек на Svelte и подключи его к API через Axios с типами
- Проверь, что доступ к файловой системе идёт через нативные API Tauri и allowlist не расширен лишним
- Напиши юнит-тест для этого компонента и e2e-сценарий на Playwright
Как установить tauri-svelte-typescript-guide-cursorrules-prompt-f
Вручную: положить файлы
.cursor/rules/tauri-svelte-typescript-guide-cursorrules-prompt-f.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/tauri-svelte-typescript-guide-cursorrules-prompt-f.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/tauri-svelte-typescript-guide-cursorrules-prompt-f.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/tauri-svelte-typescript-guide-cursorrules-prompt-f.mdВручную: положить файлы
.clinerules/tauri-svelte-typescript-guide-cursorrules-prompt-f.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о tauri-svelte-typescript-guide-cursorrules-prompt-f
Как установить правило tauri-svelte-typescript-guide в Cursor?
Создайте файл .cursor/rules/tauri-svelte-typescript-guide-cursorrules-prompt-f.mdc в корне проекта и вставьте в него содержимое правила. Cursor подхватит его автоматически.
Что делает это правило?
Задаёт агенту принципы разработки десктопных приложений на Tauri со Svelte и TypeScript: типизацию, работу с нативными API, запросы к внешнему бэкенду через Axios, безопасность и тесты.
С каким бэкендом работает правило?
В тексте разобрано взаимодействие с внешним Python-бэкендом, включая повторные попытки при сбоях и сериализацию данных. Для бэкенда на другом языке эти разделы нужно переписать.
Исходный текст
tauri-svelte-typescript-guide-cursorrules-prompt-f.mdc · CC0-1.0
--- description: "Cursor rules for Tauri development with Svelte and TypeScript guide integration." globs: **/* alwaysApply: false --- You are an expert in developing desktop applications using Tauri with Svelte and TypeScript for the frontend. Key Principles: - Write clear, technical responses with precise examples for Tauri, Svelte, and TypeScript. - Prioritize type safety and utilize TypeScript features effectively. - Follow best practices for Tauri application development, including security considerations. - Implement responsive and efficient UIs using Svelte's reactive paradigm. - Ensure smooth communication between the Tauri frontend and external backend services. Frontend (Tauri + Svelte + TypeScript): - Use Svelte's component-based architecture for modular and reusable UI elements. - Leverage TypeScript for strong typing and improved code quality. - Utilize Tauri's APIs for native desktop integration (file system access, system tray, etc.). - Implement proper state management using Svelte stores or other state management solutions if needed. - Use Svelte's built-in reactivity for efficient UI updates. - Follow Svelte's naming conventions (PascalCase for components, camelCase for variables and functions). Communication with Backend: - Use Axios for HTTP requests from the Tauri frontend to the external backend. - Implement proper error handling for network requests and responses. - Use TypeScript interfaces to define the structure of data sent and received. - Consider implementing a simple API versioning strategy for future-proofing. - Handle potential CORS issues when communicating with the backend. Security: - Follow Tauri's security best practices, especially when dealing with IPC and native API access. - Implement proper input validation and sanitization on the frontend. - Use HTTPS for all communications with external services. - Implement proper authentication and authorization mechanisms if required. - Be cautious when using Tauri's allowlist feature, only exposing necessary APIs. Performance Optimization: - Optimize Svelte components for efficient rendering and updates. - Use lazy loading for components and routes where appropriate. - Implement proper caching strategies for frequently accessed data. - Utilize Tauri's performance features, such as resource optimization and app size reduction. Testing: - Write unit tests for Svelte components using testing libraries like Jest and Testing Library. - Implement end-to-end tests for critical user flows using tools like Playwright or Cypress. - Test Tauri-specific features and APIs thoroughly. - Implement proper mocking for API calls and external dependencies in tests. Build and Deployment: - Use Vite for fast development and optimized production builds of the Svelte app. - Leverage Tauri's built-in updater for seamless application updates. - Implement proper environment configuration for development, staging, and production. - Use Tauri's CLI tools for building and packaging the application for different platforms. Key Conventions: 1. Follow a consistent code style across the project (e.g., use Prettier). 2. Use meaningful and descriptive names for variables, functions, and components. 3. Write clear and concise comments, focusing on why rather than what. 4. Maintain a clear project structure separating UI components, state management, and API communication. Dependencies: - Tauri - Svelte - TypeScript - Vite - Axios Refer to official documentation for Tauri, Svelte, and TypeScript for best practices and up-to-date APIs. Note on Backend Communication: When working with the external Python backend: - Ensure proper error handling for potential backend failures or slow responses. - Consider implementing retry mechanisms for failed requests. - Use appropriate data serialization methods when sending/receiving complex data structures.
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules