Skip to main content
A multi-step bugfix workflow that imports schemas from TypeScript and uses inline run: blocks for non-LLM steps.

bugfix.toon

imports:
  schemas[1]{from,use}:
    ./schemas.ts,TicketInput

name: bugfix
agents:
  coder:
    type: claude-code
    model: claude-opus-4-6
    subscription: true
    instructions: You are a senior software engineer specializing in debugging.

input: TicketInput

steps[4]:
  - id: fetch-context
    run: "const response = await fetch(\n  `https://api.linear.app/tickets/${input.ticketId}`,\n  { headers: { Authorization: `Bearer ${process.env.LINEAR_API_KEY}` } }\n);\nconst data = await response.json();\nreturn {\n  title: data.title,\n  body: data.description,\n  labels: data.labels.map(l => l.name),\n};"
    output:
      title: string
      body: string
      labels: "string[]"

  - id: analyze
    agent: coder
    prompt: "You are a senior software engineer.\n\nAnalyze the following bug report and identify the root cause,\naffected systems, and suggested fix approach.\n\nTitle: {fetch-context.title}\nDescription: {fetch-context.body}\nLabels: {fetch-context.labels}\n\nOriginal report: {input.description}"
    output:
      rootCause: string
      affectedFiles: "string[]"
      severity: "low" | "medium" | "high"
      suggestedApproach: string

  - id: generate-fix
    agent: coder
    prompt: "Based on this analysis, generate a code fix.\n\nRoot cause: {analyze.rootCause}\nAffected files: {analyze.affectedFiles}\nApproach: {analyze.suggestedApproach}"
    output:
      patch: string
      explanation: string
      testSuggestions: "string[]"

  - id: format-output
    run: "return {\n  summary: `## ${fetch-context.title}\\n\\n**Severity:** ${analyze.severity}\\n\\n**Root Cause:** ${analyze.rootCause}\\n\\n**Fix:**\\n\\`\\`\\`\\n${generate-fix.patch}\\n\\`\\`\\`\\n\\n${generate-fix.explanation}`,\n  filesChanged: analyze.affectedFiles.length,\n};"
    output:
      summary: string
      filesChanged: number

schemas.ts

import { Schema } from "effect";

export class TicketInput extends Schema.Class<TicketInput>("TicketInput")({
  ticketId: Schema.String,
  description: Schema.String,
}) {}

Run It

smithers run bugfix.toon --input '{"ticketId": "SMI-123", "description": "Auth tokens expire silently"}'

Key Patterns

  • Imported schema: TicketInput is a Schema.Class from TypeScript, used as the workflow input
  • run: for API calls: The fetch-context step calls an external API without an LLM
  • run: for formatting: The format-output step transforms data without a model call
  • prompt: for LLM steps: The analyze and generate-fix steps call the model
  • Cross-step references: Each step references upstream outputs like {analyze.rootCause}