GitHub Copilot CLI Slash Commands: Take Control of Long Sessions
Copilot CLI v1.0.39 adds /compact, /context, /usage, and /env commands. Stop wasting context window space and run smarter long-form coding sessions.
GitHub shipped Copilot CLI v1.0.39 on April 28, adding four slash commands that solve the biggest problem with long agent sessions: running out of context window. If you have ever spent 90 minutes coding with an agent and watched it suddenly forget the early parts of the conversation, these commands are the fix.
The Four New Commands
All four are typed at the Copilot CLI prompt with a leading slash, and all four work in any active session. They are: /compact, /context, /usage, and /env.
/context — See How Much Window You Have Left
Type /context and Copilot CLI shows a visual breakdown of your current token usage: system overhead, conversation history, free space, and the buffer reserved for automatic context management. This is the first thing to check when you feel the agent getting forgetful.
/context
# Output:
# System / Tools: 8,500 tokens (4%)
# Messages: 142,000 tokens (71%)
# Free Space: 38,000 tokens (19%)
# Buffer: 12,000 tokens (6%)
# Total: 200,000 tokens When messages hit roughly 80% of total, Copilot CLI starts compacting in the background. If /context shows you are already past 80% and the agent is acting drifty, do not wait for auto-compact. Run /compact yourself to clean things up before the next big request.
/compact — Free Up Window Space on Demand
Type /compact and Copilot CLI summarizes the older parts of your conversation, drops the original verbose history, and keeps only the summary plus the most recent few messages. You lose detail, but you gain back tens of thousands of tokens.
The smart use case is not waiting for it to fire automatically. Use /compact at planned breakpoints — right after you finish one feature and before you start the next. The summary preserves the high-level state without dragging every line of bash output and tool call into the next phase of work.
Run /compact before asking the agent to do something that needs careful attention to detail, like writing a migration or a security-sensitive change. A fresh, compacted context produces sharper output than a window stuffed with unrelated history.
/usage — Track Your Premium Request Spend
GitHub's new token-billing model means premium model requests count against a quota. /usage shows how many premium requests you have used in the current session. Combine this with /context and you have the two numbers that actually matter when you are deciding whether to keep going or wrap up: how much window is left, and how much budget is left.
If you hit your quota mid-session, Copilot CLI falls back to the included model tier. The agent keeps working but loses some quality. /usage warns you before that switch happens.
/env — Show the Active Configuration
Type /env and Copilot CLI shows the environment variables and configuration values controlling the current session: the active model, permission mode, working directory, and any custom settings. Useful for debugging when the agent is behaving unexpectedly — most strange behavior turns out to be a config issue, not a model issue.
A Real Workflow Using These Together
Here is the pattern we now use on long Copilot CLI sessions:
# Start the session with /env to confirm config
> /env
# Work for 30-45 minutes on the first feature
> implement the new search endpoint
# ...agent does work...
# Before starting feature 2, compact and check
> /compact
> /context
# Work for another 30-45 minutes
> now add input validation to the search endpoint
# ...agent does work...
# Mid-session check on quota
> /usage
# Compact again before starting unrelated work
> /compact The rhythm is: compact at natural breakpoints, check context before sensitive work, check usage before deciding to extend the session. Sessions that run for 3 to 4 hours stay coherent this way.
What These Commands Do Not Solve
These commands manage the conversation. They do not give the agent better long-term memory. If you close Copilot CLI, the next session starts fresh. For persistent context across sessions, you still need a separate mechanism — a project file the agent reads at startup, or a memory tool like the new Codex Chronicle feature.
Add a /context check to your habit at the start of each working session. Knowing your starting baseline makes the rest of the numbers meaningful.
Upgrade Path
If you are on Copilot CLI v1.0.38 or earlier, run npm update -g @github/copilot-cli to get the new version. Existing sessions started before the upgrade will not have the new commands available — you need to start a fresh session after upgrading.
Key Takeaway
The /compact, /context, /usage, and /env commands turn Copilot CLI from a fire-and-forget chat into a tool you can actively manage. The biggest single win is running /compact at natural breakpoints, which keeps long sessions coherent and cuts wasted token spend.
Frequently Asked Questions
Are these slash commands available in the GitHub Copilot extension for VS Code?
Not yet. As of April 28, 2026, /compact, /context, /usage, and /env are CLI-only. The VS Code extension has its own command palette but does not expose the same context-management primitives. GitHub has indicated some of these may come to the extension in a later release.
Does /compact lose information that the agent needs?
Sometimes. The summary preserves high-level decisions and the last few exchanges, but it can drop specific filenames, exact error messages, and code snippets from earlier in the session. If you compact and then the agent forgets a detail you need, paste the detail back in the next message — the summary plus your reminder usually restores enough context.
How does the new token billing affect free Copilot users?
Free users still get a monthly quota of premium requests but at a lower cap than paid plans. /usage works the same way on free and paid plans — it shows requests used against the active quota. When you hit zero, Copilot CLI continues to work on the included model tier.
Personalized for your role
Get Your AI Career Action Plan
Our AI Advisor builds you a personalized AI Readiness Score, skills gap analysis, and 30/60/90 day plan based on your specific role and experience.
Try the AI Advisor →Level up your AI coding every week
New tips, tool updates, and workflows every week. Stay ahead of what AI can do for your code.
We respect your privacy. No spam, ever.