Agent skill
angular-capacitor-setup
Add, repair, or validate Capacitor in Angular 20 workspaces with deterministic setup for dependency install, cap init, webDir resolution from angular.json, native platform add/open (android/ios), and build-plus-sync verification. Use when users ask to enable mobile builds, fix broken Capacitor wiring, or standardize Angular-to-native sync workflows.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/angular-capacitor-setup
SKILL.md
Angular 20 Capacitor Setup
Goal
Set up or repair Capacitor in an Angular 20 workspace so web builds sync correctly to native Android/iOS projects and can be run from native tooling.
Inputs
projectRoot(string, default: current working directory)projectName(string, optional in multi-project workspaces)platforms(array, default:['android']; optionalios)appId(string, default: inferred orcom.example.app)appName(string, default: project name)
Success Criteria
- Capacitor packages are installed.
capacitor.config.tsexists and uses the correctwebDir.- At least one native platform is added when requested.
- Angular build output can be copied/synced into native platforms.
- Native project opens/runs from Capacitor CLI commands.
Workflow
- Validate workspace and Angular version
- Confirm
package.jsonandangular.jsonexist. - Confirm
@angular/coremajor version is20. - Stop and report when workspace is not Angular 20.
- Resolve target Angular project
- Read
angular.jsonprojects. - Use explicit
projectNamewhen provided. - If only one application project exists, use it automatically.
- If multiple app projects exist and none is given, ask for
projectNamebefore making changes.
- Install Capacitor dependencies (idempotent)
- If
@capacitor/coreand@capacitor/clialready exist, keep installed versions unless user asked for an upgrade. - Otherwise run:
npm install @capacitor/core @capacitor/cli
- Keep user-managed version pinning/lockfile behavior intact.
- Initialize Capacitor config
- If
capacitor.config.tsorcapacitor.config.jsondoes not exist, run:
npx cap init <appName> <appId>
- Prefer
capacitor.config.ts. - If config already exists, merge updates instead of replacing user settings.
- Set correct
webDirfrom Angular build config
- Inspect target project build output in
angular.jsonand resolve the effective browser output folder. - Set
webDirto the directory containing builtindex.html. - For Angular application builder this is commonly
<outputPath>/browser; do not hardcode, use actual workspace config.
- Add native platform projects
- For each requested platform, run:
npx cap add android
npx cap add ios
- Skip platforms already present.
- On Windows, note that
iosbuild/open requires macOS/Xcode even if files can be configured in repo.
- Build web app and sync native projects
- Build the selected Angular app first:
ng build <projectName>
- Sync web assets/plugins:
npx cap sync
- Use
npx cap copyonly when explicitly needing copy without plugin/native project update.
- Add practical package scripts
- Add or verify scripts in
package.json:
{
"build:cap": "ng build <projectName> && npx cap sync",
"cap:sync": "npx cap sync",
"cap:copy": "npx cap copy",
"cap:update": "npx cap update",
"cap:open:android": "npx cap open android",
"cap:open:ios": "npx cap open ios"
}
- Keep existing user scripts unchanged when unrelated.
- Verify end to end
- Confirm build output exists in configured
webDir. - Run
npx cap syncwith no critical errors. - Open platform project:
npx cap open android
npx cap open ios
- For Android, verify app launches from Android Studio emulator/device.
- If local IDE launch is unavailable (for example CI/headless environment), mark launch verification as pending manual verification.
- Report deterministic completion output
- Include:
- selected
projectName - configured
webDir - platforms added or skipped
- commands run for build/sync/open
- verification result and any pending manual checks
Troubleshooting Rules
cap syncfails becausewebDirnot found
- Re-check Angular
outputPathand fixcapacitor.config.tswebDir. - Rebuild Angular before syncing.
- Native plugin changes not reflected
- Run
npx cap sync(ornpx cap updatewhen native platform deps changed). - Re-open native IDE project after sync.
- Android build fails after adding platform
- Ensure Android SDK/JDK requirements are installed.
- Re-run
npx cap doctorand fix reported environment issues.
- iOS commands fail on non-macOS
- Explain iOS build/open requires macOS with Xcode.
- Keep iOS setup optional on Windows/Linux.
Guardrails
- Always build Angular before
cap sync. - Always derive
webDirfrom actual project config, never hardcode blindly. - Preserve existing Capacitor config keys (
plugins, server options, etc.) during edits. - Avoid deleting/recreating native platform folders unless user explicitly asks.
- Do not run
npx cap addfor platforms that are already added.
Definition of Done
- Capacitor is installed and initialized.
capacitor.config.tspoints to the real Angular build output directory.- Requested native platform(s) are added and synced.
- CLI open/run workflow is verifiably usable.
References
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?