Skip to content

Commit a90ae0d

Browse files
committed
Updated readme
1 parent 412fdbc commit a90ae0d

1 file changed

Lines changed: 68 additions & 156 deletions

File tree

claude-agent-github-wiki/README.md

Lines changed: 68 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,105 @@
1-
# GitHub Repository Chat with AI
1+
# GitHub repository analyzer with Claude Agent SDK
22

3-
A production-ready Next.js application that enables real-time conversations with GitHub repositories using Claude AI. Built with Trigger.dev for background processing, Supabase for realtime messaging, and Claude Agent SDK for intelligent code analysis.
4-
5-
## Architecture Overview
6-
7-
This application uses a hybrid architecture combining:
8-
9-
- **Trigger.dev Realtime Streams v2** for streaming AI responses (main data pipeline)
10-
- **Supabase Broadcast** for sending questions to the AI (lightweight control plane)
11-
- **Claude Agent SDK** for repository analysis with tool usage
12-
- **Build Extensions** for containerized git operations
13-
14-
## Key Features
15-
16-
- **Two-Task System**:
17-
- Task 1: Clones repository with git build extension
18-
- Task 2: Long-running chat session that maintains repo in memory
19-
- **No Re-cloning**: Repository stays in memory for entire chat session (up to 60 minutes)
20-
- **Real-time Streaming**: AI responses stream live via Trigger.dev Streams v2
21-
- **Tool Usage Visualization**: See Claude using Bash, Grep, Read, and other tools
22-
- **Session Management**: Unique session IDs link clone and chat operations
3+
AI-powered repository analyzer that lets you ask questions about any public GitHub repository. Uses Anthropic's Claude Agent SDK with agentic tools to explore codebases and provide detailed answers, with real-time streaming responses to the frontend via Trigger.dev.
234

245
## Tech Stack
256

26-
- **Frontend**: Next.js 14 (App Router), TypeScript, Tailwind CSS, shadcn/ui
27-
- **Backend**: Trigger.dev v4 for task orchestration
28-
- **AI**: Claude Agent SDK with extended thinking
29-
- **Realtime**: Trigger.dev Streams v2 + Supabase Broadcast
30-
- **Build**: Trigger.dev build extensions with apt-get for git
7+
- [**Next.js**](https://nextjs.org/) – React frontend framework
8+
- [**Claude Agent SDK**](https://github.com/anthropic-ai/claude-agent-sdk) – Agentic AI with tool usage
9+
- [**Trigger.dev**](https://trigger.dev/) – Background task orchestration with real-time streaming
3110

32-
## Getting Started
11+
## Features
3312

34-
### Prerequisites
13+
- **Ask anything about any public repo** – Architecture, security vulnerabilities, API endpoints, testing strategies, etc.
14+
- **Claude Agent SDK exploration** – Claude explores the codebase and provide detailed answers
15+
- **Cancel anytime** – Abort long-running Trigger.dev task with cleanup
16+
- **Trigger.dev Realtime streaming** – Watch Claude's analysis stream in as it's generated
17+
- **Progress tracking using Trigger.dev Realtime** – See clone status, analysis progress, and repo size
3518

36-
1. Create accounts and get API keys:
37-
- [Trigger.dev](https://cloud.trigger.dev) - Project ref and secret key
38-
- [Anthropic](https://console.anthropic.com) - Claude API key
39-
- [Supabase](https://app.supabase.com) - Project URL and anon key
19+
## Setup & Running Locally
4020

41-
### Environment Setup
21+
1. **Clone the repository**
4222

43-
1. Copy the example environment file:
23+
```bash
24+
git clone <repository-url>
25+
cd claude-agent-github-wiki
26+
```
4427

45-
```bash
46-
cp .env.example .env.local
47-
```
28+
2. **Install dependencies**
4829

49-
2. Add your API keys to `.env.local`:
30+
```bash
31+
npm install
32+
```
5033

51-
```env
52-
# Trigger.dev
53-
TRIGGER_PROJECT_REF=your_project_ref
54-
TRIGGER_SECRET_KEY=your_secret_key
34+
3. **Copy environment variables and configure**
5535

56-
# Claude API
57-
ANTHROPIC_API_KEY=your_anthropic_api_key
36+
```bash
37+
cp .env.example .env
38+
```
5839

59-
# Supabase
60-
SUPABASE_URL=your_supabase_project_url
61-
SUPABASE_ANON_KEY=your_supabase_anon_key
62-
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
63-
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your_supabase_anon_key
64-
```
40+
Fill in the required variables:
6541

66-
### Installation
42+
- `TRIGGER_SECRET_KEY` – Get from [Trigger.dev dashboard](https://cloud.trigger.dev/)
43+
- `TRIGGER_PROJECT_REF` – Your Trigger.dev project ref (starts with `proj_`)
44+
- `ANTHROPIC_API_KEY` – Get from [Anthropic Console](https://console.anthropic.com/)
6745

68-
```bash
69-
npm install
70-
```
46+
4. **Start development servers**
7147

72-
### Development
48+
```bash
49+
# Terminal 1: Start Next.js dev server
50+
npm run dev
7351

74-
Run both the Next.js app and Trigger.dev dev server:
52+
# Terminal 2: Start Trigger.dev CLI
53+
npx trigger.dev@latest dev
54+
```
7555

76-
```bash
77-
# Terminal 1: Next.js
78-
npm run dev
56+
Open [http://localhost:3000](http://localhost:3000)
7957

80-
# Terminal 2: Trigger.dev
81-
npx trigger.dev@latest dev
82-
```
83-
84-
Open [http://localhost:3000](http://localhost:3000)
85-
86-
### Deployment
58+
## How It Works
8759

88-
Deploy to Trigger.dev:
60+
Trigger.dev orchestrates the repository analysis through a single long-running task:
8961

90-
```bash
91-
npx trigger.dev@latest deploy
92-
```
62+
1. **`analyzeRepo`** – Main task that:
63+
- Clones the repository to a temp directory (shallow clone for speed)
64+
- Spawns a Claude agent with file system tools
65+
- Streams Claude's response in real-time via Trigger.dev Realtime Streams
66+
- Cleans up temp directory on completion or error
9367

94-
Deploy Next.js to Vercel:
68+
**Process flow:**
9569

96-
```bash
97-
vercel deploy
9870
```
99-
100-
## How It Works
101-
102-
### Flow Diagram
103-
104-
```
105-
User enters GitHub URL
106-
107-
Task 1: clone-repo (with git build extension)
71+
User enters GitHub URL + question
10872
109-
Returns { tempDir, sessionId, repoName }
73+
API triggers analyzeRepo task
11074
111-
Task 2: repo-chat-session (long-running, 60 min timeout)
75+
Clone repo to temp directory
11276
113-
Subscribes to Supabase channel for questions
77+
Claude Agent SDK explores codebase with tools
11478
115-
User sends questions → SupabaseTask 2
79+
Response streams via Trigger.dev RealtimeFrontend
11680
117-
Claude analyzes repo with tools
118-
119-
Responses stream via Trigger.dev Streams v2 → Frontend
120-
```
121-
122-
### Key Components
123-
124-
1. **Build Extension** (`trigger.config.ts`):
125-
126-
- Installs git via apt-get in container
127-
- Enables shallow cloning without local git dependency
128-
129-
2. **Clone Task** (`trigger/clone-repo.ts`):
130-
131-
- Performs shallow clone (`--depth=1`)
132-
- Generates unique session ID
133-
- Returns temp directory path
134-
135-
3. **Chat Session Task** (`trigger/repo-chat-session.ts`):
136-
137-
- Maintains repo in memory for 60 minutes
138-
- Listens for questions via Supabase Broadcast
139-
- Streams responses via Trigger.dev Streams v2
140-
- Cleans up temp directory on exit
141-
142-
4. **Frontend** (`app/chat/[runId]/page.tsx`):
143-
- Sends questions via Supabase
144-
- Receives responses via Trigger.dev Streams
145-
- Displays tool usage and AI reasoning
146-
147-
## Project Structure
148-
81+
Cleanup temp directory
14982
```
150-
app/
151-
├── page.tsx # Landing page
152-
├── chat/[runId]/page.tsx # Chat interface
153-
└── api/
154-
├── analyze-repo/ # Triggers both tasks
155-
└── chat/ # Sends questions via Supabase
156-
157-
trigger/
158-
├── clone-repo.ts # Task 1: Git clone
159-
├── repo-chat-session.ts # Task 2: Long-running chat
160-
└── agent-stream.ts # Shared stream definition
161-
162-
components/
163-
├── chat/
164-
│ ├── user-message.tsx # User message display
165-
│ ├── ai-message.tsx # AI response with markdown
166-
│ └── tool-card.tsx # Tool usage visualization
167-
└── ui/ # shadcn/ui components
168-
```
169-
170-
## Advanced Features
17183

172-
- **60-minute sessions**: Extended timeout for complex analysis
173-
- **Abort handling**: Graceful cleanup on cancellation
174-
- **Error recovery**: Fallback to Trigger.dev streams if Supabase fails
175-
- **Progress tracking**: Real-time status updates
176-
- **Tool visualization**: Collapsible tool results over 50 lines
84+
**Claude's available tools:**
17785

178-
## Limitations
86+
- **Bash** – Run shell commands to explore the repo
87+
- **Glob** – Find files by pattern (e.g., `**/*.ts`)
88+
- **Grep** – Search file contents with regex
89+
- **Read** – Read file contents
17990

180-
- Public repositories only (no auth for private repos)
181-
- Maximum session duration: 60 minutes
182-
- Shallow clone only (no full git history)
183-
- One active question at a time per session
91+
## Relevant Code
18492

185-
## Development Notes
93+
- **Main analysis task** – Clones repo, runs Claude agent, streams response ([`trigger/analyze-repo.ts`](trigger/analyze-repo.ts))
94+
- **Stream definition** – Typed stream for real-time text responses ([`trigger/agent-stream.ts`](trigger/agent-stream.ts))
95+
- **API endpoint** – Triggers the task and returns access token ([`app/api/analyze-repo/route.ts`](app/api/analyze-repo/route.ts))
96+
- **Response page** – Real-time streaming display with progress ([`app/response/[runId]/page.tsx`](app/response/[runId]/page.tsx))
97+
- **Landing page** – Repository URL input with example repos ([`app/page.tsx`](app/page.tsx))
98+
- **Trigger.dev config** – Project settings with external SDK bundle ([`trigger.config.ts`](trigger.config.ts))
18699

187-
This demo showcases:
100+
## Learn More
188101

189-
- Trigger.dev Realtime Streams v2 for data streaming
190-
- Build extensions for containerized dependencies
191-
- Hybrid architecture pattern (control + data plane separation)
192-
- Long-running task management
193-
- Claude Agent SDK integration
102+
- [**Trigger.dev Realtime Streams**](https://trigger.dev/docs/realtime/streams) – Stream data from tasks to your frontend
103+
- [**Trigger.dev React Hooks**](https://trigger.dev/docs/realtime/react-hooks/overview)`useRealtimeStream` for consuming streams
104+
- [**Claude Agent SDK**](https://github.com/anthropic-ai/claude-agent-sdk) – Run Claude with agentic tool usage
105+
- [**Trigger.dev schemaTask**](https://trigger.dev/docs/tasks/schematask) – Type-safe task payloads with Zod

0 commit comments

Comments
 (0)