[FIX] How to automatically approve/continue GitHub Copilot terminal commands in VS Code

GitHub Copilot’s Agent Mode allows you to execute terminal commands directly from chat, but by default, it requires manual approval for every command. This can slow down your workflow significantly. Here’s how to configure VS Code to automatically approve specific commands or patterns.

The Problem

When using Copilot Agent Mode with terminal tools, VS Code prompts you to approve each command execution. While this is a safety feature, it becomes tedious when you trust certain commands or patterns.

The Solution

You can configure automatic approval for terminal commands through your settings.json file using three approaches:

1. Approve All Commands (Not Recommended)

{
  "github.copilot.chat.tools.terminal.autoApprove": true
}

⚠️ Warning: This approves ALL commands without verification. Use only in trusted environments.

2. Allowlist Specific Commands (Recommended)

{
  "github.copilot.chat.tools.terminal.allowlist": [
    "git status",
    "git log",
    "npm install",
    "npm test",
    "ls",
    "pwd"
  ]
}

This approach only auto-approves commands in your list – much safer!

3. Use Regex Patterns (Advanced)

{
  "github.copilot.chat.tools.terminal.allowlist": [
    "^git (status|log|diff)$",
    "^npm (install|test|run build)$",
    "^ls( -[la]+)?$"
  ]
}

Regex patterns give you flexible control over command approval.

4. Combine with Denylist

{
  "github.copilot.chat.tools.terminal.allowlist": [".*"],
  "github.copilot.chat.tools.terminal.denylist": [
    "rm -rf",
    "sudo",
    "del",
    "format"
  ]
}

Allow everything except dangerous commands.

Complete Configuration Example

{
  // Recommended safe configuration
  "github.copilot.chat.tools.terminal.allowlist": [
    // Git commands
    "^git (status|log|diff|branch|remote)( .*)?",
    // NPM/Node commands
    "^npm (install|test|run|list)( .*)?",
    // Safe file operations
    "^(ls|pwd|cat|grep|find)( .*)?",
    // Docker read operations
    "^docker (ps|images|logs)( .*)?"
  ],
  "github.copilot.chat.tools.terminal.denylist": [
    "rm -rf",
    "sudo",
    "format",
    "del /"
  ]
}

How to Apply Settings

  1. Open VS Code Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  2. Type “Preferences: Open User Settings (JSON)”
  3. Add your desired configuration
  4. Save the file
  5. Restart VS Code (if needed)

Important Security Considerations

  • Never use autoApprove: true in production environments
  • Review your allowlist regularly
  • Be cautious with broad regex patterns
  • Always include dangerous commands in your denylist
  • Test in a safe environment first

Benefits of This Approach

Speed up development workflow
Maintain security with specific allowlists
Reduce repetitive approval clicks
Keep dangerous commands blocked
Flexible configuration per project

Troubleshooting

Commands Still Require Approval

  • Check your regex syntax is correct
  • Ensure settings.json has no syntax errors
  • Restart VS Code
  • Verify you’re using the latest Copilot extension

Commands Not Working

  • Make sure GitHub Copilot extension is updated
  • Check that Agent Mode is enabled
  • Verify terminal integration is active

Conclusion

Automating GitHub Copilot terminal command approval can significantly improve your development workflow while maintaining security through careful allowlist configuration. Start with a conservative allowlist and expand it as you identify safe, frequently-used commands.

Remember: convenience should never compromise security. Always review what you’re auto-approving!

Categorized in: