Terminal Duck
A runtime-aware rubber duck for VS Code. @duck is a chat participant that sees the commands you actually ran in the integrated terminal — with their exit codes and output — and grounds its answers in that history instead of making you copy-paste.
How it works
Terminal Duck subscribes to VS Code's terminal shell integration events and keeps a rolling buffer of your last 20 commands (command line, working directory, exit code, captured output). When you ask @duck something in Copilot Chat, it includes the most recent executions as context for the LLM.
Requirements
- VS Code
^1.95.0
- GitHub Copilot Chat installed and signed in — Terminal Duck uses the
vscode.lm API, which routes through Copilot's entitlement
- An integrated terminal with shell integration active (default for bash, zsh, fish, and pwsh in recent VS Code)
Install
Install from the VS Code Marketplace:
- From VS Code: open the Extensions view, search for
Terminal Duck, and click Install.
- From the command line:
code --install-extension DarrenJaworski.terminal-duck
Or grab the .vsix from the latest GitHub release and use Extensions view → ... (More Actions) → Install from VSIX....
Usage
- Run some commands in the integrated terminal.
- Open Copilot Chat and type
@duck why did my last test fail? (or any follow-up question).
- Duck cites the specific command and exit code when relevant.
Example prompts:
@duck what's going wrong with my build?
@duck the last command hung — what should I try?
@duck I ran three things, give me a summary
Slash commands
| Command |
What it does |
@duck /fix |
Finds the most recent failing command and proposes a single concrete fix. |
@duck /rerun |
Suggests the next command to run — retry with different flags, or the natural follow-up step. |
@duck /explain |
Explains what the most recent command did and what its output means. |
Failure nudge
When a terminal command exits non-zero, Terminal Duck pops a subtle "Ask Duck?" entry into the right side of the status bar for ~60 seconds. Click it and Copilot Chat opens pre-filled with @duck /explain and a question about the failure — no copy-paste, no remembering the participant exists.
If you'd rather not see it, set terminalDuck.suggestOnFailure to false (see Settings).
Terminal Duck also registers a #duck tool via the lm.tools API. Any chat participant or Copilot agent-mode session can call it to fetch your recent terminal activity.
In Copilot Chat, reference it explicitly with #duck to include recent commands in the prompt:
#duck why might the test runner be picking up the wrong config?
Agents can invoke terminal-duck_getRecentCommands programmatically; accepts an optional limit (1–20, default 6).
Commands
| Command |
Description |
Terminal Duck: Clear captured shell history |
Wipes the in-memory command buffer. |
Settings
| Setting |
Default |
Description |
terminalDuck.suggestOnFailure |
true |
Show the "Ask Duck?" status bar item after a non-zero exit in the integrated terminal. Auto-hides after 60 seconds. |
Troubleshooting
@duck says "no commands captured" right after I ran something. Terminal Duck only sees commands that fire VS Code's shell-integration events. Quick checks:
- Open the integrated terminal and look for the small command decorations in the gutter (a chevron next to each prompt). If they're missing, shell integration isn't active for this terminal.
- Make sure your shell is one VS Code recognises (bash, zsh, fish, pwsh) and that you're using a recent VS Code release. See VS Code's shell integration docs for manual setup if your shell isn't auto-detected.
- Reopen the terminal after enabling integration — already-running terminals don't retroactively gain it.
@duck replies that no language model is available. Terminal Duck routes through Copilot's vscode.lm API. Confirm GitHub Copilot Chat is installed, signed in, and your account has Copilot access.
Output looks truncated. Each captured command is bounded at ~8 KB so the LLM context stays tight. The last 20 commands are kept.
Caveats
- Shell integration must be active. If your terminal is a plain PTY (or you're running inside a shell VS Code doesn't recognise), Duck has nothing to work with and will say so.
- Output is truncated at ~8 KB per command to keep the LLM context tight.
- History lives in memory only — it resets when the extension reloads.
Development
npm install
npm run kitchen-sink # format:check, lint, typecheck, test, compile, package
Press F5 in VS Code to launch an Extension Development Host with Terminal Duck loaded.
License
MIT — see LICENSE.