Using AI Powered Code Suggestions To Write Code

Okay, here’s a summary of the provided text:

The text describes the basic usage of GitHub Copilot in an IDE (specifically VS Code) after it has been installed, subscribed to, and logged into. Using a Python example of creating a Fahrenheit-to-Celsius conversion function, it shows how Copilot provides inline code suggestions as the user types.

Key takeaways mentioned are:

  1. Suggestion Variability: Copilot suggestions aren’t always the same for everyone or over time due to the nature of AI and model updates. Being more specific in typing can help guide it.

  2. Multiple Suggestions: Users can often access multiple different suggestions by pausing after typing, which may reveal a pop-up menu to cycle through options, or by opening the "Completions Panel" for a more detailed list.

  3. Accepting Suggestions: Suggestions can be accepted entirely (e.g., with the Tab key) or partially (accepting word-by-word using specific shortcuts).

The user demonstrates these features while creating the simple conversion function, ultimately accepting the full code block suggested by Copilot.

Using "Next Edit" Suggestions

GitHub Copilot’s “Next Edit Suggestions” in VS Code lets the tool predict and propose your next code change, not just complete the current line. To try it:

  1. Open User Settings in VS Code and search for “GitHub Copilot.”

  2. Locate (or enable) the Preview setting called “Next Edit Suggestions.”

  3. Back in your code, make a change—say you rename a variable from F to Fahrenheit. Copilot will then automatically suggest renaming other occurrences of that variable elsewhere.

  4. Accept the suggestion with Tab or the inline icon, reject with Esc, and adjust settings (e.g. shift code to show both suggestion and existing code).

By anticipating your next edits, this feature lets you move through large files and make bulk changes faster. Originally introduced in Cursor, it’s now integrated into Copilot to boost developer productivity.

Mastering Prompts - Using Comments To Guide Github Copilot’s AI

The speaker demonstrates how to leverage GitHub Copilot’s ability to turn natural-language comments into working code. Instead of hunting for the “perfect” function name, you can write a comment that describes exactly what you need (e.g. “Function that takes either a Celsius or Fahrenheit temperature and converts it…”). Copilot will read that comment (plus the surrounding file context) and offer suitable code completions—sometimes just a single line, sometimes an entire function.

Key tips:

  • Treat comments as prompts—write your intent in plain English and let Copilot generate the implementation.

  • If you lose a suggestion, move the cursor up and back down to re-trigger it.

  • Open the Completions panel (⇧⌥I) to get more—and often fuller—alternative snippets.

  • You can place these “prompt” comments anywhere (top-of-file, inside functions, etc.) to guide Copilot’s output.

Writing A Full Python Script With Suggestions

The text describes building a Python script to manage SQLite database backups (backing up and restoring). It utilizes GitHub Copilot’s suggestion feature (not the chat) as the primary AI tool.

  1. Setup: Global variables for the active (app.db) and backup (backup.db) database file paths were defined. Copilot suggested the second variable name, which the user slightly modified.

  2. Function Generation: Copilot successfully suggested entire functions for backup_database and restore_database, including the necessary shutil import based on the function code it generated.

  3. AI Limitations & Developer Intervention: When attempting to create the main execution logic, Copilot’s suggestions were not suitable (e.g., suggesting backing up and immediately restoring). The developer had to manually structure the script, creating a main function to handle user interaction.

  4. User Interaction Logic: Inside the main function, Copilot proved helpful again, suggesting print statements for user options (backup, restore, exit), the input() call to get user choice, and the if/elif/else structure to execute the correct action based on the input.

  5. Manual Steps: The developer needed to manually type the call to the main function at the end of the script when Copilot didn’t suggest it.

  6. Key Takeaways:

    • Copilot is effective at generating boilerplate code, functions, and suggesting imports based on context.

    • Developers must evaluate and modify Copilot’s suggestions to fit their needs and coding standards.

    • AI might not understand the overall program goal correctly, requiring developer intervention for higher-level logic (like the user interaction flow).

    • It’s crucial not to solely rely on or wait for AI suggestions; developers should type code manually when necessary for efficiency.

  7. Outcome: The final script, built with a combination of Copilot suggestions and manual developer input, successfully allowed users to back up and restore the database via a command-line menu.

Using The Inline Chat Feature To Add Error Handling

Here’s a concise summary of the key points:

  • Copilot isn’t just auto-completion—there’s a chat interface in VS Code built specifically for coding tasks.

  • You can open it in two ways:

    • Inline (faster): ⇧⌘I (macOS) or Ctrl+I (Windows/Linux)

    • Sidebar or via Command Palette (“Open Chat” or “Editor: Inline Chat”)

  • It’s context-aware, so it reads your surrounding code, and you can even attach screenshots or use voice.

  • To tweak existing code, select the snippet, invoke inline chat, and type a prompt (e.g. “Add error handling”).

  • Copilot then injects changes shown as diffs:

    • Dark green = unchanged original

    • Light green = additions

    • Red = removals

  • You can accept, discard, regenerate, toggle diff details, or adjust chat settings.

  • In the demo, adding error checks around the “backup_db” and “restore_db” functions turned a raw crash into a friendly error message when the database file was missing.

Configuring GitHub Copilot - Tips For Efficient Use

The content explains how to configure GitHub Copilot’s chat features within VS Code. It guides users to access the settings—either for a specific workspace or for all projects—and search for "copilot chat" or "copilot" to find various configuration options. Key points include:

  • Adjusting which programming languages GitHub Copilot is enabled for, allowing users to enable or disable suggestions on a per-language basis.

  • Using a copilot-instructions.md file placed in a .github folder, where concise instructions can be provided to influence the style and behavior of Copilot’s code generation. The instructions should be clear because poor instructions might lead to less desirable outcomes.

  • Utilizing the temporal context feature, which enables Copilot to take into account code from recently edited files, thereby supporting scenarios where code is spread over multiple files.

The content emphasizes the importance of periodically reviewing these settings, as they may evolve over time with updates to AI models and new features, to ensure that Copilot best meets the user’s workflow needs.

Taking Advantage of Code Actions

The content discusses GitHub Copilot’s "code actions" feature. When you select a piece of code, an icon appears that offers context-specific suggestions. For instance, it can suggest rewriting or optimizing your code using Copilot, opening an inline chat for further help and review. Additionally, when an error is detected (like a missing key), a light bulb icon appears that provides suggestions, including fixes from Copilot. This feature essentially acts as a helpful second opinion to improve your code or resolve issues automatically.

Exploring The Sidebar Chat For More Complex Tasks

Here’s a clearer, more concise walkthrough of using VS Code’s two chat modes—Inline Chat and Sidebar Chat—so you can pick the right tool for the job:

  1. Opening Sidebar Chat

    • Use the keyboard shortcut (your keymap may vary) or open the Command Palette → “Open Chat.”

    • This pane is best for larger context, long code snippets, or richer explanations.

  2. When to Use Inline Chat vs Sidebar Chat

    • Inline Chat

      • Quick edits to a specific function or line.

      • Lets you hover, ask a question, and receive an edit suggestion right where you need it.

    • Sidebar Chat

      • Paste in bigger code blocks or describe complex tasks.

      • Get a full conversational view—explanations, code, suggestions—in one place.

  3. Example: Optimizing a Python Function

    1. Paste your function into the sidebar chat and ask, “How can I optimize and improve this code?”

    2. GitHub’s server analyzes it and returns: – Recommendations (e.g. add error handling, switch to the logging module) – A revised code snippet implementing those suggestions

    3. Next to that snippet you’ll see action buttons:

      • Apply to Editor – merges changes into your file (smartly adds imports, updates signatures, etc.)

      • Insert at Cursor – drops code where your cursor sits

      • Copy – grab it for manual tweaks

      • Insert into Terminal – useful only for command-line snippets

      • Create New File – spins up a standalone file

  4. Reviewing & Applying Changes

    • Click “Apply to Editor.” VS Code will show you a diff:

      • Green = added code

      • Red = removed code

    • You can Accept, Discard, or “Show Changes” for a unified diff view.

    • If you accept, your file is updated in place with proper imports and consistent style.

  5. Verifying Your Updates

    • Rerun your code.

    • Now you’ll see structured log output (thanks to the logging module) and proper error messages if, say, a backup file doesn’t exist.

  6. When to Reach for Sidebar Chat

    • You need to paste or reference multiple functions.

    • You want explanations alongside code.

    • You’re brainstorming broader design changes, not just tiny inline tweaks.

In short:

  • Use Inline Chat for quick, in-context code tweaks.

  • Use Sidebar Chat when you need more room to ask questions, share larger snippets, or get detailed explanations.

Adding Context - Using References & Shortcuts For Smarter Code Creation

Here’s a cleaned-up, step-by-step guide showing how to ask Copilot Chat to analyze or optimize code across your project—even when you don’t paste snippets by hand:

  1. Start a New Chat

    • Click the “+” button to open a fresh conversation.

    • Ask your question, e.g.: “How can I optimize this code?”

  2. Let Copilot Auto-Detect Context

    • By default it will scan your currently open file (and sometimes the rest of your project) to gather context.

    • If it already sees the relevant code, it’ll answer without any extra steps.

  3. Explicitly Reference Files or Symbols
    If you want to be sure Copilot looks at the right piece of code, add context yourself:

    a. Click the “Add context” button (looks like a page icon)
    – Choose Code base to give access to all files.
    – Choose Current editor for just the file in your active tab.
    – Choose Selection if you’ve highlighted a snippet.
    – Choose Symbol to pick a function, class, or variable.
    – You can also pick recently edited files or terminal commands.

    b. Type a hash # in the chat box
    # file shows a list of project files (e.g. #dbBackup.py).
    # symbol lets you pick specific functions or variables.
    # editor or # selection similarly restricts scope.

    Example:
    • In your question box type:
    > How can I optimize this file?
    > # file dbBackup.py

  4. Ask Your Question

    • After you’ve attached the right context, press Enter.

    • Copilot will read that file (or those symbols) and suggest targeted improvements—
      e.g. removing redundant logging, consolidating exception blocks, etc.

  5. Review & Apply Suggestions

    • Copilot often offers one-click “Apply changes” for refactorings.

    • Validate that the proposed edits fit your style and requirements.


By explicitly tagging files or symbols, you ensure Copilot Chat has exactly the code you want it to analyze, leading to more accurate and actionable optimization tips.

Adding Additional Participants For Enhanced Sidebar Chat Context

When you’re chatting in VS Code—whether in the main sidebar or inline—two types of shortcuts let you pull in extra context or helper “participants”:

  1. Hashtag shortcuts (#)
    Bring in files or code fragments from your workspace.

    • Example:
      – Type #utils.js to reference the utils.js file.
      – The AI will see its contents and can generate or modify code based on it.

  2. At-symbol shortcuts (@)
    Invite built-in assistants or services into the conversation. Common ones include:

    • @VS Code – Ask general questions about editor settings (e.g. “Where do I tweak the code font size?”).

    • @Terminal – Get help with command-line tasks.

    • @Workspace – Query details about your entire project (structure, configs, dependencies).

    • @GitHub – (If you’ve pushed your repo) lets the AI perform live web searches and GitHub-specific checks.


Examples

1. Referring to another file

In inline chat, you might write:

Generate a function in this file that uses #dataProcessor.js

The AI then reads dataProcessor.js to inform its response.

2. Asking about VS Code settings

In the sidebar chat:

@VS Code: How can I change my editor’s bracket color?

You’ll get pointer links right into your settings.json UI.

3. Checking code style with GitHub search

First, push your code to GitHub. Then in a new chat:

@GitHub #main.py
Does this follow common Python style best practices?

The AI will pull in both the file and any relevant web references to reply.


Key Takeaways

  • Use #<filename> to inject specific files or code blocks.

  • Use @<assistant> to bring in contextual helpers like VS Code, Terminal, Workspace, or GitHub.

  • Combining both gives the AI maximum context for accurate, tailored answers.

Running Terminal Commands Efficiently With AI

1. Chat in the Editor: Asking about Terminal Commands

  1. Open the editor-sidebar chat.

  2. Ask any terminal-related question, for example:

    • “How can I use Git to manage this project?”

    • “How do I run this Python code?”

  3. The chat will propose the exact command.
    – If it uses a placeholder (e.g. python file.py), simply clarify:
    “No—I need the command to run the file I have open.”
    – It will detect your open file (e.g. db_backup.py) and update the command.

  4. Click the “Insert into Terminal” button.

  5. Always review the command before hitting Enter—this avoids accidental destructive operations.

2. Inline Chat in the Terminal

Instead of switching back to the sidebar, you can invoke the inline chat directly inside your terminal:

  1. Open your terminal and trigger the inline chat shortcut (depends on your setup).

  2. Type your request, for example:

    run this Python file
  3. If it doesn’t pick up the right filename or interpreter, refine your prompt:

    run db_backup.py with Python 3
  4. The chat will show the exact command:

    python3 db_backup.py
  5. You can either insert it into the prompt or execute immediately—again, double-check before you run.


Why This Helps

  • Context-aware: Knows which file you’re editing.

  • Saves time: No need to Google or remember obscure flags.

  • Flexible: Works both in the sidebar and inline in your terminal.

By leveraging both modes, you streamline your workflow and spend less time hunting for commands—and more time coding.

Mastering GitHub Copilot Slash Commands - Explain, Fix & More

Beyond adding context or participants to your chat, GitHub Copilot Chat provides a set of slash commands to invoke various features quickly. You can use these commands both in the terminal and inline within your editor.


1. Terminal Slash Commands

Type / in the integrated terminal to see all available commands. For example:

  • /explain
    Explains the currently selected or typed command.

    # Suppose you have this command in your terminal:
    git rebase --interactive HEAD~3
    
    # Simply type
    /explain

    Copilot will pop up a brief explanation. If you prefer a full dialog, click View in Chat to see the explanation in the main chat window.


2. Inline Chat Slash Commands

You can also select a block of code in your editor, press /, and choose a command that operates on that selection. Common inline commands include:

  • /explain
    Automatically explains the selected code block.

  • /fix
    Attempts to fix issues in the selected code. You can add a free-form instruction, e.g., “Use print instead of the logging package,” or just run /fix and let Copilot infer your intent.

  • /tests
    Generates unit tests or test scaffolding for the selected code (covered in the next lecture).

Example: Explaining Code Inline
  1. Select your code snippet.

  2. Press / and choose /explain.

  3. A small preview appears. Click View in Chat for the full explanation.

Example: Fixing Code Inline
  1. Select the code you want to modify.

  2. Press / and choose /fix.

  3. Optionally type a comment, e.g., “Don’t use the logging package.”

  4. Review Copilot’s suggestion and Accept or Discard.


3. Best Practices

  • Be explicit with slash commands.
    While you could simply ask Copilot to “fix this code,” using /fix signals your intention more clearly.

  • Add minimal but sufficient context.
    Short comments (e.g., “Make this function pure”) help Copilot tailor its suggestions without overwhelming it.

  • Iterate interactively.
    If the first suggestion isn’t quite right, refine your instruction or try a different slash command.

  • Use “View in Chat”
    For longer explanations or multi‐step refactorings, opening the full chat window gives you more space to review and interact.


4. What’s Next?

In the next lecture, we’ll deep-dive into /tests—how to automatically generate and run unit tests using GitHub Copilot Chat.

Multi-File Edits with Copilot Edits

You’re already familiar with Copilot’s inline chat and its sidebar chat: both let you ask questions, generate code, reference files, and collaborate. Copilot Edits is a third, specialized mode in the sidebar designed specifically for multi-file editing sessions. Here’s what makes it different:

  1. Purpose-built for multi-file edits

    • Instead of returning one long answer that you must copy-and-paste into different files, Copilot Edits organizes and applies changes across your project.

    • It can suggest creating entirely new files when needed and will propose the exact edits in each affected file.

  2. How it works

    • Ask your usual questions—e.g., “Add user authentication” — and use “Add Files” to bring in any relevant source files.

    • When you submit your prompt, Copilot Edits analyzes the context, determines which files to modify (or create), and presents a set of coordinated changes.

    • You review and approve these edits in one place, rather than juggling snippets across multiple windows.

  3. Key benefits

    • Streamlines large refactorings or feature additions that span several modules or packages

    • Reduces manual overhead—no more copying code between files

    • Maintains consistency by handling imports, references, and file creation for you

Copilot Edits takes inspiration from Cursor’s Composer feature (which we’ll cover later in the course) but is fully integrated into GitHub Copilot. If you’re about to tackle any change that touches multiple files, give Copilot Edits a try—it could save you a lot of time and errors.

Automating Unit Test Generation For Selected Code Sections

We now have two especially powerful slash-commands in our editor:

  1. /doc
    Generates documentation comments for the selected code. This is perfect for adding Javadoc, Docstrings or similar API documentation without ever leaving the editor.

  2. /tests
    Automatically creates unit tests for the selected code. You can:

    • Run it “as is” and let the AI decide which tests make sense,

    • Or provide extra context (e.g. “generate edge-case tests only” or “focus on error paths”).

Once you invoke /tests, the AI analyzes your code, proposes a suite of tests, and—when you accept—places them in a new file (e.g. db_backup_test.go rather than mixing them into your main source). This keeps your production code clean and your tests neatly organized.

Writing unit tests can be tedious, and many developers postpone or skip them altogether. By leveraging AI—already aware of your code’s context—you can generate comprehensive, sensible tests in seconds, saving you the manual effort and helping ensure better coverage.

Creating New Projects With The 'new' Command

You can use the /new slash command in GitHub Copilot Chat to scaffold an entire project in seconds. For example, if you type:

/new “Create a Node.js project using the Express library”

Copilot will prompt you for any missing details, then generate a suggested folder structure and show a “Create Project” button. When you click it, you choose a destination folder, and Copilot instantly creates a new workspace with:

  • A standard directory layout (e.g., src/, tests/)

  • A package.json preconfigured with Express (you’ll still need to run npm install)

  • Any starter files you requested

Once the files are generated, Copilot even asks if you’d like to open the new project right away. This saves you the repetitive setup steps and lets you dive straight into writing code—one of the most powerful features of GitHub Copilot Chat.

Prompt Engineering Essentials - Guidelines & Best Practices

When you’re using GitHub Copilot Chat or any AI coding assistant, the quality of your prompts directly determines the quality of the AI’s responses. Good prompt-engineering isn’t hype—it’s a practical skill that makes your work faster, more accurate, and less frustrating.

  1. Be Specific

    • Only include the information the AI really needs.

    • Clearly state your goal (e.g., “Write a Python function that validates email addresses using regex”).

    • Avoid irrelevant details that can distract the model.

  2. Provide Context

    • Mention the environment, framework or coding style you’re using (e.g., “In a React 18 TypeScript project…”).

    • Explain any domain-specific requirements (performance constraints, security rules, API contracts).

  3. Use Examples When Helpful

    • Showing a small input/output example or a snippet of existing code can dramatically improve accuracy.

    • You don’t need an example every time—but for tricky transformations or unusual formats, give the AI a template to follow.

  4. Break Complex Tasks into Steps

    • If you need a large feature or complex algorithm, split it into subtasks (e.g., “First, scaffold the data model. Then, write the CRUD endpoints. Finally, add validation.”).

    • Smaller, focused prompts reduce the chance of hallucinations and make debugging easier.

  5. Iterate and Maintain Control

    • Treat the AI’s first answer as a draft. Refine it with follow-up prompts (“Great, now add JSDoc comments,” or “Refactor this into a class.”).

    • Always review and test the generated code yourself—remember, you’re the developer, not the AI. Know when to stop prompting and take over manually.

What’s Next?
In the next lecture, we’ll walk through real-world examples of these techniques in action—and later in the course we’ll build an entire project together, showing how prompt engineering speeds up every stage of development.

How Being Specific & Adding Context Improves AI Code Generation Efficiency

Here’s a much tighter, clearer write-up of how to use GitHub Copilot Chat to add Express routes to a pre-existing Node/Express project—specifically, to build a simple restaurant-table reservation API.

  1. Project setup

    • You already have a Node + Express project initialized (we’ll call it “app.js” at the root).

    • In your IDE, create a new file under routes/ named tables.js. It’s empty for now.

  2. Why use Copilot Chat (vs. inline completions)?

    • Inline completions are great for line-by-line coding—but for scaffolding multiple routes at once, the chat interface lets you supply richer context and get back a cohesive code snippet.

  3. Crafting an effective prompt

    • Bring in your workspace (so Copilot knows your file structure).

    • Specify what you’re building (“a restaurant-table reservation website”).

    • Define exactly which routes you need in routes/tables.js: – POST /new-reservation (to create a reservation; body includes name, numberOfPeople, date, time)
      – DELETE /cancel/:reservationId (to cancel an existing reservation)

    • Ask Copilot to generate Express route definitions for that file.

      Example prompt (in Chat sidebar):

      I’m building a restaurant table-reservation API.
      In my project’s `routes/tables.js`, please generate two Express routes:
        • POST /new-reservation – expects { name, numberOfPeople, date, time } in req.body
        • DELETE /cancel/:reservationId – deletes the reservation by ID
      Return only the contents of `tables.js`.
  4. Applying the suggested code

    • Copilot will return something like:

      // routes/tables.js
      const express = require('express');
      const router = express.Router();
      
      // Create reservation
      router.post('/new-reservation', (req, res) => {
        const { name, numberOfPeople, date, time } = req.body;
        // TODO: add database logic here
        res.status(201).json({ message: 'Reservation created', data: { name, numberOfPeople, date, time } });
      });
      
      // Cancel reservation
      router.delete('/cancel/:reservationId', (req, res) => {
        const { reservationId } = req.params;
        // TODO: add database delete logic here
        res.json({ message: `Reservation ${reservationId} canceled` });
      });
      
      module.exports = router;
    • Accept or paste these changes into routes/tables.js.

  5. Hooking up the routes in app.js

    • Copilot may also suggest updating your root file (e.g., app.js) to import and mount the new router:

      const tablesRouter = require('./routes/tables');
      app.use('/api/tables', tablesRouter);
    • Feel free to tweak the mount path (/api/tables, /api, etc.) to your preference.

  6. Key takeaways
    – Be specific: name the file, list the exact HTTP methods and URL patterns, and describe request/response shapes.
    – Provide context: mention your existing project structure so Copilot doesn’t suggest re-initializing the app from scratch.
    – Use the chat interface when you want to generate or refactor multi-line code in one shot. Inline suggestions still shine for smaller edits.

By supplying precise intent (“generate these exact routes in this exact file”), you maximize the chance that Copilot returns code you can paste straight into your project—saving setup time and keeping your focus on the business logic.

Validating Input With GitHub Copilot Sidebar Chat

Improving Prompt Specificity for Validation and Persistence

When building API routes—such as accepting and deleting reservations—you often need more than just the route handlers. Two common follow-up tasks are:

  1. Validating incoming data (e.g., date, time, party size)

  2. Saving valid data to a database

A single, vague prompt like:

“Validate the received input and store it in the database.”

typically produces incomplete code that:
• Assumes non-existent models or libraries (e.g. Reservation model, express-validator)
• Omits the actual validation rules
• Leaves out database connection details

Why Broad Prompts Fail
  • Multiple concerns at once. Validation rules and persistence are separate problems.

  • Lack of requirements. What exactly must be validated? Which database, schema, or ORM should be used?

As a result, generated code often won’t run without you filling in all the blanks.

A Better Workflow
  1. Split tasks into separate prompts.

  2. Define precise rules for each task.

  3. Provide examples and edge cases to remove ambiguity.

Example: Adding Validation Only

Step 1. Identify the target code.

// routes/reservations.js
router.post('/reservations', (req, res) => {
  // validation goes here…
});

Step 2. Write a focused prompt:

Add input validation (no external libraries).
partySize: integer between 1 and 6
time: only 17:00, 17:30, …​, 23:00 (every 30 minutes)
date: today or in the future
Provide error responses for invalid input.

Step 3. Review and test the generated code.

Sample Generated Validation
// Define allowed time slots
const validTimes = [];
for (let h = 17; h <= 23; h++) {
  validTimes.push(`${h.toString().padStart(2,'0')}:00`);
  validTimes.push(`${h.toString().padStart(2,'0')}:30`);
}

router.post('/reservations', (req, res) => {
  const { partySize, time, date } = req.body;

  // Validate party size
  const size = Number(partySize);
  if (!Number.isInteger(size) || size < 1 || size > 6) {
    return res.status(400).json({ error: 'partySize must be between 1 and 6.' });
  }

  // Validate time
  if (!validTimes.includes(time)) {
    return res
      .status(400)
      .json({ error: `time must be one of: ${validTimes.join(', ')}.` });
  }

  // Validate date
  const today = new Date();
  today.setHours(0, 0, 0, 0);
  const inputDate = new Date(date);
  inputDate.setHours(0, 0, 0, 0);

  if (isNaN(inputDate) || inputDate < today) {
    return res
      .status(400)
      .json({ error: 'date must be today or in the future.' });
  }

  // At this point, input is valid.
  // TODO: store in database.
  res.status(201).json({ message: 'Reservation created.' });
});

This code is:

  • Self-contained (no hidden dependencies)

  • Clear in its rules

  • Easy to test and adjust

Key Takeaways
  1. Break down multi-step problems into individual prompts.

  2. Be explicit about every requirement and edge case.

  3. Use examples to illustrate permissible and impermissible values.

By engineering your prompts in this way, you’ll get more accurate, actionable code with fewer revisions.

Effective Iteration - Balancing AI & Manual Coding

1. Remember: You’re the Developer

AI is a powerful assistant, but you’re still in the driver’s seat.

  • If you spot a trivial change—say renaming a route prefix from /api to /tables—just do it yourself.

  • Don’t fall into the trap of having AI redo every little tweak. You’ll waste time on back–and–forth prompts instead of coding.

2. When to Call in AI

Use AI for bigger, repetitive refactors rather than one-off edits. For example:

  • Bulk import migration

    • Converting dozens of CommonJS require(...) statements into ESM import syntax.

    • AI can reliably update all your imports, move them to the top, and adjust file extensions in one swoop.

  • Complex pattern transformations

    • Batch renaming variables, reorganizing large blocks, or even extracting repeated logic into a helper function.

3. Iterate, but Don’t Over-Iterate

  1. Prompt AI to make a change.

  2. Review the diff.

  3. Tweak manually if something’s off (e.g. missing .js).

  4. Stop once you’ve got a correct, compile-and-run solution.

Endless AI prompts for tiny fixes will slow you down. Aim for a healthy balance:

  • You handle the simple, clear edits.

  • AI tackles the heavy, repetitive work.

4. Build Your AI-Augmented Workflow

  • Start with AI to scaffold or refactor large sections.

  • Keep manual control over naming, semantics, and tiny adjustments.

  • Practice this split until it becomes second nature—then you’ll code faster and cleaner.


By combining your developer instincts with AI’s bulk-editing power, you’ll iterate efficiently without getting stuck in unnecessary prompt loops.

GitHub Copilot Extensions

GitHub Copilot lets you add purpose-built extensions to enhance its AI-assisted coding for specific workflows. There are two kinds of extensions you can install:

  1. Copilot-Specific Extensions
    — Hosted and maintained by GitHub; they inject domain knowledge directly into your Copilot experience.
    — Examples include:

    • Docker: helps you generate Dockerfiles, Docker Compose manifests, and answers container-related questions.

    • Terraform, AWS CDK, Kubernetes, etc.
      — Installation steps:

      1. Browse the catalog at https://github.com/features/copilot/extensions

      2. Click Add on the extension you want.

      3. Authorize and install into your GitHub account.

      4. In your Copilot chat panel, include the new “participant” (e.g. @Docker) when asking a question.

  2. General VS Code Extensions
    — Regular VS Code Marketplace extensions that, when installed, also expose their APIs as chat participants in Copilot.
    — Examples include MongoDB, Azure Tools, Python environment managers, linters, and more.
    — Installation steps:

    1. Open your Copilot chat sidebar in VS Code.

    2. Type @ and choose Install Chat Extension.

    3. Search for any VS Code extension you use (e.g. “MongoDB”).

    4. Install it normally—Copilot will automatically surface a new participant (e.g. @MongoDB) in your chat.


By combining both extension types, you can tap into:
Built-in, Copilot-tuned expertise (via the GitHub apps directory)
Your existing VS Code tools and configurations, now fully integrated into Copilot chat

Feel free to explore both catalogs and tailor Copilot’s intelligence to your project’s stack.