Skip to main content
In this lesson we’ll explore GitHub Copilot Chat — the core of the extension and application — and how it helps you scaffold, iterate, and debug a small Node.js REST API that uses an in-memory database. Goal: build a simple web application in Node.js that exposes a REST API backed by an in-memory database. Each user object will contain an id, firstName, lastName, and email. Start by asking Copilot Chat to scaffold a new project (for example, use /new and request a “Node application API”). Copilot often generates files such as index.js, app.js, and basic tests to get you started.
A dark-themed Visual Studio Code window with the Explorer sidebar on the left and a large VS Code logo in the center. On the right is a chat panel showing a user message and an AI assistant's generated response.
What Copilot typically produces
  • index.js — starts the HTTP server.
  • app.js — defines the Express application and routes.
  • optional test files — e.g., using Jest + Supertest.
A simple Express application (app.js)
Server entrypoint (index.js)
Automated feature tests (app.test.js)
Minimal package.json
API endpoints (quick reference) CLI flow (typical)
  1. Install dependencies:
Expected abbreviated result:
  1. Start the application:
Expected output:
Troubleshooting common errors
  • EJSONPARSE from npm (malformed package.json):
This indicates your package.json is invalid JSON. Paste the contents into Copilot Chat and ask /fix or validate the JSON before running npm install. How Copilot Chat helps in practice
  • Scaffold project files (/new), generate routes, tests, and README.
  • Scope fixes with /fix for a file, selection, or working set.
  • Use /terminal last command to share terminal output with the chat so Copilot can analyze errors and propose patches.
Working set / context matters. Copilot Chat uses your project files (open editors, the full codebase, selected files, and terminal output) to provide focused suggestions. Narrowing the context — a specific file, selection, or terminal output — yields more relevant edits. This behavior is important when using Copilot Chat effectively.
Slash commands and context helpers
  • /new — scaffold a project or file.
  • /fix — ask Copilot Chat to fix the selected code or the current working set.
  • /clear — clear the conversation.
  • /help — get command usage and interaction info.
  • /terminal last command — send the last terminal command and output into Copilot Chat.
Hashtags to control context
  • #changes — include change history context
  • #codebase — include the full codebase
  • #editor — include currently open editors
  • #file — include a specific file
  • #selection — include just the current selection
  • #terminalLastCommand and #terminalSelection — include terminal details
Examples to send into the chat:
To ask about the last terminal command:
Practical tips
  • Accept Copilot edits (e.g., Accept All Edits) to write files into your workspace quickly.
  • If you change the API shape (for example, remove lastName), update tests, docs, and other references; Copilot can locate inconsistencies when you provide the working set and run /fix.
  • If Copilot’s response isn’t what you expected, switch models in the UI (e.g., GPT-4o, Claude, Gemini) to compare outputs.
Want more? I can:
  • produce full starter files packaged in a zip,
  • add a README and detailed API documentation,
  • walk through a live debugging session demonstrating /terminal last command and /fix.

Watch Video