Capacitor App Creation
Create a new Capacitor app from scratch, including project scaffolding, platform setup, and optional integrations.
Prerequisites
- Node.js 22+ installed. Verify with .
- For iOS: macOS with Xcode 26.0+ installed. Install Xcode Command Line Tools: .
- For Android: Android Studio 2025.2.1+ installed with Android SDK (API 24+).
Agent Behavior
- Guide step-by-step. Walk the user through the process one step at a time. Never present multiple unrelated questions at once.
- One decision at a time. When a step requires user input, ask that single question, wait for the answer, then continue.
- Present clear options. Provide concrete choices (e.g., "Do you want to add the iOS platform? (yes/no)") instead of open-ended questions.
Procedures
Step 1: Check for Ionic Framework
Before creating the app, ask the user:
Do you want to use the Ionic Framework for UI components and theming? (yes/no)
If the user answers
yes, stop this skill and switch to the
skill instead. If
no, continue with Step 2.
Step 2: Create the Web App
Ask the user which web framework they want to use. Present these options:
- Angular
- React
- Vue
- None (vanilla JS/TS or existing web app)
Based on the selection, scaffold the web project:
Angular
bash
npm install -g @angular/cli
ng new my-app
cd my-app
The default web asset directory for Angular is
. Adjust the directory name based on the actual project name.
React
bash
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
The default web asset directory for React (Vite) is
.
Vue
bash
npm create vite@latest my-app -- --template vue-ts
cd my-app
npm install
The default web asset directory for Vue (Vite) is
.
None (vanilla or existing web app)
If the user has an existing web app, confirm it meets these requirements:
- A file exists at the project root.
- A build output directory exists (e.g., , , ).
- An file exists at the root of the build output directory.
- The file contains a tag (required for Capacitor plugins to work).
If the user wants a vanilla project:
bash
mkdir my-app && cd my-app
npm init -y
mkdir www
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My App</title>
</head>
<body>
<h1>My App</h1>
</body>
</html>
The web asset directory is
.
Step 3: Install Capacitor
Navigate to the project root directory and install the Capacitor core packages:
bash
npm install @capacitor/core
npm install -D @capacitor/cli
Step 4: Initialize Capacitor
Run the Capacitor init command with the app name, app ID, and web asset directory:
bash
npx cap init <appName> <appID> --web-dir <webDir>
- : Ask the user for the display name of the app (e.g., ).
- : Ask the user for the app ID in reverse-domain format (e.g., ).
- : Use the web asset directory determined in Step 2 (e.g., , , ).
This creates a
file in the project root.
Step 5: Build the Web App
Before adding native platforms, build the web app so the output directory exists:
Angular
React / Vue (Vite)
Vanilla
No build step needed if using a static
directory.
Step 6: Add Native Platforms
Ask the user which platforms to add:
Which platforms do you want to add? (android/ios/both)
Add Android
bash
npm install @capacitor/android
npx cap add android
This creates the
directory with a native Android project.
Add iOS
bash
npm install @capacitor/ios
npx cap add ios
This creates the
directory with a native iOS project. By default, Capacitor 8 uses Swift Package Manager (SPM) for iOS dependency management.
Step 7: Sync the Project
Sync the web assets and native dependencies:
This copies the built web assets into each native platform project and installs native dependencies (Gradle for Android, SPM for iOS).
Step 8: Run the App
Run the app on a connected device or emulator/simulator:
Android
This prompts for a target device (emulator or physical device).
iOS
This prompts for a target simulator or physical device.
Step 9: Post-Creation Options
After the app is running, ask the user:
Do you want to set up Live Updates for over-the-air updates? (yes/no)
If
yes, refer the user to the
skill for live update setup.
Then ask:
Do you want to set up CI/CD for native builds and app store publishing? (yes/no)
If
yes, refer the user to the
skill for CI/CD setup.
Error Handling
- fails with "already initialized": A or file already exists. The project is already a Capacitor project. Delete the existing config file if re-initialization is intended.
- fails with "platform already exists": The or directory already exists. Remove the directory first: or , then re-run .
- fails with "could not find the web assets directory": The web app has not been built yet, or the in points to a non-existent directory. Run the web app build command first (e.g., , ).
- iOS build fails with "no such module": Run to ensure SPM dependencies are resolved.
- Android build fails with SDK errors: Verify that Android SDK is installed and or environment variable is set. Open Android Studio SDK Manager to install missing SDK versions.
- missing tag: Capacitor plugins inject scripts into the tag. Ensure the in the web asset directory contains a element.
Related Skills
- — Create a new Ionic app with UI components and theming instead of a plain Capacitor app.
capacitor-app-development
— General Capacitor app development guidance after app creation.
- — Angular-specific patterns and best practices for Capacitor apps.
- — React-specific patterns and best practices for Capacitor apps.
- — Vue-specific patterns and best practices for Capacitor apps.
- — Install and configure Capacitor plugins after app creation.
- — Set up live updates, native builds, and CI/CD for the app.