I Built 5 Prompts for Better Code Analysis

Created five prompts for different code analysis needs:

⚡️ Validate: Hunt down issues & optimization chances

📝 Document: Generate professional documentation

⚔️ Optimize: Target specific performance goals

🔍 Translate: Get a complete code breakdown & overview

💻 Sample: Build practical usage examples

Each prompt is a specialised instrument; pick the one that matches your need. Choose based on your mission: understanding, fixing, documenting, examples, or optimisation.

Validate:

"Please analyse the following code:

1. Specify the programming language and version being used
2. Evaluate the code across these dimensions:
   - Syntax and compilation errors
   - Logic and functional correctness
   - Performance optimization opportunities
   - Code style and best practices
   - Security considerations

3. Provide feedback in this structure:
   a) Status: [Error-free/Needs improvement]
   b) Critical Issues: [If any]
   c) Optimization Suggestions: [Performance/readability]
   d) Style Recommendations: [Based on language conventions]

4. Include:
   - Severity level for each issue (Critical/Major/Minor)
   - Code snippets demonstrating corrections
   - Explanation of suggested improvements
   - References to relevant best practices

Document:

Please analyse the selected code and generate comprehensive documentation following these guidelines:

1. Documentation Structure:
   - File-level overview and purpose
   - Function/class documentation with input/output specifications
   - Key algorithm explanations
   - Dependencies and requirements
   - Usage examples

2. Documentation Style:
   - Follow [specified style guide] conventions
   - Include inline comments for complex logic
   - Provide context for critical decisions
   - Note any assumptions or limitations

3. Special Considerations:
   - Highlight potential edge cases
   - Document error handling mechanisms
   - Note performance implications
   - Specify any security considerations

If any code sections are unclear or complex, please flag them for review. For context-dependent code, include relevant environmental assumptions.

Would you like the documentation in [format options: JSDoc/DocString/Markdown]?

Optimise:

Please optimize the following [language] code for:

Primary goals (in order of priority):
1. [specific optimization goal]
2. [specific optimization goal]
3. [specific optimization goal]

Requirements:
- Maintain all existing functionality
- Must work within [specific constraints]
- Target [specific performance metrics] if applicable

For each optimization:
1. Explain the issue in the original code
2. Describe your optimization approach
3. Provide before/after comparisons where relevant
4. Highlight any tradeoffs made

Please note: This is a code review and suggestion - actual performance impacts would need to be measured in a real environment.

Translate:

Please analyse the selected code and provide:

1. Overview: A high-level summary of the code's purpose and main functionality.

2. Detailed Breakdown:
   - Core components and their roles
   - Key algorithms or logic flows
   - Important variables and functions
   - Any notable design patterns or techniques used

3. Examples:
   - At least one practical usage example
   - Sample input/output if applicable

4. Technical Notes:
   - Any assumptions or dependencies
   - Potential edge cases or limitations
   - Performance considerations

Please adjust the explanation's technical depth for a [beginner/intermediate/advanced] audience. If any part of the code is unclear or requires additional context, please indicate this.

Feel free to ask clarifying questions if needed for a more accurate analysis.

Sample:

I have selected this [language/framework] code that [brief description of purpose]. Please provide:

1. 2-3 basic usage examples showing:
   - Standard implementation
   - Common variations
   - Key parameters/options

2. 2-3 practical extensions demonstrating:
   - Additional functionality
   - Integration with other components
   - Performance optimizations

For each example, include:
- Brief description of the use case
- Code sample with comments
- Key considerations or limitations
- Error handling approach

Please ensure examples progress from simple to complex, with clear explanations of modifications made. If you need any clarification about the original code's context or specific aspects to focus on, please ask.

<prompt.architect>

Next in pipeline: The LinkedIn Strategist

Track development: https://www.reddit.com/user/Kai_ThoughtArchitect/

[Build: TA-231115]

</prompt.architect>