Skip to content

Commit 0adbd42

Browse files
CopilotMarkus911111
andcommitted
Add comprehensive integration documentation and examples
Co-authored-by: Markus911111 <187272633+Markus911111@users.noreply.github.com>
1 parent d4f4eec commit 0adbd42

12 files changed

Lines changed: 1425 additions & 0 deletions

INTEGRATION.md

Lines changed: 585 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ Each time you submit a prompt to GitHub Copilot CLI, your monthly quota of premi
7373

7474
For more information about how to use the GitHub Copilot CLI, see [our official documentation](https://docs.github.com/copilot/concepts/agents/about-copilot-cli).
7575

76+
## 🔧 Integration
77+
78+
Looking to integrate Copilot CLI into your development workflow? Check out our comprehensive resources:
79+
80+
- **[Integration Guide](INTEGRATION.md)** - Detailed instructions for terminal, VS Code, MCP servers, Git hooks, and CI/CD integration
81+
- **[Examples Directory](examples/)** - Ready-to-use scripts, configurations, and workflow templates
82+
83+
Quick start integrations:
84+
85+
- **Terminal Setup**: Run `/terminal-setup` in Copilot CLI to set up shell integration
86+
- **MCP Servers**: Configure custom tools via `~/.copilot/mcp-config.json` ([examples](examples/mcp-configs/))
87+
- **Automation Scripts**: Use our [example scripts](examples/scripts/) for code review, test generation, and more
88+
- **CI/CD**: Add automated reviews with our [GitHub Actions](examples/workflows/github-actions-review.yml) or [GitLab CI](examples/workflows/gitlab-ci-review.yml) templates
7689

7790
## 📢 Feedback and Participation
7891

examples/README.md

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
# GitHub Copilot CLI Examples
2+
3+
This directory contains practical examples and templates for integrating GitHub Copilot CLI into your development workflow.
4+
5+
## Directory Structure
6+
7+
```
8+
examples/
9+
├── mcp-configs/ # MCP server configuration examples
10+
├── scripts/ # Shell scripts for automation
11+
├── workflows/ # CI/CD workflow examples
12+
└── README.md # This file
13+
```
14+
15+
## MCP Configurations
16+
17+
Located in `mcp-configs/`:
18+
19+
- **`basic-mcp-config.json`** - Basic setup with filesystem, GitHub, and Git MCP servers
20+
- **`advanced-mcp-config.json`** - Advanced setup with database, search, and communication integrations
21+
- **`development-mcp-config.json`** - Development-focused configuration with limited GitHub tools
22+
23+
### Usage
24+
25+
Copy a configuration file to your home directory:
26+
27+
```bash
28+
# For system-wide configuration
29+
cp examples/mcp-configs/basic-mcp-config.json ~/.copilot/mcp-config.json
30+
31+
# For project-specific configuration
32+
cp examples/mcp-configs/development-mcp-config.json .copilot/mcp-config.json
33+
```
34+
35+
Don't forget to set required environment variables:
36+
37+
```bash
38+
export GITHUB_TOKEN="your-token"
39+
export WORKSPACE="$(pwd)"
40+
```
41+
42+
## Scripts
43+
44+
Located in `scripts/`:
45+
46+
### Code Review Script
47+
48+
**`copilot-review.sh`** - Review code files or directories for issues
49+
50+
```bash
51+
# Make executable
52+
chmod +x examples/scripts/copilot-review.sh
53+
54+
# Review a single file
55+
./examples/scripts/copilot-review.sh src/utils.js
56+
57+
# Review entire directory
58+
./examples/scripts/copilot-review.sh src/
59+
```
60+
61+
### Commit Message Generator
62+
63+
**`generate-commit-message.sh`** - Generate conventional commit messages
64+
65+
```bash
66+
# Make executable
67+
chmod +x examples/scripts/generate-commit-message.sh
68+
69+
# Stage your changes
70+
git add .
71+
72+
# Generate and commit
73+
./examples/scripts/generate-commit-message.sh
74+
```
75+
76+
### Test Generator
77+
78+
**`generate-tests.sh`** - Generate unit tests for source files
79+
80+
```bash
81+
# Make executable
82+
chmod +x examples/scripts/generate-tests.sh
83+
84+
# Generate tests
85+
./examples/scripts/generate-tests.sh src/utils.js
86+
# Creates: src/utils.test.js
87+
88+
./examples/scripts/generate-tests.sh lib/parser.py
89+
# Creates: lib/parser_test.py
90+
```
91+
92+
Supports:
93+
- JavaScript (`.js`) → Jest
94+
- TypeScript (`.ts`) → Jest
95+
- React (`.jsx`, `.tsx`) → React Testing Library
96+
- Python (`.py`) → pytest
97+
- Go (`.go`) → Go testing
98+
- Rust (`.rs`) → Rust testing
99+
- Java (`.java`) → JUnit 5
100+
101+
### Documentation Generator
102+
103+
**`generate-docs.sh`** - Generate API documentation
104+
105+
```bash
106+
# Make executable
107+
chmod +x examples/scripts/generate-docs.sh
108+
109+
# Generate docs for single file
110+
./examples/scripts/generate-docs.sh src/utils.js
111+
112+
# Generate docs for directory
113+
./examples/scripts/generate-docs.sh src/ docs/api
114+
```
115+
116+
## Workflows
117+
118+
Located in `workflows/`:
119+
120+
### GitHub Actions
121+
122+
**`github-actions-review.yml`** - Automated PR reviews
123+
124+
Copy to your repository:
125+
126+
```bash
127+
cp examples/workflows/github-actions-review.yml .github/workflows/
128+
```
129+
130+
Requires:
131+
- GitHub token with Copilot access (automatically provided)
132+
- PR permissions (configured in workflow)
133+
134+
### GitLab CI
135+
136+
**`gitlab-ci-review.yml`** - Automated MR reviews
137+
138+
Copy to your repository:
139+
140+
```bash
141+
cp examples/workflows/gitlab-ci-review.yml .gitlab-ci.yml
142+
```
143+
144+
Or merge with existing `.gitlab-ci.yml`:
145+
146+
```yaml
147+
include:
148+
- local: examples/workflows/gitlab-ci-review.yml
149+
```
150+
151+
Requires:
152+
- `COPILOT_GITHUB_TOKEN` variable (with Copilot access)
153+
- `GITLAB_TOKEN` variable (optional, for posting comments)
154+
155+
## Quick Start
156+
157+
1. **Install Copilot CLI**:
158+
```bash
159+
npm install -g @github/copilot
160+
```
161+
162+
2. **Set up authentication**:
163+
```bash
164+
export GITHUB_TOKEN="your-personal-access-token"
165+
```
166+
167+
3. **Copy and customize MCP config**:
168+
```bash
169+
mkdir -p ~/.copilot
170+
cp examples/mcp-configs/basic-mcp-config.json ~/.copilot/mcp-config.json
171+
```
172+
173+
4. **Make scripts executable**:
174+
```bash
175+
chmod +x examples/scripts/*.sh
176+
```
177+
178+
5. **Test it out**:
179+
```bash
180+
# Review a file
181+
./examples/scripts/copilot-review.sh README.md
182+
```
183+
184+
## Environment Variables
185+
186+
Scripts and workflows use these environment variables:
187+
188+
| Variable | Description | Required |
189+
|----------|-------------|----------|
190+
| `GITHUB_TOKEN` | GitHub personal access token with Copilot access | Yes |
191+
| `WORKSPACE` | Current workspace/project directory | No (defaults to pwd) |
192+
| `COPILOT_MODEL` | Model to use (e.g., claude-sonnet-4.5) | No |
193+
| `PGUSER` | PostgreSQL username (for postgres MCP) | If using postgres |
194+
| `PGPASSWORD` | PostgreSQL password (for postgres MCP) | If using postgres |
195+
| `BRAVE_API_KEY` | Brave Search API key (for search MCP) | If using Brave Search |
196+
| `SLACK_BOT_TOKEN` | Slack bot token (for Slack MCP) | If using Slack |
197+
| `SLACK_TEAM_ID` | Slack team ID (for Slack MCP) | If using Slack |
198+
199+
## Best Practices
200+
201+
1. **Start Simple**: Begin with `basic-mcp-config.json` and add servers as needed
202+
2. **Secure Tokens**: Never commit tokens to version control; use environment variables
203+
3. **Test Scripts**: Review generated code/tests/docs before using in production
204+
4. **Customize Prompts**: Adjust prompts in scripts to match your team's standards
205+
5. **CI/CD Integration**: Make CI checks advisory, not blocking, initially
206+
207+
## Troubleshooting
208+
209+
### MCP servers not connecting
210+
211+
```bash
212+
# Check if executables are in PATH
213+
which npx
214+
215+
# Test server startup manually
216+
npx -y @modelcontextprotocol/server-filesystem ~/projects
217+
218+
# Check Copilot logs
219+
COPILOT_DEBUG=true copilot
220+
```
221+
222+
### Scripts not working
223+
224+
```bash
225+
# Ensure scripts are executable
226+
chmod +x examples/scripts/*.sh
227+
228+
# Check Copilot is installed
229+
copilot --version
230+
231+
# Verify authentication
232+
echo $GITHUB_TOKEN
233+
```
234+
235+
### Workflow failures
236+
237+
- Check GitHub token has Copilot access
238+
- Verify token permissions in repository secrets
239+
- Review workflow logs for specific errors
240+
241+
## Contributing
242+
243+
Have a useful script or configuration? Contributions are welcome!
244+
245+
1. Add your example with clear comments
246+
2. Update this README with usage instructions
247+
3. Test thoroughly before submitting
248+
249+
## Additional Resources
250+
251+
- [Integration Guide](../INTEGRATION.md) - Comprehensive integration documentation
252+
- [Official Docs](https://docs.github.com/copilot/concepts/agents/about-copilot-cli)
253+
- [MCP Specification](https://modelcontextprotocol.io/)
254+
255+
## Support
256+
257+
For issues or questions:
258+
- [GitHub Copilot CLI Issues](https://github.com/github/copilot-cli/issues)
259+
- [Community Discussions](https://github.com/github/copilot-cli/discussions)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"mcpServers": {
3+
"filesystem": {
4+
"type": "local",
5+
"command": "npx",
6+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "${HOME}/projects"],
7+
"tools": ["*"]
8+
},
9+
"github": {
10+
"type": "local",
11+
"command": "npx",
12+
"args": ["-y", "@modelcontextprotocol/server-github"],
13+
"env": {
14+
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
15+
},
16+
"tools": ["*"]
17+
},
18+
"git": {
19+
"type": "local",
20+
"command": "npx",
21+
"args": ["-y", "@modelcontextprotocol/server-git"],
22+
"tools": ["*"]
23+
},
24+
"postgres": {
25+
"type": "local",
26+
"command": "npx",
27+
"args": [
28+
"-y",
29+
"@modelcontextprotocol/server-postgres",
30+
"postgresql://localhost:5432/mydb"
31+
],
32+
"env": {
33+
"PGUSER": "${PGUSER}",
34+
"PGPASSWORD": "${PGPASSWORD}"
35+
},
36+
"tools": ["*"]
37+
},
38+
"sequential-thinking": {
39+
"type": "local",
40+
"command": "npx",
41+
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"],
42+
"tools": ["*"]
43+
},
44+
"puppeteer": {
45+
"type": "local",
46+
"command": "npx",
47+
"args": ["-y", "@modelcontextprotocol/server-puppeteer"],
48+
"tools": ["*"]
49+
},
50+
"brave-search": {
51+
"type": "local",
52+
"command": "npx",
53+
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
54+
"env": {
55+
"BRAVE_API_KEY": "${BRAVE_API_KEY}"
56+
},
57+
"tools": ["*"]
58+
},
59+
"slack": {
60+
"type": "local",
61+
"command": "npx",
62+
"args": ["-y", "@modelcontextprotocol/server-slack"],
63+
"env": {
64+
"SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
65+
"SLACK_TEAM_ID": "${SLACK_TEAM_ID}"
66+
},
67+
"tools": ["*"]
68+
}
69+
}
70+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"mcpServers": {
3+
"filesystem": {
4+
"type": "local",
5+
"command": "npx",
6+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "${HOME}/projects"],
7+
"tools": ["*"]
8+
},
9+
"github": {
10+
"type": "local",
11+
"command": "npx",
12+
"args": ["-y", "@modelcontextprotocol/server-github"],
13+
"env": {
14+
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
15+
},
16+
"tools": ["*"]
17+
},
18+
"git": {
19+
"type": "local",
20+
"command": "npx",
21+
"args": ["-y", "@modelcontextprotocol/server-git"],
22+
"tools": ["*"]
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)