enhance_prompt
Improve prompt quality by applying optimal engineering techniques like chain-of-thought reasoning based on intent analysis.
Instructions
Enhance a prompt with the best prompt engineering technique for its intent.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | The raw prompt to enhance | |
| technique | No | Force a specific technique ID (optional) |
Implementation Reference
- bin/prompte-mcp.js:150-183 (handler)The implementation of the `enhance_prompt` tool within the `dispatch` function in `bin/prompte-mcp.js`. It validates input, handles technique forcing, calls the `enhance` engine, updates session stats, and formats the result.
case 'enhance_prompt': { const { prompt, technique: forceTechnique } = args; if (!prompt) throw new Error('prompt is required'); let overrides = {}; if (forceTechnique) { const { getTechniqueNames } = await import('../src/techniques/library.js'); const others = getTechniqueNames().filter(id => id !== forceTechnique); overrides = { preferredTechniques: [forceTechnique], disabledTechniques: others }; } const result = await enhance(prompt, overrides); sessionStats.enhanced++; if (result.technique) sessionStats.accepted++; else sessionStats.skipped++; // techniqueInstruction tells Claude how to apply the technique with its own // intelligence rather than using the static template verbatim. const techniqueInstruction = result.technique ? `Apply the ${result.technique.name} technique when answering: ${result.technique.description}.` : null; return { original: result.original, techniqueInstruction, technique: result.technique, intent: result.intent, confidence: result.confidence, bypassed: result.bypassed, // enhanced is still included for the UserPromptSubmit hook, which needs // a ready-to-use string before Claude sees the prompt at all. enhanced: result.enhanced, }; } - src/engine/index.js:58-110 (handler)The core `enhance` function in `src/engine/index.js` which orchestrates classification, technique scoring, and prompt rewriting.
export async function enhance(prompt, overrideConfig = {}) { const globalConfig = getConfig(); const projectConfig = getProjectConfig(); const config = { ...globalConfig, ...projectConfig, ...overrideConfig }; if (shouldBypass(prompt, config)) { return { original: prompt, enhanced: prompt.startsWith(config.bypassPrefix) ? prompt.slice(config.bypassPrefix.length).trimStart() : prompt, technique: null, intent: null, confidence: null, classifierMode: null, bypassed: true, }; } const classification = classify(prompt); const { intent, confidence, techniqueScores, mode } = classification; const ranked = scoreTechniques(techniqueScores, config); const best = ranked[0]; if (best.score < 0) { // All techniques disabled return { original: prompt, enhanced: prompt, technique: null, intent, confidence, classifierMode: mode, bypassed: false, }; } const enhanced = best.technique.apply(prompt); return { original: prompt, enhanced, technique: { id: best.technique.id, name: best.technique.name, description: best.technique.description, }, intent, confidence, classifierMode: mode, bypassed: false, score: best.score, }; } - bin/prompte-mcp.js:75-86 (registration)MCP tool registration for `enhance_prompt` in `bin/prompte-mcp.js`.
{ name: 'enhance_prompt', description: 'Enhance a prompt with the best prompt engineering technique for its intent.', inputSchema: { type: 'object', properties: { prompt: { type: 'string', description: 'The raw prompt to enhance' }, technique: { type: 'string', description: 'Force a specific technique ID (optional)' }, }, required: ['prompt'], }, },