Streamline Your Coding Workflow: Use GitHub Copilot Sessions in VS Code

Seamlessly transition GitHub Copilot sessions to VS Code, maintaining context and conversation intact.

Developers using the GitHub Copilot app can now seamlessly transition their coding sessions to Visual Studio Code (VS Code) with complete context. This integration ensures continuity, allowing you to leverage Copilot's AI capabilities alongside VS Code’s robust development environment—all without losing conversational history or code changes. By enabling a connected workflow, developers can effortlessly move from automated code generation to intensive debugging, refinement, and deployment processes.

Why the GitHub Copilot and VS Code Integration Matters

Picture this: you’re utilizing GitHub Copilot to automate repetitive tasks and now need to refine, test, and deploy the code manually. Previously, shifting this workflow entirely into an editor involved manual steps that were cumbersome and time-consuming. This Copilot-VS Code focus changes the game by transferring your entire session—code, changes, and the conversation—into VS Code. It’s an excellent strategy for maintaining flow and ensuring critical development continuity.

I’d suggest all developers using GitHub Copilot embrace this workflow. It facilitates a clear division of labor; AI handles bulk edits, while you focus on the nuances. The beauty here is continuity—the session context travels with you. You gain a streamlined process for integrating machine learning assistance without disrupting the development process.

How to Transition Your GitHub Copilot Session

If you're ready to move your Copilot session into VS Code, here’s how to do it with careful attention to ensuring the complete transition of context and accuracy of workflow:

  1. Start with a Session in the Copilot App: Begin by verifying the task and work completed by Copilot within the app. Ensure you understand the context, as conversations and tasks are preserved and pivotal when moving the session. The task and plan remain tied to that session, providing insight into the reasoning behind the generated code.

    Check for any incomplete tasks or additional details that need attention before transitioning, as these might affect the session’s results in VS Code.

  2. Open the Session in VS Code: Use the Open in VS Code feature from the Copilot app. This action exports the project using the associated worktree, maintaining access to the task, plan, and the entirety of the conversation history. Be meticulous in selecting the correct editor if multiple options are available.

    Verify the worktree’s integrity after opening it in VS Code to ensure no context is lost, and all dependencies are intact.

  3. Review Agent’s Changes: Check the Source Control view to inspect the code by reviewing the line-by-line differences. Ensure the modifications solve the intended problem and adhere to repository standards. Pay close attention to the handling of error states, edge cases, and the inclusion of adequate tests for the affected code paths.

    For instance:

    const result = calculateValue(input);
    // Verifying that edge cases are handled properly if (result < 0) {
      throw new Error("Negative values not allowed");
    }

    Ensure that no unnecessary functions or large changes outside the scope of the task have been made, as they can introduce risk.

  4. Make Hands-on Edits: Adjustments such as label refinements or variable renaming can be efficiently managed within VS Code, working directly with the existing session’s worktree. This includes incorporating repository-specific conventions, ensuring consistent styling, and clarifying code intent through comments or documentation updates.

    Make sure all manual edits comply with project guidelines, especially regarding performance impact and readability enhancements.

  5. Run and Verify Locally: Utilize the integrated terminal in VS Code for local testing. Common workflows might include running npm install, npm test, or npm run lint. Treat AI-generated code with the same scrutiny you’d apply to human-written code. Remember to run a full suite of tests to verify that all components interact as expected.

    Example commands for a JavaScript-based project:

          
            npm install    // Installs all required dependencies
            npm run lint   // Ensures code adheres to style guidelines
            npm test       // Executes all unit and integration tests
          
        

    Check for common issues such as dependency conflicts or test failures that may not be directly related to the changes but can impact overall functionality.

  6. Continue with Copilot or Keep Editing Yourself: At any point, decide on the interaction that best suits the next step. This might involve prompting Copilot to extend functionality or making direct code edits for exact changes known beforehand. Utilize both methods together to refine and test implementations iteratively.

    Example prompt:

    "Add a test for the newly updated function and confirm its edge case handling without touching unrelated components."

    Select prompt requests carefully to focus on the specific areas of improvement or exploration within the codebase.

  7. Commit and Push Changes: It’s straightforward to finalize your changes. Use VS Code’s terminal for commands such as git commit and git push to update the pull request that Copilot has tracked. Ensure clean commit messages and follow your team's review processes.

    Ensure that all changes are accurately represented in your commit messages for concise retrieval during future audits or reviews.

Am I Affected? Do I Need This Integration?

If you're a developer who frequently switches context between AI-generated suggestions and manual edits, you should integrate this workflow immediately. It aligns well for those already using GitHub Copilot and VS Code. Such integration can improve productivity by reducing the complexity of managing multiple tools and contexts, streamlining the coding process significantly.

It also fits companies seeking to streamline team workflows between AI tools and manual coding during development cycles. Teams aiming to maintain high development speeds while ensuring code quality can greatly benefit. Engage with Copilot regularly and become familiar with its functionalities to maximize efficiency gains.

Potential Limitations and Considerations

This integration primarily benefits those already using GitHub Copilot with VS Code. If you're in a different editor ecosystem, the advantages may not directly apply. Also, since this workflow optimally functions with Copilot’s AI, those less inclined towards AI tools might find the transition unnecessary.

I’d recommend team leaders ensure their workflows support this integration before a team-wide implementation is planned. Ensure all systems align with GitHub’s AI requirements to avoid disruptive transitions. Furthermore, teams focusing on adherence to strict privacy policies should evaluate how session data handling aligns with internal standards.

Additionally, integration efficiency heavily depends on the habitual interaction with Copilot and the degree of customization in VS Code. Consider user training to smooth out early adoption challenges, and carefully evaluate any areas where user acceptance might be low, providing additional resources or training as necessary.

More Workflow Enhancements

For developers interested in further optimizing their coding environment, the Top 5 Git Commands for Developers provides additional insights into managing workflows with efficiency and precision.

Furthermore, understanding how to harness environment variables effectively can assist in managing secure configurations for your applications. Check out our guide on environment variables in Node.js.

As AI is poised to impact even more areas of software development, reading about AI hardware accelerators could provide a broader perspective on the efficiency gains possible with AI technologies.

FAQ

Frequently asked questions

How do I start a GitHub Copilot session?

Download the GitHub Copilot app, start a session, and review the task it completed.

What happens if I have multiple VS Code installations?

Choose from multiple supported editor installations when opening the session in VS Code.

Can I continue the session's conversation in VS Code?

Yes, the session's conversation is preserved and can be continued in VS Code.

What commands are useful for verifying the project?

Run commands like npm test and npm run lint to verify the project's integrity locally.

Source: github.blog

How this article was made: drafted with AI from the source above and fact-checked against it, then reviewed and tested by Vishal — see the hands-on notes.

Vishal
· Developer

Vishal writes Trickyworld's tutorials and interview-preparation guides on programming, databases, cyber security and AI. Vishal has been shipping production software long enough to have firm opinions about Python, PHP, Node.js, and JavaScript, and to have been wrong about each of them at least once. The work has run the whole stack: Drupal and Laravel applications, React front ends, MySQL and MongoDB underneath, Redis and Memcached for the things that had to be fast, Apache Solr for the things that had to be findable. That last part turned out to matter more than anyone expected. Tune a Solr index for a season, then watch a language model confidently retrieve the wrong document, and you recognise an old problem wearing new clothes. Most of what is hard about AI systems is not the model. It is retrieval, caching, latency budgets, and deciding what the system does when the answer comes back wrong — which is work he has been doing since well before anyone called it AI engineering. He plays a lot of games, which is less a hobby disclosure than an admission of where a good share of his engineering instinct came from. Real-time systems with a frame budget. State that has to stay coherent while a player does something no designer anticipated. The permanent question of what happens when the frame cannot finish in time. Those habits carry over more directly than they have any right to. He has written several books on programming, all built on the same conviction: most technical writing is unclear because the author never decided what to leave out. More from Vishal →

More on Git.

$ subscribe --weekly

Get the next tutorial in your inbox.

Programming, security and AI — the practical bits, no spam. Unsubscribe any time.