New Tech and AI Integration Evaluation
Purpose
Decide whether to adopt a new library / framework version / AI capability with evidence — bundle impact, type safety, maintenance health, security, migration cost — not hype. Default to skepticism: proven "boring" tech is the baseline, and each new dependency spends an innovation token — the burden is on the candidate to beat what you'd otherwise write or already use.
Universal — evaluation rubric (size / types / maintenance / migration / license / a11y) applies to any frontend stack; size-check tools differ.
Procedure
New library evaluation
Measure bundle impact first
- Primary: Bundlephobia for the candidate
- Fallback when Bundlephobia data is stale or missing (a known issue since ~2024): pkg-size.dev or
npx vite-bundle-visualizer against a real install
- Look at min+gzip (what users actually download), NOT raw size
- Check tree-shakability — a 200KB library that tree-shakes to 8KB beats a 30KB monolith
- Gate library adoption on size delta in PR review
TypeScript support quality
- First-class TypeScript (types shipped with library) >> @types/* package >> @ts-ignore needed
- Check: do the types actually represent runtime behavior, or are they
any underneath?
Maintenance health
- Last release date (< 6 months)
- Open issue count + median response time
- Number of contributors (bus factor > 1)
- Major-version stability (breaking changes every 6 months = high migration cost)
- Adoption momentum: downloads/week trend (not absolute), is it the de-facto choice or a niche bet? A well-maintained library the community has moved away from is still a risk
Migration cost (build vs borrow) — and exit cost
- Hours to integrate
- Hours to migrate existing code (if replacing something)
- Hours of ongoing maintenance (updates, breaking-change handling)
- Exit cost, not just entry cost: how hard is it to remove later? A thin wrapper is cheap to swap; something that metastasizes through the codebase (ORM, state lib, styling system) is high lock-in — weight that as a one-way-door decision (see
decision-records)
- Compatibility: supported React/Node versions, peer-dep conflicts, and Server Component support — a client-only library forces
'use client' and drags its subtree into the client bundle (see bundle-optimization)
- Compare to "just write it ourselves" — sometimes 200 lines is cheaper than a dep
4b. License compatibility
- Safe for commercial use: MIT, Apache 2.0, BSD-2-Clause, BSD-3-Clause, ISC
- Caution required: LGPL (linking restrictions), MPL (file-level copyleft)
- Avoid for closed-source products: GPL, AGPL — viral copyleft
- Check transitive deps too (a dual-licensed top-level dep can still pull GPL deps)
4c. Accessibility (for UI libraries)
- Keyboard navigation works out of the box?
- ARIA attributes correct?
prefers-reduced-motion honored?
- Non-negotiable for UI libraries — a "great DX" component that fails a11y becomes tech debt fast
4d. Security & supply-chain
- Known vulnerabilities:
npm audit / Snyk / OSV against the candidate and its transitive tree
- Maintainer trust: recent ownership transfer, a typosquatted name, or a lone unverified maintainer = supply-chain risk
- Each dependency is attack surface and install-time code (postinstall scripts) — fewer, well-vetted deps beat many convenient ones (see
security-audit)
POC code
- Use the candidate in an actual project pattern, not a toy example
- Benchmark against current solution if replacing one
- Document what worked and what didn't
Document decision in ADR (see decision-records skill for template — MADR recommended for 3+ alternatives)
- Even rejections deserve an ADR — saves the team from re-evaluating the same library in 6 months
React / Next.js major upgrade
- Read the official migration guide thoroughly
- Run the codemod (Next.js ships codemods for major version bumps)
- Audit deprecated APIs in build output
- Update one feature area at a time, ship incrementally
AI integration evaluation
Streaming UI patterns
- Server Action returns
ReadableStream → render progressively via useChat or custom reader
- Loading state shows partial output as it arrives (don't block UI on complete response)
3-state handling for AI responses
- Streaming: progressive render + visible "AI is thinking" indicator
- Complete: final state with regenerate button
- Failed: error message + retry + fallback path
Human-in-the-loop gates
- For high-stakes AI output (financial, legal, medical, code-deploy)
- Always show the AI output for review before applying
- Audit trail: who approved, when, what input produced it
Graceful degradation
- AI API down? App should keep working via non-AI flow
- Never make the AI a single point of failure
- Cache previous AI responses where it makes sense
Cost monitoring
- Track tokens per session, per user
- Alert on cost spikes (often signals a prompt-injection or loop bug)
Trust boundary: protect what goes in, distrust what comes out
- Prompt injection: untrusted content in the prompt can hijack instructions — don't interpolate user/third-party text into a system prompt unguarded
- Treat AI output as untrusted input: never
dangerouslySetInnerHTML it or run it as code/SQL without validation — it's an XSS/RCE vector like any user input
- Data governance: user data sent to a third-party API leaves your boundary — scrub PII, check data-retention / training opt-out and region/compliance
- (see
security-audit)
Pin the model + add an eval harness
- Pin the model / API version — outputs drift across versions, so an "upgrade" can silently regress your feature
- You can't assert exact strings: build an eval set (golden cases, LLM-as-judge) to catch quality regressions (see
test-strategy)
Completion Criteria
Output
- POC code: branch
poc/<library-or-feature-name> with realistic usage (not toy example), benchmark script in scripts/poc-benchmark-<name>.ts
- Evaluation report:
docs/evaluations/<library-or-feature>-YYYY-MM-DD.md with sections:
## Bundle impact (Bundlephobia + actual analyzer numbers)
## TypeScript support (first-class / @types / @ts-ignore needed)
## Maintenance health (last release, contributors, issue response)
## Migration cost (estimated hours)
## License compatibility (MIT / Apache / GPL / etc.)
## A11y (if UI library)
## Verdict (adopt / reject / re-evaluate in N months)
- Decision ADR:
docs/adr/ADR-NNN-adopt-<library>.md (or reject-) — even rejections deserve documentation
- AI integration only: streaming UI implementation, HITL gate code, graceful degradation fallback
Implementation
React + Next.js (default)
- Size check: Bundlephobia / pkg-size.dev /
npx vite-bundle-visualizer
- Security/supply-chain:
npm audit / OSV-Scanner / Snyk; check the candidate's transitive tree
- Server Component compat: does the lib work without
'use client'? Client-only libs inflate the client bundle (cross-check bundle-optimization)
- React/Next.js major upgrade: official codemods (
npx @next/codemod)
- AI streaming: Server Action returning
ReadableStream + useChat (Vercel AI SDK) or custom reader
- AI evals: pin the model id; golden-set or LLM-as-judge eval suite for regression (cross-check
test-strategy)
- Build-time check:
next build warns on deprecated APIs
Other stacks
- Vue / Nuxt: same Bundlephobia; Nuxt has its own codemods for major upgrades
- SvelteKit: same Bundlephobia; SvelteKit migration guides per release
- Angular: same Bundlephobia; Angular's
ng update handles major version upgrades automatically (best-in-class)
- AI streaming (any framework):
ReadableStream is a web standard — adapter pattern works across stacks; differences are in how the framework's streaming primitives consume it
Related skills
decision-records — every adoption decision results in an ADR; weigh adoption as a one-way vs two-way door
bundle-optimization — size delta + Server Component compatibility are key adoption gates
security-audit — dependency supply-chain risk and treating AI output as untrusted
test-strategy — eval harness for non-deterministic AI features
Reference
- Key insight encoded: Always compare on min+gzip + tree-shakability — a 200KB library that tree-shakes to 8KB beats a 30KB monolith. Gate library adoption on Bundlephobia size delta in PR review, and check Server Component compatibility (client-only libs balloon the bundle). Evaluate exit cost and supply-chain risk, not just entry cost — and default to boring/proven tech. For AI integration, the HITL gate is mandatory for high-stakes output (review + audit trail), AI is never a single point of failure, and crucially: treat AI output as untrusted input (don't render/execute it unsanitized) and pin the model behind an eval harness so version drift doesn't silently regress quality.
1---2name: new-tech-evaluation3description: Evaluate a new library, framework version, or AI integration with bundle size, TypeScript support, maintenance status, security/supply-chain, and migration + exit cost. POC + benchmark before adoption. Use at quarterly tech review, when a new library could solve a pain point, on a React/Next.js major version release, or on AI API major updates. Not for recording the resulting decision (use decision-records) or shrinking an already-adopted dependency (use bundle-optimization).4license: MIT5---67# New Tech and AI Integration Evaluation89## Purpose10Decide whether to adopt a new library / framework version / AI capability with evidence — bundle impact, type safety, maintenance health, security, migration cost — not hype. Default to skepticism: proven "boring" tech is the baseline, and each new dependency spends an innovation token — the burden is on the candidate to beat what you'd otherwise write or already use.1112**Universal** — evaluation rubric (size / types / maintenance / migration / license / a11y) applies to any frontend stack; size-check tools differ.1314## Procedure1516### New library evaluation17181. **Measure bundle impact first**19 - Primary: [Bundlephobia](https://bundlephobia.com/) for the candidate20 - **Fallback when Bundlephobia data is stale or missing** (a known issue since ~2024): [pkg-size.dev](https://pkg-size.dev/) or `npx vite-bundle-visualizer` against a real install21 - Look at min+gzip (what users actually download), NOT raw size22 - Check tree-shakability — a 200KB library that tree-shakes to 8KB beats a 30KB monolith23 - Gate library adoption on size delta in PR review24252. **TypeScript support quality**26 - First-class TypeScript (types shipped with library) >> @types/* package >> @ts-ignore needed27 - Check: do the types actually represent runtime behavior, or are they `any` underneath?28293. **Maintenance health**30 - Last release date (< 6 months)31 - Open issue count + median response time32 - Number of contributors (bus factor > 1)33 - Major-version stability (breaking changes every 6 months = high migration cost)34 - Adoption momentum: downloads/week trend (not absolute), is it the *de-facto* choice or a niche bet? A well-maintained library the community has moved away from is still a risk35364. **Migration cost (build vs borrow) — and exit cost**37 - Hours to integrate38 - Hours to migrate existing code (if replacing something)39 - Hours of ongoing maintenance (updates, breaking-change handling)40 - **Exit cost, not just entry cost**: how hard is it to *remove* later? A thin wrapper is cheap to swap; something that metastasizes through the codebase (ORM, state lib, styling system) is high lock-in — weight that as a one-way-door decision (see `decision-records`)41 - Compatibility: supported React/Node versions, peer-dep conflicts, and **Server Component support** — a client-only library forces `'use client'` and drags its subtree into the client bundle (see `bundle-optimization`)42 - Compare to "just write it ourselves" — sometimes 200 lines is cheaper than a dep43444b. **License compatibility**45 - **Safe for commercial use**: MIT, Apache 2.0, BSD-2-Clause, BSD-3-Clause, ISC46 - **Caution required**: LGPL (linking restrictions), MPL (file-level copyleft)47 - **Avoid for closed-source products**: GPL, AGPL — viral copyleft48 - Check transitive deps too (a dual-licensed top-level dep can still pull GPL deps)49504c. **Accessibility (for UI libraries)**51 - Keyboard navigation works out of the box?52 - ARIA attributes correct?53 - `prefers-reduced-motion` honored?54 - Non-negotiable for UI libraries — a "great DX" component that fails a11y becomes tech debt fast55564d. **Security & supply-chain**57 - Known vulnerabilities: `npm audit` / Snyk / OSV against the candidate *and* its transitive tree58 - Maintainer trust: recent ownership transfer, a typosquatted name, or a lone unverified maintainer = supply-chain risk59 - Each dependency is attack surface and install-time code (postinstall scripts) — fewer, well-vetted deps beat many convenient ones (see `security-audit`)60615. **POC code**62 - Use the candidate in an actual project pattern, not a toy example63 - Benchmark against current solution if replacing one64 - Document what worked and what didn't65666. **Document decision in ADR** (see `decision-records` skill for template — MADR recommended for 3+ alternatives)67 - Even rejections deserve an ADR — saves the team from re-evaluating the same library in 6 months6869### React / Next.js major upgrade70711. **Read the official migration guide thoroughly**722. **Run the codemod (Next.js ships codemods for major version bumps)**733. **Audit deprecated APIs in build output**744. **Update one feature area at a time, ship incrementally**7576### AI integration evaluation77781. **Streaming UI patterns**79 - Server Action returns `ReadableStream` → render progressively via `useChat` or custom reader80 - Loading state shows partial output as it arrives (don't block UI on complete response)81822. **3-state handling for AI responses**83 - **Streaming**: progressive render + visible "AI is thinking" indicator84 - **Complete**: final state with regenerate button85 - **Failed**: error message + retry + fallback path86873. **Human-in-the-loop gates**88 - For high-stakes AI output (financial, legal, medical, code-deploy)89 - Always show the AI output for review before applying90 - Audit trail: who approved, when, what input produced it91924. **Graceful degradation**93 - AI API down? App should keep working via non-AI flow94 - Never make the AI a single point of failure95 - Cache previous AI responses where it makes sense96975. **Cost monitoring**98 - Track tokens per session, per user99 - Alert on cost spikes (often signals a prompt-injection or loop bug)1001016. **Trust boundary: protect what goes in, distrust what comes out**102 - Prompt injection: untrusted content in the prompt can hijack instructions — don't interpolate user/third-party text into a system prompt unguarded103 - Treat AI output as untrusted input: never `dangerouslySetInnerHTML` it or run it as code/SQL without validation — it's an XSS/RCE vector like any user input104 - Data governance: user data sent to a third-party API leaves your boundary — scrub PII, check data-retention / training opt-out and region/compliance105 - (see `security-audit`)1061077. **Pin the model + add an eval harness**108 - Pin the model / API version — outputs drift across versions, so an "upgrade" can silently regress your feature109 - You can't assert exact strings: build an eval set (golden cases, LLM-as-judge) to catch quality regressions (see `test-strategy`)110111## Completion Criteria112- [ ] POC code exists for the candidate, not just docs reading113- [ ] Bundle impact measured (Bundlephobia + actual analyzer)114- [ ] Security/supply-chain checked (`npm audit`/OSV clean, maintainer trust); Server Component compatibility verified115- [ ] Exit cost / lock-in assessed, not just integration cost116- [ ] Decision documented in ADR (adopt or reject — both deserve documentation)117- [ ] For AI integration: 3-state UI implemented, HITL gate for high-stakes output, graceful degradation verified118- [ ] For AI: output treated as untrusted (not rendered/executed unsanitized); model version pinned + eval harness in place119120## Output121- **POC code**: branch `poc/<library-or-feature-name>` with realistic usage (not toy example), benchmark script in `scripts/poc-benchmark-<name>.ts`122- **Evaluation report**: `docs/evaluations/<library-or-feature>-YYYY-MM-DD.md` with sections:123 - `## Bundle impact` (Bundlephobia + actual analyzer numbers)124 - `## TypeScript support` (first-class / @types / @ts-ignore needed)125 - `## Maintenance health` (last release, contributors, issue response)126 - `## Migration cost` (estimated hours)127 - `## License compatibility` (MIT / Apache / GPL / etc.)128 - `## A11y` (if UI library)129 - `## Verdict` (adopt / reject / re-evaluate in N months)130- **Decision ADR**: `docs/adr/ADR-NNN-adopt-<library>.md` (or `reject-`) — even rejections deserve documentation131- **AI integration only**: streaming UI implementation, HITL gate code, graceful degradation fallback132133## Implementation134135### React + Next.js (default)136- Size check: Bundlephobia / pkg-size.dev / `npx vite-bundle-visualizer`137- Security/supply-chain: `npm audit` / OSV-Scanner / Snyk; check the candidate's transitive tree138- Server Component compat: does the lib work without `'use client'`? Client-only libs inflate the client bundle (cross-check `bundle-optimization`)139- React/Next.js major upgrade: official codemods (`npx @next/codemod`)140- AI streaming: Server Action returning `ReadableStream` + `useChat` (Vercel AI SDK) or custom reader141- AI evals: pin the model id; golden-set or LLM-as-judge eval suite for regression (cross-check `test-strategy`)142- Build-time check: `next build` warns on deprecated APIs143144### Other stacks145- **Vue / Nuxt**: same Bundlephobia; Nuxt has its own codemods for major upgrades146- **SvelteKit**: same Bundlephobia; SvelteKit migration guides per release147- **Angular**: same Bundlephobia; Angular's `ng update` handles major version upgrades automatically (best-in-class)148- **AI streaming (any framework)**: `ReadableStream` is a web standard — adapter pattern works across stacks; differences are in how the framework's streaming primitives consume it149150## Related skills151- `decision-records` — every adoption decision results in an ADR; weigh adoption as a one-way vs two-way door152- `bundle-optimization` — size delta + Server Component compatibility are key adoption gates153- `security-audit` — dependency supply-chain risk and treating AI output as untrusted154- `test-strategy` — eval harness for non-deterministic AI features155156## Reference157- **Key insight encoded**: Always compare on min+gzip + tree-shakability — a 200KB library that tree-shakes to 8KB beats a 30KB monolith. Gate library adoption on Bundlephobia size delta in PR review, and check Server Component compatibility (client-only libs balloon the bundle). Evaluate exit cost and supply-chain risk, not just entry cost — and default to boring/proven tech. For AI integration, the HITL gate is mandatory for high-stakes output (review + audit trail), AI is never a single point of failure, and crucially: treat AI output as untrusted input (don't render/execute it unsanitized) and pin the model behind an eval harness so version drift doesn't silently regress quality.