Changes between Version 2 and Version 3 of SOPs/AIcodingTools


Ignore:
Timestamp:
02/19/26 15:34:13 (41 hours ago)
Author:
xinlei.gao
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SOPs/AIcodingTools

    v2 v3  
    11== '''Why AI for coding?'''
    2 • Efficient: automatic code/documentation generation
    3 • Speed: accelerate data analysis pipeline development
    4 • Troubleshooting: get instant help with complex R/python errors
     2**Efficient**: automatic code/documentation generation
     3
     4**Speed**: accelerate data analysis pipeline development
     5
     6**Troubleshooting**: get instant help with complex R/python errors
    57
    68
    7 ----
    89== '''What is an AI Coding Assistant?'''
    9 • Definition: Large language model (LLMs) trained on massive code datasets.
    10 • Key capabilities: Code generation, code completion, Documentation, Language translation (e.g., python to R)
     10**Definition**: Large language model (LLMs) trained on massive code datasets.
    1111
    12 '''Set Clear Expectations'''
     12**Key capabilities**: Code generation, code completion, Documentation, Language translation (e.g., python to R)
    1313
    14 AI is a pair programmer, not a replacement for developer judgment. It accelerates work but requires human oversight.
     14'''Set Clear Expectations''': AI is a pair programmer, not a replacement for developer judgment. It accelerates work but requires human oversight.
    1515
    16 '''Key Features of AI Coding Assistants'''
     16=== '''Key Features of AI Coding Assistants'''
    1717||=Feature=||=Description=||
    1818||Code suggestions||Provides code suggestions based on comments and file context||
     
    3131
    3232
    33 '''Popular Tools for AI coding'''
    34 • Chat-based (ChatGPT, Gemini, Claude) Best for: reasoning, debugging, learning, prompt iteration
    35 • IDE-integrated (Github Copilot, Cursor, Claude Code) Best for: writing code faster inside existing projects
     33=== '''Popular Tools for AI coding'''
     34**Chat-based (ChatGPT, Gemini, Claude) **
     35
     36Best for: reasoning, debugging, learning, prompt iteration
     37
     38**IDE-integrated (Github Copilot, Cursor, Claude Code) **
     39
     40Best for: writing code faster inside existing projects
    3641
    3742
    3843----
    39 == '''General guidelines when using AI for coding'''
    40 '''1. Clear Problem Definition'''
    41 * Best Practice: Before asking ChatGPT for help, clearly define the problem or task. A well-defined question improves the quality of the response.
    4244
    43 * Example: Instead of saying “Fix my code,” provide context such as “I'm trying to optimize this Python function that clusters the sequence alignment positions in proximity recursively, but it's too slow for large inputs. How can I improve it?”
    4445
    45 '''2. Break Problems into Smaller Chunks'''
    46 * Best Practice: For complex tasks, break the problem down into smaller, manageable steps. Ask about each step individually to get focused and accurate assistance.
     46== Best Practices for Using AI Tools in Coding
    4747
    48 * Example: Rather than asking for a full solution in one go, ask for help with specific functions, then how to test them, and finally how to integrate them into your larger project.
    49 
    50 '''3. Iterate and Refine Your Questions'''
    51 * Best Practice: If the initial response isn’t quite right, clarify your question and ask for refinement. ChatGPT often improves its responses based on follow-up queries.
    52 
    53 * Example: “The solution works, but it doesn't handle edge cases where the input is negative. Can you adjust it?”
    54 
    55 '''4. Ask for Explanations, Not Just Code'''
    56 * Best Practice: Don’t just request code; ask for an explanation of how and why it works. This helps you learn and apply the knowledge in future problems.
    57 
    58 * Example: “Can you explain why you're using a heuristic search algorithm here and how it improves the time complexity?”
    59 
    60 '''5. Use ChatGPT for Code Reviews'''
    61 * Best Practice: Ask ChatGPT to review your code for potential improvements in readability, performance, or best practices.
    62 
    63 * Example: “Can you review this Python function for any inefficiencies or suggest improvements for readability?”
    64 
    65 '''6. Leveraging ChatGPT for Debugging'''
    66 * Best Practice: Provide the exact error message and a concise description of what the code is supposed to do when asking ChatGPT for debugging help.
    67 
    68 * Example: “I’m getting a TypeError in this Python code when trying to perform a log transformation. Can you help me identify why this is happening?”
    69 
    70 '''7. Specify Language, Framework, and Version'''
    71 * Best Practice: Always mention the programming language, framework, and version you're using to avoid receiving outdated or incompatible code.
    72 
    73 * Example: “I have a Python script created by Python 2.7. Could you please modify it to be compatible with Python 3.8?”
    74 
    75 '''8. Request Test Cases'''
    76 * Best Practice: Ask for test cases when getting help with functions or algorithms to ensure the solution is robust.
    77 
    78 * Example: “Can you provide a few test cases to verify that this sorting algorithm works with edge cases like empty lists or lists with duplicate values?”
    79 
    80 '''9. Use ChatGPT as a Learning Tool'''
    81 * Best Practice: Don’t just use ChatGPT to get answers—use it as a learning resource. Ask it to explain new concepts or techniques introduced in its responses.
    82 
    83 * Example: “You used dimentionality reduction in this solution. Can you explain what that is and when it should be used?”
    84 
    85 '''10. Understand Limitations and Double-Check Critical Code'''
    86 * Best Practice: ChatGPT might not always produce the optimal or correct code, especially in complex scenarios. Always review and test the code yourself.
    87 
    88 * Example: After receiving code from ChatGPT, test it thoroughly, and if it’s a critical part of your project, cross-reference it with documentation or experienced developers.
     48AI coding assistants can significantly boost productivity, but their effectiveness depends on how well you interact with them. These guidelines help you get the most out of AI tools while maintaining code quality and continuing to grow as a programmer.
    8949
    9050----
    9151
     52=== 1. Crafting Good Prompts
     53
     54The quality of AI output is directly tied to the quality of your input. A well-structured prompt produces a focused, accurate response.
     55
     56**1.1 Define the problem clearly**
     57
     58Before asking for help, take a moment to think about exactly what you need. Vague requests lead to generic answers.
     59> ❌ "Fix my code."
     60
     61> ✅ "I'm trying to optimize this Python function that clusters sequence alignment positions recursively, but it's too slow for large inputs. How can I improve it?"
     62
     63**1.2 Specify language, framework, and version**
     64
     65Always include your technical environment to avoid receiving outdated or incompatible suggestions.
     66> ✅ "I have a Python script written in Python 2.7. Could you modify it to be compatible with Python 3.8?"
     67
     68**1.3 Break complex problems into smaller steps**
     69
     70For large tasks, ask about one piece at a time — a specific function, how to test it, and then how to integrate it — rather than requesting a full solution in a single prompt.
     71
     72----
     73
     74=== 2. Getting the Most from Responses
     75
     76**2.1 Ask for explanations, not just code**
     77
     78Request that the AI explain *how* and *why* a solution works. This reinforces your understanding and helps you apply the same thinking to future problems.
     79> ✅ "Can you explain why you're using a heuristic search algorithm here and how it improves time complexity?"
     80
     81**2.2 Iterate and refine**
     82
     83If the first response isn't quite right, follow up with specific feedback rather than starting over. AI tools improve significantly with targeted clarification.
     84> ✅ "The solution works, but it doesn't handle edge cases where the input is negative. Can you adjust it?"
     85
     86**2.3 Request test cases**
     87
     88Ask for test cases alongside any function or algorithm to verify correctness, especially for edge cases.
     89> ✅ "Can you provide test cases to verify this sorting algorithm handles empty lists and duplicate values?"
     90
     91----
     92
     93=== 3. Code Quality and Review
     94
     95**3.1 Use AI for code reviews**
     96
     97AI tools can spot inefficiencies, suggest readability improvements, and flag deviations from best practices — use them as a first-pass reviewer before a human review.
     98> ✅ "Can you review this Python function for inefficiencies or readability improvements?"
     99
     100**3.2 Use AI to assist debugging**
     101
     102When debugging, provide the exact error message and a clear description of the intended behavior. The more context, the better the diagnosis.
     103> ✅ "I'm getting a `TypeError` in this Python code when performing a log transformation. Here is the function and the full error message. Can you help identify the cause?"
     104
     105----
     106
     107=== 4. Critical Thinking and Validation
     108
     109**4.1 Always review and test AI-generated code**
     110
     111AI tools can produce plausible-looking but incorrect or suboptimal code, especially for complex logic. Never treat output as production-ready without thorough review and testing.
     112
     113**4.2 Cross-reference for critical components**
     114
     115For security-sensitive or functionally critical code, validate AI suggestions against official documentation or have them reviewed by an experienced developer.
     116
     117**4.3 Be aware of knowledge limitations**
     118
     119AI tools have a training data cutoff and may suggest deprecated libraries, outdated APIs, or obsolete syntax. Always verify that suggested dependencies and methods are current.
     120
     121----
     122
     123=== 5. Using AI as a Learning Tool
     124
     125AI tools are most valuable when they make you a better developer, not just a faster one.
     126
     127- Ask the AI to explain new concepts or techniques it introduces in its responses.
     128- Use it to explore unfamiliar languages or frameworks interactively.
     129- If you can't explain the code it generated, dig deeper before using it.
     130
     131> ✅ "You used dimensionality reduction in this solution. Can you explain what it is and when it should be used?"
     132
     133----
     134
     135=== Summary
     136
     137||=Principle=||=Key Action=||
     138|| Clear prompts || Define problem, context, and environment upfront ||
     139|| Iterative dialogue || Refine with follow-up questions ||
     140|| Understand the output || Ask for explanations alongside code ||
     141|| Validate thoroughly || Test, review, and cross-reference critical code ||
     142|| Keep learning || Use AI to understand, not just to copy ||