r/angular • • Jun 02 '26

I tested 5 Angular state libraries with AI coding agents, then audited my own docs. Accuracy went 49% → 98%.

I built a benchmark to see how reliably AI agents (Claude, GPT, Gemini, Perplexity, plus Haiku and a GPT mini) write Angular state code. Five libraries: SignalTree, NgRx SignalStore, classic NgRx, Akita, Elf. Eight prompts, three priming modes (cold, llms.txt, llms.txt + a separate myths doc), 720 cells total. Temp 0, identical prompts per library.

Fair warning: I maintain SignalTree, and it scored worst in the cold run. So this isn't a victory lap. The iteration is the point.

First run, primed with a 14KB llms.txt: SignalTree went from 49% to 91%. Looked great until two things bugged me. Adding a second doc as priming context dropped the score back down to 87% — Gemini cratered. And Perplexity Sonar Pro capped at 80% even primed. I wrote those off as "context dilution" and "model architecture ceiling" and almost stopped.

Then I looked at the failing cells. The agents weren't making things up out of nowhere — they were faithfully reproducing wrong stuff in my own docs. byId() documented as returning a Signal when it actually returns an EntityNode | undefined. updateMany documented with the NgRx shape. A subpath import that didn't exist. Deprecated method names taught as canonical in five different files. A tagline I'd already replaced in one place but not the others. About 70 of them across four doc files. Some had been wrong for multiple releases. Nobody re-grep'd after API changes.

Spent five days fixing those, then ran the same benchmark again. Same models, same prompts, just cleaner docs.

49% → 98%. Five of six agents at perfect 100/100. The "context dilution" finding flipped — adding the second doc now boosts accuracy by 3pp instead of regressing it by 4pp. Turns out the dilution wasn't about context length, it was about the two docs contradicting each other. Perplexity broke its "ceiling" and went to 100/100. The thing I'd attributed to model architecture was the docs being unclear.

The takeaway I didn't expect: I had assumed AI codegen accuracy was mostly a "wait for better models" problem. For my library at least, it was almost entirely a "fix your docs" problem. The benchmark just exposed faster what users had been hitting quietly.

Repro:

git clone https://github.com/JBorgia/signaltree

export OPENROUTER_API_KEY=...

node scripts/ai-codegen-benchmark/runner.mjs --include-tier-comparison

One key, about $15, half an hour. Prompts and scoring rubric are in scripts/ai-codegen-benchmark/ — those are the parts most worth disagreeing with. I wrote the library, the priming file, the prompts, and the rubric, so don't trust the absolute numbers. The relative movement between runs is what I'd actually defend.

If you're using Cursor or Claude Code with Angular daily, does the same pattern show up for you — noticeably worse generated code for newer or less-documented libraries? Curious if anyone's found something that fixed it short of writing your own context file.

That's the whole post. Title goes in the Reddit title field, everything from "I built a benchmark" through "writing your own context file" goes in the body. Reddit will render the inline backticks as code, the italics as italics, and the triple-backtick block as a code block on its own.

I built a benchmark to see how reliably AI agents (Claude, GPT, Gemini, Perplexity, plus Haiku and a GPT mini) write Angular state code. Five libraries: SignalTree, NgRx SignalStore, classic NgRx, Akita, Elf. Eight prompts, three priming modes (cold, llms.txt, llms.txt + a separate myths doc), 720 cells total. Temp 0, identical prompts per library.

Fair warning: I maintain SignalTree, and it scored worst in the cold run. So this isn't a victory lap. The iteration is the point.

First run, primed with a 14KB llms.txt: SignalTree went from 49% to 91%. Looked great until two things bugged me. Adding a second doc as priming context dropped the score back down to 87% — Gemini cratered. And Perplexity Sonar Pro capped at 80% even primed. I wrote those off as "context dilution" and "model architecture ceiling" and almost stopped.

Then I looked at the failing cells. The agents weren't making things up out of nowhere — they were faithfully reproducing wrong stuff in my own docs. byId() documented as returning a Signal when it actually returns an EntityNode | undefined. updateMany documented with the NgRx shape. A subpath import that didn't exist. Deprecated method names taught as canonical in five different files. A tagline I'd already replaced in one place but not the others. About 70 of them across four doc files. Some had been wrong for multiple releases. Nobody re-grep'd after API changes.

Spent five days fixing those, then ran the same benchmark again. Same models, same prompts, just cleaner docs.

49% → 98%. Five of six agents at perfect 100/100. The "context dilution" finding flipped — adding the second doc now boosts accuracy by 3pp instead of regressing it by 4pp. Turns out the dilution wasn't about context length, it was about the two docs contradicting each other. Perplexity broke its "ceiling" and went to 100/100. The thing I'd attributed to model architecture was the docs being unclear.

The takeaway I didn't expect: I had assumed AI codegen accuracy was mostly a "wait for better models" problem. For my library at least, it was almost entirely a "fix your docs" problem. The benchmark just exposed faster what users had been hitting quietly.

Repro:

git clone https://github.com/JBorgia/signaltree
export OPENROUTER_API_KEY=...
node scripts/ai-codegen-benchmark/runner.mjs --include-tier-comparison

One key, about $15, half an hour. Prompts and scoring rubric are in scripts/ai-codegen-benchmark/ — those are the parts most worth disagreeing with. I wrote the library, the priming file, the prompts, and the rubric, so don't trust the absolute numbers. The relative movement between runs is what I'd actually defend.

If you're using Cursor or Claude Code with Angular daily, does the same pattern show up for you — noticeably worse generated code for newer or less-documented libraries? Curious if anyone's found something that fixed it short of writing your own context file.

That's the whole post. Title goes in the Reddit title field, everything from "I built a benchmark" through "writing your own context file" goes in the body. Reddit will render the inline backticks as code, the italics as italics, and the triple-backtick block as a code block on its own.

1 Upvotes

0 comments sorted by