wiki:SOPs/AIcodingTools

Why AI for coding?

Efficient: automatic code/documentation generation

Speed: accelerate data analysis pipeline development

Troubleshooting: get instant help with complex R/python errors

What is an AI Coding Assistant?

Definition: Large language model (LLMs) trained on massive code datasets.

Key capabilities: Code generation, code completion, Documentation, Language translation (e.g., python to R)

Set Clear Expectations: AI is a pair programmer, not a replacement for developer judgment. It accelerates work but requires human oversight.

Key Features of AI Coding Assistants

FeatureDescription
Code suggestionsProvides code suggestions based on comments and file context
Context-aware completionsOffers context-aware code completions based on all or a part of the codebase
Test generationAnalyzes code to generate tests
User-IDE interactionAutomatically provides guidance as users type code in the IDE; Chat within IDE
Code analysisAnalyze code snippets to provide reliable code prediction and tag suspicious code
Bug detection and fixingIdentifies bugs and suggests to fix them
Code autodocumentationAutomatically adds docstrings and enhances code documentation
Routine task automationHelps with code creation for routine or time-consuming tasks
API and SDK usage optimizationAids in making correct and effective use of APIs and SDKs
Open source discovery and attributionFacilitates discovery and attribution of open source code and libraries

*Source: AI-Assisted Programming, by Tom Taulli (O’REILLY)

Popular Tools for AI coding

Chat-based (ChatGPT, Gemini, Claude)

Best for: reasoning, debugging, learning, prompt iteration

IDE-integrated (Github Copilot, Cursor, Claude Code)

Best for: writing code faster inside existing projects


Best Practices for Using AI Tools in Coding

AI 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.


1. Crafting Good Prompts

The quality of AI output is directly tied to the quality of your input. A well-structured prompt produces a focused, accurate response.

1.1 Define the problem clearly

Before asking for help, take a moment to think about exactly what you need. Vague requests lead to generic answers.

❌ "Fix my code."

✅ "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?"

1.2 Specify language, framework, and version

Always include your technical environment to avoid receiving outdated or incompatible suggestions.

✅ "I have a Python script written in Python 2.7. Could you modify it to be compatible with Python 3.8?"

1.3 Break complex problems into smaller steps

For 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.


2. Getting the Most from Responses

2.1 Ask for explanations, not just code

Request that the AI explain *how* and *why* a solution works. This reinforces your understanding and helps you apply the same thinking to future problems.

✅ "Can you explain why you're using a heuristic search algorithm here and how it improves time complexity?"

2.2 Iterate and refine

If the first response isn't quite right, follow up with specific feedback rather than starting over. AI tools improve significantly with targeted clarification.

✅ "The solution works, but it doesn't handle edge cases where the input is negative. Can you adjust it?"

2.3 Request test cases

Ask for test cases alongside any function or algorithm to verify correctness, especially for edge cases.

✅ "Can you provide test cases to verify this sorting algorithm handles empty lists and duplicate values?"


3. Code Quality and Review

3.1 Use AI for code reviews

AI tools can spot inefficiencies, suggest readability improvements, and flag deviations from best practices — use them as a first-pass reviewer before a human review.

✅ "Can you review this Python function for inefficiencies or readability improvements?"

3.2 Use AI to assist debugging

When debugging, provide the exact error message and a clear description of the intended behavior. The more context, the better the diagnosis.

✅ "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?"


4. Critical Thinking and Validation

4.1 Always review and test AI-generated code

AI 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.

4.2 Cross-reference for critical components

For security-sensitive or functionally critical code, validate AI suggestions against official documentation or have them reviewed by an experienced developer.

4.3 Be aware of knowledge limitations

AI 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.


5. Using AI as a Learning Tool

AI tools are most valuable when they make you a better developer, not just a faster one.

  • Ask the AI to explain new concepts or techniques it introduces in its responses.
  • Use it to explore unfamiliar languages or frameworks interactively.
  • If you can't explain the code it generated, dig deeper before using it.

✅ "You used dimensionality reduction in this solution. Can you explain what it is and when it should be used?"


Summary

PrincipleKey Action
Clear prompts Define problem, context, and environment upfront
Iterative dialogue Refine with follow-up questions
Understand the output Ask for explanations alongside code
Validate thoroughly Test, review, and cross-reference critical code
Keep learning Use AI to understand, not just to copy
Note: See TracWiki for help on using the wiki.