Tauri Desktop Development & Testing
Provides architectural guidelines for developing Tauri desktop apps, including sidecar integration and port management.
Install
mkdir -p .claude/skills/tauri-desktop-development-testing && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/19295" && unzip -o skill.zip -d .claude/skills/tauri-desktop-development-testing && rm skill.zipInstalls to .claude/skills/tauri-desktop-development-testing
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Core guidelines and instructions for Tauri desktop development, static build integration, dynamic port discovery, and WKWebView binary download handling.Key capabilities
- →Execute Python sidecar binaries
- →Perform dynamic backend port discovery
- →Implement path traversal guards for file operations
- →Manage JNI concurrency for database access
How it works
The skill manages a hybrid architecture where a Python sidecar communicates with a Tauri Rust host, using dynamic port mapping and native file system commands to bypass WebView IPC limitations.
Inputs & outputs
When to use Tauri Desktop Development & Testing
- →Implement dynamic backend port discovery
- →Configure Tauri sidecar execution
- →Fix race conditions in frontend bridge
About this skill
Tauri Desktop Development & Testing Guidelines
Architecture Overview
The application runs as a hybrid Tauri desktop client. The frontend is built using Next.js (prerendered to static HTML and JS via next export), which runs inside a native web view (WKWebView on macOS, WebView2 on Windows). The backend server runs as a Python sidecar executable packaged via PyInstaller.
Dynamic Port Discovery
- During app startup, the Tauri native host executes the sidecar. The sidecar finds a free port to bind to (e.g.
8080for backend services and another port like8081for the REST gateway). - The sidecar writes its dynamic port mapping to a local registry file at
~/.mmtools/active_ports.jsonand notifies Tauri. - The Tauri Rust backend stores the active port in its state and exposes it to the frontend via the Tauri command
get_backend_port. - Race Condition Prevention: Tauri's startup connection loop initializes the port to
""(instead of a default fallback like"8081") and only attempts loopback TCP handshakes once the sidecar log parser has successfully captured and populated the port state. - CRITICAL: The JS frontend must NEVER cache the REST port in module state across the lifetime of the application. It must call
getRestPort()fromlib/tauri-bridge.tsdynamically on every request to avoid race conditions during startup.
Filesystem and Binary Download Limits & Security
- Problem: WKWebView has strict sandboxing and message size limitations on macOS. Sending massive byte arrays over the WebView IPC channel (e.g. JSON number arrays
[1, 2, 3...]for ZIP report bundles) will crash or freeze the bridge. - Rules:
- For large file downloads (like the report pack ZIP bundles), do NOT download the file inside the WebView JS. Use the Rust custom command
copy_file_from_storage(relative_path, dest_path). The frontend resolves the ZIP URL, extracts the relative storage path (from thepathURL parameter), and instructs Rust to copy the file on disk natively. - For writing files, do NOT pass JSON integer arrays over the IPC channel. Convert the data to a Base64 string in Javascript and decode it natively in Rust using the
base64crate to ensure fast, sub-millisecond writes. - Path Traversal Guards: The custom command
copy_file_from_storagemust canonicalize joined paths (fs::canonicalize) to resolve symlinks and relative tokens before verifying they reside strictly inside the application data directory (starts_with). The commandsave_file_to_pathmust enforce that target paths are absolute and reject any attempts to write to sensitive OS locations (e.g. home shell profiles,.ssh,/etc,/Windows).
- For large file downloads (like the report pack ZIP bundles), do NOT download the file inside the WebView JS. Use the Rust custom command
Access Database connection & Concurrency (Windows)
- Access Database File Locks: On Windows, open database handles hold file locks that prevent dynamic file deletions, triggering
WinError 32 PermissionError.- Rule: Always instantiate
MmToJsonConverterwithin a context manager (withblock) or wrap it intry/finallyblocks calling.close(). - Rule: Harden the
.close()method to verify the JVM is still active (viajpype.isJVMStarted()) before releasing connections, preventing interpreter teardown crashes during garbage collection destructors (__del__).
- Rule: Always instantiate
- JNI Concurrency Safety: Bootstrapping the JVM is non-reentrant.
- Rule: Protect JVM startup calls (
ensure_jvm_started) inmdb_writer.pywith a synchronization lock to prevent concurrent worker threads from triggering JNI runtime crashes.
- Rule: Protect JVM startup calls (
- Singleton Thread Spawning: Ensure background threads (like the parent process stdin monitor thread in
platform_setup.py) are protected by a global thread lock and check-flag to prevent duplicate thread leaks.
Desktop Testing & Verification
- Desktop-specific E2E tests are configured in
playwright.tauri.config.tsand targettauri_smoke.spec.ts. - Run Tauri smoke tests using:
npx playwright test --config playwright.tauri.config.ts - Before committing any changes, run local formatting, linting, and type checking:
just fix
Windows Dependency Packaging & Sidecar Stdin Monitoring
- WeasyPrint DLLs: WeasyPrint relies on external shared C libraries (Cairo, Pango, GObject) to compile and render PDF reports on Windows. On the Windows builder runner, these must be installed (e.g. via MSYS2 pacman
mingw-w64-x86_64-pango) and copied into thebackend/src/mm_to_json/lib/directory so PyInstaller bundles them. Point WeasyPrint to them at startup by setting theWEASYPRINT_DLL_DIRECTORIESenv var. - Orphan Sidecar Process Prevention: If the Tauri host app crashes or is force-terminated, the sidecar child process can leak. Set
MONITOR_PARENT_PROCESS=truein the sidecar's environment when spawning it from Tauri (inlib.rs). This enables a stdin-monitoring daemon thread in Python that will exit immediately upon parent EOF. Do NOT enable this check in headless/Docker environments. - Validation: Always run the packaged sidecar binary with
--check-weasyprintin GHA before building the final MSI/DMG installers to catch packaging regressions early.
When not to use it
- →Caching REST ports in module state
- →Sending massive byte arrays over WebView IPC
Prerequisites
Limitations
- →JS frontend must not cache REST port
- →WKWebView has message size limitations
How it compares
It uses native Rust commands for file operations to avoid the performance and stability issues of sending large data over the WebView IPC channel.
Compared to similar skills
Tauri Desktop Development & Testing side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| Tauri Desktop Development & Testing (this skill) | 0 | 17d | Review | Advanced |
| nextjs-supabase-auth | 12 | 6mo | No flags | Intermediate |
| debugging-streamlit | 7 | 4mo | Review | Intermediate |
| telegram-dev | 2 | 7mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
nextjs-supabase-auth
davila7
Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.
debugging-streamlit
streamlit
Debug Streamlit frontend and backend changes using make debug with hot-reload. Use when testing code changes, investigating bugs, checking UI behavior, or needing screenshots of the running app.
telegram-dev
2025Emma
Telegram 生态开发全栈指南 - 涵盖 Bot API、Mini Apps (Web Apps)、MTProto 客户端开发。包括消息处理、支付、内联模式、Webhook、认证、存储、传感器 API 等完整开发资源。
app-specific-patterns
growilabs
GROWI main application (apps/app) specific patterns for Next.js, Jotai, SWR, and testing. Auto-invoked when working in apps/app.
javascript-typescript-typescript-scaffold
sickn33
You are a TypeScript project architecture expert specializing in scaffolding production-ready Node.js and frontend applications. Generate complete project structures with modern tooling (pnpm, Vite, N
podcast-generation
microsoft
Generate AI-powered podcast-style audio narratives using Azure OpenAI's GPT Realtime Mini model via WebSocket. Use when building text-to-speech features, audio narrative generation, podcast creation from content, or integrating with Azure OpenAI Realtime API for real audio output. Covers full-stack implementation from React frontend to Python FastAPI backend with WebSocket streaming.