Skip to content

Commit 9c8e573

Browse files
authored
Merge pull request #1 from arilivigni/copilot/update-readme-for-copilot-cli
Create complete GitHub Skills exercise for Copilot CLI with calculator app
2 parents 11eebeb + 1895063 commit 9c8e573

14 files changed

Lines changed: 625 additions & 120 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Copilot CLI Calculator Exercise",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",
4+
"features": {
5+
"ghcr.io/devcontainers/features/github-cli:1": {
6+
"installDirectlyFromGitHubRelease": true,
7+
"version": "latest"
8+
}
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"GitHub.copilot",
14+
"GitHub.copilot-chat"
15+
],
16+
"settings": {
17+
"files.autoSave": "afterDelay"
18+
}
19+
}
20+
},
21+
"postCreateCommand": "echo '🚀 Welcome to the Copilot CLI Exercise!' && echo '' && echo '📝 To install the standalone GitHub Copilot CLI:' && echo ' Run: npm install -g @github/copilot' && echo '' && echo '📝 Then start Copilot CLI by running:' && echo ' copilot' && echo '' && echo '📖 Open README.md to get started with the exercise!' && echo '' && npm install",
22+
"onCreateCommand": "chmod +x .devcontainer/setup.sh 2>/dev/null || true",
23+
"portsAttributes": {
24+
"3000": {
25+
"label": "Application",
26+
"onAutoForward": "notify"
27+
}
28+
},
29+
"remoteUser": "node"
30+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature or enhancement for the calculator
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Feature Description
10+
11+
A clear and concise description of the feature you'd like to see.
12+
13+
## Use Case
14+
15+
Describe the use case or problem this feature would solve.
16+
17+
## Proposed Solution
18+
19+
How do you envision this feature working?
20+
21+
## Additional Context
22+
23+
Add any other context, screenshots, or examples about the feature request here.

.github/steps/1-step.md

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,93 @@
1-
## Step 1: (replace-me: STEP-NAME)
1+
## Step 1: Install Copilot CLI and Use the Issue Template
22

3-
(replace-me: OPTIONAL Brief story or scenario to introduce the step)
3+
Duck is getting ready to manage development for the Node.js calculator app and wants to install the standalone Copilot CLI and use the existing issue template to create a new issue.
44

5-
### 📖 Theory: (replace-me: Theory title)
5+
### 📖 Theory: GitHub Copilot CLI - A Standalone Terminal Application
66

7-
<!-- GitHub-styled notifications can be used outside of ordered lists. Available options are: NOTE, IMPORTANT, WARNING, TIP, CAUTION -->
8-
<!--
9-
> [!NOTE]
10-
> (Important note or additional information relevant to this section)
11-
-->
7+
**What is GitHub Copilot CLI?**
8+
9+
GitHub Copilot CLI is a **standalone terminal application** that brings the power of GitHub Copilot directly to your command line. It is installed via npm and provides a rich interactive experience for developers.
10+
11+
Key capabilities include:
12+
- Providing intelligent command suggestions powered by the latest AI models from OpenAI and Google
13+
- Generating code snippets and scripts directly in your terminal
14+
- Assisting with Git operations and GitHub interactions
15+
- Supporting image inputs via paste and drag-and-drop for visual context
16+
- Using the `/share` command to save chat sessions as Markdown files or GitHub gists
17+
- Creating **custom agents** to encode specialized prompts and workflows
18+
- Delegating tasks to **Copilot coding agent** using the `/delegate` command
19+
20+
**Installation Requirements**
21+
22+
To install Copilot CLI, you need:
23+
- Node.js version 22 or later
24+
- npm version 10 or later
25+
- An active GitHub Copilot subscription (Pro, Pro+, Business, or Enterprise)
26+
27+
**Issue Templates**
28+
29+
Issue templates help maintain consistency when team members create issues. This repository already has a `feature_request.md` template that you'll use to create your calculator app issue. Templates ensure:
30+
- All necessary information is captured upfront
31+
- Issues follow a standard format
32+
- The team can triage and respond to issues more efficiently
33+
34+
**References:**
35+
- [Installing GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli)
36+
- [Using GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli)
37+
- [GitHub Copilot CLI 101](https://github.blog/ai-and-ml/github-copilot-cli-101-how-to-use-github-copilot-from-the-command-line/)
1238

13-
(replace-me: Optional theory or background information relevant to this step)
39+
### ⌨️ Activity 1: Install the Standalone Copilot CLI
1440

15-
### ⌨️ Activity: (replace-me: Activity title)
41+
1. Open your Codespace (if not already open)
42+
1. Install the standalone GitHub Copilot CLI by running:
43+
```bash
44+
npm install -g @github/copilot
45+
```
46+
1. Verify the installation by running:
47+
```bash
48+
copilot --version
49+
```
50+
1. Start Copilot CLI and authenticate with your GitHub account:
51+
```bash
52+
copilot
53+
```
54+
Follow the prompts to complete authentication if this is your first time.
1655

17-
1. (replace-me: First instruction)
18-
1. (replace-me: Second instruction)
19-
1. (replace-me: Additional instructions as needed)
56+
> [!TIP]
57+
> After installation, you can use the `copilot` command anywhere in your terminal to start an interactive session!
58+
59+
### ⌨️ Activity 2: Create an Issue Using Copilot CLI
60+
61+
1. Start an interactive Copilot CLI session:
62+
```bash
63+
copilot
64+
```
65+
66+
1. Ask Copilot CLI to help you create a feature request issue for the calculator app:
67+
```
68+
Help me create a GitHub issue for a Node.js calculator app. I want to request a feature for basic arithmetic operations including addition, subtraction, multiplication, and division. The calculator should be implemented in calculator.js.
69+
```
70+
71+
1. Copilot CLI will help you draft and create the issue. Follow the prompts to:
72+
- **Feature description**: Create a basic Node.js calculator with addition, subtraction, multiplication, and division operations
73+
- **Use case**: Learning to use Copilot CLI for code generation and development
74+
- **Additional context**: The calculator should be implemented in calculator.js
75+
76+
1. You can also use the `/delegate` command to have Copilot create the issue for you:
77+
```
78+
/delegate Create a GitHub issue titled "Initial Node.js Calculator App" requesting basic arithmetic operations (add, subtract, multiply, divide) to be implemented in calculator.js
79+
```
80+
81+
> [!NOTE]
82+
> When you create the issue, the workflow will automatically verify your work and prepare the next step!
2083
2184
<details>
2285
<summary>Having trouble? 🤷</summary><br/>
2386

24-
- (replace-me: Troubleshooting tip or hint)
25-
- (replace-me: Additional troubleshooting tips as needed)
87+
- Make sure you have Node.js 22+ installed: `node --version`
88+
- If npm install fails, try: `sudo npm install -g @github/copilot`
89+
- Make sure you have GitHub Copilot access enabled for your account
90+
- If authentication fails, run `copilot` and follow the login prompts
91+
- You can also create the issue through the GitHub UI if needed
2692

2793
</details>

.github/steps/2-step.md

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,89 @@
1-
## Step 2: (replace-me: STEP-NAME)
1+
## Step 2: Work on the Calculator Issue with Copilot CLI
22

3-
(replace-me: OPTIONAL Brief story or scenario to introduce the step)
3+
With the issue created, Duck works with the standalone Copilot CLI interactively to start building the calculator application.
44

5-
### 📖 Theory: (replace-me: Theory title)
5+
### 📖 Theory: Collaborative Development with Copilot CLI
66

7-
<!-- GitHub-styled notifications can be used outside of ordered lists. Available options are: NOTE, IMPORTANT, WARNING, TIP, CAUTION -->
8-
<!--
9-
> [!NOTE]
10-
> (Important note or additional information relevant to this section)
11-
-->
7+
**Interactive Development with Copilot CLI**
8+
9+
The standalone Copilot CLI (`copilot` command) provides a rich interactive experience for development:
10+
- Start a session by simply running `copilot` in your terminal
11+
- Have natural conversations about your code and get intelligent suggestions
12+
- Generate boilerplate code based on your requirements
13+
- Use the latest AI models for cutting-edge responses
14+
- Share your session using the `/share` command to save as Markdown or a gist
15+
16+
**Custom Agents**
17+
18+
Copilot CLI supports custom agents that you can define in your repository:
19+
- Create agent profiles in `.github/agents/` directory
20+
- Encode specialized prompts, tool selections, and workflows
21+
- Invoke agents using `/agent <name>` command
22+
- Great for documentation, infrastructure, security, or domain-specific tasks
23+
24+
**Delegating Tasks**
25+
26+
When you have larger tasks, you can delegate them to Copilot coding agent:
27+
- Use `/delegate TASK-DESCRIPTION` to assign work
28+
- Copilot creates a new branch and draft pull request
29+
- The coding agent works autonomously in the background
30+
- Review the changes when complete
31+
32+
> [!TIP]
33+
> Use the `/share` command to save your Copilot CLI chat sessions as Markdown files or GitHub gists for future reference!
34+
35+
**References:**
36+
- [Using GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli)
37+
- [Custom agents in Copilot CLI](https://github.blog/changelog/2025-10-28-github-copilot-cli-use-custom-agents-and-delegate-to-copilot-coding-agent/)
38+
- [About custom agents](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-custom-agents)
1239

13-
(replace-me: Optional theory or background information relevant to this step)
40+
### ⌨️ Activity: Generate Calculator Code with Copilot CLI
1441

15-
### ⌨️ Activity: (replace-me: Activity title)
42+
1. Start an interactive Copilot CLI session:
43+
```bash
44+
copilot
45+
```
1646

17-
1. (replace-me: First instruction)
18-
1. (replace-me: Second instruction)
19-
1. (replace-me: Additional instructions as needed)
47+
1. Ask Copilot CLI to help you create the calculator functions:
48+
```
49+
Help me create a Node.js calculator module with functions for addition, subtraction, multiplication, and division. The functions should be exported so they can be used in other files.
50+
```
51+
52+
1. Alternatively, use the headless mode with a prompt:
53+
```bash
54+
copilot -p "Create JavaScript calculator functions for add, subtract, multiply, and divide that can be exported from a Node.js module"
55+
```
56+
57+
1. Update your `calculator.js` file with the generated code. You can also ask Copilot for explanations:
58+
```bash
59+
copilot -p "Explain how module.exports works in Node.js"
60+
```
61+
62+
1. Test your calculator functions:
63+
```bash
64+
node -e "const calc = require('./calculator'); console.log('2 + 3 =', calc.add(2, 3)); console.log('10 - 4 =', calc.subtract(10, 4));"
65+
```
66+
67+
1. Commit your changes:
68+
```bash
69+
git add calculator.js
70+
git commit -m "Implement basic calculator operations"
71+
git push
72+
```
73+
74+
> [!TIP]
75+
> You can paste or drag-and-drop images into Copilot CLI to provide visual context for your questions!
76+
77+
> [!NOTE]
78+
> Pushing your changes will trigger the workflow to verify your work and prepare the next step!
2079
2180
<details>
2281
<summary>Having trouble? 🤷</summary><br/>
2382

24-
- (replace-me: Troubleshooting tip or hint)
25-
- (replace-me: Additional troubleshooting tips as needed)
83+
- Make sure you're in the repository directory when running commands
84+
- The `copilot` command requires Node.js 22+ to be installed
85+
- If authentication fails, run `copilot` and follow the login prompts
86+
- You can also edit the calculator.js file manually based on Copilot's suggestions
87+
- Remember to export your functions using `module.exports`
2688

2789
</details>

.github/steps/3-step.md

Lines changed: 97 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,109 @@
1-
## Step 3: (replace-me: STEP-NAME)
1+
## Step 3: Expand Calculator Functionality
22

3-
(replace-me: OPTIONAL Brief story or scenario to introduce the step)
3+
Duck wants to expand the calculator with additional operations by creating a new issue and working with Copilot CLI to implement the enhancements.
44

5-
### 📖 Theory: (replace-me: Theory title)
5+
### 📖 Theory: Iterative Development with Copilot CLI
66

7-
<!-- GitHub-styled notifications can be used outside of ordered lists. Available options are: NOTE, IMPORTANT, WARNING, TIP, CAUTION -->
8-
<!--
9-
> [!NOTE]
10-
> (Important note or additional information relevant to this section)
11-
-->
7+
**Iterative Development and Agile Practices**
8+
9+
Modern software development follows iterative approaches where features are built incrementally:
10+
- Start with a minimal viable product (MVP)
11+
- Add features in small, manageable chunks
12+
- Test and validate each addition
13+
- Continuously improve based on feedback
14+
15+
**Maintaining Momentum with Copilot CLI**
16+
17+
The standalone Copilot CLI helps maintain development momentum by:
18+
- Quickly generating code for new features using the latest AI models
19+
- Suggesting best practices and patterns
20+
- Helping debug and test new functionality
21+
- Reducing context switching by keeping you in the terminal
22+
- Handling long-running shell commands more efficiently
23+
- Supporting improved automation with the headless `-p` mode
24+
25+
**Delegating Larger Tasks**
26+
27+
For more complex tasks, you can use the `/delegate` command:
28+
```bash
29+
copilot
30+
> /delegate Add modulo, exponentiation, and square root functions to calculator.js with proper error handling
31+
```
32+
33+
Copilot coding agent will:
34+
1. Create a new branch automatically
35+
2. Open a draft pull request
36+
3. Work on the task autonomously
37+
4. Stream output to your terminal
38+
5. Request your review when complete
39+
40+
**Testing and Improvement Workflows**
41+
42+
As you add features, Copilot CLI can help you:
43+
- Generate test cases for new operations
44+
- Suggest edge cases to consider
45+
- Create documentation
46+
- Refactor code for better maintainability
47+
- Save and share your development sessions using `/share`
1248

13-
(replace-me: Optional theory or background information relevant to this step)
49+
### ⌨️ Activity: Add More Operations to the Calculator
1450

15-
### ⌨️ Activity: (replace-me: Activity title)
51+
1. Start an interactive Copilot CLI session:
52+
```bash
53+
copilot
54+
```
1655

17-
1. (replace-me: First instruction)
18-
1. (replace-me: Second instruction)
19-
1. (replace-me: Additional instructions as needed)
56+
1. Ask Copilot CLI to help you create another issue for expanding the calculator:
57+
```
58+
Help me create a GitHub issue to add more operations to my calculator. I want to add modulo, exponentiation (power), and square root functions with proper error handling.
59+
```
60+
61+
1. Or use the `/delegate` command to create the issue:
62+
```
63+
/delegate Create a GitHub issue titled "Add More Operations to Calculator" requesting modulo, exponentiation, and square root functions to be added to calculator.js with error handling
64+
```
65+
66+
1. Work with Copilot CLI to implement the new operations:
67+
```
68+
Help me add these functions to my calculator.js:
69+
1. modulo(a, b) - returns the remainder of a divided by b
70+
2. power(base, exponent) - returns base raised to the exponent
71+
3. squareRoot(n) - returns the square root of n with error handling for negative numbers
72+
```
73+
74+
1. Alternatively, use the headless mode:
75+
```bash
76+
copilot -p "Add modulo, exponentiation (power), and square root functions to a Node.js calculator module. Include proper error handling for edge cases like negative square roots."
77+
```
78+
79+
1. Update your `calculator.js` file with the new functions
80+
81+
1. Test your new functions:
82+
```bash
83+
node -e "const calc = require('./calculator'); console.log('5 % 2 =', calc.modulo(5, 2)); console.log('2 ^ 3 =', calc.power(2, 3)); console.log('√16 =', calc.squareRoot(16));"
84+
```
85+
86+
1. Commit your changes:
87+
```bash
88+
git add calculator.js
89+
git commit -m "Add modulo, power, and square root operations"
90+
git push
91+
```
92+
93+
> [!TIP]
94+
> Use `/share` in your Copilot CLI session to save your conversation as a Markdown file or GitHub gist for future reference!
95+
96+
> [!NOTE]
97+
> Creating this second issue will complete the exercise and trigger the review workflow!
2098
2199
<details>
22100
<summary>Having trouble? 🤷</summary><br/>
23101

24-
- (replace-me: Troubleshooting tip or hint)
25-
- (replace-me: Additional troubleshooting tips as needed)
102+
- Make sure your issue title includes "Calculator" or "Operations"
103+
- The calculator.js file should export functions that can be required/imported
104+
- You can test operations manually using Node.js REPL: `node` then type your code
105+
- For square root of negative numbers, consider returning `NaN` or throwing an error
106+
- Remember to commit and push any code changes you make
107+
- Use `copilot --help` to see all available command options
26108

27109
</details>

0 commit comments

Comments
 (0)