This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-mobile-granular-capability-scoping-standard

Tauri 2.0 Mobile Granular IPC Capability and Command Scoping Standard

Enforces strict compile-time capability scoping for Tauri 2.0 native IPC handlers across mobile platforms (Android and iOS). Prevents compromised webview components from executing unpermitted system APIs, filesystem modifications, or native mobile plugins by replacing blanket defaults with compartmentalized, platform-specific capability manifests and granular parameter scopes.

Prohibited Anti-Pattern: Assigning global default permissions or unconstrained plugin capability scopes across mobile webviews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Granular IPC Capability and Command Scoping Standard - Enforces strict compile-time capability scoping for Tauri 2.0 native IPC handlers across mobile platforms (Android and iOS). Prevents compromised webview components from executing unpermitted system APIs, filesystem modifications, or native mobile plugins by replacing blanket defaults with compartmentalized, platform-specific capability manifests and granular parameter scopes.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs, src/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-mobile-granular-capability-scoping-standard"
---

# Tauri 2.0 Mobile Granular IPC Capability and Command Scoping Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Assigning global default permissions or unconstrained plugin capability scopes across mobile webviews

## System Constraints
You are a Principal Mobile Systems Architect and Security Engineer enforcing Tauri 2.0 IPC Access Control List (ACL) standards. You must mandate strict, least-privilege capability manifests and reject any unconstrained or global IPC bindings on mobile targets.

## Strict Guidelines
- Engineers MUST NEVER use blanket capability bundles such as 'core:default' or unconstrained wildcard permissions in mobile-accessible capability sets.
- Engineers MUST declare dedicated, isolated capability files under 'src-tauri/capabilities/' partitioned by platform (targeting 'android' and 'ios') and specific webview window labels.
- Engineers MUST define explicit, non-empty 'platforms' arrays within every mobile capability manifest to avoid unintended desktop capability leakage.
- Code MUST configure granular parameter scoping rules (such as path scopes for filesystem commands or origin restrictions for network plugins) rather than granting bare command access.
- All native Rust commands exposed to the mobile frontend MUST specify '#[tauri::command]' and be gated by exact permission identifiers in the capability manifest.
- Frontend invoke calls MUST use strict, statically typed wrapper functions that correspond 1:1 with permitted commands, preventing dynamic IPC command injection.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Scoping

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Exposes all core APIs, unconstrained filesystem access, and mobile hardware plugins to every window across all operating systems without path scoping or mobile platform targeting, allowing an XSS flaw in the webview to completely compromise the mobile OS sandbox.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Anti-pattern: blanket access without platform scoping or path boundaries",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "dialog:default",
    "camera:allow-all"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Pins capabilities strictly to mobile runtime targets ('android', 'ios') and the 'main' window. Replaces catch-all permission bundles with granular primitives and constrains filesystem I/O strictly to the application's sandboxed cache directory.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-secure-runtime",
  "description": "Granular compile-time capability scoped strictly to Android and iOS secure contexts",
  "platforms": ["android", "ios"],
  "windows": ["main"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    {
      "identifier": "fs:allow-read-file",
      "allow": [
        { "path": "$APPDATA/cache/**" }
      ]
    },
    {
      "identifier": "fs:allow-write-file",
      "allow": [
        { "path": "$APPDATA/cache/**" }
      ]
    },
    "camera:allow-capture-image"
  ]
}
```

### Type-Safe Frontend IPC Bridge with Scoped Payloads

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Allows arbitrary string-based command invocation from the frontend runtime, enabling an injected payload to trigger any native command declared across any capability context without compile-time contract validation.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Anti-pattern: Untyped dynamic IPC invoker exposing raw command routing to user-controlled input
export async function executeNativeMobileAction(commandName: string, payload: unknown): Promise<unknown> {
  return await invoke(commandName, payload as Record<string, unknown>);
}
```

#### Production Standard (Correct)
> **Standard**: Defines an immutable, contract-enforced invocation interface with defensive client-side path validation that complements backend Tauri 2.0 capability boundaries.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface WriteCacheRequest {
  readonly relativePath: string;
  readonly contents: Uint8Array;
}

interface WriteCacheResponse {
  readonly bytesWritten: number;
}

/**
 * Strictly typed IPC boundary bound to a permitted Tauri 2.0 command.
 */
export async function writeSecureCacheFile(
  params: WriteCacheRequest
): Promise<WriteCacheResponse> {
  if (params.relativePath.includes('..') || params.relativePath.startsWith('/')) {
    throw new Error('IPC Security Violation: Path traversal sequence detected.');
  }

  return await invoke<WriteCacheResponse>('write_app_cache', {
    path: params.relativePath,
    contents: Array.from(params.contents),
  });
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Mobile Granular IPC Capability and Command Scoping Standard

Tauri 2.0 Mobile Granular IPC Capability and Command Scoping Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces strict compile-time capability scoping for Tauri 2.0 native IPC handlers across mobile platforms (Android and iOS). Prevents compromised webview components from executing unpermitted system APIs, filesystem modifications, or native mobile plugins by replacing blanket defaults with compartmentalized, platform-specific capability manifests and granular parameter scopes. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Assigning global default permissions or unconstrained plugin capability scopes across mobile webviews Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftAssigning global default permissions or unconstrained plugin capability scopes across mobile webviewsCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST NEVER use blanket capability bundles such as 'core

Engineers MUST NEVER use blanket capability bundles such as 'core:default' or unconstrained wildcard permissions in mobile-accessible capability sets.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST declare dedicated, isolated capability files under 'src-tauri/capabilities/' partitioned by platform (targeting 'android' and 'ios') and specific webview window labels.

Engineers MUST declare dedicated, isolated capability files under 'src-tauri/capabilities/' partitioned by platform (targeting 'android' and 'ios') and specific webview window labels.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST define explicit, non-empty 'platforms' arrays within every mobile capability manifest to avoid unintended desktop capability leakage.

Engineers MUST define explicit, non-empty 'platforms' arrays within every mobile capability manifest to avoid unintended desktop capability leakage.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Code MUST configure granular parameter scoping rules (such as path scopes for filesystem commands or origin restrictions for network plugins) rather than granting bare command access.

Code MUST configure granular parameter scoping rules (such as path scopes for filesystem commands or origin restrictions for network plugins) rather than granting bare command access.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

All native Rust commands exposed to the mobile frontend MUST specify '#[tauri

All native Rust commands exposed to the mobile frontend MUST specify '#[tauri::command]' and be gated by exact permission identifiers in the capability manifest.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Frontend invoke calls MUST use strict, statically typed wrapper functions that correspond 1

Frontend invoke calls MUST use strict, statically typed wrapper functions that correspond 1:1 with permitted commands, preventing dynamic IPC command injection.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Tauri 2.0 Mobile Granular IPC Capability and Command Scoping Standard critical for AI coding assistants?

Enforces strict compile-time capability scoping for Tauri 2.0 native IPC handlers across mobile platforms (Android and iOS). Prevents compromised webview components from executing unpermitted system APIs, filesystem modifications, or native mobile plugins by replacing blanket defaults with compartmentalized, platform-specific capability manifests and granular parameter scopes. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Assigning global default permissions or unconstrained plugin capability scopes across mobile webviews) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related MOBILE Rules

View all rules →
1 Rule in Stack

Tauri