feat: add review_plan prompt builder

This commit is contained in:
2026-06-11 15:55:42 +01:00
parent 008f38e630
commit 89940c25fb
4 changed files with 428 additions and 3 deletions
+84 -1
View File
@@ -1 +1,84 @@
// review_plan prompt template.
// Tool-specific prompt builder for review_plan.
import { buildBasePrompt } from "./base.js";
/**
* Build a tool-specific prompt for the review_plan MCP tool.
*
* @param {{ question: string, context?: string, constraints?: string[], expectedOutput?: string, projectSummary?: string, taskSummary?: string }} input
* @returns {string} A two-part prompt: base system message + review_plan user message.
*/
export function buildReviewPlanPrompt(input) {
if (!input || typeof input.question !== "string" || input.question.length === 0) {
const err = new TypeError("review_plan requires a non-empty 'question' field.");
err.kind = "ValidationError";
throw err;
}
const base = buildBasePrompt();
const lines = [
"",
"---",
"",
"You are acting as a plan reviewer for Claude Code. Claude Code will implement your suggestions — you do not implement anything yourself.",
"",
"Your task: review the proposed implementation plan and identify issues before Claude Code acts on it.",
"",
"Review the plan systematically across these dimensions:",
"- Missing requirements — steps, edge cases, or considerations the plan omits.",
"- Risks — operational, security, reliability, or deployment risks.",
"- Incorrect assumptions — any false or unverified premises in the plan.",
"- Security concerns — secrets handling, auth, authorization, injection, data exposure.",
"- Maintainability concerns — complexity, future modification cost, test gaps.",
"- Over-engineering — parts of the plan that are unnecessarily complex; suggest simpler alternatives.",
"- Task decomposition — tasks that should be split into smaller, safer steps.",
"- Pre-implementation validation — anything that should be validated before implementation begins.",
"",
"Respond in this exact structure:",
"- Summary: Brief overall assessment.",
"- Risks: Listed items with severity.",
"- Missing Requirements: Listed items.",
"- Assumptions: Incorrect or risky assumptions identified.",
"- Recommended Changes: Specific changes to the plan.",
"- Suggested Next Steps: Ordered actions for Claude Code to take.",
"",
"Important rules:",
"- Claude Code remains the implementation agent. You are acting only as a reviewer.",
"- Use only the context provided — do not assume access to the full repository.",
"- Call out uncertainty clearly — do not guess about unprovided information.",
"",
];
lines.push(`Question: ${input.question}`);
if (input.context) {
lines.push("");
lines.push(`Context: ${input.context}`);
}
if (input.constraints && input.constraints.length > 0) {
lines.push("");
lines.push("Constraints:");
for (const c of input.constraints) {
lines.push(`- ${c}`);
}
}
if (input.expectedOutput) {
lines.push("");
lines.push(`Expected output: ${input.expectedOutput}`);
}
if (input.projectSummary) {
lines.push("");
lines.push(`Project summary: ${input.projectSummary}`);
}
if (input.taskSummary) {
lines.push("");
lines.push(`Task summary: ${input.taskSummary}`);
}
return base + "\n" + lines.join("\n");
}