|
| 1 | +# GitHub repository analyzer agent using Claude and Trigger.dev |
| 2 | + |
| 3 | +This demo shows how to build a simple AI-powered repository analyzer that lets you ask questions about any public GitHub repository, using [Trigger.dev](https://trigger.dev/) for workflow orchestration, streaming, and showing progress on the frontend and [Anthropic's Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) for the agentic loop. |
| 4 | + |
| 5 | +## Demo video |
| 6 | + |
| 7 | +<video src="https://content.trigger.dev/Claude%20GitHub%20Wiki-example.mp4" controls autoplay loop muted width="100%"></video> |
| 8 | + |
| 9 | +## Tech stack |
| 10 | + |
| 11 | +- [**Next.js**](https://nextjs.org/) – Frontend framework using the App Router |
| 12 | +- [**Claude Agent SDK**](https://platform.claude.com/docs/en/agent-sdk/overview) – Anthropic's SDK for building AI agents; provides an agentic loop with shell, file, and search tools |
| 13 | +- [**Trigger.dev**](https://trigger.dev/) – runs the agent in a long-running background task with real-time streaming to the frontend |
| 14 | + |
| 15 | +## Features |
| 16 | + |
| 17 | +- **Ask anything about any public repo** – Architecture, security vulnerabilities, API endpoints, testing strategies, etc. |
| 18 | +- **Claude Agent SDK exploration** – Claude explores the codebase and provide detailed answers |
| 19 | +- **Cancel anytime** – Abort long-running Trigger.dev task with cleanup |
| 20 | +- **Trigger.dev Realtime streaming** – Watch Claude's analysis stream in as it's generated |
| 21 | +- **Progress tracking using Trigger.dev Realtime** – See clone status, analysis progress, and repo size |
| 22 | + |
| 23 | +## Setup & running locally |
| 24 | + |
| 25 | +1. **Clone the repository** |
| 26 | + |
| 27 | + ```bash |
| 28 | + git clone <repository-url> |
| 29 | + cd claude-agent-github-wiki |
| 30 | + ``` |
| 31 | + |
| 32 | +2. **Install dependencies** |
| 33 | + |
| 34 | + ```bash |
| 35 | + npm install |
| 36 | + ``` |
| 37 | + |
| 38 | +3. **Copy environment variables and configure** |
| 39 | + |
| 40 | + ```bash |
| 41 | + cp .env.example .env |
| 42 | + ``` |
| 43 | + |
| 44 | + Fill in the required environment variables: |
| 45 | + |
| 46 | + - `TRIGGER_SECRET_KEY` – Get this from the [Trigger.dev dashboard](https://cloud.trigger.dev/) |
| 47 | + - `TRIGGER_PROJECT_REF` – Your Trigger.dev project ref (starts with `proj_`) |
| 48 | + - `ANTHROPIC_API_KEY` – Get this from the [Anthropic Console](https://console.anthropic.com/) |
| 49 | + |
| 50 | +4. **Start the development servers** |
| 51 | + |
| 52 | + ```bash |
| 53 | + # Terminal 1: Start Next.js dev server |
| 54 | + npm run dev |
| 55 | + |
| 56 | + # Terminal 2: Start Trigger.dev CLI |
| 57 | + npx trigger.dev@latest dev |
| 58 | + ``` |
| 59 | + |
| 60 | + Open [http://localhost:3000](http://localhost:3000) |
| 61 | + |
| 62 | +## How it works |
| 63 | + |
| 64 | +Trigger.dev orchestrates the repository analysis through a single long-running task: |
| 65 | + |
| 66 | +1. **`analyzeRepo`** – Main task that: |
| 67 | + - Clones the repository to a temp directory (shallow clone for speed) |
| 68 | + - Spawns a Claude agent with file system tools |
| 69 | + - Streams Claude's response to the frontend in real-time via Trigger.dev's Realtime Streams |
| 70 | + - Cleans up the temp directory on completion or error |
| 71 | + |
| 72 | +## Relevant code |
| 73 | + |
| 74 | +- **Main analysis task** – Clones repo, runs Claude agent, streams response ([`trigger/analyze-repo.ts`](trigger/analyze-repo.ts)) |
| 75 | +- **Stream definition** – Typed stream for real-time text responses ([`trigger/agent-stream.ts`](trigger/agent-stream.ts)) |
| 76 | +- **API endpoint** – Triggers the task and returns a public access token ([`app/api/analyze-repo/route.ts`](app/api/analyze-repo/route.ts)) |
| 77 | +- **Response page** – Real-time streaming display with progress ([`app/response/[runId]/page.tsx`](app/response/[runId]/page.tsx)) |
| 78 | +- **Landing page** – Repository URL input with example repos ([`app/page.tsx`](app/page.tsx)) |
| 79 | +- **Trigger.dev config** – Project settings with external SDK bundle ([`trigger.config.ts`](trigger.config.ts)) |
| 80 | + |
| 81 | +## Learn more |
| 82 | + |
| 83 | +- [**Trigger.dev Realtime Streams**](https://trigger.dev/docs/realtime/streams) – Stream data from tasks to your frontend |
| 84 | +- [**Trigger.dev React Hooks**](https://trigger.dev/docs/realtime/react-hooks/overview) – `useRealtimeStream` for consuming streams |
| 85 | +- [**Claude Agent SDK**](https://platform.claude.com/docs/en/agent-sdk/overview) – Run Claude with agentic tool usage |
| 86 | +- [**Trigger.dev schemaTask**](https://trigger.dev/docs/tasks/schemaTask) – Type-safe task payloads with Zod |
0 commit comments