Apply a github-tools recipe to this project
Shorter than the full examples, these are single-file snippets for one specific technique. Each one reads GITHUB_TOKEN from the environment by default, swap in Vercel Connect if you're deploying on Vercel.
Triage incoming issues with selective approval
Approves destructive actions but lets comments through unattended:
import { createGithubTools } from '@github-tools/sdk'
import { generateText } from 'ai'
const { text } = await generateText({
model: 'anthropic/claude-sonnet-4.6',
tools: createGithubTools({
preset: 'issue-triage',
requireApproval: {
addIssueComment: false,
closeIssue: true,
createIssue: true,
},
}),
prompt: `
Read all issues labeled "needs-triage" on vercel-labs/github-tools.
For each one, classify it as bug, feature, or question.
Post a comment with the classification and a suggested next step.
`,
})
See Configure approval per operation for the full risk table.
Build a reusable review agent
For behavior shared across multiple calls, use createGithubAgent once and call it repeatedly:
import { createGithubAgent } from '@github-tools/sdk'
const reviewer = createGithubAgent({
model: 'anthropic/claude-sonnet-4.6',
preset: 'code-review',
system: `
You review pull requests for code quality and security issues.
Always cite specific file paths and line numbers.
Never approve a PR that introduces console.log statements.
`,
})
Explore a repository, read-only
A script with no write permissions at all, safe to run against any repo:
import { createGithubTools } from '@github-tools/sdk'
import { streamText } from 'ai'
const result = streamText({
model: 'anthropic/claude-sonnet-4.6',
tools: createGithubTools({ preset: 'repo-explorer' }),
prompt: 'Find all TypeScript files that export a function named "create" in vercel-labs/github-tools and explain what each one does.',
})
for await (const chunk of result.textStream) {
process.stdout.write(chunk)
}
Run a maintainer workflow with full approval
Full write access, gated behind approval on every operation:
import { createGithubTools } from '@github-tools/sdk'
import { generateText } from 'ai'
const { text } = await generateText({
model: 'anthropic/claude-sonnet-4.6',
tools: createGithubTools({
preset: 'maintainer',
requireApproval: true,
}),
prompt: `
Check if there are any stale issues (no activity for 30 days) on vercel-labs/github-tools.
For each stale issue, post a comment asking the author for an update.
If no response after the comment, close the issue with a polite message.
`,
})
See the full eve version of this task for a standalone agent, schedule included.
Reduce tool context with toolpick
With all 53 tools visible on every step, tool definitions eat tokens. toolpick selects only the most relevant ones per step:
import { createGithubTools } from '@github-tools/sdk'
import { createToolIndex } from 'toolpick'
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'
const tools = createGithubTools()
const index = createToolIndex(tools, {
embeddingModel: openai.embeddingModel('text-embedding-3-small'),
})
const result = await generateText({
model: openai('gpt-4o'),
tools,
prepareStep: index.prepareStep(),
prompt: 'Check if the CI is passing on the main branch of vercel/ai.',
})
Each step, toolpick picks the best ~5 tools. All tools remain callable, only the visible set changes. Add a rerankerModel for maximum accuracy on ambiguous queries:
const index = createToolIndex(tools, {
embeddingModel: openai.embeddingModel('text-embedding-3-small'),
rerankerModel: openai('gpt-4o-mini'),
})
See toolpick docs for caching, description enrichment, and model-driven discovery options.
Add AI observability with evlog
Wrap the model with evlog to log token usage, tool calls, cost, and timing for every agent turn:
import { createGithubTools } from '@github-tools/sdk'
import { generateText } from 'ai'
import { createLogger } from 'evlog'
import { createAILogger } from 'evlog/ai'
const log = createLogger()
const ai = createAILogger(log, { toolInputs: { maxLength: 500 } })
const result = await generateText({
model: ai.wrap('anthropic/claude-sonnet-4.6'),
tools: createGithubTools({ preset: 'code-review' }),
prompt: 'Review the latest PR on vercel-labs/github-tools.',
})
log.emit()
Choose the right pattern
| Pattern | Entry point | Best for |
|---|---|---|
| One-shot generation | generateText + createGithubTools | scripts, CLI tools, batch jobs |
| Streaming | streamText + createGithubTools | chat UIs, interactive terminals |
| Reusable agent | createGithubAgent | multi-turn assistants, persistent bots |
| eve agent | githubExtension from @github-tools/eve-extension | standalone agents in 3 files, durable HITL approval (once, predicates) |
| Durable agent + streaming | createDurableGithubAgent + "use workflow" | hosted chat, crash-safe tool loops, Nuxt/Next APIs on Vercel |
| Platform bot | createGithubTools + Chat SDK + Workflow | GitHub/Slack/Discord bots with durable multi-turn sessions |
| Multi-agent | eve subagents or agent-as-tool | one entry point routing to preset-scoped specialists |
See API Reference for the full type signatures and Tools Catalog for every available tool.