Capacitor app creation

From capawesome-team/skills · View interactive version

Capacitor app creation is an AI agent skill from the GitHub repository capawesome-team/skills. Guides the agent through creating a new Capacitor app from scratch. Covers project scaffolding with the Capacitor CLI, configuring the app (appId, appName, webDir), adding native platforms (iOS, Android), and syncing. Includes decision points for Ionic Framework integration, live updates, and CI/CD

How to use this skill

Skill file

Capacitor App Creation

Create a new Capacitor app from scratch, including project scaffolding, platform setup, and optional integrations.

Prerequisites

  1. Node.js 22+ installed. Verify with node --version.
  2. For iOS: macOS with Xcode 26.0+ installed. Install Xcode Command Line Tools: xcode-select --install.
  3. For Android: Android Studio 2025.2.1+ installed with Android SDK (API 24+).

Agent Behavior

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 ionic-app-creation 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:

  1. Angular
  2. React
  3. Vue
  4. None (vanilla JS/TS or existing web app)

Based on the selection, scaffold the web project:

Angular
npm install -g @angular/cli
ng new my-app
cd my-app

The default web asset directory for Angular is dist/my-app/browser. Adjust the directory name based on the actual project name.

React
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install

The default web asset directory for React (Vite) is dist.

Vue
npm create vite@latest my-app -- --template vue-ts
cd my-app
npm install

The default web asset directory for Vue (Vite) is dist.

None (vanilla or existing web app)

If the user has an existing web app, confirm it meets these requirements:

  1. A package.json file exists at the project root.
  2. A build output directory exists (e.g., dist, www, build).
  3. An index.html file exists at the root of the build output directory.
  4. The index.html file contains a <head> tag (required for Capacitor plugins to work).

If the user wants a vanilla project:

mkdir my-app && cd my-app
npm init -y
mkdir www

Then create www/index.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 www.

Step 3: Install Capacitor

Navigate to the project root directory and install the Capacitor core packages:

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:

npx cap init <appName> <appID> --web-dir <webDir>

This creates a capacitor.config.ts 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
ng build
React / Vue (Vite)
npm run build
Vanilla

No build step needed if using a static www/ 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
npm install @capacitor/android
npx cap add android

This creates the android/ directory with a native Android project.

Add iOS
npm install @capacitor/ios
npx cap add ios

This creates the ios/ 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:

npx cap sync

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
npx cap run android

This prompts for a target device (emulator or physical device).

iOS
npx cap run 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 capawesome-cloud 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 capawesome-cloud skill for CI/CD setup.

Error Handling

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.