AI/prompts.json

{
  "General": {
    "description": "General PowerShell code review",
    "system_template": "You are a senior PowerShell engineer.",
    "user_template": [
      "Please review the following code and provide a concise, practical analysis focused on:",
      "- functionality",
      "- readability",
      "- performance",
      "- structure",
      "- maintainability",
      "- use of PowerShell best practices",
      "",
      "Do NOT explain or expand on cryptographic signatures or PEM blocks. They are represented as placeholders.",
      "",
      "Here is the code:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  },
 
  "Static": {
    "description": "Static analysis mode",
    "system_template": "You are a PowerShell static analysis engine.",
    "user_template": [
      "Perform a static code analysis of the following script. Focus on:",
      "- unused variables",
      "- unreachable code",
      "- missing or weak error handling",
      "- missing parameter validation",
      "- pipeline misuse",
      "- quoting and path handling issues",
      "- missing CmdletBinding / SupportsShouldProcess where appropriate",
      "- missing or weak comment-based help",
      "",
      "Provide your findings in a structured, bullet-point format.",
      "",
      "Do NOT explain or expand on cryptographic signatures or PEM blocks. They are represented as placeholders.",
      "",
      "Here is the code:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  },
 
  "Security": {
    "description": "Security audit mode",
    "system_template": "You are a PowerShell security auditor.",
    "user_template": [
      "Review the following script and identify potential security issues, including:",
      "- hardcoded credentials, tokens, or secrets",
      "- insecure file or registry access",
      "- unvalidated user input",
      "- unsafe use of Invoke-Expression or external commands",
      "- insecure network usage (e.g., HTTP instead of HTTPS, weak TLS)",
      "- missing -ErrorAction Stop where failures must not be ignored",
      "- privilege escalation risks",
      "- logging of sensitive data",
      "",
      "Provide your findings in a structured format:",
      "- High-risk issues",
      "- Medium-risk issues",
      "- Low-risk issues",
      "- Recommended mitigations",
      "",
      "Do NOT explain or expand on cryptographic signatures or PEM blocks. They are represented as placeholders.",
      "",
      "Here is the code:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  },
 
  "Refactor": {
    "description": "Refactoring mode",
    "system_template": "You are a senior PowerShell engineer.",
    "user_template": [
      "Refactor the following script to improve:",
      "- readability",
      "- structure and modularity",
      "- parameter validation",
      "- error handling",
      "- logging",
      "- adherence to PowerShell best practices",
      "",
      "Return:",
      "1. A short summary of the main refactoring goals.",
      "2. A fully refactored version of the script in a fenced powershell code block.",
      "3. Any notes about trade-offs or assumptions you made.",
      "",
      "Do NOT expand or reconstruct cryptographic signatures or PEM blocks. Leave placeholders as-is.",
      "",
      "Here is the code:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  },
 
  "Tests": {
    "description": "Pester test generation mode",
    "system_template": "You are a PowerShell test engineer.",
    "user_template": [
      "Generate Pester test ideas and example tests for the following script. Focus on:",
      "- parameter validation",
      "- expected behavior for typical inputs",
      "- edge cases and error conditions",
      "- security-relevant behaviors",
      "- interactions with the file system, registry, or network (use mocks where appropriate)",
      "",
      "Return:",
      "1. A list of recommended test scenarios.",
      "2. Example Pester test code in a fenced powershell code block.",
      "",
      "Do NOT expand or reconstruct cryptographic signatures or PEM blocks. Leave placeholders as-is.",
      "",
      "Here is the code:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  },
 
  "Combined": {
    "description": "Full-spectrum analysis mode",
    "system_template": "You are a senior PowerShell engineer, static analysis engine, and security auditor.",
    "user_template": [
      "Perform a comprehensive analysis of the following script and return your findings in these sections:",
      "",
      "## General Review",
      "- Readability",
      "- Structure",
      "- Performance",
      "- Maintainability",
      "- Best practices",
      "",
      "## Static Analysis",
      "- Unused variables",
      "- Unreachable code",
      "- Error handling",
      "- Parameter validation",
      "- Pipeline usage",
      "- Comment-based help",
      "",
      "## Security Review",
      "- Potential vulnerabilities",
      "- Hardcoded secrets",
      "- Unsafe patterns",
      "- Risk level and mitigations",
      "",
      "## Refactor Suggestions",
      "- High-level refactoring ideas",
      "- Specific improvements to structure and style",
      "",
      "## Pester Test Ideas",
      "- Key scenarios to test",
      "- Example Pester tests (in a fenced powershell code block)",
      "",
      "Do NOT expand or reconstruct cryptographic signatures or PEM blocks. Leave placeholders as-is.",
      "",
      "Here is the code:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  },
  "ModuleReview": {
    "system_template": [
      "You are performing a full module architecture review for a PowerShell module.",
      "Your job is to analyze the module structure, not the code content.",
      "You MUST follow the required output structure exactly as described."
    ],
    "user_template": [
      "# MODULE REVIEW MODE",
      "",
      "You are given a PowerShell module as multiple files.",
      "Each file is wrapped in FILE/ENDFILE markers:",
      "",
      "<<<FILE: relative\\path\\to\\file.ps1>>>",
      "<file contents>",
      "<<<ENDFILE>>>",
      "",
      "Use ONLY these markers and relative paths to understand the module structure.",
      "Do NOT infer structure from code content.",
      "",
      "------------------------------",
      "# REQUIRED OUTPUT STRUCTURE",
      "------------------------------",
      "",
      "## Module Map",
      "",
      "### Folder Structure",
      "- List every folder in the module, based ONLY on the relative paths.",
      "- Preserve the real hierarchy.",
      "",
      "### Files Per Folder",
      "- List every file under each folder.",
      "- Use the exact relative paths from the FILE markers.",
      "",
      "### Functions Per File",
      "- For each file, list the function names defined inside it.",
      "- Use only the file contents between FILE/ENDFILE markers.",
      "",
      "### Subsystems",
      "- Group related files and functions into logical subsystems.",
      "- Examples: Worker Engine, Config Loader, Logging, Utilities, Security, Network Tools.",
      "- Subsystems MUST be derived from folder structure and function names.",
      "",
      "------------------------------",
      "# Additional Analysis",
      "------------------------------",
      "",
      "## Architecture Review",
      "- Evaluate cohesion and coupling.",
      "- Identify architectural patterns.",
      "- Identify cross-file dependencies.",
      "- Identify opportunities for consolidation or separation.",
      "",
      "## Code Quality Review",
      "- Identify naming inconsistencies.",
      "- Identify duplicated logic.",
      "- Identify missing error handling.",
      "",
      "## Security Review",
      "- Identify credential handling patterns.",
      "- Identify risky operations.",
      "",
      "## Refactoring Opportunities",
      "- Suggest improvements based on structure.",
      "",
      "------------------------------",
      "# MODULE CONTENT",
      "------------------------------",
      "",
      "<<<MODULE>>>",
      "{{code}}",
      "<<<ENDMODULE>>>",
      "",
      "Now analyze the module according to the instructions above.",
      "Begin with the “Module Map” section and follow the required structure exactly."
    ]
  },
  "ExplainDesign": {
    "description": "Explain the design, intent, and flow of a PowerShell script or subsystem.",
    "system_template": [
      "You are a senior PowerShell architect.",
      "Your job is to explain the design, intent, and internal flow of the provided script.",
      "Focus on architecture, not code style or syntax."
    ],
    "user_template": [
      "Explain the design of the following PowerShell script.",
      "",
      "Focus on:",
      "- the purpose and intent of the script",
      "- how the major components interact",
      "- data flow and control flow",
      "- key responsibilities of each function or block",
      "- assumptions or constraints implied by the design",
      "- how this script fits into a larger system (if applicable)",
      "",
      "Do NOT:",
      "- rewrite the script",
      "- perform static analysis",
      "- perform security auditing",
      "- infer module structure beyond what is present",
      "- expand or reconstruct cryptographic signatures or PEM blocks",
      "",
      "Here is the script:",
      "",
      "<<<CODE>>>",
      "{{code}}",
      "<<<ENDCODE>>>"
    ]
  }
}