Skip to main content
Glama
gr3enarr0w

Claude Code Prompt Engineer

by gr3enarr0w

engineer_prompt

Engineers and optimizes prompts for Claude Code with interactive refinement and automatic optimization to improve effectiveness.

Instructions

Intelligently engineers and optimizes prompts for Claude Code, with interactive refinement and automatic optimization for maximum effectiveness.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe raw user prompt that needs engineering
languageNoThe programming language (optional, will be detected if not provided)
contextNoAdditional context about the codebase or project (optional)
interactiveNoWhether to enable interactive Q&A refinement (default: false)

Implementation Reference

  • Main handler for the engineer_prompt tool in the CallToolRequestSchema. Validates arguments, handles interactive and direct modes, manages sessions, and returns optimized prompts.
    case "engineer_prompt": {
      if (!isEngineerPromptArgs(args)) {
        throw new Error("Invalid arguments for engineer_prompt");
      }
      
      const { prompt, language, context, interactive } = args;
      
      if (interactive) {
        // Start interactive session
        const sessionId = generateSessionId();
        const detectedInfo = await detectLanguageAndTaskType(prompt);
        const questions = await generateClarifyingQuestions(prompt, language || detectedInfo.language, context);
        
        activeSessions.set(sessionId, {
          originalPrompt: prompt,
          context: context ? [context] : [],
          refinements: [],
          language: language || detectedInfo.language,
          complexity: detectedInfo.complexity as any,
          taskType: detectedInfo.taskType as any
        });
        
        return {
          content: [{ 
            type: "text", 
            text: `Interactive prompt engineering session started (ID: ${sessionId}).\n\nTo help create the best prompt for Claude Code, please answer these questions:\n\n${questions.map((q, i) => `${i + 1}. ${q}`).join('\n')}\n\nUse the answer_questions tool with session ID "${sessionId}" to provide your answers.`
          }],
          isError: false,
        };
      } else {
        // Direct prompt engineering
        const engineeredPrompt = await engineerPrompt(prompt, language, context);
        return {
          content: [{ 
            type: "text", 
            text: `**Optimized Prompt for Claude Code:**\n\n${engineeredPrompt}\n\n**Are you ready to proceed with this task?**`
          }],
          isError: false,
        };
      }
    }
  • Tool definition including name, description, and input schema for engineer_prompt.
    const ENGINEER_PROMPT_TOOL: Tool = {
      name: "engineer_prompt",
      description: "Intelligently engineers and optimizes prompts for Claude Code, with interactive refinement and automatic optimization for maximum effectiveness.",
      inputSchema: {
        type: "object",
        properties: {
          prompt: {
            type: "string",
            description: "The raw user prompt that needs engineering"
          },
          language: {
            type: "string",
            description: "The programming language (optional, will be detected if not provided)"
          },
          context: {
            type: "string", 
            description: "Additional context about the codebase or project (optional)"
          },
          interactive: {
            type: "boolean",
            description: "Whether to enable interactive Q&A refinement (default: false)"
          }
        },
        required: ["prompt"],
        title: "engineer_promptArguments"  
      }
    };
  • index.ts:570-572 (registration)
    Registers the engineer_prompt tool by including ENGINEER_PROMPT_TOOL in the ListTools response.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [ENGINEER_PROMPT_TOOL, ASK_CLARIFICATION_TOOL, ANSWER_QUESTIONS_TOOL, AUTO_OPTIMIZE_TOOL],  
    }));
  • Internal helper function that performs the core prompt engineering by delegating to generateOptimizedPrompt.
    async function engineerPrompt(
      prompt: string, 
      language?: string, 
      context?: string, 
      refinements: string[] = []
    ): Promise<string> {
      // Always use built-in optimization - no external API calls
      return generateOptimizedPrompt(prompt, language, context, refinements);
    }
  • Type guard function for validating input arguments to the engineer_prompt tool.
    function isEngineerPromptArgs(args: unknown): args is { 
      prompt: string; 
      language?: string;
      context?: string;
      interactive?: boolean;
    } {
      return (
        typeof args === "object" &&
        args !== null &&
        "prompt" in args &&
        typeof (args as { prompt: string }).prompt === "string"
      );
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'interactive refinement' and 'automatic optimization,' which gives some behavioral context, but lacks details on how the optimization works, what 'maximum effectiveness' entails, potential rate limits, authentication needs, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It avoids redundancy and wastes no words, making it easy to parse. However, it could be slightly more structured by separating key features for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and 4 parameters with full schema coverage, the description is minimally adequate. It covers the tool's purpose and hints at behavior but lacks details on output, optimization specifics, and error handling. For a tool with interactive and optimization features, more context would be beneficial to ensure complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain how 'interactive' refinement works in practice). With high schema coverage, the baseline is 3, as the description doesn't compensate with extra insights.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Intelligently engineers and optimizes prompts for Claude Code' with specific verbs ('engineers', 'optimizes') and resource ('prompts'). It distinguishes from sibling tools like 'answer_questions' and 'ask_clarification' by focusing on prompt engineering rather than direct Q&A. However, it doesn't explicitly differentiate from 'auto_optimize', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through phrases like 'interactive refinement' and 'automatic optimization for maximum effectiveness,' suggesting when interactive mode might be beneficial. However, it doesn't explicitly state when to use this tool versus alternatives like 'auto_optimize' or provide clear exclusions. The guidance is present but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gr3enarr0w/cc_peng_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server