ai-agentlisted
Install: claude install-skill gurenjs/guren
# AI Agent Skill
An in-process agent is a class under `app/Ai/Agents` that calls a model configured in `config/ai.ts`. It reaches the application **only** through `appTools()`, which turns the app's `.agent()` routes into model tools and runs every call through the same pipeline as the MCP endpoint: scopes, the route's validation and policies, approvals, and the audit trail. Nothing about a route is written twice.
## Setup (once per app)
```bash
bunx guren add ai # config/ai.ts, the key in config/env.ts, aiPlugin(), conversation tables
bunx guren add ai --provider openai # or gateway
```
It needs `config/env.ts`. The key is optional: the app boots without it and the first prompt fails. Do not remove the `if (!env.ANTHROPIC_API_KEY) throw` guard in `config/ai.ts`; without a key the provider SDK reads `process.env` and sends a blank key.
## Writing an agent
```bash
bunx guren make:ai-agent TicketDigest --tools tickets_index --output --test
```
`--tools` fails if no route derives a name, so expose the route first (the `agent-interface` skill). Then check the generated class:
```typescript
import { Agent, Output } from '@guren/plugin-ai'
import { z } from 'zod'
export class TicketDigest extends Agent<typeof TicketDigest.scopes> {
static override agentName = 'ticket-digest'
static override scopes = ['tool:tickets_index'] as const
instructions = 'You write a short digest of the open support tickets for an operator.'
output = Output.object