Brainstorming with Copilot Workspace

Published 11/2/2024 7:05:41 AM
Filed under Developers life

I've been very fortunate to be able to use the new Copilot Workspace technical preview for the past few months. There are a lot of promises around AI, including Copilot Workspace, that sound amazing but don't deliver. It takes effort to learn to use AI-based tools like Copilot Workspace. To help people who may be frustrated about the results they're getting with these kinds of tools, I decided to cover some scenarios in which I use Copilot Workspace to get you over the speed bumps.

In this post, we'll go over using Copilot Workspace to brainstorm bug fixes, ideas, and features. We'll cover how to get started and iterate on your ideas to get the best code possible.

Getting started

Copilot workspace supports two main entrypoints into generating code:

  1. You can start a task from scratch and brainstorm ideas.
  2. You can work off an existing issue on your backlog.

I think that most hobby developers will start from scratch, while in a professional setting you're like going to refine a backlog first and then start coding from tasks you defined with your team. However, I highly recommend splitting your design into several issues if you're building something bigger as a hobbyist.

For this post, we'll cover brainstorming in the context of a task you start from scratch. To start a task from scratch, navigate to https://copilot-workspace.githubnext.com.

Homepage of Copilot Workspace
Homepage of Copilot Workspace

Select the repository you want to work on. You'll now see a task window that allows you to describe a task that you want to work on.

Editing a task in Copilot Workspace
Editing a task in Copilot Workspace

Now it gets interesting, this task window has a button to brainstorm. Let's discuss what this button can do.

The brainstorming feature is best explained by talking you through a scenario. I have an AI agent that I built entirely with Copilot Workspace. But I forgot to ask for tests for a specific set of classes.

I wrote down the task:

I want tests for the command handlers. I want to reuse as much as possible in my tests because they can be pretty hard to maintain.

I'll get the following screen when I click the "Brainstorm" button.

Copilot Workspace showing brainstorming results
Copilot Workspace showing brainstorming results

This first result answers the question: "How do I solve this?". This is called the specification. It's a special kind of brainstorming idea that's used to generate a plan later.

You can refine the specification in two ways:

  1. You can ask questions to refine the idea using the chatbox at the bottom.
  2. Or you can use the suggested questions.

Let's first try the suggested questions and see how they help refine the specification.

Using suggested questions

In my case, I would like to refine the layout of the base class for the command handler tests. There's a suggested question for it at the bottom of the spec.

Copilot showing results with suggestions
Copilot showing results with suggestions

Notice how the brainstorming window lists the answer to the question. I can add this idea to the task to refine the specification.

Sometimes, you'll find that the idea isn't quite what you want; you have two options to fix it:

  • You can edit the response using the edit toolbar button.
  • Alternatively, you can regenerate the response.

Most of the time, the specification generated in response to "How do I solve this task?" is almost what I want. The extra ideas helped me refine the initial specs with additional information that improved the result.

As you add ideas in the brainstorm, you'll notice that the specification indicated by "How do I solve this task?" is regenerated.

Of course, you're not limited to the suggested questions. But I find that often, they provide me with things that I didn't think of myself. For example, I don't think of validation, performance optimizations, and security checks when writing a first specification for my task.

Asking questions

Using suggested questions can help you quickly refine the spec. But what if you're unfamiliar with the code base? Or you're super busy and sort of lost track of what is or isn't in the code yet?

Copilot Workspace allows you to ask questions about the code base. For example, I can ask about what command handlers They are in my code base.

Copilot Workspace showing the answer to a question about the code base
Copilot Workspace showing the answer to a question about the code base

Of course, I wouldn't want to add this idea to my specification, but it's nice that I can ask these questions to better understand my codebase.

When I added the idea to the task, I noticed that Copilot Workspace used it and found more files where I was missing tests. So, although these questions may not look helpful to add to your task, I recommend trying to add ideas generated from your questions and verifying the results. You may be surprised.

You may think brainstorming only works when you haven't generated any code yet, but that's not the case.

Iterating as you develop

After you've created a specification for a task, you can generate a plan using the "Generate plan" button. When that's done, you can let Copilot Workspace implement the plan in code. It initially felt that brainstorming wouldn't work beyond this point. But that's not true.

After writing the code, you can return to the brainstorming feature to refine the code and specification based on the results you've seen. When you do so, the brainstorming will take into account the generated code so you can iterate more effectively.

Brainstorming is the scratch pad to your development process. It's always available wherever you are in developing your feature. I frequently use it to figure things out when I'm not in a mood to look at other code in my application. Brainstorming will find it and generate ideas to enhance the task I'm working on.

Once you know how it works, you'll find yourself going back to it quite a lot more often.

Summary

Learning how to use the brainstorming feature in Copilot Workspace will take some time. Still, I hope the tips in this article will help you gain more productivity with Copilot Workspace using brainstorming.

Feel free to leave a comment with your experience. Let me know what worked well and what didn't :-)