Thanks for contributing! This guide covers everything you need to get from a fresh clone to a merged PR.
- pnpm: 10.17.0 or newer. Use the version pinned in
packageManager(pnpm@11.1.1).- Recommended: install via Corepack. Run
corepack enableonce and pnpm is managed automatically.
- Recommended: install via Corepack. Run
- Git.
git clone https://github.com/TanStack/ai.git
cd ai
pnpm install
pnpm run build:all # build all public packages once so workspace deps resolvepnpm install runs Playwright's chromium download (used by the E2E suite). If you don't need E2E, you can skip it via PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pnpm install.
packages/ # Public, published packages (@tanstack/ai, @tanstack/ai-openai, etc.)
testing/ # Internal test harnesses — NOT published
e2e/ # Playwright + aimock E2E suite (mandatory coverage for all changes)
panel/ # Stream processor visualisation panel
examples/ # Example apps (React, Solid, Vue, Svelte, vanilla)
codemods/ # Internal codemods (not published)
docs/ # Documentation source
scripts/ # Repo-level scripts (doc generation, model sync, link verification)
- Direct children of
packages/are public packages (published to npm). - Everything under
examples/,testing/, andcodemods/is"private": trueand excluded from build/publish. - The build system is Nx with affected-target detection.
- The package manager is pnpm with workspace + catalog protocols.
For deeper architecture details (adapter system, isomorphic tools, framework integrations), see CLAUDE.md at the repo root.
All commands are run from the repo root. Nx handles affected detection and caching.
| Goal | Command |
|---|---|
| Run unit tests (affected) | pnpm test:lib |
| Watch unit tests | pnpm test:lib:dev |
| Type-check (affected) | pnpm test:types |
| Lint (affected) | pnpm test:eslint |
| Verify build artifacts | pnpm test:build |
| Format the repo | pnpm format |
| Build (affected) | pnpm build |
| Build everything | pnpm build:all |
| Run the full CI suite locally | pnpm test |
| Run the affected-PR check | pnpm test:pr |
| E2E suite | pnpm test:e2e |
| E2E with Playwright UI | pnpm test:e2e:ui |
Working on a single package? cd packages/<pkg> and use its scripts directly (pnpm test:lib, pnpm test:types, etc.).
There is a single tsconfig.base.json at the repo root with the shared compilerOptions. Every package extends it and overrides only what's unique to that package (e.g. outDir, JSX runtime, framework lib).
The standardised per-package shape is:
Tests are included in typecheck. vite.config.ts / vitest.config.ts are not — they're tooling configs typechecked by the build tools themselves.
- Place tests under
packages/<pkg>/tests/with the suffix.test.ts(or.test.tsxfor JSX). - Vitest's defaults discover anything matching
**/*.{test,spec}.?(c|m)[jt]s?(x)— no per-package config is needed. - Tests are typechecked by
tscand linted by ESLint.
Every feature, bug fix, or behaviour change MUST have E2E coverage. See testing/e2e/README.md for the full guide. Quick reference:
| Change type | What to add |
|---|---|
| New provider adapter | Add provider to feature-support.ts + test-matrix.ts. Tests auto-run. |
| New feature (e.g. new generation type) | Add to types, feature config, support matrix, fixture, spec file. |
| Chat / streaming bug fix | Test case in chat.spec.ts or tools-test/. |
| Tool system change | Scenario in tools-test-scenarios.ts + spec. |
| Middleware change | Test in middleware.spec.ts. |
| Client-side change (useChat etc.) | Test covering the observable behavior change. |
Run the suite locally with pnpm test:e2e. Record real LLM fixtures with OPENAI_API_KEY=sk-... pnpm --filter @tanstack/ai-e2e record.
Any change that ships in a published package requires a changeset. Examples, internal test harnesses, codemods, and docs do not.
pnpm changesetPick the affected packages and the bump type:
- patch: bug fix, internal refactor, perf, docs in package, no API change.
- minor: new public API, new opt-in behaviour, backwards-compatible enhancement.
- major: breaking change to a published API surface. Coordinate with maintainers first.
The defensive ignore list in .changeset/config.json blocks accidental publication from examples/testing/codemods even if "private": true is ever dropped.
- Branch off
main. Name the branch after the change (fix/openai-streaming-eof,feat/anthropic-cache-control). - Conventional Commits aren't strictly enforced, but follow the prefixes you see in
git log:feat:,fix:,docs:,refactor:,chore:,ci:. - Keep commits logical. The repo prefers a few coherent commits over one giant squash.
- Push your branch and open a PR against
main. - CI runs:
pnpm test:pr(sherif workspace check, knip dead-code, docs link verification, ESLint, unit tests, typecheck, build artifacts, build) + the full E2E suite. - Address review comments.
- A maintainer merges. Releases are cut via Changesets — your changeset entry lands in the next release.
The PR template lists the steps. The Test plan section is required — describe how a reviewer can verify your change.
The pattern lives in packages/ai-openai/, packages/ai-anthropic/, packages/ai-gemini/, etc. New core adapters typically:
- Create
packages/ai-<provider>/withpackage.json,tsconfig.json,src/,tests/,README.md. Copy structure from an existing adapter. - Implement tree-shakeable adapter exports under
src/adapters/(text.ts,embed.ts,summarize.ts, etc.). - Add
model-meta.tsso per-model type safety works. - Wire the provider into
testing/e2e/feature-support.tsandtesting/e2e/test-matrix.ts. Existing provider-coverage tests pick it up automatically. - Record fixtures (
OPENAI_API_KEY=... pnpm --filter @tanstack/ai-e2e record) — or write deterministic ones by hand. No real API keys at test time. - Add a
pnpm changesetentry.
If you're building a community/third-party adapter that lives outside this repo, follow docs/community-adapters/guide.md instead.
- Vue/Svelte SFCs are not currently linted. Our linter doesn't yet support
.vue/.svelteparsers in the toolchain we use; the script blocks inside those files rely on TypeScript and tests for safety. If you're touching a.svelteor.vuefile, lean ontsc/svelte-check/vue-tscand explicit tests. - Build configs (
vite.config.ts,vitest.config.ts) are not in thetsctypecheck pass. They're typechecked at build time by vite/vitest themselves. If you make changes there, runpnpm buildorpnpm test:libto surface issues.
- Bugs: open a GitHub issue with a minimal repro (the bug report template in
.github/issue_template/bug_report.ymlwalks you through it). - Questions / discussions: TanStack Discord.
- Security: follow the disclosure process in
SECURITY.md(if applicable) or email the maintainers directly.
By participating you agree to abide by our Code of Conduct.
{ "extends": "../../../tsconfig.base.json", "compilerOptions": { "outDir": "dist", // + package-specific overrides only }, "include": ["src", "tests"], "exclude": ["node_modules", "dist"], }