stitch-sdk-pipeline

Exécutez le pipeline complet de génération du SDK Stitch. À utiliser lorsqu'un nouvel outil est ajouté ou que le SDK doit être régénéré de bout en bout.

npx skills add https://github.com/google-labs-code/stitch-sdk --skill stitch-sdk-pipeline

Stitch SDK Pipeline

This skill orchestrates the full SDK generation pipeline — from capturing MCP tool schemas to publishing a tested, validated package. Use this when:

  • The Stitch MCP server adds or changes tools
  • You need to regenerate the SDK from scratch
  • You want to verify the pipeline is healthy

[!IMPORTANT] Stage 2 is the only step requiring agent intelligence. All other stages are deterministic scripts. For Stage 2, use the stitch-sdk-domain-design skill.


Prerequisites

  • STITCH_API_KEY environment variable set
  • bun installed
  • Working directory: project root (stitch-sdk/)

Pipeline Stages

Stage 1: Capture Tool Schemas 🤖

// turbo
npm run capture

Connects to the Stitch MCP server, calls tools/list, and writes the raw schemas to packages/sdk/generated/tools-manifest.json. Updates the manifest section of stitch-sdk.lock.

Output: packages/sdk/generated/tools-manifest.json (includes inputSchema + outputSchema for every tool)

When to skip: If tools-manifest.json is already up to date and no server-side changes occurred.


Stage 2: Domain Design 🧠 (Agent)

Use the stitch-sdk-domain-design skill for this stage.

Read tools-manifest.json and edit packages/sdk/generated/domain-map.json to map tools → classes → methods.

Key decisions at this stage:

  • Which class owns each tool?
  • What are the arg routing rules (self, param, computed, selfArray)?
  • What is the response projection path?
  • Should the method cache data from the construction response?

Input: tools-manifest.json + scripts/ir-schema.ts (the canonical IR contract) Output: packages/sdk/generated/domain-map.json

When to skip: If domain-map.json already has the correct bindings and you only changed ir-schema.ts or generate-sdk.ts.


Stage 3: Generate TypeScript 🤖

// turbo
npm run generate

Validates the IR (Zod schema) and every projection (against outputSchema), then emits TypeScript files via ts-morph into packages/sdk/generated/src/.

Output: packages/sdk/generated/src/*.ts + updated stitch-sdk.lock

If this fails with a projection error, go back to Stage 2 and fix domain-map.json.


Stage 4: Build 🤖

// turbo
npm run build

TypeScript compilation: packages/sdk/packages/sdk/dist/.


Stage 5: Unit Tests 🤖

// turbo
npm run test

Runs core unit tests (vitest) — mocked callTool, verifying generated method signatures, caching, and error handling.


Stage 6: Script Tests 🤖

// turbo
npm run test:scripts

Runs contract tests (IR schema acceptance/rejection) and logic tests (expression builders) using bun:test.


Stage 7: E2E Tests 🤖

npm run test:e2e

Live API tests against the built package. Requires STITCH_API_KEY (and GEMINI_API_KEY for AI SDK tests). Two test suites:

  • live.test.ts — Direct SDK calls: create projects, generate screens, verify responses.
  • ai-sdk-e2e.test.ts — AI SDK integration via stitchTools(): Gemini autonomously calls Stitch tools, generates designs, extracts HTML + Tailwind config, produces modular React components, validates via SWC, and scaffolds a Vite preview app at .stitch/preview/.

Stage 8: Lock Validation 🤖

// turbo
npm run validate:generated

Verifies that stitch-sdk.lock hashes match the actual generated files. Catches drift (someone edited generated files manually or forgot to regenerate).

[!IMPORTANT] Always run after Stage 3 (Generate). If you run Capture (Stage 1) then Validate without re-generating, the hashes will mismatch because the manifest hash changed.


Stage 9: Skill Audit 🧠 (Agent)

After the pipeline passes, audit agent skills for freshness. Read the current source of truth and update any skills that reference stale methods, args, or examples.

Inputs:

  • packages/sdk/src/index.ts (public surface)
  • Generated class files in packages/sdk/generated/src/
  • packages/sdk/src/spec/errors.ts (error codes)
  • packages/sdk/src/spec/client.ts (config schema)

Skills to audit (in priority order):

  1. stitch-sdk-usage — highest churn, references specific methods and constructor signatures
  2. stitch-sdk-readme — must document stitchTools(), toolDefinitions, and AI SDK integration examples
  3. stitch-sdk-development — check cache examples match current domain-map patterns
  4. stitch-sdk-domain-design — check code examples in the cache section

Skills to skip: stitch-sdk-pipeline (self-referential), red-green-yellow (generic methodology).

What to check:

  • Every method name in a code example exists on its class
  • Every import in an example matches an export in index.ts
  • Constructor signatures match the actual constructors
  • Config fields match StitchConfigSchema
  • Error codes match StitchErrorCode

When to skip: If only infrastructure code changed (packages/sdk/src/client.ts, packages/sdk/src/proxy/) and no public API surface changed.


Quick Reference

Full pipeline (script stages only)

npm run pipeline

Runs Stage 1 → 3 → 4 → 5 in sequence. Does not include Stage 2 (agent), Stage 7 (e2e), or Stage 9 (skill audit).

Starting from a specific stage

ScenarioStart from
New tool added to MCP serverStage 1
Need to change how a tool maps to a methodStage 2
Changed ir-schema.ts or generate-sdk.tsStage 3
Changed code in packages/sdk/src/ (client, errors)Stage 4
Just want to verify everything worksStage 5
Changed AI SDK tools adapter or tool definitionsStage 5
Public API surface changedStage 9

Key files

FileLocationRole
tools-manifest.jsonpackages/sdk/generated/Raw MCP tool schemas (Stage 1 output)
domain-map.jsonpackages/sdk/generated/IR: tool → class → method mappings (Stage 2 output)
tool-definitions.tspackages/sdk/generated/src/Generated JSON Schema tool definitions for AI SDK
tools-adapter.tspackages/sdk/src/stitchTools() — AI SDK v6 adapter (imported via @google/stitch-sdk/ai)
ir-schema.tsscripts/Zod schema defining valid IR structure
tool-schema.tsscripts/TypeScript types for JSON Schema
generate-sdk.tsscripts/ts-morph codegen (Stage 3)
stitch-sdk.lockpackages/sdk/generated/Integrity hashes for drift detection
stitch-html.tspackages/sdk/test/helpers/Stitch HTML parser (Tailwind config + font extraction)
component-validator.tspackages/sdk/test/helpers/SWC AST validator for generated React components

Plus de skills de google-labs-code

remotion
google-labs-code
We need to translate the given English text into French, preserving the name "remotion" (which appears as "Remotion" in the text, but we preserve it as is). The instruction says: "Preserve product names, protocol names, URLs, numbers, and technical terms." So "Remotion" is a product name, keep it. Also "Stitch" is a product name? It says "Stitch app designs" - likely a product name, keep as "Stitch". Also "ScreenSlide", "WalkthroughComposition" are component names, keep as is. "zoom effects", "fade transitions", "text overlays" are technical terms, translate? The instruction says "technical terms" - but these are common terms. However, the instruction says "Preserve ... technical terms" - meaning do not translate? Actually it says "Preserve product names, protocol names, URLs, numbers, and technical terms." So technical terms should be preserved as is. But "zoom effects" might be considered a technical term? Possibly keep as "zoom effects
official
ink
google-labs-code
Moteur de rendu terminal Ink pour json-render qui transforme des spécifications JSON en interfaces utilisateur terminal interactives. À utiliser lorsque vous travaillez avec @json-render/ink, construisez des interfaces utilisateur terminal à partir de…
official
stitch-sdk-readme
google-labs-code
Générer ou mettre à jour le README pour le Stitch SDK. Utiliser la structure Bookstore Test et sourcer l'API actuelle depuis la base de code. Utiliser lorsque le README doit…
official
typed-service-contracts
google-labs-code
Architecture standard for building robust, type-safe TypeScript services using the "Spec and Handler" pattern. Use when building CLIs, libraries, or complex…
official
agent-dx-cli-scale
google-labs-code
A scoring scale for evaluating how well a CLI is designed for AI agents, based on the "Rewrite Your CLI for AI Agents" principles.
official
ink
google-labs-code
Rendu terminal ink pour json-render qui transforme les spécifications JSON en interfaces terminal interactives. À utiliser avec @json-render/ink, pour créer des interfaces terminal à partir de…
official
stitch-sdk-bug-bash
google-labs-code
Find bugs in the Stitch SDK using a real API key. Covers standard functional edges and tricky situations.
official
stitch-sdk-development
google-labs-code
Develop the Stitch SDK. Covers the generation pipeline, dual modality (agent vs SDK), error handling, and Traffic Light (Red-Green-Yellow) implementation…
official