编写、调试与调优 Playwright 测试,涵盖定位器策略、追踪诊断与 CI 友好的超时配置。
安全
tauri2-best-practice
试用Comprehensive best-practice guide for building, securing, testing, and shipping Tauri v2 desktop/mobile apps (Rust core + any web frontend — React, Next.js, Vue, Svelte, vanilla). Covers IPC (commands/events/channels), the v2 capabilities & permissions security model, CSP, state management (Manager/
它能做什么
Tauri v2 is a Rust-core, webview-frontend framework for desktop (Windows/macOS/Linux) and mobile (iOS/Android) apps. This skill is deliberately **overkill**: it encodes the parts of Tauri v2 that are easy to get wrong, silently insecure, or scattered across many doc pages, so you don't have to rele…
技能文档
Tauri v2 Best Practice
Tauri v2 is a Rust-core, webview-frontend framework for desktop (Windows/macOS/Linux) and mobile (iOS/Android) apps. This skill is deliberately overkill: it encodes the parts of Tauri v2 that are easy to get wrong, silently insecure, or scattered across many doc pages, so you don't have to relearn them from scratch every session.
Every code example and claim in this skill and its reference files is grounded in the official Tauri v2 docs (v2.tauri.app), docs.rs/tauri, or the tauri-apps/tauri-docs GitHub source. Reference files carry per-topic source URLs at the top — verify against them (via web search / fetch) before shipping anything security-critical, since Tauri v2 is still evolving and APIs move between minor versions.
0. First, orient yourself
Before writing anything, check:
- Version.
src-tauri/Cargo.toml→tauri = "2.x"andtauri.conf.json's$schemapointing at av2/2.0.0schema URL confirms v2. If you seetauri.allowlistintauri.conf.json, that's v1 — stop and flag it; the allowlist system was fully replaced by capabilities in v2, and the two are not interchangeable. - Project shape.
src-tauri/(Rust core:Cargo.toml,tauri.conf.json,src/,capabilities/, optionallybinaries/for sidecars) + a frontend root (any framework, or none — vanilla HTML/JS is fully supported). - What the user actually needs. Route to the relevant reference file below rather than dumping everything — but read
security-capabilities.mdproactively any time the task adds a new command, plugin, or filesystem/shell/network access, even if the user didn't ask about security.
1. Reference map — read before you write code
| If the task involves... | Read |
|---|---|
#[tauri::command], invoke(), emit/listen, streaming data, Channel | references/ipc-commands.md |
capabilities/*.json, permissions, scopes, CSP, withGlobalTauri, isolation pattern, "why is invoke undefined/failing silently" | references/security-capabilities.md |
app.manage(), tauri::State, sharing data across commands/threads, async mutex vs sync mutex | references/state-management.md |
Writing a custom plugin, embedding an external binary (Python/Node/Go/Rust CLI) as a sidecar, tauri-plugin-shell | references/plugins-sidecar.md |
Multiple windows, WebviewWindowBuilder, window labels, mobile multi-window, window/webview split, system tray, menus | references/windowing-multiwindow.md |
tauri build, code signing (macOS notarization / Windows Azure Key Vault), the updater plugin, latest.json, GitHub Actions release pipeline | references/bundling-updater-cicd.md |
Unit tests, tauri::test::mock_builder, @tauri-apps/api/mocks / mockIPC, WebDriver / tauri-driver / WebdriverIO, CI test matrices | references/testing.md |
Each reference file is self-contained with runnable code, gotchas, and a "sources" section. Files run 200–500 lines — read the whole file for the topic you're touching rather than skimming, since the gotchas are usually in the second half.
2. The eight rules that cause 90% of Tauri v2 bugs
These are condensed here because they're cross-cutting and worth having in working memory even before you open a reference file.
- Nothing is allowed by default. Tauri v2 is default-deny. A window with no
capabilities/*.jsonentry for a command cannot call it — the call fails at runtime (often silently, or as a vague" not allowed"IPC error), not at compile time. If a frontendinvoke()call "does nothing," check capabilities before touching the Rust code. - Capabilities are matched by
windowslabel. A permission granted in a capability file only applies to windows whose label matches thewindowsarray (glob-capable). Adding a new window (e.g. a settings window) without adding its label to the relevant capability is the #1 cause of "works in main window, broken in the new one." - Plugin permissions are separate from core permissions, and are namespaced
plugin-name:permission-id(e.g.fs:allow-read-file,shell:allow-execute). Installing a plugin's crate + npm package is not enough — you must also grant its permissions in a capability file, and this has no compile-time check. - State is auto-wrapped, don't double-wrap.
app.manage(x)makesxretrievable asState<'_, X>from any command. Tauri does not require you to wrap it inArcyourself for theStateextractor to work across threads — do that only if you're independently sharing it outside Tauri's state system. Do wrap the inner data inMutex/RwLock(or an asynctokio::sync::Mutexif you need to hold the lock across.await) since managed state must beSend + Sync. window.__TAURI__is opt-in.app.withGlobalTauridefaults tofalsein v2. Any code (including a plain bundledindex.htmlwith no bundler) that referenceswindow.__TAURI__.core.invokeinstead of importing from@tauri-apps/apiwill silently fail unless you've explicitly set"app": {"withGlobalTauri": true}intauri.conf.json.- Sidecar filenames must carry the target triple, e.g.
my-sidecar-x86_64-pc-windows-msvc.exe, matchingrustc -Vv | grep host(orrustc --print host-tupleon Rust ≥1.84).Command.sidecar()on the JS side takes the logical name frombundle.externalBin, not the suffixed filename. - Creating a window synchronously inside a command can deadlock on Windows (a known WebView2 issue). Always create windows from an
async fncommand, or spawn a thread/async task, when the trigger is IPC. - CSP defaults matter.
tauri.conf.json'sapp.security.cspis enforced; setting it tonulldisables CSP entirely (don't, except transiently while debugging). A restrictive CSP plus a locked-downcapabilitiesset is what actually makes "no Node.js/Electron-style full OS access from the webview" true in practice — don't rely on capabilities alone if the CSP is wide open.
3. Working style for this skill
- When reviewing existing Tauri code, actively look for capability/permission mismatches (rule 1–3) and sidecar target-triple issues (rule 6) even if not explicitly asked — these are the most common silent-failure classes.
- When scaffolding new commands/plugins/windows, always show the matching
capabilities/*.jsondiff alongside the Rust/JS code — don't leave permission-wiring as an exercise for the user. - Default to the principle of least privilege: prefer narrow, per-command permissions and per-window capability files over
*:defaultblanket grants, and say so explicitly if you do reach for a blanket grant (e.g. rapid prototyping). - Cross-check anything version-sensitive (plugin APIs churn between Tauri 2.0/2.1/2.2+) against current docs via web search rather than asserting from memory, and say so if something looks like it may have shifted since the reference file was written.
相关技能
通过 6551 REST API 查询 Twitter/X 用户资料、推文、粉丝事件与 KOL 数据。
通过托管的 OAuth GraphQL 接口查询与管理 Linear 的 issue、项目、团队、周期、标签和评论。
通过托管 OAuth 访问 Microsoft Graph Excel 接口,读写 OneDrive 中的工作簿、工作表、区域、表格与图表。
通过 OAuth 认证网关管理 Stripe 客户、订阅、发票、产品、价格和支付。
用 Python 自适应抓取网页,默认绕过反爬保护,支持从单次请求到大规模并发爬取。
anjasta-tarigan 的更多技能
浏览全部技能Use this skill whenever the user wants to build, refine, or review a production-grade user interface with Tailwind CSS v4 and shadcn/ui. Triggers include: building a landing page, dashboard, auth flow, admin panel, marketing site, SaaS UI, or any React/Next.js component or page.
Build a complete, production-ready masterplan for a new project/system from scratch (0 to 100%).
Use this skill whenever the user wants to build a production-grade UI with native/vanilla CSS — no Tailwind, no CSS-in-JS, no utility framework. Triggers include: plain Vite + HTML/CSS projects, static sites, simple landing pages, or any project explicitly avoiding a CSS framework.
Execute/build/implement a project strictly from an existing masterplan (the output of masterplan-builder, typically at docs/masterplan/masterplan.md in the project directory). Use whenever the user wants to start or continue actually building a project that has a masterplan — e.g. "build this", "imp
Initialize a brand-new monorepo project in an empty (or near-empty) folder. Use when the user wants to "set up a monorepo", "scaffold a project", or "bootstrap a repo with multiple packages/apps".
Detects and removes "AI slop" — the formulaic vocabulary, sentence structures, sycophantic openers/closers, over-formatting (bullet walls, bold spam, needless headers), and code anti-patterns (over-engineering, swallowed errors, hallucinated APIs, dead code) that make writing or code read as generic