|
| 1 | +--- |
| 2 | +title: "Changelog generator using Claude Agent SDK" |
| 3 | +sidebarTitle: "Claude changelog generator" |
| 4 | +description: "Automatically generate changelogs from your git commit history using the Claude Agent SDK and Trigger.dev." |
| 5 | +--- |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +This demo how to build an AI agent using the Claude Agent SDK that explores GitHub commits, investigates unclear changes by fetching diffs on demand, and generates developer-friendly changelogs. |
| 10 | + |
| 11 | +## Tech stack |
| 12 | + |
| 13 | +- **[Next.js](https://nextjs.org)** – Frontend framework using App Router |
| 14 | +- **[Claude Agent SDK](https://docs.anthropic.com/en/docs/agents-and-tools/claude-agent-sdk)** – Anthropic's agent SDK for building AI agents with custom tools |
| 15 | +- **[Trigger.dev](https://trigger.dev)** – workflow orchestration with real-time streaming, observability, and deployment |
| 16 | +- **[Octokit](https://github.com/octokit/octokit.js)** – GitHub API client for fetching commits and diffs |
| 17 | + |
| 18 | +## Demo video |
| 19 | + |
| 20 | +<video |
| 21 | + controls |
| 22 | + className="w-full aspect-video" |
| 23 | + src="https://github.com/user-attachments/assets/ea151c1d-f866-4da4-90e4-96d65008d51a" |
| 24 | +></video> |
| 25 | + |
| 26 | +## GitHub repo |
| 27 | + |
| 28 | +<Card |
| 29 | + title="View the changelog generator repo" |
| 30 | + icon="GitHub" |
| 31 | + href="https://github.com/triggerdotdev/examples/tree/main/changelog-generator" |
| 32 | +> |
| 33 | + Click here to view the full open source code for this project in our examples repository on |
| 34 | + GitHub. You can fork it and use it as a starting point for your own project. |
| 35 | +</Card> |
| 36 | + |
| 37 | +## How it works |
| 38 | + |
| 39 | +The agent workflow: |
| 40 | + |
| 41 | +1. **Receive request** – User provides a GitHub repo URL and date range |
| 42 | +2. **List commits** – Agent calls `list_commits` MCP tool to get all commits |
| 43 | +3. **Analyze commits** – Agent categorizes each commit: |
| 44 | + - Skip trivial commits (typos, formatting) |
| 45 | + - Include clear features/improvements directly |
| 46 | + - Investigate unclear commits by fetching their diffs |
| 47 | +4. **Generate changelog** – Agent writes a categorized markdown changelog |
| 48 | +5. **Stream output** – Changelog streams to the frontend in real-time |
| 49 | + |
| 50 | +## Features |
| 51 | + |
| 52 | +- **Two-phase analysis** – Lists all commits first, then selectively fetches diffs only for ambiguous ones |
| 53 | +- **Custom tools** – `list_commits` and `get_commit_diff` called autonomously by Claude |
| 54 | +- **Real-time streaming** – Changelog streams to the frontend as it's generated via Trigger.dev Realtime |
| 55 | +- **Live observability** – Agent phase, turn count, and tool calls broadcast via run metadata |
| 56 | +- **Private repo support** – Optional GitHub token for private repositories |
| 57 | + |
| 58 | +## Relevant code |
| 59 | + |
| 60 | +| File | Description | |
| 61 | +| ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | |
| 62 | +| [`trigger/generate-changelog.ts`](https://github.com/triggerdotdev/examples/blob/main/changelog-generator/trigger/generate-changelog.ts) | Main task with custom tools | |
| 63 | +| [`trigger/changelog-stream.ts`](https://github.com/triggerdotdev/examples/blob/main/changelog-generator/trigger/changelog-stream.ts) | Stream definition for real-time output | |
| 64 | +| [`app/api/generate-changelog/route.ts`](https://github.com/triggerdotdev/examples/blob/main/changelog-generator/app/api/generate-changelog/route.ts) | API endpoint that triggers the task | |
| 65 | +| [`app/response/[runId]/page.tsx`](https://github.com/triggerdotdev/examples/blob/main/changelog-generator/app/response/%5BrunId%5D/page.tsx) | Streaming display page | |
| 66 | + |
| 67 | +## trigger.config.ts |
| 68 | + |
| 69 | +You need to mark the Claude Agent SDK as external in your trigger.config.ts file. |
| 70 | + |
| 71 | +```ts trigger.config.ts |
| 72 | +import { defineConfig } from "@trigger.dev/sdk"; |
| 73 | + |
| 74 | +export default defineConfig({ |
| 75 | + project: process.env.TRIGGER_PROJECT_REF!, |
| 76 | + runtime: "node", |
| 77 | + logLevel: "log", |
| 78 | + maxDuration: 300, |
| 79 | + build: { |
| 80 | + external: ["@anthropic-ai/claude-agent-sdk"], |
| 81 | + }, |
| 82 | + machine: "small-2x", |
| 83 | +}); |
| 84 | +``` |
| 85 | + |
| 86 | +<Note> |
| 87 | + Adding packages to `external` prevents them from being bundled, which is necessary for the Claude |
| 88 | + Agent SDK. See the [build configuration docs](/config/config-file#external) for more details. |
| 89 | +</Note> |
| 90 | + |
| 91 | +## Learn more |
| 92 | + |
| 93 | +- [**Building agents with Claude Agent SDK**](/guides/ai-agents/claude-code-trigger) – Comprehensive guide for using Claude Agent SDK with Trigger.dev |
| 94 | +- [**Realtime**](/realtime/overview) – Stream task progress to your frontend |
| 95 | +- [**Scheduled tasks**](/tasks/scheduled) – Automate changelog generation on a schedule |
0 commit comments