davila7/claude-code-templates · error

Please provide a detailed prompt (at least 10 characters)

Error message

Please provide a detailed prompt (at least 10 characters)

What it means

POST /api/execute requires a non-empty prompt of at least 10 characters in the request body. The endpoint destructures { prompt } from req.body and returns 400 with this message when prompt is missing, empty, or shorter than 10 characters after trimming.

Source

Thrown at cli-tool/src/sandbox-server.js:138

app.use('/js', express.static(path.join(__dirname, '../../docs/js')));
app.use('/assets', express.static(path.join(__dirname, '../../docs/assets')));

// Serve components.json for agent autocomplete
app.get('/components.json', (req, res) => {
    const componentsPath = path.join(__dirname, '../../docs/components.json');
    if (fs.existsSync(componentsPath)) {
        res.sendFile(componentsPath);
    } else {
        res.status(404).json({ error: 'Components file not found' });
    }
});

// API endpoint to execute task (local or cloud)
app.post('/api/execute', async (req, res) => {
    const { prompt, mode = 'local', agent = 'development-team/frontend-developer' } = req.body;
    
    if (!prompt || prompt.trim().length < 10) {
        return res.status(400).json({
            success: false,
            error: 'Please provide a detailed prompt (at least 10 characters)'
        });
    }
    
    const taskId = `task-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
    
    // Create task object
    const task = {
        id: taskId,
        title: prompt.substring(0, 60) + (prompt.length > 60 ? '...' : ''),
        prompt: prompt.trim(),
        agent: agent,
        mode: mode,
        status: 'running',
        startTime: new Date(),
        progress: 0,
        output: [],

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Send a prompt of at least 10 non-whitespace characters in the JSON body
  2. Ensure the request includes header Content-Type: application/json so Express parses req.body
  3. Validate prompt length client-side before calling the endpoint

Example fix

// before
await fetch(`${base}/api/execute`, {
  method: 'POST',
  body: JSON.stringify({ prompt: 'test' })
});
// after
await fetch(`${base}/api/execute`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ prompt: 'Refactor the login form to use React hooks' })
});
Defensive patterns

Strategy: validation

Validate before calling

function isValidPrompt(p) {
  return typeof p === 'string' && p.trim().length >= 10;
}
if (!isValidPrompt(prompt)) throw new Error('prompt must be >= 10 chars');

Type guard

const isValidPrompt = (p) => typeof p === 'string' && p.trim().length >= 10;

Prevention

When it happens

Trigger: POST /api/execute with body {"prompt":"hi"}, {"prompt":""}, or with no prompt field at all; also a request without JSON content-type so req.body.prompt is undefined.

Common situations: Client sends a placeholder or test prompt; forgetting to set Content-Type: application/json so the body is not parsed; sending a prompt field with a whitespace-only string.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/39c0ffecef8ac5db. Report an issue: GitHub.