command-line-interface

4 posts

github

GitHub Copilot CLI for Beginners: Overview of common slash commands (opens in new tab)

GitHub Copilot CLI’s slash commands provide a central way to control sessions directly from the terminal. They help users select models, manage context, inspect changes, switch projects, resume work, and control permissions. The article recommends typing `/` to explore the available commands and build a more deliberate CLI workflow. ## Slash Commands as Copilot CLI Controls - Slash commands are built-in terminal controls for: - Guiding Copilot’s behavior - Inspecting project changes - Managing conversation context - Moving between sessions and repositories - Resetting tool permissions - Typing `/` displays a scrollable list of supported commands. ## Selecting a Model - `/model` opens the list of available models. - Model information includes: - Capabilities for lightweight tasks or deeper reasoning - Availability based on the user’s plan or organization - Cost multipliers indicating relative usage cost - Choosing an appropriate model can balance speed, quality, and cost. ## Managing Context and Tokens - `/context` shows remaining tokens, system usage, and available buffer. - `/compact` summarizes the current conversation to free context space without starting over. - Copilot may compact automatically near the context limit, but users can trigger it manually when changing tasks. - `/clear` completely resets the current session. ## Resuming Previous Sessions - `/resume` lists earlier local and remote sessions. - Users can select a session to review its history and continue where they left off. ## Reviewing Changes - `/diff` displays recent modifications made during the session. - This helps users inspect and validate Copilot’s changes before proceeding. ## Switching Projects - `/cwd` changes Copilot’s current working directory. - It allows users to move between repositories or project directories without exiting the CLI. ## Resetting Permissions - `/reset-allowed-tools` removes previously granted permissions for actions such as editing files. - This is useful when switching to a repository that requires more cautious access controls. Users should start by typing `/` in Copilot CLI to discover available commands, then use commands such as `/model`, `/context`, `/compact`, `/diff`, and `/cwd` to maintain control over their coding sessions.

github

GitHub Copilot CLI for Beginners: Interactive v. non-interactive mode (opens in new tab)

GitHub Copilot CLI offers two ways to work from the terminal: interactive mode for ongoing, collaborative sessions and non-interactive mode for quick, one-off prompts. The article recommends choosing between them based on whether you need iterative exploration or a fast answer within an existing shell workflow. Previous sessions can also be resumed in either mode. ## Interactive Mode for Collaborative Work - Start it by running `copilot`. - It is the default mode and provides a chat-like, back-and-forth experience. - Users can: - Ask questions about a project. - Review Copilot’s responses. - Ask follow-up questions. - Request actions, such as running a local server. - Copilot may request permission to trust the current folder because it needs to read or modify project files. - This mode is best for exploratory coding, troubleshooting, and tasks that require multiple steps. ## Non-Interactive Mode for Quick Prompts - Start it with `copilot -p "your prompt"`. - It produces a single response without opening a full conversational session. - Typical uses include: - Summarizing a repository. - Generating code snippets. - Running Copilot inside automated workflows. - It is designed to keep users in their normal terminal flow and is most useful when the required task is clear and narrowly defined. ## Resuming Previous Sessions - In interactive mode, enter `/resume` to select a previous session. - From the regular shell, use `copilot --resume` to open the session picker directly. - Resuming preserves the context of earlier conversations, making it easier to continue unfinished work. The practical choice is simple: use interactive mode for deeper, iterative collaboration and non-interactive mode for focused, one-shot requests.

github

GitHub Copilot CLI for Beginners: Getting started with GitHub Copilot CLI (opens in new tab)

GitHub Copilot CLI brings Copilot’s agentic coding capabilities directly into the terminal, allowing developers to inspect projects, generate code, run tests, and correct errors without switching tools. The post introduces the tool, explains installation and authentication, and demonstrates how to use it for project overviews, coding tasks, and delegated work. Its central message is that Copilot CLI can preserve development flow while supporting increasingly autonomous coding workflows. ## What GitHub Copilot CLI Does - Runs Copilot from a command-line interface with context from the current repository. - Can autonomously: - Build or modify code - Run tests - Detect and correct errors - Explore project files and documentation - Lets developers review results and request follow-up changes directly in the terminal. - Can delegate well-defined tasks to the Copilot cloud agent. ## Installing Copilot CLI - The primary cross-platform installation method, assuming Node.js is available, is: ```bash npm install -g @github/copilot ``` - Users can also install it through package managers such as Homebrew or WinGet. ## First-Time Setup - Launch the tool by entering `Copilot` in the terminal. - Authenticate with GitHub using: ```plaintext /login ``` - Authentication connects the CLI to the user’s Copilot account and the read-only GitHub MCP server. - Copilot must be granted permission to access the current folder so it can inspect or modify files. - Folder permissions can apply only to the current session or be saved for future sessions. ## Common Development Tasks - **Understand an existing project** - Prompt Copilot with: ```plaintext Give me an overview of this project ``` - It examines important files and summarizes the project structure and purpose. - **Generate new code** - For example: ```plaintext Let’s add a new endpoint to return all categories ``` - Copilot reviews existing conventions, documentation, and examples before proposing or creating files. - It requests permission before making changes. - **Delegate work to the cloud agent** - A task can be sent using: ```plaintext /delegate Let’s deal with issue #14 to add the rest of the CRUD endpoints to games ``` - The cloud agent retains the current context, creates a branch, opens a draft pull request, and performs the work in the background for later review. ## What Comes Next The broader beginner series will cover interactive mode, non-interactive mode using the `-p` flag, slash commands, and MCP server integration. These features expand Copilot CLI from an interactive coding assistant into a flexible terminal-based automation tool. Copilot CLI is recommended for developers who want AI assistance without leaving the shell: install it with npm, authenticate, grant project permissions, and begin with exploratory prompts before assigning code changes or delegated tasks.

github

From idea to pull request: A practical guide to building with GitHub Copilot CLI (opens in new tab)

GitHub Copilot CLI helps developers move from an idea to reviewable code without leaving the terminal. The recommended workflow is to begin with intent, let Copilot propose plans and scaffolding, validate changes through tests and diffs, then move to an IDE for refinement and GitHub for collaboration. Copilot accelerates development but does not replace design judgment, code review, or user approval. ## What Copilot CLI Is—and Isn’t - It is a GitHub-aware coding agent that operates in the terminal. - Developers can describe goals in natural language and use `/plan` or `Shift + Tab` planning mode. - It proposes commands, file changes, and diffs for review before execution. - It can generate files, modify code, and explain failures. - It does not silently run commands or eliminate the need for careful design and review. ## Start with Intent - Begin by describing the application or feature rather than choosing a framework or copying a template. - For example, ask Copilot to create a small web service with a JSON endpoint and tests. - Copilot may suggest a technology stack, file structure, and setup commands. - Review these suggestions before deciding what to execute. ## Scaffold Only What You Own - Once the direction is clear, ask Copilot to create a minimal project structure. - It can generate directories, configuration, test runners, and README files. - Generated scaffolding should be treated as a starting point, not an unquestioned design. - Developers remain responsible for reviewing, editing, or discarding the result. ## Iterate from Real Failures - Run tests directly within the CLI and use the resulting output as context. - Ask Copilot to explain a failure or propose a fix with a reviewable diff. - The recommended loop is: run a command, inspect the output, ask for help, and review the proposed change. - Use `explain` when understanding is the goal and `suggest` when seeking a concrete proposal. ## Handle Mechanical Repository-Wide Changes - Copilot CLI is effective for clearly scoped, repetitive work such as renaming symbols across a repository. - It can update related tests and provide a concrete diff. - Mechanical changes are relatively easy to inspect, revert, and validate. ## Move to the IDE for Precision - The terminal is best for fast exploration, planning, scaffolding, and low-ceremony changes. - Move to an editor or IDE when refining APIs, handling edge cases, and making design decisions. - A practical division is: - **CLI:** plan, generate diffs, and move quickly. - **IDE:** refine logic and shape the implementation. - **GitHub:** commit, open pull requests, review, and collaborate. ## Finish by Shipping on GitHub - Copilot CLI can help add descriptive commits, push changes, and create pull requests. - Pull requests make the work durable through teammate review, CI testing, and asynchronous collaboration. - The workflow can also add Copilot as a reviewer. - The ultimate value comes from reaching commits and pull requests, not merely generating suggestions. Copilot CLI is most effective as a momentum tool: use it to turn intent into concrete, testable changes, while retaining human control over design, approval, and review.