On this page#
Before you install anything#
Install GitHub Copilot CLI only after you define repository instructions, permission boundaries, and a rollback path. The correct order is policy first, installation second, authentication third, and a bounded real task last. Otherwise, a successful install merely gives an agent broad access to an ambiguously governed repository.
GitHub Copilot is GitHub’s AI coding system; the CLI brings that interaction into the terminal where your repository, credentials, and destructive commands are already within reach. That proximity is useful, but it changes the risk model.
Before installation, decide four things:
- Which repository may the agent access?
- Which commands may it run without confirmation?
- Which files are off-limits?
- What evidence must accompany a completed change?
The permission boundary should be narrower than your normal developer account. Start in one repository, on a disposable branch, with no production credentials and no permission to push, merge, publish packages, alter infrastructure, or change remote state.
Prompts are not security controls. A repository instruction can tell the agent not to touch deployment files, but your shell environment, credentials, filesystem permissions, and branch protection must enforce the consequential boundaries.
This ordering also makes the setup transferable. The second engineer should inherit a repository policy, not a collection of shell aliases and warnings remembered only by the first engineer. If your repository cannot state its invariants clearly, work through the PairFoundry foundations track before adding another agent.
Photo by Boris K. on Pexels.
The steps#
The installation itself is short; the useful work is constraining what happens afterward. Follow these steps in order so every new capability arrives with an explicit boundary, an observable test, and a clean way back. Do not begin by handing the CLI your normal environment and asking it to explore.
-
Create a fresh branch and require a clean working tree.
This prevents pre-existing edits from being mixed into the agent’s patch or accidentally reverted. -
Remove production and organization-wide credentials from the session.
This prevents a local coding task from inheriting authority to deploy, publish, administer repositories, or modify unrelated systems. -
Add the repository instruction file shown below.
This prevents the agent from guessing invariants, validation commands, ownership boundaries, and completion criteria. -
Install the CLI through npm:
npm install --global @github/copilotThis uses npm’s global installation mode; review the behavior of global and local installs in the official
npm installdocumentation. -
Authenticate with the narrowest GitHub identity that can perform the task.
This prevents a terminal session from silently receiving broader repository or organization access than the work requires. -
Start the CLI from the intended repository root.
This prevents the wrong directory from becoming the working context and keeps the first review boundary obvious. -
Ask for a read-only repository summary before requesting edits.
This exposes incorrect assumptions about architecture, commands, and scope before they turn into a patch. -
Approve one bounded edit, then inspect the diff yourself.
This prevents installation success from being confused with trustworthy repository behavior. -
Run the repository’s existing checks and record the exact results.
This prevents “done” from meaning only that files changed without an immediate error.
Authentication and invocation details can change, so use the GitHub Copilot documentation for those vendor-controlled mechanics. Keep repository policy independent of transient login screens or installer behavior.
A working configuration#
Use .github/copilot-instructions.md as a committed operating contract for the repository. The file below is deliberately strict: it separates exploration from modification, names protected areas, requires small diffs, and defines completion through evidence. Replace only the bracketed repository-specific values; do not soften the defaults during installation.
<!-- Scope: tells the agent where its authority begins and ends. -->
# Repository operating rules
<!-- Invariant: prevents work from starting on an already ambiguous tree. -->
Before editing, report the current branch and whether the working tree is clean.
<!-- Planning gate: makes the proposed scope reviewable before mutation. -->
Before editing, list the files you expect to change and the reason for each.
<!-- Repository boundary: blocks opportunistic work in adjacent projects. -->
Work only inside this repository.
<!-- Task boundary: prevents unrelated cleanup from expanding the diff. -->
Change only what the requested task requires.
<!-- Protected paths: replace these examples with the real sensitive areas. -->
Do not modify `[deployment-path]`, `[generated-path]`, or `[secrets-path]`.
<!-- Dependency boundary: keeps package changes explicit and reviewable. -->
Do not add, remove, or upgrade dependencies unless the task explicitly requires it.
<!-- Remote-state boundary: reserves consequential actions for a human. -->
Do not push, merge, publish, deploy, create releases, or change remote settings.
<!-- Destructive-action boundary: protects local work and repository history. -->
Do not delete files, rewrite history, or discard existing changes.
<!-- Invariant preservation: makes compatibility obligations explicit. -->
Preserve `[public-interface]`, `[data-format]`, and `[runtime-contract]`.
<!-- Validation source: stops the agent from inventing substitute checks. -->
Use only the repository's existing validation commands.
<!-- Required checks: replace these placeholders with commands already present. -->
Run `[focused-test-command]` after the relevant edit.
<!-- Broader check: confirms the patch against the repository acceptance line. -->
Run `[full-validation-command]` before declaring completion.
<!-- Failure behavior: keeps a failed check visible instead of patched around. -->
If a required check fails, stop and report the command and failure summary.
<!-- Completion contract: requires evidence a reviewer can independently inspect. -->
Finish with changed files, checks run, results, and unresolved risks.This file guides behavior; it does not grant or revoke operating-system permissions. Enforce the hard boundary separately by withholding credentials, protecting branches, restricting filesystem access where practical, and requiring review for remote changes.
For a fuller repository operating system—including instruction templates, review gates, and handoff patterns—the natural next step is the PairFoundry Agent Operating Kit. The broader PairFoundry packs overview shows the alternatives without forcing every team into the same workflow.
Photo by Christina Morillo on Pexels.
What to skip#
Skip any setup step that increases authority, duplicates existing repository truth, or proves only that the CLI can generate text. Most tutorials optimize for a fast demonstration. A production repository needs a narrow change, an inspectable diff, and repeatable validation—not a celebratory first prompt.
| Common tutorial step | Why you should skip it | |---|---| | Export every development credential before launch | It gives a coding task unrelated authority and makes accidental remote actions possible. | | Ask the agent to “scan everything and improve the repo” | The scope is unreviewable, so regressions and unrelated cleanup become hard to separate. | | Create new test or lint commands for the demo | It replaces the repository’s acceptance criteria instead of proving compatibility with them. | | Install extra global tools “just in case” | It expands machine state without demonstrating that the repository needs them. | | Copy a generic instruction file unchanged | Generic rules omit the actual protected paths, invariants, and validation commands. | | Treat a successful login as completed setup | Authentication proves identity, not safe behavior inside your repository. | | Enable automatic pushing or merging immediately | Remote mutation removes the simplest human checkpoint before trust is established. |
Also skip elaborate prompt libraries during the first session. One committed policy and one real task reveal more than a folder of abstract prompt examples. Use the official Copilot documentation for product operation, and use repository-owned instructions for the constraints GitHub cannot know.
For more setup patterns at the same level, use the PairFoundry agent setup hub.
First real task#
The first task should be small, consequential, and already covered by repository validation. Choose a real defect or maintenance change that touches a narrow surface, preserves known invariants, and produces an easy-to-review diff. Do not use generated documentation or a toy file as your trust test.
A good first request looks like this:
Read .github/copilot-instructions.md first.
Investigate [specific failing behavior] in [bounded area].
Before editing, explain the likely cause, list the files you expect to change,
and name the existing validation command you will use.
Make the smallest change that preserves [named invariant].
Do not change dependencies or remote state.
After editing, show the diff summary and report validation results.This task tests the entire operating loop: instruction discovery, repository comprehension, scope control, implementation, validation, and handoff. If the agent proposes unrelated cleanup, invents a command, ignores a protected path, or reports success without evidence, stop. Tighten the contract before granting more authority.
The standard is not “Copilot produced a plausible patch.” The standard is “another engineer can understand the intent, inspect the exact change, reproduce the checks, and revert the branch without reconstructing a private conversation.”
Photo by Lukas Blazek on Pexels.
Related reading#
- How to start vibe coding: the order matters more than the settings
- MCP server tutorial — the setup that survives a real repo
FAQ#
How narrow should Copilot CLI permissions be for the first repository task?#
Give it local read access to the target repository and only the write access required for the chosen branch. Withhold production, publishing, deployment, organization administration, and unrelated repository credentials. A prompt can express the policy, but credential scope and branch controls must enforce the boundary.
How is this different from following GitHub’s official installation instructions?#
The official GitHub Copilot documentation explains the product-controlled path: availability, authentication, features, and current operation. This setup covers the repository-controlled path GitHub cannot specify for you: invariants, protected areas, permitted actions, validation commands, review evidence, and handoff expectations.
What usually breaks when a second engineer adopts the setup?#
The second engineer usually inherits an implicit environment: missing aliases, different global tools, broader credentials, or validation commands known only to the original user. Commit repository instructions, use existing project commands, and keep authentication outside the configuration so the workflow survives a different machine and identity.
How do I back out if the first task goes wrong?#
Stop the agent, preserve its output for inspection, and discard only the dedicated branch after confirming no valuable pre-existing work was mixed into it. Do not let the agent perform the recovery. A clean starting tree and isolated branch make rollback an ordinary Git review decision.
When should I not use GitHub Copilot CLI?#
Do not use it when the task requires unreviewed production access, irreversible data changes, ambiguous repository ownership, or invariants nobody can state. Fix the operating boundary first. An agent attached to an unclear system does not remove uncertainty; it converts uncertainty into faster, harder-to-audit changes.