Agent skill
angular-pwa-setup
Add, repair, or validate Angular 20 Progressive Web App support with `@angular/pwa`, including deterministic `ng add` execution, service-worker registration verification, manifest/icon checks, production-build artifact validation, and manual install/offline checks. Use when users ask to set up PWA, fix broken service workers, troubleshoot installability/offline behavior, or review `ngsw-config.json`/`manifest.webmanifest`.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/angular-pwa-setup
SKILL.md
Angular 20 PWA Setup
Goal
Set up or repair Angular 20 PWA support with @angular/pwa so the app has a valid manifest, service worker registration, generated icons, and verifiable install/offline behavior from a production build.
Inputs
projectRoot(string, default: current working directory)projectName(string, optional in multi-project workspaces)registrationStrategy(string, default:registerWhenStable:30000)enabledInDev(boolean, default:false)verifyRuntime(boolean, default:true)
Success Criteria
@angular/pwais installed in dependencies.- PWA scaffolding exists (
manifest.webmanifest, icons,ngsw-config.json). - Angular registers
ngsw-worker.jscorrectly. - Build output includes service worker artifacts (
ngsw.json, worker files). - App passes basic manual checks for installability and offline behavior.
Workflow
- Validate workspace and Angular version
- Confirm
package.jsonandangular.jsonexist. - Confirm
@angular/coremajor version is20. - Stop and report when the 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 no target is given, ask for the project name.
- Apply official PWA integration
- Run the schematic non-interactively:
ng add @angular/pwa --project <projectName> --skip-confirmation
- Keep generated files unless the user explicitly requests customization.
- Verify generated/updated files
- Confirm presence of:
<projectRoot>/ngsw-config.json<sourceRoot>/manifest.webmanifest- icon assets in
<sourceRoot>/iconsor configured public assets path <link rel="manifest" href="manifest.webmanifest">in<sourceRoot>/index.htmltheme-colormeta tag in<sourceRoot>/index.html
- Verify service worker registration wiring
- For standalone bootstrap (preferred in Angular 20), ensure provider exists in
src/app/app.config.ts:
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})
- For NgModule-based apps, ensure equivalent
ServiceWorkerModule.register(...)wiring exists. - Keep production-safe default behavior: enabled only outside dev mode unless
enabledInDev=true. - If
registrationStrategyinput is provided, verify registration uses that exact value.
- Build and confirm artifacts
- Run project build for the selected app:
ng build <projectName>
- Confirm service-worker artifacts are present in output (for example
ngsw.jsonandngsw-worker.js).
- Verify runtime behavior over HTTP server
- If
verifyRuntime=true, serve the production output from a static server (notfile://). - Open in Chrome and verify:
- Application tab shows active service worker
- Manifest is detected and installable
- Offline toggle still loads cached app shell/routes
- Apply minimal, safe customizations when requested
- Only customize
ngsw-config.jsonwhen user asks for explicit asset/data caching behavior. - Keep broad defaults first, then add targeted
assetGroups/dataGroupsrules. - Avoid overcaching API calls unless TTL/versioning strategy is defined.
- Report deterministic completion output
- Include:
- selected
projectName - files created or changed
- registration wiring location (
app.config.tsor module file) - build command run and artifact paths found
- runtime verification result (or reason skipped)
Troubleshooting Rules
ng addfails
- Confirm Angular CLI and workspace dependencies are consistent.
- Re-run with explicit
--projectin multi-project repos.
- Service worker never activates
- Confirm app is served from built output via HTTP(S), not
ng servein normal dev mode. - Confirm registration code exists and
enabledevaluates totruein production.
- Offline mode does not work
- Confirm
ngsw.jsonexists in build output. - Inspect
ngsw-config.jsonpatterns and ensure the tested routes/assets are covered.
- App not installable
- Confirm manifest fields/icons are valid and reachable.
- Confirm HTTPS (or localhost), and no critical PWA warnings in DevTools.
Guardrails
- Prefer schematic-generated defaults before manual edits.
- Merge config changes; do not overwrite unrelated workspace settings.
- Keep environment-aware service worker enablement (
!isDevMode()) by default. - Validate with a real production build before declaring success.
- If runtime verification cannot be executed (for example CI-only environment), explicitly mark as pending manual verification.
Definition of Done
ng add @angular/pwahas been applied successfully for the target app.- Manifest, icons, and service worker registration are present and valid.
- Production build emits service worker artifacts.
- Installability and basic offline behavior are verified.
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?