Copilot Triggers Extension
A lightweight VS Code extension that auto-starts Copilot Chat and renders workspace markdown triggers via the single @copilot-trigger participant.
https://marketplace.visualstudio.com/items?itemName=yash-vs-ext.copilot-triggers
Key Features
| Capability |
Description |
| Auto Start |
Opens a fresh Copilot Chat thread on startup with interpreted instructions. |
| Environment Injection |
COPILOT_TASK="<doc>:<arg string>" maps directly to @copilot-trigger <doc> <args>. |
| Generic Templates |
Any .md file under .copilot-triggers/ becomes instantly callable. |
| Argument Placeholders |
{{ARGC}}, {{ARGS}}, {{ARG0}}..{{ARG19}}, {{TARGET}} (alias of ARG0). |
| Safe Fallback |
Built-in help text displays if no template file exists. |
Installation
From Marketplace
- Open the Extensions view (Ctrl/Cmd+Shift+X)
- Search for "Copilot Triggers"
- Install
- Reload (if VS Code doesn't auto‑reload)
Manual / Local (VSIX)
From the extension root folder:
npm install
npm run package # creates a .vsix via vsce
code --install-extension copilot-triggers-*.vsix
Packaging relies on the onStartupFinished activation event (see VS Code docs) so startup is not delayed.
Packaging & Publishing (Maintainers)
npm run package # create VSIX
npm run publish # publish (requires VSCE_PAT environment variable)
Auto-Start Logic
On activation (triggered by onStartupFinished) the extension reads process.env.COPILOT_TASK:
- Empty / unset → Prefills
@copilot-trigger help.
- Matches
<doc>:<args> (split on the FIRST colon only) → Prefills @copilot-trigger <doc> <args>.
Environment variables are available because VS Code launches the extension host as a Node.js process before this activation event fires (see official Activation Events documentation). No additional configuration is required beyond exporting the variable in the shell / container environment before VS Code starts.
Creating a New Trigger (Workspace Author)
- Create
.copilot-triggers/myflow.md in the workspace root.
- Add content using placeholders as needed.
- Optional: Add a one-line description as a blockquote right after the heading (the extension will extract this and display it in help).
Example:
# My Flow
> One-line description of what this trigger does
Target: {{TARGET}}
Args: {{ARGS}} ({{ARGC}} total)
Description Format:
- Must be a blockquote (line starting with
>) immediately after the heading
- Blank lines between heading and blockquote are okay
- Will be displayed in
@copilot-trigger help output
Usage:
@copilot-trigger myflow foo bar baz
Argument Placeholders
| Placeholder |
Meaning |
{{ARGC}} |
Number of arguments provided |
{{ARGS}} |
All arguments joined by a single space |
{{ARG0}} |
First argument |
{{TARGET}} |
Alias for first argument (compatibility) |
{{ARG1..ARG19}} |
Subsequent arguments (up to 20 total indexed) |
Help Override
If .copilot-triggers/help.md exists it replaces the built-in help. Otherwise the extension renders the internal fallback help document listing available triggers.
Using in Codespaces (Environment Auto-Start)
Set COPILOT_TASK before the Codespace (or local dev container) starts and the first chat will be auto‑seeded:
Options
- Codespaces UI: Repository → Codespaces → Create → Add variable
COPILOT_TASK.
- Codespaces Secret (persistent): Settings → Codespaces → Secrets → New secret
COPILOT_TASK.
devcontainer.json: Add under containerEnv (good for defaults):
{
"containerEnv": { "COPILOT_TASK": "myflow:alpha beta" }
}
- Shell export before launching
code . locally.
Accepted Pattern
COPILOT_TASK="<doc>:<raw argument string>"
Only the first colon divides the template name from the rest; additional colons stay inside the argument string. If your arguments contain spaces, just include them—they are passed as a single string then tokenized for placeholders.
Examples
export COPILOT_TASK="help:"
export COPILOT_TASK="myflow:customer-123 refresh"
export COPILOT_TASK="deploy-plan:staging:api v2 rollout"
Behavior Summary
| Scenario |
Result |
COPILOT_TASK unset |
Prefills @copilot-trigger help |
COPILOT_TASK=demo:alpha beta |
Prefills @copilot-trigger demo alpha beta |
Any <doc>:<args> |
Prefills with parsed values |
Unknown <doc> |
Lists available templates + help |
Contributing
- Add new participant logic carefully; keep core extension orchestration-only.
- Avoid network calls: let Copilot Agent + MCP servers handle data fetching.
- Use
.copilot-triggers/ for extensibility instead of modifying extension code.
License
MIT