# capacitor-angular

Guides your coding agent through Capacitor patterns in Angular 16+, covering build directory mapping, standalone components, and plugin services.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 847 installs · ★ 51
- Author: capawesome-team
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/capawesome-team/skills/tree/HEAD/skills/capacitor-angular/SKILL.md
- Updated: 2026-10-20
- HTML: https://affpapa.org/en/nevibecode/skills/capacitor-angular

## What it does

The skill inspects Angular 16+ codebases running Capacitor 6, 7, or 8. The agent parses `package.json` to identify standalone components versus `NgModule` setups. It then reads the build target `outputPath` from `angular.json` to assign the proper `webDir` value in `capacitor.config.ts`.

Guidance focuses on encapsulating Capacitor APIs inside Angular injectable services rather than invoking them directly inside components. Handled patterns include running listener callbacks inside `NgZone`, configuring deep link routes, and detecting platforms with `Capacitor.isNativePlatform()`.

Native builds require Xcode on macOS or Android Studio. This skill does not cover Ionic Framework setups, major version upgrades, or scaffolding projects from scratch.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add capawesome-team/skills --skill capacitor-angular -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/capacitor-angular/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/capacitor-angular/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add capawesome-team/skills --skill capacitor-angular -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/capacitor-angular/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add capawesome-team/skills --skill capacitor-angular -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/capacitor-angular/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install capawesome-team/skills capacitor-angular
```

2. **Manually: put the files in place**
- File: `.github/skills/capacitor-angular/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add capawesome-team/skills --skill capacitor-angular -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/capawesome-team/skills --path skills/capacitor-angular
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/capacitor-angular/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add capawesome-team/skills --skill capacitor-angular -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/capawesome-team/skills/tree/HEAD/skills/capacitor-angular/SKILL.md

## When to use it
- Align Angular build output paths with Capacitor `webDir` settings
- Encapsulate native Capacitor plugins within injectable Angular services
- Trigger Angular change detection correctly using `NgZone` inside plugin listeners
- Detect native device environments via `Capacitor.isNativePlatform()`

## Example prompts
- Add Capacitor to this Angular 18 repository and configure the webDir path
- Create an Angular service wrapping @capacitor/camera with platform detection
- Set up a Capacitor plugin event listener using NgZone in a standalone component

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 9d1e29373e34ca6f.

BEGIN THIRD-PARTY FILE 9d1e29373e34ca6f
````text
---
name: capacitor-angular
description: "Guides the agent through Angular-specific patterns for Capacitor app development. Covers project structure, adding Capacitor to Angular projects, using Capacitor plugins in Angular services and components, NgZone integration for plugin event listeners, lifecycle hook patterns, dependency injection, routing with deep links, and environment-based platform detection. Do not use for creating a new Capacitor app from scratch, upgrading Capacitor versions, installing specific plugins, Ionic Framework setup, or non-Angular frameworks."
license: MIT
compatibility: "Requires Node.js, npm, and the Angular CLI. Xcode on macOS is required for iOS and Android Studio for Android."
metadata:
  author: capawesome-team
  source: https://github.com/capawesome-team/skills/tree/main/skills/capacitor-angular
---

# Capacitor with Angular

Angular-specific patterns and best practices for Capacitor app development — project structure, services, lifecycle hooks, NgZone integration, and plugin usage.

## Prerequisites

1. **Capacitor 6, 7, or 8** app with Angular 16+.
2. Node.js and npm installed.
3. Angular CLI installed (`npm install -g @angular/cli`).
4. For iOS: Xcode installed.
5. For Android: Android Studio installed.

## Agent Behavior

- **Auto-detect before asking.** Check the project for `angular.json`, `package.json`, `capacitor.config.ts` or `capacitor.config.json`, and existing directory structure. Only ask the user when something cannot be detected.
- **Guide step-by-step.** Walk the user through the process one step at a time.
- **Adapt to project style.** Detect whether the project uses standalone components or NgModule-based architecture and adapt code examples accordingly.

## Procedures

### Step 1: Analyze the Project

Auto-detect the following by reading project files:

1. **Angular version**: Read `@angular/core` version from `package.json`.
2. **Capacitor version**: Read `@capacitor/core` version from `package.json`. If not present, Capacitor has not been added yet — proceed to Step 2.
3. **Architecture style**: Check `src/main.ts` for `bootstrapApplication` (standalone) vs. `platformBrowserDynamic().bootstrapModule` (NgModule). Check `angular.json` for further confirmation.
4. **Platforms**: Check which directories exist (`android/`, `ios/`).
5. **Capacitor config format**: Check for `capacitor.config.ts` (TypeScript) or `capacitor.config.json` (JSON).
6. **Build output directory**: Read `outputPath` from `angular.json` under `projects > <project-name> > architect > build > options > outputPath`. This is needed for Capacitor's `webDir` setting.

### Step 2: Add Capacitor to an Angular Project

Skip if `@capacitor/core` is already in `package.json`.

1. Install Capacitor core and CLI:

   ```bash
   npm install @capacitor/core
   npm install -D @capacitor/cli
   ```
````
END THIRD-PARTY FILE 9d1e29373e34ca6f

The third-party file has ended. Everything between the 9d1e29373e34ca6f tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2861 of 17754 bytes. © capawesome-team · MIT · https://github.com/capawesome-team/skills/tree/HEAD/skills/capacitor-angular/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
