Power agentic workflows in your terminal with GitHub Copilot CLI

By GitHub

Share:

Key Concepts

  • GitHub Copilot CLI: An AI assistant integrated into the terminal, designed to enhance developer productivity by assisting with tasks outside of the IDE.
  • Agentic AI Assistant: An AI that can perform tasks autonomously or semi-autonomously, often involving multiple steps or interactions.
  • Terminal: A command-line interface that provides a powerful and flexible way to interact with a computer.
  • MCP Server (GitHub MCP Server): A component of the Copilot CLI that allows interaction with GitHub repositories directly from the terminal, enabling tasks like searching for issues.
  • Custom Agents: User-defined AI agents within the Copilot ecosystem, capable of enforcing specific rules or performing specialized tasks (e.g., accessibility review).
  • Playwright MCP Server: A specific MCP Server that integrates with Playwright, a tool for end-to-end web testing, to ensure fixes are verified.
  • delegate command: A Copilot CLI command that allows users to hand off complex or time-consuming tasks to the AI for asynchronous completion.
  • allow all tools flag: A Copilot CLI flag that grants the AI permission to use any available tools on the system, with a caution for production environments.
  • npm install @github/copilot-cli: The command to install the GitHub Copilot CLI.

GitHub Copilot CLI: An Agentic AI Assistant for the Terminal

Ryan Hecht, a product manager on the GitHub Copilot team, introduces the GitHub Copilot CLI, which launched in public preview last month. The CLI aims to bring the power of an agentic AI assistant directly into the developer's terminal, bridging the gap between IDE-based development and other essential developer workflows.

The Need for a Terminal-Based AI Assistant

Hecht highlights that developers spend significant time outside their IDEs, performing tasks such as:

  • SSHing into servers
  • Debugging in containers
  • Triaging issues on GitHub.com
  • Managing CI/CD pipelines
  • Writing deployment scripts

These tasks often don't fit neatly into an IDE. The terminal, being a universal and powerful interface, is identified as the ideal environment for an AI assistant that can offer fine-grained control, customizability, and composable scripting for automation. The Copilot CLI aims to make everyone a "terminal whiz" by providing an editor-agnostic tool that connects to the broader GitHub ecosystem. This allows developers to spend less time searching documentation and more time executing tasks, integrating AI into their automation and scripts.

Demonstration: On-Call Scenario and Bug Fixing

A live demonstration illustrates the capabilities of the Copilot CLI in a realistic on-call scenario. The user takes over on-call duties for a feedback form application without prior knowledge of the codebase or its stack.

1. Initial Setup and Environment Configuration:

  • Cloning the Repository: The user, not having the repository downloaded, asks Copilot to clone the "feedback repo" and set it up.
  • Dependency Management: Copilot analyzes the repository (identifying package.json) and automatically runs npm install to set up the project dependencies. This process is described as being able to handle more complex setups, such as installing JVMs, specific Go versions, or Python virtual environments.
  • Running the Development Server: Copilot suggests running npm run dev to start the development server.

2. Resolving Port Conflicts:

  • Problem: The npm run dev command fails because port 3000 is already in use.
  • Copilot Assistance: Instead of manually looking up lsof commands and flags, the user asks Copilot, "what is using currently using port 3000".
  • Execution: Copilot identifies the process using the port and provides its Process ID (PID). The user then uses a quick command (kill -9 <PID>) to terminate the conflicting process.
  • Outcome: The development server can now be started successfully on localhost:3000.

3. Debugging and Fixing a UI Bug:

  • Bug Identification: The user observes a bug where the submit button overlays the text area, as shown in an image provided by design.
  • Image-to-Code Functionality: The user copies the fix-this.png image into the repository and asks Copilot to "fix this.png app". Copilot is capable of reading the image and understanding the visual bug.
  • Code Modification: Copilot identifies the issue (button overlapping text area) and locates the relevant CSS file to make the necessary adjustments. The user grants permission for Copilot to modify the CSS file and perform file operations.
  • Partial Fix and Next Steps: Copilot reports the fix, but upon checking, the bug is not entirely resolved.

4. Accessibility Review and Custom Agents:

  • Team Requirements: The user's team has strict accessibility requirements.
  • Custom Accessibility Agent: A custom agent, released that day, is introduced. This agent defines accessibility rules and uses "MCP tools" to check for guardrails.
  • Reviewing Changes: The user invokes the custom agent with agent accessibility reviewer review our changes. The agent analyzes the code modifications and identifies a critical accessibility issue, proposing a fix.

5. Interacting with GitHub Issues and Asynchronous Delegation:

  • Searching for Open Issues: The user queries the Copilot CLI using the "GitHub MCP Server" to find open issues related to the current work: "are there any open issues that map to the work we're doing?".
  • Issue Identification: The MCP Server confirms it's a GitHub repository and finds an issue. The issue mentions the button being oversized on mobile, which is related to the current bug.
  • Delegating Further Work: Recognizing that further fixes are needed and having other tasks to attend to, the user uses the delegate command: "delegate finish fixing the issue outlined in number one and use the playwright MCP Server to ensure that it is fixed."
  • Automated Workflow: This command stages changes, commits them to a new branch, and initiates a Pull Request (PR). The Copilot Coding agent will then asynchronously work on resolving the issue, leveraging the Playwright MCP Server for verification. This allows the user to move on to other tasks.

Advanced Features and Security

1. "Heedless" Operations and Tool Permissions:

  • Allowing All Tools: The demonstration revisits the port conflict scenario, this time using the allow all tools flag. This grants Copilot permission to use any tool on the system, including lsof and xargs to kill the process using port 3000.
  • Security Considerations: A strong caution is issued against using allow all tools in production environments. The CLI offers flags to restrict access to specific directories or tools, and to explicitly deny access to certain tools, providing granular control over AI permissions.

2. Authentication:

  • Interactive Login: Users can authenticate interactively using OAuth via a login command.
  • Personal Access Tokens (PATs): PATs can also be used, enabling integration with automation workflows.
  • Enterprise Features: The team is working on enterprise-friendly authentication methods, such as organization-owned PATs.

Development and Community Engagement

  • Rapid Iteration: Since its release, the Copilot CLI has seen daily updates, with each release containing multiple bullet points of improvements.
  • Community-Driven Development: The team actively solicits feedback and implements features requested by users through open issues on their public repository.
  • Installation: The Copilot CLI is available as an npm module and can be installed using npm install -g @github/copilot-cli on Windows (WSL and PowerShell), macOS, and Linux.
  • Call to Action: Developers are encouraged to join the public repository, participate in discussions, and contribute to building the best terminal-based AI system.

Conclusion

The GitHub Copilot CLI represents a significant step in bringing AI assistance to the developer's entire workflow, not just within the IDE. By integrating agentic AI into the terminal, it empowers developers to handle complex tasks, automate processes, and resolve issues more efficiently, ultimately allowing them to focus on higher-level problem-solving. The emphasis on security, customizability, and community involvement underscores the project's commitment to creating a powerful and trustworthy tool.

Chat with this Video

AI-Powered

Load the transcript when you're ready to chat so the initial page stays lighter.

Ready to summarize another video?

Summarize YouTube Video
Power agentic workflows in your terminal with GitHub Copilot CLI - AI Video Summary