tRPC API Endpoints
Relevant source files
The following files were used as context for generating this wiki page:
The tRPC API Endpoints constitute the primary communication layer between the Electron-based Next.js frontend and the Node.js Express backend. This architecture ensures end-to-end type safety across the monorepo, utilizing Zod for input validation and TypeScript for schema synchronization between the client and server packages.
The API is organized into modular routers that handle specific domain logic, such as Skill management, credential handling, and chat operations. By leveraging tRPC, the project avoids the overhead of manual REST endpoint definitions while maintaining strict data integrity through the use of the Shared package for common types and utilities.
Sources: Comprehensive.md:21-25, scripts/generate-docs.js:33-38, PROGRESS.md:123-125
API Architecture
The system follows a monorepo structure where the backend serves as a tRPC provider and the frontend acts as a type-safe consumer. The core of this interaction is defined in the server's root router, which aggregates specialized domain routers.
Data Flow Overview
The flow of data starts at the client-side tRPC hooks, passes through the network as JSON, and is validated on the server using Zod schemas before being processed by business logic or database services.
This diagram illustrates the request lifecycle from the React UI to the underlying SQLite database.
Sources: Comprehensive.md:21-25, apps/server/src/routers/index.ts, PROGRESS.md:123-125
Primary Routers and Endpoints
The API is divided into several key routers, each responsible for a distinct functional area of the Claude Skill Builder platform.
Skill Router
The Skill Router manages the lifecycle of AI Skills, including CRUD operations, version control, and restoration. It is the most critical component for skill-driven development within the IDE.
| Endpoint | Method | Parameters | Description |
|---|---|---|---|
getVersions | Query | skillId: string, limit?: number | Retrieves the version history for a specific skill. |
restoreVersion | Mutation | versionId: string | Restores a skill to a previous state based on its version ID. |
create | Mutation | SkillSchema | Creates a new skill template. |
getById | Query | id: string | Fetches full skill details. |
Sources: PROGRESS.md:31-38, scripts/generate-docs.js:34-35, Comprehensive.md:46-47
Version History Logic
The versioning system allows users to track changes over time. When a restoreVersion mutation is called, the backend retrieves the archived content and updates the current active skill record.
This sequence diagram shows the internal logic of the restoration feature implemented in Phase 5.
Sources: PROGRESS.md:31-48
Credential Router
This router handles sensitive information regarding AI providers (e.g., AWS Bedrock, OpenRouter). It manages encryption, provider configuration, and authentication testing.
Sources: Comprehensive.md:48-49, scripts/generate-docs.js:36
Security and Type Safety
All tRPC endpoints utilize Zod for runtime validation, ensuring that the data arriving at the server strictly matches the expected TypeScript interfaces. Errors are handled through a standardized format that provides clear feedback to the frontend.
Error Response Format
When a validation or runtime error occurs, the API returns a structured JSON response:
{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found"
}
}
Sources: scripts/generate-docs.js:52-59
Technology Integration
The API integrates with several core technologies to perform its duties:
- Prisma/SQLite: For data persistence of skills and settings.
- Zod: For schema validation on every request.
- Express: The underlying HTTP framework for the tRPC server.
Sources: Comprehensive.md:21-25, PROGRESS.md:12-16
Summary
The tRPC API Endpoints provide a robust, type-safe backbone for the Claude Skill Builder. By modularizing logic into routers like skill and credential, the system maintains high maintainability and developer productivity. The integration of version history and automated database checks within the CI/CD pipeline ensures that these endpoints remain reliable and performant as the project scales.
Sources: Comprehensive.md:113-120, PROGRESS.md:53-62