-
Notifications
You must be signed in to change notification settings - Fork 17
Added claude agent wiki example #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
D-K-P
wants to merge
28
commits into
main
Choose a base branch
from
claude-agent-github-wiki
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f0eec34
initial commit
D-K-P 9904d13
First pass
D-K-P 04a741f
Started skeletoning out broadcasts
D-K-P e3ad906
Started cleanup
D-K-P c8e9db5
Simpified architecture
D-K-P b3595c7
More experimentation
D-K-P df16170
More tweaks
D-K-P ad4ae4a
Simplify
D-K-P aa50329
Updated the streams to v2
D-K-P 36bcdc1
Now getting a message back but it’s a single chunk
D-K-P 57bd696
Parts coming through now
D-K-P a35b332
Fixing UI
D-K-P ce6ca5f
Merge branch 'main' into claude-agent-github-wiki
D-K-P 444c68b
Updated trigger packages
D-K-P 48384a7
Removed duplicate parts streaming
D-K-P 412fdbc
Removed unused code and console logs
D-K-P a90ae0d
Updated readme
D-K-P e25ddba
Delete unused file
D-K-P 0537dc6
Added example to the main table
D-K-P 282be2c
Improved the readme tech stack
D-K-P 040c27e
Fixed links
D-K-P 1fd637b
Added missing ‘type’ and updated trigger package
D-K-P ca78be9
Updated nextjs, removed reactmarkdown and added streamdown
D-K-P 58ca84d
Updated styling
D-K-P 036f5e1
Improved styling and task code
D-K-P 580475e
Updated the readme
D-K-P e47d632
Fixed text, updated readme
D-K-P d563f1f
Added video
D-K-P File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Trigger.dev Configuration | ||
| # Get these from https://cloud.trigger.dev | ||
| TRIGGER_PROJECT_REF=your_project_ref | ||
| TRIGGER_SECRET_KEY=your_secret_key | ||
|
|
||
| # Claude API Key | ||
| # Get from https://console.anthropic.com | ||
| ANTHROPIC_API_KEY=your_anthropic_api_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": "next/core-web-vitals" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| CLAUDE.md | ||
|
|
||
| postgres-data | ||
| # dependencies | ||
| node_modules | ||
| .pnp | ||
| .pnp.js | ||
|
|
||
| # testing | ||
| coverage | ||
|
|
||
| # next.js | ||
| .next/ | ||
| out/ | ||
| dist | ||
| packages/**/dist | ||
|
|
||
| # Tailwind | ||
| apps/**/styles/tailwind.css | ||
| packages/**/styles/tailwind.css | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # local env files | ||
| .env.docker | ||
| .docker/*.env | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| # turbo | ||
| .turbo | ||
| .vercel | ||
| .cache | ||
| .env | ||
| .output | ||
| apps/**/public/build | ||
| .tests-container-id.txt | ||
| .sentryclirc | ||
| .buildt | ||
|
|
||
| **/tmp/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /playwright/.cache/ | ||
|
|
||
| .cosine | ||
| .trigger | ||
| .tshy* | ||
| .yarn | ||
| *.tsbuildinfo | ||
| .claude |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # GitHub repository analyzer with Claude Agent SDK | ||
|
|
||
| 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. | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| - [**Next.js**](https://nextjs.org/) – React framework with App Router | ||
| - [**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 | ||
| - [**Trigger.dev**](https://trigger.dev/) – runs the agent in a long-running background task with real-time streaming to the frontend | ||
|
|
||
| ## Features | ||
|
|
||
| - **Ask anything about any public repo** – Architecture, security vulnerabilities, API endpoints, testing strategies, etc. | ||
| - **Claude Agent SDK exploration** – Claude explores the codebase and provide detailed answers | ||
| - **Cancel anytime** – Abort long-running Trigger.dev task with cleanup | ||
| - **Trigger.dev Realtime streaming** – Watch Claude's analysis stream in as it's generated | ||
| - **Progress tracking using Trigger.dev Realtime** – See clone status, analysis progress, and repo size | ||
|
|
||
| ## Setup & Running Locally | ||
|
|
||
| 1. **Clone the repository** | ||
|
|
||
| ```bash | ||
| git clone <repository-url> | ||
| cd claude-agent-github-wiki | ||
| ``` | ||
|
|
||
| 2. **Install dependencies** | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 3. **Copy environment variables and configure** | ||
|
|
||
| ```bash | ||
| cp .env.example .env | ||
| ``` | ||
|
|
||
| Fill in the required variables: | ||
|
|
||
| - `TRIGGER_SECRET_KEY` – Get from [Trigger.dev dashboard](https://cloud.trigger.dev/) | ||
| - `TRIGGER_PROJECT_REF` – Your Trigger.dev project ref (starts with `proj_`) | ||
| - `ANTHROPIC_API_KEY` – Get from [Anthropic Console](https://console.anthropic.com/) | ||
|
|
||
| 4. **Start development servers** | ||
|
|
||
| ```bash | ||
| # Terminal 1: Start Next.js dev server | ||
| npm run dev | ||
|
|
||
| # Terminal 2: Start Trigger.dev CLI | ||
| npx trigger.dev@latest dev | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) | ||
|
|
||
| ## How It Works | ||
|
|
||
| Trigger.dev orchestrates the repository analysis through a single long-running task: | ||
|
|
||
| 1. **`analyzeRepo`** – Main task that: | ||
| - Clones the repository to a temp directory (shallow clone for speed) | ||
| - Spawns a Claude agent with file system tools | ||
| - Streams Claude's response in real-time via Trigger.dev Realtime Streams | ||
| - Cleans up temp directory on completion or error | ||
|
|
||
| **Process flow:** | ||
|
|
||
| ``` | ||
| User enters GitHub URL + question | ||
| ↓ | ||
| API triggers analyzeRepo task | ||
| ↓ | ||
| Clone repo to temp directory | ||
| ↓ | ||
| Claude Agent SDK explores codebase with tools | ||
| ↓ | ||
| Response streams via Trigger.dev Realtime → Frontend | ||
| ↓ | ||
| Cleanup temp directory | ||
| ``` | ||
|
|
||
| **Claude's available tools:** | ||
|
|
||
| - **Bash** – Run shell commands to explore the repo | ||
| - **Glob** – Find files by pattern (e.g., `**/*.ts`) | ||
| - **Grep** – Search file contents with regex | ||
| - **Read** – Read file contents | ||
|
|
||
| ## Relevant Code | ||
|
|
||
| - **Main analysis task** – Clones repo, runs Claude agent, streams response ([`trigger/analyze-repo.ts`](trigger/analyze-repo.ts)) | ||
| - **Stream definition** – Typed stream for real-time text responses ([`trigger/agent-stream.ts`](trigger/agent-stream.ts)) | ||
| - **API endpoint** – Triggers the task and returns access token ([`app/api/analyze-repo/route.ts`](app/api/analyze-repo/route.ts)) | ||
| - **Response page** – Real-time streaming display with progress ([`app/response/[runId]/page.tsx`](app/response/[runId]/page.tsx)) | ||
| - **Landing page** – Repository URL input with example repos ([`app/page.tsx`](app/page.tsx)) | ||
| - **Trigger.dev config** – Project settings with external SDK bundle ([`trigger.config.ts`](trigger.config.ts)) | ||
|
|
||
| ## Learn More | ||
|
|
||
| - [**Trigger.dev Realtime Streams**](https://trigger.dev/docs/realtime/streams) – Stream data from tasks to your frontend | ||
| - [**Trigger.dev React Hooks**](https://trigger.dev/docs/realtime/react-hooks/overview) – `useRealtimeStream` for consuming streams | ||
| - [**Claude Agent SDK**](https://platform.claude.com/docs/en/agent-sdk/overview) – Run Claude with agentic tool usage | ||
| - [**Trigger.dev schemaTask**](https://trigger.dev/docs/tasks/schemaTask) – Type-safe task payloads with Zod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { runs } from "@trigger.dev/sdk"; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const { runId } = await request.json(); | ||
|
|
||
| // Validate input | ||
| if (!runId || typeof runId !== "string") { | ||
| return NextResponse.json( | ||
| { error: "Run ID is required" }, | ||
| { status: 400 } | ||
| ); | ||
| } | ||
|
|
||
| // Cancel the running task | ||
| // This will trigger the AbortController in the task, which propagates to the Claude agent | ||
| await runs.cancel(runId); | ||
|
|
||
| return NextResponse.json({ success: true }); | ||
|
|
||
| } catch (error: any) { | ||
| console.error("Failed to abort task:", error); | ||
| return NextResponse.json( | ||
| { error: error.message || "Failed to abort task" }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { tasks } from "@trigger.dev/sdk"; | ||
| import { analyzeRepo } from "@/trigger/analyze-repo"; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const { repoUrl, question } = await request.json(); | ||
|
|
||
| // Validate inputs | ||
| if (!repoUrl || typeof repoUrl !== "string") { | ||
| return NextResponse.json( | ||
| { error: "Repository URL is required" }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| if (!question || typeof question !== "string") { | ||
| return NextResponse.json( | ||
| { error: "Question is required" }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| // Basic GitHub URL validation | ||
| const githubUrlPattern = /^https?:\/\/(www\.)?github\.com\/[\w-]+\/[\w.-]+/; | ||
| if (!githubUrlPattern.test(repoUrl)) { | ||
| return NextResponse.json( | ||
| { error: "Invalid GitHub URL format" }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| // Trigger the analyze task | ||
| const handle = await tasks.trigger<typeof analyzeRepo>( | ||
| "analyze-repo", | ||
| { repoUrl, question }, | ||
| ); | ||
|
|
||
| // Get public access token from handle (auto-generated, expires in 15 min) | ||
| const accessToken = handle.publicAccessToken; | ||
|
|
||
| // Return run details | ||
| return NextResponse.json({ | ||
| runId: handle.id, | ||
| accessToken, | ||
| }); | ||
| } catch (error: any) { | ||
| console.error("Failed to trigger analyze-repo task:", error); | ||
| return NextResponse.json( | ||
| { error: error.message || "Failed to start analysis" }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
|
|
||
| :root { | ||
| --foreground-rgb: 0, 0, 0; | ||
| --background-start-rgb: 214, 219, 220; | ||
| --background-end-rgb: 255, 255, 255; | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| :root { | ||
| --foreground-rgb: 255, 255, 255; | ||
| --background-start-rgb: 0, 0, 0; | ||
| --background-end-rgb: 0, 0, 0; | ||
| } | ||
| } | ||
|
|
||
| @layer base { | ||
| :root { | ||
| --background: 0 0% 100%; | ||
| --foreground: 0 0% 3.9%; | ||
| --card: 0 0% 100%; | ||
| --card-foreground: 0 0% 3.9%; | ||
| --popover: 0 0% 100%; | ||
| --popover-foreground: 0 0% 3.9%; | ||
| --primary: 0 0% 9%; | ||
| --primary-foreground: 0 0% 98%; | ||
| --secondary: 0 0% 96.1%; | ||
| --secondary-foreground: 0 0% 9%; | ||
| --muted: 0 0% 96.1%; | ||
| --muted-foreground: 0 0% 45.1%; | ||
| --accent: 0 0% 96.1%; | ||
| --accent-foreground: 0 0% 9%; | ||
| --destructive: 0 84.2% 60.2%; | ||
| --destructive-foreground: 0 0% 98%; | ||
| --border: 0 0% 89.8%; | ||
| --input: 0 0% 89.8%; | ||
| --ring: 0 0% 3.9%; | ||
| --chart-1: 12 76% 61%; | ||
| --chart-2: 173 58% 39%; | ||
| --chart-3: 197 37% 24%; | ||
| --chart-4: 43 74% 66%; | ||
| --chart-5: 27 87% 67%; | ||
| --radius: 0.5rem; | ||
| } | ||
| .dark { | ||
| --background: 0 0% 3.9%; | ||
| --foreground: 0 0% 98%; | ||
| --card: 0 0% 3.9%; | ||
| --card-foreground: 0 0% 98%; | ||
| --popover: 0 0% 3.9%; | ||
| --popover-foreground: 0 0% 98%; | ||
| --primary: 0 0% 98%; | ||
| --primary-foreground: 0 0% 9%; | ||
| --secondary: 0 0% 14.9%; | ||
| --secondary-foreground: 0 0% 98%; | ||
| --muted: 0 0% 14.9%; | ||
| --muted-foreground: 0 0% 63.9%; | ||
| --accent: 0 0% 14.9%; | ||
| --accent-foreground: 0 0% 98%; | ||
| --destructive: 0 62.8% 30.6%; | ||
| --destructive-foreground: 0 0% 98%; | ||
| --border: 0 0% 14.9%; | ||
| --input: 0 0% 14.9%; | ||
| --ring: 0 0% 83.1%; | ||
| --chart-1: 220 70% 50%; | ||
| --chart-2: 160 60% 45%; | ||
| --chart-3: 30 80% 55%; | ||
| --chart-4: 280 65% 60%; | ||
| --chart-5: 340 75% 55%; | ||
| } | ||
| } | ||
|
|
||
| @layer base { | ||
| * { | ||
| @apply border-border; | ||
| } | ||
| body { | ||
| @apply bg-background text-foreground; | ||
| } | ||
| } | ||
|
|
||
| @keyframes bounce { | ||
| 0%, 100% { | ||
| transform: translateY(0); | ||
| } | ||
| 50% { | ||
| transform: translateY(-0.5rem); | ||
| } | ||
| } | ||
|
|
||
| .animate-bounce { | ||
| animation: bounce 0.6s ease-in-out infinite; | ||
| } | ||
|
|
||
| .line-clamp-3 { | ||
| display: -webkit-box; | ||
| -webkit-line-clamp: 3; | ||
| -webkit-box-orient: vertical; | ||
| overflow: hidden; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.