Generate type-safe TypeScript tool handlers from Porchestra agents with Zod validation, automatic code generation, and multi-environment support
Generate type-safe TypeScript LLM tool handlers from Porchestra agents with automatic Zod schema validation and code generation.
This skill helps you:
1. **Check if Porchestra CLI is installed:**
```bash
which porchestra
```
2. **If not installed, install globally:**
```bash
npm install -g @porchestra/cli
```
3. **Verify installation:**
```bash
porchestra --version
```
1. **Login to Porchestra account:**
```bash
porchestra login
```
2. **For on-premise deployments:**
```bash
porchestra login --api-url https://porchestra.company.com/api/v1
```
3. **Verify authentication:**
```bash
porchestra whoami
```
4. **Expected output includes:** Email, name, org, token expiry, tracked projects
1. **Launch interactive agent browser:**
```bash
porchestra explore
```
2. **Navigate through:**
- Project list with agent counts
- Agent browser with folder paths
- Checkbox selection for agents
- Version resolution display (PRODUCTION/STAGING/DEVELOPMENT)
3. **Or start with specific project:**
```bash
porchestra explore --project customer-support
```
4. **List currently tracked agents:**
```bash
porchestra agents list
```
1. **Pull all tracked agents:**
```bash
porchestra pull
```
2. **Pull specific project only:**
```bash
porchestra pull --project customer-support
```
3. **Pull specific agent only:**
```bash
porchestra pull --agent ticket-classifier
```
4. **Target specific environment:**
```bash
porchestra pull --env staging
# Options: production, staging, development
```
5. **Custom output directory:**
```bash
porchestra pull --output ./src/my-agents
```
1. **Locate generated files for each agent:**
- `tool-schemas.ts` - Zod schemas (auto-generated, don't modify)
- `tool-dispatcher.ts` - Switch/case dispatcher (auto-generated, don't modify)
- `tool-impl.ts` - Implementation stubs (edit this file)
2. **Implement functions in `tool-impl.ts`:**
```typescript
import { GetUserParams } from './tool-schemas.js';
export async function getUser(params: GetUserParams): Promise<any> {
// Replace the TODO with actual implementation
const user = await fetchUserFromDB(params.id);
return user;
}
```
3. **Never modify auto-generated files** (`tool-schemas.ts`, `tool-dispatcher.ts`)
1. **Import the dispatcher:**
```typescript
import { dispatchTool } from './src/agents/main/ticket-classifier/tool-dispatcher.js';
```
2. **Use in your LLM loop:**
```typescript
const toolCall = llmResponse.tool_calls[0];
try {
const result = await dispatchTool(
toolCall.name,
JSON.parse(toolCall.arguments)
);
if (result.success) {
// Send result back to LLM
console.log('Tool result:', result.data);
} else {
console.error('Tool failed:', result.error);
}
} catch (error) {
console.error('Tool execution failed:', error);
}
```
```bash
porchestra config list
porchestra config get api.baseUrl
porchestra config get output.baseDir
```
```bash
porchestra config set api.baseUrl https://api.porchestra.io/v1
porchestra config set output.baseDir ./src/agents
porchestra config set output.createIndexFiles true
```
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `api.baseUrl` | string | `https://api.porchestra.io/v1` | API endpoint URL |
| `api.skipTlsVerify` | boolean | `false` | Skip TLS verification (dev only) |
| `output.baseDir` | string | `./src/agents` | Base directory for generated files |
| `output.createIndexFiles` | boolean | `true` | Create index.ts files for exports |
```bash
porchestra agents
porchestra agents list --project customer-support
porchestra agents list --json
```
```bash
porchestra agents remove ticket-classifier
porchestra agents remove ticket-classifier --project customer-support
porchestra agents remove ticket-classifier --project customer-support --force
```
When no environment specified, uses priority:
1. **PRODUCTION** (highest priority)
2. **STAGING** (fallback)
3. **DEVELOPMENT** (fallback)
```bash
porchestra pull --env production
porchestra pull --env staging
porchestra pull --env development
```
**Note:** Cannot pin to specific versions. Always fetches latest version from requested environment.
```
./src/agents/
├── main/
│ ├── ticket-classifier/
│ │ ├── tool-schemas.ts # Zod schemas (auto-generated)
│ │ ├── tool-dispatcher.ts # Dispatcher (auto-generated)
│ │ └── tool-impl.ts # Your implementation
│ └── response-generator/
│ ├── tool-schemas.ts
│ ├── tool-dispatcher.ts
│ └── tool-impl.ts
└── sales/
└── lead-scorer/
├── tool-schemas.ts
├── tool-dispatcher.ts
└── tool-impl.ts
```
```bash
porchestra status
```
Shows:
```bash
porchestra whoami
```
Shows:
```bash
porchestra logout
porchestra logout --all
```
**Problem:** "Invalid email or password"
**Problem:** "Token expired"
**Problem:** "ECONNREFUSED" or "ENOTFOUND"
**Problem:** "No projects selected for tracking"
**Problem:** "tool-impl.ts already exists"
**Problem:** "Agent has no published versions"
```bash
porchestra login # Login
porchestra logout # Logout current device
porchestra whoami # Show user info
porchestra explore # Browse and select agents
porchestra agents list # List tracked agents
porchestra agents remove <agent> # Remove tracked agent
porchestra pull # Generate all tracked agents
porchestra pull --env staging # Use staging environment
porchestra pull --project <id> # Pull specific project
porchestra pull --force # Overwrite implementation files
porchestra config list # Show all config
porchestra config get <key> # Get config value
porchestra config set <key> <val> # Set config value
porchestra status # Show CLI status
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/porchestra-agent-generator/raw