|
1 | 1 | # GitHub repository analyzer agent using Claude and Trigger.dev |
2 | 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> |
| 3 | +Ask questions about any public GitHub repository and get AI-powered analysis using the Claude Agent SDK for agentic exploration and Trigger.dev for real-time streaming to the frontend. |
8 | 4 |
|
9 | 5 | ## Tech stack |
10 | 6 |
|
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 |
| 7 | +- **[Next.js](https://nextjs.org/)** – React framework with App Router for the frontend |
| 8 | +- **[Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview)** – Anthropic's SDK for building AI agents with file system and search tools |
| 9 | +- **[Trigger.dev](https://trigger.dev/)** – Background task orchestration with real-time streaming to the frontend, observability, and deployment |
14 | 10 |
|
15 | | -## Features |
| 11 | +## Demo |
16 | 12 |
|
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** |
| 13 | +<video src="https://content.trigger.dev/Claude%20GitHub%20Wiki-example.mp4" controls autoplay loop muted width="100%"></video> |
26 | 14 |
|
27 | | - ```bash |
28 | | - git clone <repository-url> |
29 | | - cd claude-agent-github-wiki |
30 | | - ``` |
| 15 | +## Running the project locally |
31 | 16 |
|
32 | | -2. **Install dependencies** |
| 17 | +1. **Install dependencies** |
33 | 18 |
|
34 | 19 | ```bash |
35 | 20 | npm install |
36 | 21 | ``` |
37 | 22 |
|
38 | | -3. **Copy environment variables and configure** |
| 23 | +2. **Configure environment variables** |
39 | 24 |
|
40 | 25 | ```bash |
41 | 26 | cp .env.example .env |
42 | 27 | ``` |
43 | 28 |
|
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/) |
| 29 | + - `TRIGGER_SECRET_KEY` – From [Trigger.dev dashboard](https://cloud.trigger.dev/) |
| 30 | + - `TRIGGER_PROJECT_REF` – Your project ref (starts with `proj_`) |
| 31 | + - `ANTHROPIC_API_KEY` – From [Anthropic Console](https://console.anthropic.com/) |
49 | 32 |
|
50 | | -4. **Start the development servers** |
| 33 | +3. **Start development servers** |
51 | 34 |
|
52 | 35 | ```bash |
53 | | - # Terminal 1: Start Next.js dev server |
| 36 | + # Terminal 1: Next.js |
54 | 37 | npm run dev |
55 | 38 |
|
56 | | - # Terminal 2: Start Trigger.dev CLI |
| 39 | + # Terminal 2: Trigger.dev |
57 | 40 | npx trigger.dev@latest dev |
58 | 41 | ``` |
59 | 42 |
|
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: |
| 43 | +4. Open [http://localhost:3000](http://localhost:3000) in your browser |
65 | 44 |
|
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 |
| 45 | +## Features |
73 | 46 |
|
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)) |
| 47 | +- **Ask anything about any public repo** – Architecture, security vulnerabilities, API endpoints, testing strategies, etc. |
| 48 | +- **Claude Agent SDK exploration** – Claude explores the codebase using Grep and Read tools to provide detailed answers |
| 49 | +- **Cancel anytime** – Abort long-running tasks with proper cleanup |
| 50 | +- **Trigger.dev Realtime streaming** – Watch Claude's analysis stream in as it's generated |
| 51 | +- **Progress tracking** – See clone status, analysis progress, and repo size via Trigger.dev metadata |
80 | 52 |
|
81 | | -## Learn more |
| 53 | +## Relevant files |
82 | 54 |
|
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 |
| 55 | +- [`trigger/analyze-repo.ts`](trigger/analyze-repo.ts) – Main task that clones repo, runs Claude agent, and streams response |
| 56 | +- [`trigger/agent-stream.ts`](trigger/agent-stream.ts) – Typed stream definition for real-time text responses |
| 57 | +- [`app/api/analyze-repo/route.ts`](app/api/analyze-repo/route.ts) – API endpoint that triggers the task and returns a public access token |
| 58 | +- [`app/response/[runId]/page.tsx`](app/response/[runId]/page.tsx) – Real-time streaming display with progress |
| 59 | +- [`trigger.config.ts`](trigger.config.ts) – Project config with external SDK bundle |
0 commit comments