A collection of automation scripts and examples for working with the GitHub Copilot CLI Agent. This repository demonstrates how to automate Copilot CLI workflows, including installation, authentication, and non-interactive execution.
Copilot CLI Agent is GitHub's terminal-based agentic AI assistant that works seamlessly with existing GitHub Copilot entitlements. Unlike other tools that require separate subscriptions and API keys, Copilot CLI leverages your existing Copilot access and runs synchronously in your terminal with access to your local tools.
.github/
βββ instructions/
β βββ coding-agent-cli-instructions.instructions.md # Copilot CLI documentation
scripts/
βββ copilot_run.sh # Bash automation script
βββ copilot_run.py # Python automation script
βββ .copilot_env # Environment configuration (example)
βββ .env.example # Template for environment variables
βββ prompt.txt # Sample prompt for non-interactive execution
βββ README.md # Detailed usage instructions
- Automated Installation: Installs Copilot CLI using npm with PAT authentication
- Interactive Login: Handles Copilot authentication flow
- Repository Cloning: Automatically clones target repositories for analysis
- Non-Interactive Execution: Runs Copilot with predefined prompts using
--full-auto - Cross-Platform: Both Bash and Python implementations
- Secure Configuration: Environment-based configuration with example templates
- Node.js: Version 22 or higher
- npm: Version 10 or higher
- Git: For repository cloning (if using
GIT_REPO) - GitHub PAT: Classic Personal Access Token with
read:packagesscope
- Linux
- macOS
- Windows via WSL (Ubuntu recommended)
Copy the example environment file and configure it:
cp scripts/.env.example scripts/.copilot_envEdit scripts/.copilot_env with your values:
# Classic GitHub PAT for npm package installation and git cloning
COPILOT_PAT=ghp_your_classic_pat_here
# Directory where code will be cloned and Copilot will run
COPILOT_WORKDIR=/path/to/your/workspace
# Path to the prompt file
PROMPT_FILE=./prompt.txt
# Git repository to clone (optional)
GIT_REPO=https://github.com/yourusername/your-repo.gitEdit scripts/prompt.txt with your desired prompt:
Add a rating feature to this application. Add API to get books by rating.
Improve the frontend with rating display. Only make changes.
Compile the application and make sure it's compiled.
Do not launch, run, or test the application.
Choose either the Bash or Python script:
Using Bash:
cd scripts
chmod +x copilot_run.sh
./copilot_run.shUsing Python:
cd scripts
python3 copilot_run.py- Installation Check: Verifies if
copilotbinary exists, installs via npm if missing - Authentication: Triggers interactive login using
/logincommand - Workspace Setup: Creates workspace directory and clones repository if specified
- Execution: Runs Copilot in non-interactive mode with
--full-autoflag
- Never commit real PATs to version control
- Store sensitive values in secure locations outside the repository
- The scripts use temporary npm configuration files to avoid modifying
~/.npmrc - PATs are embedded in git URLs temporarily for authentication and cleared after use
| Variable | Description | Required | Example |
|---|---|---|---|
COPILOT_PAT |
Classic GitHub PAT with read:packages scope |
Yes | ghp_... |
COPILOT_WORKDIR |
Target workspace directory | Yes | /path/to/workspace |
PROMPT_FILE |
Path to prompt file | No | ./prompt.txt |
GIT_REPO |
Repository to clone | No | https://github.com/user/repo.git |
ENV_FILE |
Custom environment file path | No | ./.copilot_env |
-p, --prompt: Execute prompt directly without interactive mode--full-auto: Allow all tools to run automatically without confirmation
# Set prompt to analyze a repository
echo "Analyze this codebase and suggest improvements" > scripts/prompt.txt
./scripts/copilot_run.sh# Set prompt to add specific features
echo "Add authentication middleware to this Express.js application" > scripts/prompt.txt
python3 scripts/copilot_run.py# Set prompt for code review
echo "Review this code for security vulnerabilities and performance issues" > scripts/prompt.txt
./scripts/copilot_run.shIf you encounter build errors during installation:
# On WSL/Ubuntu
sudo apt-get update
sudo apt-get install make build-essential- Ensure your PAT has
read:packagesscope - Enable SSO for the
githuborganization (if applicable) - Keep PAT expiration under 90 days
The login step is interactive and may open a browser. Complete the OAuth flow when prompted.
Feel free to submit issues and enhancement requests! When contributing:
- Test scripts on multiple platforms
- Update documentation for new features
- Follow security best practices for handling credentials
This project contains examples and automation scripts for GitHub Copilot CLI Agent. Please refer to GitHub's terms of service for Copilot usage.