Token导航 LogoToken导航

Agent Skill · 开发

capacitor(capacitor 命令行)

capacitor 用于补充开发相关能力,适合在 OpenClaw 中需要让 Agent 承接开发相关任务时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

capacitor 是开发类 Agent Skill,可用宿主为 OpenClaw,通过ClawHub获取,权限为操作浏览器;许可证为 MIT-0,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 6,870。

总安装 4,272周安装 178GitHub Stars 1下载 1,424核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT-0
版本
1.0.0

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:capacitor(capacitor 命令行)
来源仓库:https://github.com/robingenz/capacitor
安装命令:
openclaw skills install capacitor
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install capacitor

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

全面掌握 Capacitor CLI 工具及跨平台应用开发核心概念。涵盖应用程序创建、插件管理和框架集成等内容。适合移动应用开发者维护和扩展混合项目。capacitor 属于开发类 Skill,可作为该场景下的辅助能力补充。需 Node.js 环境和 npm 包管理权限。建议先阅读官方文档再结合本技能实践操作。

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 OpenClaw;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 openclaw skills install capacitor;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

capacitor 怎么安装?

在终端执行 openclaw skills install capacitor。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

capacitor 支持哪些 AI 工具?

公开资料标注支持 OpenClaw。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

capacitor 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

capacitor 是免费的吗?

来源标注的许可证是 MIT-0。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

capacitor 用的人多吗?

公开数据是累计安装 4,272 次,近一周安装 178 次,下载 1,424 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

capacitor 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 专注 OpenClaw 一种宿主,触发方式和使用习惯不用来回切换。
  • 许可证明确为 MIT-0,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 OpenClaw,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
capacitor

capacitor 命令行 · 本页

4,2721操作浏览器MIT-0通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
capacitor
description
Comprehensive Capacitor expert skill that consolidates core concepts, CLI usage, app creation, plugin management, framework integration, cross-platform best practices, storage, security, testing, troubleshooting, upgrading, and Capawesome Cloud workflows (live updates, native builds, app store publishing). Use as a single-source reference for Capacitor app and plugin development.
metadata
author
capawesome-team
source
https://github.com/capawesome-team/skills/tree/main/skills/capacitor

Capacitor

Comprehensive reference for building cross-platform apps with Capacitor. Covers architecture, CLI, plugins, framework integration, best practices, and Capawesome Cloud.

Core Concepts

Capacitor is a cross-platform native runtime for building web apps that run natively on iOS, Android, and the web. The web app runs in a native WebView, and Capacitor provides a bridge to native APIs via plugins.

Architecture

A Capacitor app has three layers:

  1. Web layer -- HTML/CSS/JS app running inside a native WebView (WKWebView on iOS, Android System WebView on Android).
  2. Native bridge -- Serializes JS plugin calls, routes them to native code, and returns results as Promises.
  3. Native layer -- Swift/ObjC (iOS) and Kotlin/Java (Android) code implementing native functionality.

Data passed across the bridge must be JSON-serializable. Pass files as paths, not base64.

Project Structure

my-app/
  android/                  # Native Android project (committed to VCS)
  ios/                      # Native iOS project (committed to VCS)
    App/
      App/                  # iOS app source files
      App.xcodeproj/
  src/                      # Web app source code
  dist/ or www/ or build/   # Built web assets
  capacitor.config.ts       # Capacitor configuration
  package.json

The android/ and ios/ directories are full native projects -- they are committed to version control and can be modified directly.

Capacitor Config

capacitor.config.ts (preferred) or capacitor.config.json controls app behavior:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.example.app',
  appName: 'My App',
  webDir: 'dist',
  server: {
    // androidScheme: 'https', // default in Cap 6+
  },
};

export default config;

For details, see App Configuration.

Creating a New App

Quick Start

# 1. Create a web app (React example with Vite)
npm create vite@latest my-app -- --template react-ts
cd my-app && npm install

# 2. Install Capacitor
npm install @capacitor/core
npm install -D @capacitor/cli

# 3. Initialize Capacitor
npx cap init "My App" com.example.myapp --web-dir dist

# 4. Build web assets
npm run build

# 5. Add platforms
npm install @capacitor/android @capacitor/ios
npx cap add android
npx cap add ios

# 6. Sync and run
npx cap sync
npx cap run android
npx cap run ios

Web asset directories by framework:

  • Angular: dist/<project-name>/browser (Angular 17+ with application builder)
  • React (Vite): dist
  • Vue (Vite): dist
  • Vanilla: www

For the full guided creation flow, see capacitor-app-creation.

Capacitor CLI

All commands: npx cap <command>. Most important commands:

CommandPurpose
npx cap init <name> <id>Initialize Capacitor in a project
npx cap add <platform>Add Android or iOS platform
npx cap syncCopy web assets + update native dependencies (run after every plugin install, config change, or web build)
npx cap copyCopy web assets only (faster, no native dependency update)
npx cap run <platform>Build, sync, and deploy to device/emulator
npx cap run <platform> -l --externalRun with live reload
npx cap open <platform>Open native project in IDE
npx cap build <platform>Build native project
npx cap doctorDiagnose configuration issues
npx cap lsList installed plugins
npx cap migrateAutomated upgrade to newer Capacitor version

For the full CLI reference, see CLI Reference.

Framework Integration

Capacitor works with any web framework. Framework-specific patterns:

Angular

  • Wrap Capacitor plugins in Angular services for DI and testability.
  • Plugin event listeners run outside NgZone -- always wrap callbacks in NgZone.run().
  • Register listeners in ngOnInit, remove in ngOnDestroy.

For details, see capacitor-angular.

React

  • Create custom hooks (useCamera, useNetwork) that wrap Capacitor plugins.
  • Use useEffect for listener registration with cleanup to prevent memory leaks.
  • React 18 strict mode double-mounts -- ensure cleanup functions work correctly.

For details, see capacitor-react.

Vue

  • Create composables (useCamera, useNetwork) using Vue 3 Composition API.
  • Register listeners in onMounted, remove in onUnmounted.
  • Vue reactivity picks up ref changes automatically (no NgZone equivalent needed).

For details, see capacitor-vue.

Plugins

Plugins are Capacitor's extension mechanism. Each plugin exposes a JS API backed by native implementations.

Plugin Sources

  • Official (@capacitor/*) -- Camera, Filesystem, Geolocation, Preferences, etc.
  • Capawesome (@capawesome/*, @capawesome-team/*) -- SQLite, NFC, Biometrics, Live Update, etc.
  • Community (@capacitor-community/*) -- AdMob, BLE, SQLite, Stripe, etc.
  • Firebase (@capacitor-firebase/*) -- Analytics, Auth, Messaging, Firestore, etc.
  • MLKit (@capacitor-mlkit/*) -- Barcode scanning, face detection, translation.
  • RevenueCat (@revenuecat/purchases-capacitor) -- In-app purchases.

Installing a Plugin

npm install @capacitor/camera
npx cap sync

After installation, apply any required platform configuration (permissions in AndroidManifest.xml, Info.plist entries, etc.) as documented by the plugin.

Using a Plugin

import { Camera, CameraResultType } from '@capacitor/camera';

const photo = await Camera.getPhoto({
  quality: 90,
  resultType: CameraResultType.Uri,
});

For the full plugin index (160+ plugins) and setup guides, see capacitor-plugins.

Plugin Development

Create custom Capacitor plugins with native iOS (Swift) and Android (Java/Kotlin) implementations:

  1. Scaffold with npm init @capacitor/plugin@latest.
  2. Define the TypeScript API in src/definitions.ts.
  3. Implement the web layer in src/web.ts.
  4. Implement iOS plugin in ios/Sources/.
  5. Implement Android plugin in android/src/main/java/.
  6. Verify with npm run verify.

Key rules:

  • The registerPlugin() name in src/index.ts must match jsName on iOS and @CapacitorPlugin(name = "...") on Android.
  • iOS methods need @objc and must be listed in pluginMethods (CAPBridgedPlugin).
  • Android methods need @PluginMethod() annotation and must be public.

For full details, see capacitor-plugin-development.

Cross-Platform Best Practices

Platform Detection

import { Capacitor } from '@capacitor/core';

const platform = Capacitor.getPlatform(); // 'android' | 'ios' | 'web'
if (Capacitor.isNativePlatform()) { /* native-only code */ }
if (Capacitor.isPluginAvailable('Camera')) { /* plugin available */ }

Permissions

Follow the check-then-request pattern:

const status = await Camera.checkPermissions();
if (status.camera !== 'granted') {
  const requested = await Camera.requestPermissions();
  if (requested.camera === 'denied') {
    // Guide user to app settings -- cannot re-request on iOS
    return;
  }
}
const photo = await Camera.getPhoto({ ... });

Performance

  • Minimize bridge calls -- batch operations instead of many individual calls.
  • Use file paths over base64 for binary data.
  • Lazy-load plugins with dynamic imports for code splitting.

Error Handling

Always wrap plugin calls in try-catch:

try {
  const photo = await Camera.getPhoto({ resultType: CameraResultType.Uri });
} catch (error) {
  if (error.message === 'User cancelled photos app') {
    // Not an error
  } else {
    console.error('Camera error:', error);
  }
}

For full details, see Cross-Platform Best Practices.

Deep Links

Deep links open specific content in the app from external URLs.

  • iOS: Universal Links via apple-app-site-association hosted at https://<domain>/.well-known/.
  • Android: App Links via assetlinks.json hosted at https://<domain>/.well-known/.

Listener Setup

import { App } from '@capacitor/app';

App.addListener('appUrlOpen', (event) => {
  const path = new URL(event.url).pathname;
  // Route to the appropriate page
});

Platform Configuration

  • iOS: Add applinks:<domain> to Associated Domains capability in ios/App/App/App.entitlements.
  • Android: Add <intent-filter android:autoVerify="true"> to android/app/src/main/AndroidManifest.xml.

For full setup, see Deep Links.

Storage

RequirementSolution
App settings, preferences@capacitor/preferences (native key-value, persists reliably)
Sensitive data (tokens, credentials)@capawesome-team/capacitor-secure-preferences (Keychain/Keystore)
Relational data, offline-firstSQLite (@capawesome-team/capacitor-sqlite or @capacitor-community/sqlite)
Files, images, documents@capacitor/filesystem

Do NOT use localStorage, IndexedDB, or cookies for persistent data -- the OS can evict them (especially on iOS).

For details, see Storage.

Security

  • Never embed secrets (API keys with write access, OAuth secrets, DB credentials) in client code -- move to a server API.
  • Use secure storage (@capawesome-team/capacitor-secure-preferences) for tokens and credentials, not localStorage or @capacitor/preferences.
  • HTTPS only -- never allow cleartext HTTP in production.
  • Content Security Policy -- add a <meta> CSP tag in index.html.
  • Disable WebView debugging in production: set webContentsDebuggingEnabled: false in capacitor.config.ts.
  • Prefer Universal/App Links over custom URL schemes (verified via HTTPS).
  • iOS Privacy Manifest (PrivacyInfo.xcprivacy) -- required for iOS 17+ when using privacy-sensitive APIs.

For details, see Security.

Testing

Unit Testing

Mock Capacitor plugins in Jest/Vitest since tests run in Node.js, not a WebView:

vi.mock('@capacitor/camera', () => ({
  Camera: {
    getPhoto: vi.fn().mockResolvedValue({
      webPath: 'https://example.com/photo.jpg',
    }),
  },
}));

E2E Testing

  • Web E2E: Cypress or Playwright (tests web layer, plugins must be mocked).
  • Native E2E: Appium (cross-platform) or Detox (iOS-focused).

Debugging

  • Android: Enable webContentsDebuggingEnabled: true, open chrome://inspect in Chrome.
  • iOS: Enable webContentsDebuggingEnabled: true, use Safari > Develop menu > select device.

For details, see Testing.

Troubleshooting

Android

  • npx cap sync fails: Verify @capacitor/core and @capacitor/cli versions match. Run cd android && ./gradlew clean.
  • Build fails after config changes: Clean with cd android && ./gradlew clean, then rebuild.
  • Plugin not found at runtime: Run npx cap sync after plugin installation. Verify Gradle sync completed.
  • SDK errors: Verify ANDROID_HOME is set. Install missing SDK versions via Android Studio SDK Manager.
  • White square notification icon: Push notification icons must be white pixels on transparent background.

iOS

  • Build fails with "no such module": Run npx cap sync ios. For CocoaPods: cd ios/App && pod install --repo-update.
  • Build fails after config changes: Clean build folder (Xcode Product > Clean Build Folder) or delete ios/App/Pods and re-run pod install.
  • Simulator cannot receive push notifications: Use a physical device for push notification testing.
  • Permission denied permanently: Cannot re-request on iOS. Guide user to Settings > App > Permissions.
  • WebView not loading: Verify webDir in capacitor.config.ts matches the actual build output directory.

General

  • Live reload not connecting: Ensure device and dev machine are on the same network. Use --external flag.
  • Plugin not found: Run npx cap sync. Verify plugin is in package.json dependencies.
  • Capacitor is not defined: Install @capacitor/core (npm install @capacitor/core).

For full troubleshooting, see Android Troubleshooting and iOS Troubleshooting.

Upgrading

Capacitor supports upgrades across major versions (4 through 8). Apply each major version jump sequentially -- do not skip intermediate versions.

Current to TargetNode.jsXcodeAndroid Studio
to 516+14.1+Flamingo 2022.2.1+
to 618+15.0+Hedgehog 2023.1.1+
to 720+16.0+Ladybug 2024.2.1+
to 822+26.0+Otter 2025.2.1+

Quick automated upgrade:

npx cap migrate
npx cap sync

If npx cap migrate fails partially, apply manual steps from the upgrade guides.

For app upgrades, see capacitor-app-upgrades. For plugin upgrades, see capacitor-plugin-upgrades.

Capawesome Cloud

Capawesome Cloud provides cloud infrastructure for Capacitor apps: native builds, live updates, and automated app store publishing.

Website: capawesome.io | Cloud Services: cloud.capawesome.io

Getting Started

# Install and authenticate
npx @capawesome/cli login

# Create an app
npx @capawesome/cli apps:create

Live Updates

Deploy over-the-air (OTA) web updates to Capacitor apps without going through the app stores. Users receive updates immediately on next app launch.

Setup:

# Install the live update plugin
npm install @capawesome/capacitor-live-update
npx cap sync

Configure in capacitor.config.ts:

const config: CapacitorConfig = {
  plugins: {
    LiveUpdate: {
      appId: '<APP_ID>',
      autoUpdate: true,
    },
  },
};

Deploy an update:

npm run build
npx @capawesome/cli apps:liveupdates:upload --app-id <APP_ID>

Native Builds

Build iOS and Android apps in the cloud without local build environments. Supports signing certificates, environments, and build configuration.

# Trigger a build
npx @capawesome/cli apps:builds:create --app-id <APP_ID> --platform android

# Download the artifact
npx @capawesome/cli apps:builds:download --app-id <APP_ID> --build-id <BUILD_ID>

App Store Publishing

Automate submissions to Apple App Store (TestFlight) and Google Play Store.

# Create a deployment destination
npx @capawesome/cli apps:destinations:create --app-id <APP_ID>

# Deploy a build
npx @capawesome/cli apps:deployments:create --app-id <APP_ID> --build-id <BUILD_ID>

CI/CD Integration

Use token-based auth for CI/CD pipelines:

npx @capawesome/cli login --token <TOKEN>
npx @capawesome/cli apps:builds:create --app-id <APP_ID> --platform ios --detached

For full Capawesome Cloud setup, see capawesome-cloud. For the Capawesome CLI reference, see capawesome-cli.

Push Notifications

Set up push notifications using Firebase Cloud Messaging (FCM) via @capacitor-firebase/messaging:

npm install @capacitor-firebase/messaging firebase
npx cap sync

Requires Firebase project setup, platform-specific configuration (APNs for iOS, google-services.json for Android), and permission handling.

For the full setup guide, see capacitor-push-notifications.

In-App Purchases

Set up in-app purchases and subscriptions with either:

  • Capawesome Purchases (@capawesome-team/capacitor-purchases) -- lightweight, no third-party backend, requires Capawesome Insiders license.
  • RevenueCat (@revenuecat/purchases-capacitor) -- full managed backend with receipt validation, analytics, and integrations.

Both require App Store Connect (iOS) and/or Google Play Console (Android) product configuration.

For the full setup guide, see capacitor-in-app-purchases.

Related Skills

平台分布

OpenClaw

85.31%
按下载量换算1,215

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills