add-tauri-command
Skill13 starsChanged 4 months agoMITView on GitHub
Use when adding a new Tauri command to Cowork-Z — a new backend capability the React frontend must call, a new `#[tauri::command]` fn, or a new `invoke()` wrapper in tauri-api.ts. Also use when a newly written command returns "Command not found" at runtime.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- Mooshieblob1/MooshieUItheir own version, first seen Oct 8, 2026
- openfootmanager/openfootmanagertheir own version, first seen Oct 8, 2026
- Konadu-Akwasi-Akuoko/kattotheir own version, first seen Jul 2, 2026
- devlint/GitWandtheir own version, first seen Jun 17, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- openfootmanager/openfootmanager★ 1.2ksame name
- Mooshieblob1/MooshieUI★ 225same name
- devlint/GitWand★ 198same name
- Konadu-Akwasi-Akuoko/katto★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Files
Add a Tauri Command
A command is not usable until it exists in four places. Miss one and it fails at runtime, not at build time — generate_handler! takes any path that compiles, and invoke() takes any string.
The four edits
| Order | File | Edit |
| 1 | src-tauri/src/commands/<domain>.rs | the #[tauri::command] fn |
| 2 | src-tauri/src/commands/mod.rs | pub mod <domain>; — only when the file is new |
| 3 | src-tauri/src/lib.rs | one line in tauri::generate_handler![], under the matching // Domain comment |
| 4 | src/lib/tauri-api.ts | the typed invoke() wrapper |
Pick an existing domain file before creating one. There are 22; a new domain is rare.
Step 1 — the command
Copy templates/command.rs. Two shapes: plain, and path-taking.
Any command that accepts a caller-supplied path MUST go through path_guard. The renderer is untrusted — an agent will pass whatever path its model produced. Model it on the validate_path helper at the top of src-tauri/src/commands/files.rs, and validate before any fs:: call, never after.
Return Result<T, String>. T must be Serialize; shared shapes live in src-tauri/src/types.rs.
Step 2 — register
lib.rs groups the handler list by domain with // comments. Add the line to its group, not the end of the list.
Step 3 — the frontend wrapper
Copy templates/wrapper.ts.
Argument names cross the bridge as camelCase in TS, snake_case in Rust — Tauri converts them. invoke('add_workspace', { folderPath }) binds to folder_path: String. Get this wrong and the argument silently arrives empty.
The function name is camelCase; the invoke string is the exact Rust fn name.
New return types go in src/shared/ and must mirror the Rust struct's serde casing (rename_all = "camelCase" on the Rust side).
Step 4 — verify
cd src-tauri && cargo check # Rust compiles
pnpm typecheck # TS compilesThen check the wiring, which neither compiler sees:
grep -c '<fn_name>' src-tauri/src/lib.rs src/lib/tauri-api.ts # both must be >= 1Rust changes need an app restart (pnpm tauri dev); the frontend hot-reloads. Do not report the command as working until you have seen it return in the running app or in a test.
Capabilities
If the command calls a Tauri plugin API (shell, dialog, opener, updater, process), the calling window needs the permission in src-tauri/capabilities/. Those files are protected — do not edit them. Say which permission is needed and which window needs it, and let the user make the change.
Plain Rust (std::fs, rusqlite, reqwest) needs no capability entry.
Tests
Rust: #[cfg(test)] mod tests in the same file, cd src-tauri && cargo test. Pure logic — extract it out of the command body so it is testable without a State.
Frontend: __tests__/ next to the code, pnpm test --run.
Common mistakes
| Symptom | Cause |
Command <name> not found | Step 2 skipped — not in generate_handler![] |
Argument arrives empty or None | camelCase/snake_case mismatch between the invoke object and the Rust param |
| Command compiles, never reachable | New file, no pub mod line in commands/mod.rs |
| Works in dev, fails on a user's machine | Path used without path_guard — outside the sandbox roots |
unknown permission at runtime | Plugin API called from a window whose capability file does not grant it |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

