Skip to content
OVEX TECH
Education & E-Learning

Boost Your Coding: Master AI Tools for Efficiency

Boost Your Coding: Master AI Tools for Efficiency

Learn to Supercharge Your Development with AI Assistants

AI coding tools are changing how developers work. They aren’t just a passing trend; they offer real improvements in how quickly and effectively you can code. Studies show that experienced developers can see big jumps in their productivity while keeping code quality high when they use these tools the right way. But it’s not magic. You need to understand how these AI tools work, when to use them, and just as importantly, when not to use them.

This guide will walk you through the essentials of AI-assisted coding. You’ll learn the basic concepts behind AI, explore powerful tools like GitHub Copilot and Gemini CLI, and discover how to use AI for tasks from writing code to reviewing it. By the end, you’ll know how to integrate these tools into your workflow to save time and improve your code.

Prerequisites

To get the most out of this guide, you should have some programming experience. You don’t need to be a coding expert, but you should be comfortable writing basic programs. It also helps to know how to use a code editor and have a basic understanding of Git, a system for tracking code changes.

Understanding AI Coding Fundamentals

Before diving into the tools, let’s cover some key ideas. Understanding these concepts will help you get better results from any AI tool you use.

1. Tokens: The Building Blocks of AI Understanding

Think of tokens as small pieces of words. This is how AI reads your code and text. When you give input to an AI, it doesn’t see letters or words like we do. Instead, it breaks everything down into tokens. A token could be a whole word, part of a word, a punctuation mark, or even a space. For example, the word ‘function’ might be one token, but ‘functionalize’ could be split into several tokens. This matters because AI services often have limits on how many tokens they can process. Free versions might limit your daily or monthly usage. Knowing about tokens helps you understand why you might hit limits and why longer requests cost more.

2. Context Window: The AI’s Short-Term Memory

The context window is the amount of information an AI can remember during a conversation. It’s like the AI’s short-term memory. If an AI has a small context window, it can only consider a little bit of code or conversation at a time. A larger context window allows the AI to understand more of your project, recall earlier parts of your chat, and provide more helpful suggestions. Context windows are measured in tokens. For instance, some AI models can handle hundreds of thousands or even over a million tokens. This means some AI tools can look at your entire project at once, while others can only focus on a few files.

3. Hallucinations: When AI Gets It Wrong

A hallucination happens when an AI confidently suggests something that is completely incorrect. It might invent a function that doesn’t exist, mention a library that was removed years ago, or even create fake API methods. The AI doesn’t realize it’s wrong; it’s just predicting the next likely pieces of text based on its training. Sometimes these predictions are accurate, and sometimes they are made up. This is why you must always check AI suggestions. Never accept code without testing it, reviewing the official documentation, and confirming that all functions actually exist.

4. Prompts: Guiding the AI

A prompt is simply an instruction given to the AI. It can be a comment in your code, a question in a chat window, or a detailed description of what you need. The quality of your prompts directly affects the quality of the AI’s responses. Vague prompts lead to vague answers, while specific, detailed prompts result in useful code. The clearer you are about what you want, the better the results you will get.

When to Use AI Assistance

AI is excellent for writing repetitive code, like basic functions for getting or setting data (getters and setters), simple database operations (CRUD), writing tests and documentation, and fixing simple syntax errors. It’s also great for learning new coding languages or frameworks. However, there are times when you should rely on your own coding skills. This includes designing the overall structure of a system, making important security decisions, writing complex business rules, learning entirely new concepts for the first time, or working on code that needs to be extremely fast. In short, use AI to speed up the ‘how’ – how to write the code, how to use the syntax. You should focus on the ‘what’ and ‘why’ – what you are building and why you are building it that way. Think of AI as a very fast junior developer; it can write code quickly, but you need to guide it, review its work, and make the key decisions.

Getting Started with GitHub Copilot

GitHub Copilot is a popular AI pair programmer that integrates directly into your code editor. We’ll use Visual Studio Code (VS Code) for this example, which you can download for free from code.visualstudio.com.

Installing GitHub Copilot Chat

  1. Open VS Code.
  2. Click on the Extensions icon in the left sidebar (it looks like four squares, one with a smaller square inside).
  3. In the search bar, type “GitHub Copilot Chat”.
  4. Look for the official “GitHub Copilot Chat” extension and click the “Install” button. (Note: There might be an older, now-deprecated version, so make sure you get the chat version.)

Signing In and Setup

  1. After installation, you’ll likely need to sign in. You might see a login prompt, or you may need to click the account icon (usually a person silhouette) in the bottom-left corner of VS Code.
  2. Follow the prompts to sign in with your GitHub account. This usually involves authorizing VS Code through your web browser.
  3. Once signed in, you should see a GitHub Copilot icon in the VS Code status bar (often at the bottom). If not, you can right-click the status bar and ensure “Copilot status” is enabled.
  4. Click the Copilot icon or a prompt like “Use AI features” to complete the setup.
  5. The Copilot chat window will typically appear on the right side of your screen. You can toggle this chat window open or closed using a button in the corner.

Understanding Copilot’s Pricing and Tiers

GitHub Copilot offers a free tier with a limited number of code completions and chat requests per month. Students, teachers, and open-source maintainers can often get the Pro plan for free, which provides unlimited completions and access to more advanced AI models. Check the GitHub Copilot website for the latest details on pricing and eligibility.

Using Copilot for Code Completions

  1. Create a new file (e.g., demo.js).
  2. Start typing a comment describing what you want the code to do. For example, type // function to calculate the area of a circle.
  3. As you type, Copilot will suggest code completions in gray text.
  4. To accept a single line suggestion, press Enter. To accept the entire suggested block of code, press the Tab key.
  5. Try more complex prompts like // function to validate an email address using regex. Copilot can suggest entire functions with correct syntax and logic.

Exploring Multiple Suggestions and Shortcuts

Copilot doesn’t always offer just one suggestion. Sometimes, it provides multiple options.

  1. When Copilot shows a suggestion, hover over it. It might indicate how many options are available (e.g., “1 of 3”).
  2. You can cycle through these different suggestions using keyboard shortcuts. On Windows, this is often Alt + [ or Alt + ]. On Mac, it’s typically Option + [ or Option + ].
  3. Once you find a suggestion you like, press Tab to accept it.

The Neighboring Tabs Trick: Expanding Copilot’s Context

Copilot’s suggestions improve significantly when it has more context about your project. It doesn’t just look at the current file; it also scans other files you have open in VS Code.

  1. Open multiple related files in VS Code. For example, if you’re working on a JavaScript file (user.js), also open its corresponding CSS file (users.css) and a test file (user.test.js).
  2. Now, when you are typing in user.js, Copilot can use information from users.css (like class names) or user.test.js (like test IDs) to provide more accurate suggestions.
  3. For instance, if your CSS file defines a class named user-card-name, Copilot might suggest using that class name when you’re creating a UI element in user.js. This makes its suggestions much more relevant to your project’s specific style and structure.

Practice Exercise: Building a To-Do App

  1. Create a new file named todo.js.
  2. Close any other files you have open to focus Copilot’s context.
  3. Start with a descriptive comment: // To-do app with add, remove, and list functions.
  4. Press Enter. Copilot will likely suggest initializing an array for your to-dos. Press Tab to accept.
  5. Copilot will then automatically suggest the next function, such as function addTodo(). Press Tab to accept and then continue accepting suggestions for removeTodo() and listTodos().
  6. In just a few seconds, you’ll have a basic structure for a to-do application. Remember to test this code to ensure it works as expected.

Advanced GitHub Copilot Chat Features

GitHub Copilot’s chat feature goes beyond simple code completion. It offers different modes for various tasks, allowing you to interact with the AI more effectively.

Understanding Chat Modes

There are three main modes available in the Copilot chat:

  • Ask Mode: This is the default mode, best for asking questions, getting explanations, and learning. It won’t change your code unless you manually copy the output.
  • Edit Mode: Use this mode for refactoring and making specific changes to your code. It provides a clear view of the old code versus the new code (a diff view) before you apply the changes.
  • Agent Mode: This is an autonomous mode where Copilot can plan and execute multi-step tasks across your entire project. It can create files, install packages, and write code based on your instructions.

Using Ask Mode for Explanations

  1. Open the Copilot chat window (usually via a button in the corner or keyboard shortcut like Ctrl+Alt+I or Cmd+Alt+I).
  2. Select “Ask Mode” from the dropdown menu at the top of the chat window.
  3. You can ask general questions like, “What does the reduce method do in JavaScript and how does it compare to a for loop?”
  4. Copilot will provide a detailed explanation, including syntax, behavior, and examples.
  5. You can also right-click on a specific function in your code and select “Explain” to have Copilot explain that particular piece of code in Ask Mode.

Using Edit Mode for Refactoring

  1. Open the Copilot chat window.
  2. Select “Edit Mode” from the dropdown.
  3. Describe the changes you want to make. For example, you could say, “Refactor this callback-based function to use async/await and add a 5-second timeout.”
  4. Copilot will apply the changes directly to your file and show you a diff view. You can review the old code (in red) and the new code (in green).
  5. Click “Apply” to accept the changes or “Discard” to reject them. This is a fast way to refactor code safely.

Using Agent Mode for Complex Tasks

  1. Open the Copilot chat window.
  2. Select “Agent Mode” from the dropdown.
  3. Describe a larger task, such as: “Create a full REST API with Express that has JWT authentication and saves users to a local SQLite database.”
  4. Click “Start”. Copilot will first create a plan and then begin executing it. This might involve creating new files, installing necessary packages via your terminal, and writing code.
  5. You may need to approve certain actions, like editing sensitive files (e.g., package.json). You can choose to “Allow” or “Auto-approve” actions for smoother execution, but be aware this increases risk.
  6. Agent mode can even attempt to fix issues it encounters during the process. Once finished, it will provide a summary of what was built and suggest next steps, like running the server.

Customizing Copilot with Instructions

You can train Copilot to follow your project’s specific rules and conventions by creating an instructions file.

  1. Create a file named .copilot/instructions.md in your project’s root directory.
  2. Add instructions here, such as “Always use TypeScript,” “Prefer functional components,” or specific naming conventions.
  3. Alternatively, you can use a slash command within the Copilot chat: type /init and press Enter.
  4. This command will scan your project and generate a customized instruction file for you. Any suggestions Copilot gives will then follow these project-specific guidelines.

Using Participants and Slash Commands

Copilot chat supports special commands and “participants” to direct its attention:

  • Participants:
    • @workspace: Ask questions about your entire project. Example: “@workspace where is the database connection defined?”
    • @terminal: Ask for help with command-line tasks. Example: “@terminal how do I prune my Docker images?”
    • @vscode: Perform actions related to VS Code. Example: “@vscode set up debugging for Node.”
    • @github: Search your GitHub pull requests and issues directly from VS Code.
  • Slash Commands:
    • /doc: Generate documentation for selected code.
    • /explain: Explain selected code.
    • /fix: Fix errors in the selected code.
    • /test: Generate unit tests for selected code.
    • /new: Create a new project structure.

For example, typing /test might prompt Copilot to ask if you want to set up tests and then ask which testing framework (like Jest or Mocha) you prefer.

Streamlining Code Reviews with CodeRabbit

Automated code reviews are a powerful use of AI. Instead of waiting days for a human review, AI can provide feedback in minutes while your code is still fresh in your mind.

What is CodeRabbit?

CodeRabbit is an AI platform for code reviews. It offers:

  • Automatic PR Reviews: Analyzes your code changes the moment you create a pull request.
  • Security Analysis: Catches potential vulnerabilities before they go into production.
  • Code Quality Suggestions: Offers ways to improve your code beyond just fixing bugs.
  • Natural Language Chat: Lets you discuss feedback directly within the pull request comments.
  • Learning System: It learns your codebase and common coding patterns over time.
  • Integrations: Works with GitHub, GitLab, Bitbucket, and Azure DevOps.

CodeRabbit Workflow

  1. You create a pull request (PR).
  2. CodeRabbit automatically starts a review.
  3. Within minutes, you receive a summary of changes, identified issues with severity levels, improvement suggestions, and security alerts.
  4. You can chat with CodeRabbit to ask for clarifications.
  5. When you push new commits, CodeRabbit performs incremental reviews.

Reviews are categorized by severity, from critical issues that could cause failures or breaches to trivial improvements for code quality.

Setting Up CodeRabbit

  1. Go to CodeRabbit.ai and log in or start a free trial.
  2. Connect your GitHub account. You’ll need to authorize CodeRabbit to access your repositories.
  3. Choose whether to authorize it for all repositories or specific ones. For this guide, select a specific repository.
  4. Install and authorize CodeRabbit for your chosen repository.
  5. Ensure you have two-factor authentication enabled on your GitHub account for security.

Simulating a Code Review Scenario

  1. In your code editor (like VS Code), create a new branch for your feature (e.g., feature/discountcodes).
  2. Create new files or modify existing ones to add functionality. For example, add a discountService.js file and update server.js to use it.
  3. Intentionally introduce common mistakes that might slip through quick coding sessions.
  4. Commit your changes using Git (e.g., git commit -m "Add discount code feature").
  5. Push the branch to your remote repository (e.g., git push origin feature/discountcodes).
  6. Go to GitHub and create a pull request for your new branch.
  7. Wait a few minutes. CodeRabbit will automatically analyze the pull request and provide its review findings directly on the PR page.

You’ll see a summary of your changes, potential issues, and suggestions. You can then discuss these findings with CodeRabbit.

Conclusion

By understanding the fundamentals of AI, mastering tools like GitHub Copilot, and integrating automated reviews with CodeRabbit, you can significantly boost your coding efficiency and code quality. Remember to always review AI suggestions critically and use these tools to augment, not replace, your own development expertise.


Source: AI-Assisted Coding Tutorial – OpenClaw, GitHub Copilot, Claude Code, CodeRabbit, Gemeni CLI (YouTube)

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by

John Digweed

2,376 articles

Life-long learner.