Skip to main content

Overview

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.

Tech stack

  • Next.js – Frontend framework using App Router
  • Claude Agent SDK – Anthropic’s agent SDK for building AI agents with custom tools
  • Trigger.dev – workflow orchestration with real-time streaming, observability, and deployment
  • Octokit – GitHub API client for fetching commits and diffs

Demo video

GitHub repo

View the changelog generator repo

Click here to view the full open source code for this project in our examples repository on GitHub. You can fork it and use it as a starting point for your own project.

How it works

The agent workflow:
  1. Receive request – User provides a GitHub repo URL and date range
  2. List commits – Agent calls list_commits MCP tool to get all commits
  3. Analyze commits – Agent categorizes each commit:
    • Skip trivial commits (typos, formatting)
    • Include clear features/improvements directly
    • Investigate unclear commits by fetching their diffs
  4. Generate changelog – Agent writes a categorized markdown changelog
  5. Stream output – Changelog streams to the frontend in real-time

Features

  • Two-phase analysis – Lists all commits first, then selectively fetches diffs only for ambiguous ones
  • Custom toolslist_commits and get_commit_diff called autonomously by Claude
  • Real-time streaming – Changelog streams to the frontend as it’s generated via Trigger.dev Realtime
  • Live observability – Agent phase, turn count, and tool calls broadcast via run metadata
  • Private repo support – Optional GitHub token for private repositories

Relevant code

FileDescription
trigger/generate-changelog.tsMain task with custom tools
trigger/changelog-stream.tsStream definition for real-time output
app/api/generate-changelog/route.tsAPI endpoint that triggers the task
app/response/[runId]/page.tsxStreaming display page

trigger.config.ts

You need to mark the Claude Agent SDK as external in your trigger.config.ts file.
trigger.config.ts
import { defineConfig } from "@trigger.dev/sdk";

export default defineConfig({
  project: process.env.TRIGGER_PROJECT_REF!,
  runtime: "node",
  logLevel: "log",
  maxDuration: 300,
  build: {
    external: ["@anthropic-ai/claude-agent-sdk"],
  },
  machine: "small-2x",
});
Adding packages to external prevents them from being bundled, which is necessary for the Claude Agent SDK. See the build configuration docs for more details.

Learn more