Overview
This node integrates with the GitHub Copilot CLI to provide AI-powered code suggestions, explanations, and shell command recommendations directly within an n8n workflow. It leverages the official GitHub Copilot CLI tool (gh copilot) to generate context-aware outputs based on user prompts.
Common scenarios where this node is beneficial include:
- Automatically generating code snippets or functions in various programming languages.
- Getting explanations for existing code or commands to improve understanding.
- Receiving shell command suggestions tailored to specific contexts like Git, Docker, npm/yarn, or file operations.
Practical examples:
- A developer wants a JavaScript function to parse JSON safely; they input a prompt describing the task, and the node returns a suggested implementation.
- A DevOps engineer needs a Docker command to clean up unused images; they ask for a shell suggestion filtered by the "Docker" command type.
- A learner wants an explanation of a complex Python snippet; they provide the code as a prompt and receive a detailed explanation.
Properties
| Name | Meaning |
|---|---|
| Prompt | The request or question you want GitHub Copilot to assist with. For example, a description of the code or command you need help generating or explaining. |
| GitHub Token (Optional) | An optional authentication token generated specifically by the GitHub CLI (gh auth token). Personal Access Tokens from the GitHub website will not work. If omitted, the node uses local CLI authentication configured via gh auth login. |
| Filter Output | When enabled, removes the GitHub Copilot CLI header and footer from the response, leaving only the useful suggestion or explanation text. |
| Language | Programming language context for code suggestions when using the "Suggest" operation. Options include JavaScript, TypeScript, Python, Java, C#, C++, Go, Rust, PHP, Ruby, Shell, SQL, or Other. |
| Additional Context | Optional extra information or constraints to provide more precise or relevant suggestions from GitHub Copilot. |
Output
The node outputs a JSON object per input item containing:
operation: The selected operation ("suggest", "explain", or "shell").prompt: The original prompt provided.context: Any additional context given (if any).authMethod: Indicates whether authentication was done via a manual token or local CLI.tokenUsed: Boolean indicating if a manual token was used.tokenPrefix: First few characters of the token used (for reference), or "none".language: Programming language chosen (only for "suggest" operation).commandType: Type of shell command requested (only for "shell" operation).output: The processed output from GitHub Copilot, optionally filtered to remove headers/footers.cliRawOutput: The raw standard output from the GitHub Copilot CLI command.cliStderr: Any error output from the CLI command.timestamp: ISO timestamp of when the execution occurred.
If the node encounters an error and continueOnFail is enabled, it outputs an object with an error field describing the issue instead.
The node does not output binary data.
Dependencies
- Requires the GitHub CLI (
gh) installed on the system where n8n runs, specifically thegh copilotextension. - Authentication depends on either:
- A valid GitHub Copilot token generated by the GitHub CLI (
gh auth token), or - Local CLI authentication configured via
gh auth login.
- A valid GitHub Copilot token generated by the GitHub CLI (
- The node executes shell commands (
/usr/bin/gh copilot ...) and thus requires appropriate permissions and environment setup. - Environment variable
HOMEis overridden internally during execution to/opt/n8n-source/packages/cli/bin.
Troubleshooting
Common Issues
- Authentication failures: Using personal access tokens from the GitHub website will not work. Only tokens generated by
gh auth tokenare accepted. - GitHub Copilot service errors: Temporary server issues may cause HTTP 500 errors.
- Malformed requests: Incorrect prompts or parameters can lead to HTTP 400 errors.
- Access denied: Lack of a valid Copilot subscription results in HTTP 403 errors.
- Timeouts or large outputs: The node sets a 30-second timeout and limits buffer size; very large responses might cause issues.
Error Messages and Resolutions
"GitHub authentication failed (HTTP 401)": Ensure you have rungh auth loginand obtained a token viagh auth token. Do not use regular GitHub personal access tokens."GitHub Copilot service is temporarily unavailable (HTTP 500)": This is a server-side issue; retry after some time."GitHub Copilot request failed (HTTP 400)": Check your prompt and parameters for correctness."GitHub Copilot access denied (HTTP 403)": Verify that your GitHub account has an active Copilot subscription.- Generic CLI errors without output usually indicate misconfiguration or environment issues.