davila7/claude-code-templates · error · Error
GitHub API error: ${response.status}
Error message
GitHub API error: ${response.status} What it means
Thrown after listing agent directories/components via the GitHub Contents API when the response is not OK (and none of the built-in fallback category listings applied). This is the batch/interactive agent listing path: a failed GitHub API call (rate limit 403, 5xx, network failure) aborts listing available agents.
Source
Thrown at cli-tool/src/index.js:1475
// Return comprehensive fallback list
return [
{ name: 'frontend-developer', path: 'development-team/frontend-developer', category: 'development-team' },
{ name: 'backend-developer', path: 'development-team/backend-developer', category: 'development-team' },
{ name: 'fullstack-developer', path: 'development-team/fullstack-developer', category: 'development-team' },
{ name: 'devops-engineer', path: 'development-team/devops-engineer', category: 'development-team' },
{ name: 'nextjs-architecture-expert', path: 'web-tools/nextjs-architecture-expert', category: 'web-tools' },
{ name: 'react-developer', path: 'web-tools/react-developer', category: 'web-tools' },
{ name: 'vue-developer', path: 'web-tools/vue-developer', category: 'web-tools' },
{ name: 'data-scientist', path: 'data-analytics/data-scientist', category: 'data-analytics' },
{ name: 'data-analyst', path: 'data-analytics/data-analyst', category: 'data-analytics' },
{ name: 'security-auditor', path: 'security/security-auditor', category: 'security' },
{ name: 'api-security-audit', path: 'api-security-audit', category: 'root' },
{ name: 'database-optimization', path: 'database-optimization', category: 'root' },
{ name: 'react-performance-optimization', path: 'react-performance-optimization', category: 'root' }
];
}
}
throw new Error(`GitHub API error: ${response.status}`);
}
const contents = await response.json();
const agents = [];
for (const item of contents) {
if (item.type === 'file' && item.name.endsWith('.md')) {
// Direct agent file
agents.push({
name: item.name.replace('.md', ''),
path: item.name.replace('.md', ''),
category: 'root'
});
} else if (item.type === 'dir') {
// Category directory, fetch its contents
try {
const categoryResponse = await fetch(`https://api.github.com/repos/davila7/claude-code-templates/contents/cli-tool/components/agents/${item.name}`);
if (categoryResponse.ok) {View on GitHub (pinned to a0851ed10c)
Solutions
- Wait for rate-limit reset or export GITHUB_TOKEN to authenticate API requests
- Retry after checking https://www.githubstatus.com
- Run from a network that doesn't block api.github.com
- Pin an exact agent name (`--agent <name>`) to skip the directory listing entirely
Example fix
// before
throw new Error(`GitHub API error: ${response.status}`);
// after
console.error(`GitHub API error: ${response.status}. Rate limited? Set GITHUB_TOKEN.`);
return []; // graceful degradation to empty list Defensive patterns
Strategy: fallback
Validate before calling
const r = await fetch('https://api.github.com/rate_limit');
const { resources: { core: { remaining } } } = await r.json();
if (remaining < 10 && !process.env.GITHUB_TOKEN) {
console.warn('GitHub API quota low — listing may fail; set GITHUB_TOKEN');
} Try / catch
try {
const agents = await listAvailableAgents();
renderMenu(agents);
} catch (e) {
if (/GitHub API error: 403/.test(e.message)) {
renderMenu(FALLBACK_AGENT_LIST); // use a pinned local list
} else throw e;
} Prevention
- Cache the agent list locally between runs instead of re-fetching
- Set GITHUB_TOKEN for authenticated requests
- Pin specific agents with --agent <name> to bypass listing
When it happens
Trigger: Fetching the component agents directory listing (github repo contents API) during interactive mode or `--agent list`-style flows; any non-200 response (403 rate limit, 500, proxy block) that doesn't match the hardcoded fallback branches throws.
Common situations: Unauthenticated GitHub API rate limit (60 req/hr/IP) exhausted after repeated CLI runs; CI runners on shared IPs; GitHub API incidents; restrictive corporate firewalls.
Related errors
- Warning: Could not fetch category ${item.name}:
- HTTP {}
- Warning: Could not fetch agents, using fallback list
- Invalid response from x0.at: ${uploadUrl || stderr}
- Download failed: ${stderr}
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/718b1862ae680b42.
Report an issue: GitHub.