|
| 1 | +# Changelog Generator using Claude Agent SDK and Trigger.dev |
| 2 | + |
| 3 | +Generate intelligent changelogs from GitHub commits using AI with a two-phase approach: scan commits first, then selectively fetch diffs for unclear changes. |
| 4 | + |
| 5 | +## Tech Stack |
| 6 | + |
| 7 | +- **Next.js** – Frontend framework using App Router |
| 8 | +- **Claude Agent SDK** – Anthropic's SDK for building AI agents with custom tools |
| 9 | +- **Trigger.dev** – Background task orchestration with real-time streaming |
| 10 | +- **Octokit** – GitHub API client |
| 11 | + |
| 12 | +## Features |
| 13 | + |
| 14 | +- **Two-phase intelligent analysis**: |
| 15 | + 1. Claude first lists all commits in the date range |
| 16 | + 2. For unclear commits ("fix bug", "update"), Claude requests the actual diff |
| 17 | + 3. Generates grouped changelog with full context |
| 18 | +- **Custom MCP tools** – Claude can call `list_commits` and `get_commit_diff` on demand |
| 19 | +- **Private repo support** – Optional GitHub token for private repositories |
| 20 | +- **Real-time streaming** – Watch the changelog generate live |
| 21 | + |
| 22 | +## How It Works |
| 23 | + |
| 24 | +``` |
| 25 | +User enters repo URL + date range |
| 26 | + ↓ |
| 27 | +API triggers generate-changelog task |
| 28 | + ↓ |
| 29 | +Claude Agent SDK with custom GitHub tools: |
| 30 | + - list_commits: fetches commit messages via GitHub API |
| 31 | + - get_commit_diff: fetches diff for specific commit SHA |
| 32 | + ↓ |
| 33 | +Claude explores commits, requests diffs as needed |
| 34 | + ↓ |
| 35 | +Generates grouped changelog |
| 36 | + ↓ |
| 37 | +Streams to frontend via Trigger.dev Realtime |
| 38 | +``` |
| 39 | + |
| 40 | +## Setup |
| 41 | + |
| 42 | +1. **Install dependencies** |
| 43 | + |
| 44 | + ```bash |
| 45 | + npm install |
| 46 | + ``` |
| 47 | + |
| 48 | +2. **Configure environment variables** |
| 49 | + |
| 50 | + ```bash |
| 51 | + cp .env.example .env |
| 52 | + ``` |
| 53 | + |
| 54 | + Fill in: |
| 55 | + - `TRIGGER_SECRET_KEY` – From [Trigger.dev dashboard](https://cloud.trigger.dev/) |
| 56 | + - `TRIGGER_PROJECT_REF` – Your project ref (starts with `proj_`) |
| 57 | + - `ANTHROPIC_API_KEY` – From [Anthropic Console](https://console.anthropic.com/) |
| 58 | + - `GITHUB_TOKEN` (optional) – For private repos, needs `repo` scope |
| 59 | + |
| 60 | +3. **Start development servers** |
| 61 | + |
| 62 | + ```bash |
| 63 | + # Terminal 1: Next.js |
| 64 | + npm run dev |
| 65 | + |
| 66 | + # Terminal 2: Trigger.dev CLI |
| 67 | + npx trigger.dev@latest dev |
| 68 | + ``` |
| 69 | + |
| 70 | +4. Open [http://localhost:3000](http://localhost:3000) |
| 71 | + |
| 72 | +## Relevant Files |
| 73 | + |
| 74 | +- `trigger/generate-changelog.ts` – Main task with custom MCP tools for GitHub |
| 75 | +- `trigger/changelog-stream.ts` – Stream definition for real-time output |
| 76 | +- `app/api/generate-changelog/route.ts` – API endpoint |
| 77 | +- `app/response/[runId]/page.tsx` – Streaming display page |
| 78 | + |
| 79 | +## Custom Tools |
| 80 | + |
| 81 | +The task defines two custom MCP tools that Claude can use: |
| 82 | + |
| 83 | +```typescript |
| 84 | +// List commits with messages (lightweight) |
| 85 | +list_commits({ since: "2024-01-01", until: "2024-02-01" }) |
| 86 | + |
| 87 | +// Get full diff for a specific commit (on-demand) |
| 88 | +get_commit_diff({ sha: "abc1234" }) |
| 89 | +``` |
| 90 | + |
| 91 | +This two-phase approach minimizes token usage while giving Claude full context when needed. |
0 commit comments