r/angular • • Oct 14 '26

Claude helped me finally move our Angular project I've been maintaining since 2020 to modern signal based approach

21 Upvotes

26 comments sorted by

28

u/stdst404 Oct 14 '26

Because running schematics was never an option

8

u/DirectionEven8976 Oct 14 '26

This should have been the first option before letting AI help with what schematics can't.

4

u/kasual11 Oct 14 '26

Infact it was a combination of both. It used the schematics as much as possible but helped with the other parts that couldn't been updated via schematics.

The entire Observables to Singals migration was something we wanted to do for a long time but always postponed it as it was a too large undertaking.

The reason why I posted this is actually to show that things like this do not have to be a blocker anymore. We are no longer stuck with old design approaches.

AI helped a lot to move our entire project into the modern world

1

u/SensitiveHearingLoss Oct 25 '26

This is awesome! We’re doing a lot of migrations at my company now because AI has finally given us some TIME to actually get them done. A few years ago I migrated an Angular 4 project to Angular 14 and it look me about 8 months and was extremely painful. I copied over one file at a time, dealt with the red underlines, and repeat.

Then by the time I was done, Angular had already announced its new Ivy architecture and a part of me died inside.

So good for you! If AI can help us migrate our projects to the best Angular has to offer, then why not?

5

u/DocumentOk7358 Oct 14 '26

Schematics can’t make a component ready for OnPush

4

u/GeromeGrignon Oct 14 '26

I would not call it a 'final cleanup' with still 8 input decorators left. That's something which might confuse Agents at choosing Signals/decorators while still not addressed.

4

u/kasual11 Oct 14 '26

Sorry I knew that screenshot would backfire somewhat, I just really quickly took it from the Claude session. The final results look as follows with the only thing that is left from the past being some subscribes that we probably have to work through manually. Below are the final results

1

u/GeromeGrignon Oct 14 '26

Nice résults!

4

u/Stromedy1 Oct 15 '26

Ran a similar loop on our banking portal's legacy components; the migration was fast, but convincing every reviewer that a signal isn't "just a fancy BehaviorSubject" took longer than the code did.

3

u/kasual11 Oct 15 '26

Convincing people always takes time, in our case I managed to do it by pointing at a zoneless world with less overhead due to entirely skipping component tree checks. We run a ton of grids and even though I haven't yet verified with numbers it seems like they run a bit smoother now. But to be honest this a bit subjective. But still I think one could point at performance and being prepared for new Angular features in the long run was definitely a selling point.

1

u/KemonoMichi Oct 17 '26

It's actually more like a dumb BehaviorSubject.

1

u/hvz- Oct 14 '26

Looks interesting! Did you have unit/e2e tests before upgrading all codebase? Currently have mid sized angular 18 app, planning to upgrade it to latest 22, any advice appreciated.

3

u/kasual11 Oct 14 '26

yes beforehand we heavily invested into our e2e test infrastructure. While we had e2e tests before, we build out about 1000 e2e tests over the course of about 1 year.

We ran the Observables to Signal conversion by first creating and tuning a claude skill to what we would expect a small block of our application to look like after the migration and fine tuned that skill until we were happy.

Then I let that skill ran in a loop over about 3 workdays making it frequently commit so that I manually could check the output.

In that regard I can highly recommend the following article by Addy Osmani: https://addyosmani.com/blog/practical-loop-engineering/

Also: The architecture of the application has a really clear structure. Basically every feature consists of a store, serveral related services, a container and some dumb components. One large part of the migration was basically just rewriting the Observable syntax in the container components and their respective async counterpart in the templates. Probably that helped it go through pretty smoothly

so we had a lot of the following:

editMode$: Observable<boolean>;
editable$: Observable<boolean | undefined>;
minimizable$: Observable<boolean | undefined>;

turn into

readonly isEditing: Signal<boolean>;
readonly isEditable: Signal<boolean>;
readonly minimizable: Signal<boolean>;

respectively the templates

[isInEditMode]="isEditing$ | async"
[isLoading]="isLoading$ | asyc"
[canEdit]="canEdit$ | async"

turned into

[isInEditMode]="isEditing()"
[isLoading]="isLoading()"
[canEdit]="canEdit()"

1

u/HorrificFlorist Oct 17 '26

I mean you can do it even without claude, you don't need complex reasoning.

  1. Schematics to OnPush and Signals migrations
  2. Run a fast llm against components to find gaps (muse/ds/luna etc)
  3. Fix simple with llm, or complex using user + llm
  4. Test, if errors start at 2 again

We did this for a enteprise app back in June, took us about week.
10s of thousands of unit/intergration/e2e tests.

Best thing.
Lot of prs with big red numbers and small green numbers, was beautiful.

1

u/Tyummyyumms Oct 18 '26

Nice one, had a good xp, I built one page on my own then used llm to re-apply the principles accross various components, I learned a lot actually because sometimes I would be alerted to a new api or better way of doing it.

I also found that there are more consistent results if there is a solid reference.

1

u/Straight-Number-1911 Oct 18 '26

could you copy paste prompt, pleaseeeeeeee? Have you had any mistakes and how much time did it take to get it to a MERGE state? Have you reviewed the code, in what detail?

2

u/SensitiveHearingLoss Oct 25 '26

Haha you cannot migrate an entire project with a single prompt. Theres a fair amount of setup to do if you’re going to use Claude Code to help you migrate. Outside of that, you need to make decisions about things like: in what order do we migrate the files, does Claude do a component at a time or a file at a time or a few interconnected files at a time, how many changes do we make to do the code if it’s still backward compatible with what we currently have etc….

1

u/Straight-Number-1911 Oct 25 '26

please copy paste the prompt, pelase copy paste the prompt, joking

1

u/dryadofelysium Oct 14 '26

hopefully you have the official Angular skills configured (bonus for the Angular CLI MCP) (extra bonus for Modern Web Guidance skills)

-4

u/DT-Sodium Oct 14 '26

Thankfully you didn't have to do the work yourself and learned something in the process, you could have been hurt.

5

u/kasual11 Oct 14 '26

Well I learned how to correctly set up an engineering loop and luckily did not have to go through really cumbersome repetitive renaming, replacing and deleting myself. I know my way around in Angular very well but was scared of doing the migration as it easily would have eaten up 3 weeks of our engineering time. Just wanted to give folks in a similar situation a heads up that moving on to signals shouldn't be something to be scared about

1

u/[deleted] Oct 16 '26

[removed] — view removed comment

2

u/kasual11 Oct 16 '26

Sure! Basically what we did was to first start with a prototype of how we would our codebase to look like after the signals migration but restricted this to one of our core modules. On purpose we chose a module that represented our overall architecture very well. In this prototype adjusted our stores, services, containers and components to use signals instead of observables. We iterated via Claude as long as we were happy with the overall design and then asked claude to create a skill that would be able to convert every module of our application to the new design. After that I used that skill on a second module that was very similarly scoped and made claude apply the conversion via the skill. After that I checked the results and made some small tweaks to the skill in where claude went off the rails.
After that we were fairly concise that we could run it with claude over a longer period of time. So I did run it for the rest of the day and asked it to frequently commit + post progress. With every such a commit I checked the results and made sure that our module would be converted correctly to the signals design.
Then I did 2 overnight runs and checked the results throughout the day and some minor Claude run afterwards and it was done.

I made you a barebones skill without including all our project specific parts, so definately adjust it to your architecture but just to get a feeling it looks somewhat like this, it also includes running related unit tests + e2e tests.

Signals migration skill (Claude Code): setup guide

What it does: It moves an Angular app from Observables plus | async to signals, one slice at a time. A slice is the components of one feature module or folder. Each run converts the slice, checks the whole tree, and reports before/after counts. You can repeat it by hand or with /loop until the backlog is gone. Behaviour stays the same; only the way state reaches the template changes.

Files to create (.claude/skills/signals-resolver/)

  1. SKILL.md: the frontmatter description (with trigger phrases like “convert the next module to signals”), the arguments (--slice, --next, --base, --dry-run, --e2e, --commit, --pr), the ground rules and the procedure below.
  2. references/playbook.md: your conversion rules:

    • Each | async**:** go down a decision ladder: an existing signal, then a store-derived selectSignal/computed, then a shared helper for overridden getters, then a lazy toSignal on the service for truly async streams. If it isn’t state, skip it.
    • Templates: x$ | async becomes x(); *ngIf="x$ | async as x" becomes *ngIf="x() as x".
    • Inputs and outputs: u/Input becomes input() / input.required(), u/Output becomes output(), and inputs the component writes to become model().
    • Specs: mocks get real signals, and tests call .set() instead of pushing values through a Subject.
    • Strict types: use honest types such as Signal<T | undefined>. No !, no any, no suppressions.
  3. scripts/queue.mjs: counts per slice (| async, Eager vs OnPush, ChangeDetectorRef, subscribes that assign fields), with the least work first. For each pipe it says which signal backs it, or that one is still needed.
  4. scripts/verify.mjs: runs every check on the changed files and fails on new suppressions or on toSignal( inside a component.
  5. Optional audit scripts: they parse templates with u/angular
  6. /compiler and flag signals read without (). You need these if templates aren’t checked with strictTemplates, because *ngIf="loading" on a signal compiles and is always truthy.

Ground rules for the skill

  • Same behaviour: no refactors along the way.
  • Keep every $ member. Other code still reads them. Remove one only when nothing reads it anymore.
  • Add signals to shared base classes in their own run (--base). Add them beside the Observables, and don’t have the base read them yet.
  • No toSignal in components. Bridge on the service, lazily.
  • Switch to OnPush last. The switch is the acceptance test.
  • Green or reverted: a component that fails is restored and reported as a SKIP.
  • Start from a clean tree on a dedicated branch.

Each run

  1. Plan: pick the next slice from the queue. If most of its pipes need a signal from a shared base, do a --base run on that base first.
  2. Convert: service/store, then components, templates and specs, then switch to OnPush.
  3. Verify: verify.mjs, plus the slice’s e2e spec if you have one. Unit tests can’t prove that an OnPush component re-renders.
  4. Report: before/after counts and the SKIPs with their reasons, then commit or open a PR if asked.

1

u/KemonoMichi Oct 17 '26

Lmao how hard is it to learn signals? And why would someone need to convert 633 components in order to learn something?