agentleFS
Phaedra-SolutionsPhaedra-Solutions/cursor-rules/skills/migrate-angularjs/SKILL.md

migrate-angularjs

Skill4 starsChanged 10 days agoMITView on GitHub

Plan and run a migration off AngularJS 1.x (EOL since 31 Dec 2021, unfixed CVEs) to Angular - choose between an incremental hybrid with ngUpgrade (@angular/upgrade), a per-route strangler rewrite, or a full rewrite; prepare the AngularJS code (1.8.3, components, TypeScript, a bundler, tests); then move services and components feature by feature and remove AngularJS. Use when asked to migrate, upgrade or replace AngularJS, or when legacy/angularjs applies and the user wants out.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 5 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user to choose an approach (explain the trade-offs):

    line 21
  2. Very specific:

    Follow the AngularJS style that maps to Angular: one component per file, .component() with </& bindings instead of $scope-heavy controllers …

    line 33
  3. Very specific:

    Create the Angular app (standalone bootstrap) and add @angular/upgrade.

    line 39
  4. Very specific:

    Remove AngularJS when no AngularJS components, services or routes remain.

    line 43
  5. Very specific:

    Put both apps behind one origin (reverse proxy or server routing).

    line 47
  6. Distinctive:

    Keep shared chrome (header, navigation) visually consistent.

    line 49
  7. Very specific:

    Verify (next section); show the diff and results.

    line 53
  8. Very specific:

    Keep the security controls from legacy/angularjs (CSP, no trustAs*, no user-controlled templates) on the AngularJS side until it's gone.

    line 54
  9. Distinctive:

    Check in the browser: migrated features behave the same (forms, validation messages, routing, deep links), no console errors from either …

    line 67
  10. Distinctive:

    Never rewrite everything in one change.

    line 71
  11. Very specific:

    Never relax $sce or CSP to make hybrid templates work.

    line 72
  12. Very specific:

    Never leave two-way data sharing via $rootScope events as the integration layer.

    line 73
  13. Distinctive:

    Never auto-commit, push or deploy.

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Migrate AngularJS → Angular

When to use

  • The app depends on angular 1.x and the user wants to move to Angular (or another framework).
  • Security review flagged the unfixed AngularJS CVEs (see legacy/angularjs).

Before you start

  • Inventory: AngularJS version, module count, routes (ngRoute or ui-router), directives with link/compile functions, filters, $scope usage, third-party AngularJS modules, build tool (none, gulp, grunt, webpack), and test coverage.
  • Ask the user to choose an approach (explain the trade-offs):
    • Hybrid (ngUpgrade): AngularJS and Angular run in one page; migrate component by component. Best for large apps that must keep shipping. Requires a bundler and TypeScript.
    • Strangler (per route): a new Angular app serves migrated routes; a proxy or server routes the rest to the old app. Simpler runtime, but shared UI (header, auth) must exist in both.
    • Full rewrite: for small apps or ones with little reusable logic; freeze the old app behind compensating controls until cut-over.
  • Target: the current Angular major (22; see frontend/angular) with standalone components.
  • Working tree clean; new branch; E2E tests (Playwright or Cypress) for main flows. Add them first if missing.

Steps

Prepare the AngularJS app (all approaches)

  1. Upgrade to AngularJS 1.8.3 and fix console warnings.
  2. Follow the AngularJS style that maps to Angular: one component per file, .component() with </& bindings instead of $scope-heavy controllers and two-way = bindings, services instead of $rootScope events, controllerAs syntax.
  3. Introduce a module bundler (webpack or Vite) and TypeScript for the AngularJS code if they're missing; replace script-tag ordering with imports.
  4. Replace jQuery-heavy directives and AngularJS-only third-party modules with plain code or libraries that have Angular equivalents.

Hybrid with ngUpgrade

  1. Create the Angular app (standalone bootstrap) and add @angular/upgrade; bootstrap the hybrid with UpgradeModule (or downgradeModule for lazy Angular).
  2. Migrate services first (upgrade AngularJS services with providers, or write Angular services and downgrade them with downgradeInjectable).
  3. Migrate leaf components to Angular and expose them to AngularJS templates with downgradeComponent; upgrade AngularJS components that Angular needs with UpgradeComponent only temporarily.
  4. Move routing last: switch the router to Angular's once most routes' components are Angular, keeping AngularJS routes behind a catch-all during the transition.
  5. Remove AngularJS when no AngularJS components, services or routes remain; drop @angular/upgrade.

Strangler

  1. Put both apps behind one origin (reverse proxy or server routing); share auth via HttpOnly cookies.
  2. Rebuild a route in Angular, switch the proxy for that path, and delete the AngularJS route; repeat.
  3. Keep shared chrome (header, navigation) visually consistent; move it early or render it in both.

Every step

  • Verify (next section); show the diff and results; wait for approval before the next feature. Commit only when asked (git-commit skill).
  • Keep the security controls from legacy/angularjs (CSP, no trustAs*, no user-controlled templates) on the AngularJS side until it's gone.

Verify

npm ci
npx ng build && npx ng test --watch=false    # Angular side
npm test                                     # AngularJS side (Karma or the existing runner)
npx playwright test                          # or Cypress: the same E2E suite against the current build
npm audit --audit-level=moderate
npm ls angular @angular/core @angular/upgrade

Check in the browser: migrated features behave the same (forms, validation messages, routing, deep links), no console errors from either framework, and change detection works across the boundary (values update both ways).

Safety

  • Never rewrite everything in one change; migrate one feature or route per change with E2E coverage.
  • Never relax $sce or CSP to make hybrid templates work.
  • Never leave two-way data sharing via $rootScope events as the integration layer; use services.
  • Never auto-commit, push or deploy.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.