Skip to content
generate-sdk-types logo

Generate SDK Types Skill

generate-sdk-types

Generates TypeScript type definitions for SDK from Rust tool schemas, ensuring type safety between server and client

SKILL.md

Full skill instructions

Generate SDK Types Skill

Purpose

Generates TypeScript type definitions for the SDK from Rust tool schemas, ensuring type safety between server and client.

CLAUDE.md Compliance

  • ✅ Automated type generation (no manual sync)
  • ✅ Validates type consistency
  • ✅ Prevents type drift between Rust and TypeScript

Usage

Run this skill:

  • After adding/​modifying MCP tools
  • After changing tool parameter schemas
  • Before SDK releases
  • After protocol changes

Prerequisites

  • Bun runtime installed
  • Pierre server must be runnable
  • sdk/ directory with dependencies installed

Commands

Standard Type Generation

# 1. Ensure server is running
cargo run --bin pierre-mcp-server &
SERVER_PID=$!
sleep 3

# 2. Generate TypeScript types
cd sdk
bun run generate-types

# 3. Verify types changed
git diff src/​types.ts

# 4. Cleanup
kill $SERVER_PID
cd ..

One-Command Generation

# Run from project root (handles server lifecycle)
./​scripts/​generate-sdk-types.js

Manual Generation Process

# 1. Start server
cargo run --bin pierre-mcp-server &
SERVER_PID=$!
sleep 3

# 2. Fetch tool schemas via MCP
curl -X POST http://localhost:8081/​mcp \
  -H "Content-Type: application/​json" \
  -d '{"jsonrpc":"2.0","method":"tools/​list","id":1}' \
  > /​tmp/​tools.json

# 3. Parse and generate types
cd sdk
node scripts/​generate-types.js /​tmp/​tools.json

# 4. Format generated code
bun run format

# 5. Cleanup
kill $SERVER_PID
cd ..

Generated Type Structure

Tool Definitions

// Generated from Rust ToolDefinition structs
export interface Tool {
  name: string;
  description: string;
  inputSchema: {
    type: 'object';
    properties: Record<string, JsonSchema>;
    required?: string[];
  };
}

// Example: get_activities tool
export interface GetActivitiesParams {
  start_date?: string;
  end_date?: string;
  limit?: number;
  provider?: 'strava' | 'garmin' | 'fitbit';
}

Tool Registry

// All available tools
export const TOOLS: Tool[] = [
  {
    name: 'get_activities',
    description: 'Retrieves fitness activities...',
    inputSchema: { /​* ... */ }
  },
  // ... 35+ tools
];

Type Validation

Pre-Generation Check

# Verify Rust tools compile
cargo build --lib

# Check tool count
rg "^pub const TOOL_" src/​protocols/​universal/​tool_registry.rs --type rust | wc -l

Post-Generation Validation

# Verify types compile
cd sdk
bun run build

# Run type tests
bun test -- test/​unit/​types.test.ts

# Check type coverage
bun run type-check
cd ..

Diff Analysis

# Compare generated types with committed version
git diff sdk/​src/​types.ts

# Expected changes after adding a tool:
# + New tool interface
# + New tool definition in TOOLS array
# + Updated tool count comment

Type Generation Workflow

1. Add New Tool in Rust

// src/​protocols/​universal/​tool_registry.rs
pub const TOOL_MY_NEW_FEATURE: ToolDefinition = ToolDefinition {
    name: "my_new_feature",
    description: "Does something useful",
    input_schema: json!({
        "type": "object",
        "properties": {
            "param1": { "type": "string" },
            "param2": { "type": "number" }
        },
        "required": ["param1"]
    }),
};

2. Register Tool

// src/​protocols/​universal/​mod.rs
impl UniversalToolExecutor {
    pub fn register_tools(&mut self) {
        self.register(TOOL_MY_NEW_FEATURE, handle_my_new_feature);
    }
}

3. Generate TypeScript Types

cd sdk
bun run generate-types

4. Verify Generated Types

// sdk/​src/​types.ts (auto-generated)
export interface MyNewFeatureParams {
  param1: string;
  param2?: number;
}

export const TOOL_MY_NEW_FEATURE: Tool = {
  name: 'my_new_feature',
  description: 'Does something useful',
  inputSchema: { /​* ... */ }
};

5. Commit Changes

git add src/​protocols/​universal/​tool_registry.rs
git add sdk/​src/​types.ts
git commit -m "feat: add my_new_feature tool with TypeScript types"

Success Criteria

  • ✅ TypeScript types match Rust tool definitions
  • ✅ All tools have corresponding TypeScript interfaces
  • ✅ Generated code compiles without errors
  • ✅ Type tests pass
  • ✅ No manual type definitions (all auto-generated)
  • ✅ Git diff shows expected changes only

Related Files

  • scripts/​generate-sdk-types.js - Type generation script
  • sdk/​src/​types.ts - Generated TypeScript types
  • src/​protocols/​universal/​tool_registry.rs - Rust tool definitions
  • sdk/​TYPE_GENERATION.md - Type generation documentation

Related Skills

  • test-mcp-compliance - MCP protocol validation

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View