davila7/claude-code-templates · error
Agent name is required
Error message
Agent name is required
What it means
POST /api/install-agent requires an agentName field in the JSON body. The endpoint returns 400 immediately when agentName is falsy (missing, empty, null, undefined).
Source
Thrown at cli-tool/src/sandbox-server.js:225
progress: task.progress,
startTime: task.startTime,
endTime: task.endTime,
sandboxId: task.sandboxId,
output: task.output.slice(-3).join('\\n') // Last 3 lines for preview
}));
res.json({
success: true,
tasks: tasks.sort((a, b) => new Date(b.startTime) - new Date(a.startTime))
});
});
// API endpoint to install agent
app.post('/api/install-agent', async (req, res) => {
const { agentName } = req.body;
if (!agentName) {
return res.status(400).json({
success: false,
error: 'Agent name is required'
});
}
// SECURITY: agent names are `category/name` slugs. Reject anything else so a
// value like "x; rm -rf ~" can never reach the child process.
if (!/^[A-Za-z0-9._/-]+$/.test(agentName)) {
return res.status(400).json({
success: false,
error: 'Invalid agent name'
});
}
try {
console.log(chalk.blue('🔧 Installing agent:'), chalk.cyan(agentName));
// SECURITY: shell:false (default) keeps agentName as a single argv entry —View on GitHub (pinned to a0851ed10c)
Solutions
- Send {"agentName":"development-team/frontend-developer"} in the JSON body with Content-Type: application/json
- Check the field name is exactly agentName, matching the component slug format category/name
- Guard client-side that a non-empty agent was selected before submitting
Example fix
// before
{ "name": "frontend-developer" }
// after
{ "agentName": "development-team/frontend-developer" } Defensive patterns
Strategy: validation
Validate before calling
if (!body?.agentName || typeof body.agentName !== 'string') {
throw new Error('agentName is required');
} Type guard
const hasAgentName = (b) => b != null && typeof b.agentName === 'string' && b.agentName.length > 0;
Prevention
- Disable the install button until an agent is selected
- Send Content-Type: application/json
- Use the exact field name agentName with a category/name slug
When it happens
Trigger: POST /api/install-agent with body {}, {"agentName":""}, or {"agentName":null}; or a non-JSON request so req.body.agentName is undefined.
Common situations: Client UI submits before the agent selector is populated; forgetting Content-Type: application/json; sending a differently named field like name or agent instead of agentName.
Related errors
- sessionId and message are required
- Please provide a detailed prompt (at least 10 characters)
- Invalid cache type. Use "all" or "conversations"
- Invalid agent name
- Invalid workflow hash format. Expected format: #hash
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/8164ebb9c0923f73.
Report an issue: GitHub.