-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Building on Copilot CLI Sessions
Copilot CLI persists sessions as JSONL files in ~/.copilot/session-state/, supports resumption via --resume and --continue, and tracks conversation history, tool executions, and corrections.
Proposal: Provide native export from session learnings to permanent repository context - instructions, custom agents, skills, and prompt files.
The Ask
- Export session context - Convert session corrections and explanations into permanent artifacts
- Generate from patterns - Analyze multiple sessions to surface repeated learnings
- Support Copilot repository context types:
- Repository instructions -
.github/copilot-instructions.md - Path-specific instructions -
.github/instructions/*.instructions.md - Custom agents -
.github/agents/*.agent.md - Prompt files -
.github/prompts/*.prompt.md - Skills -
.github/skills/*/
- Repository instructions -
Why Export Matters
Sessions accumulate knowledge that currently dies when the session ends:
- Developer corrects "No, we use handler pattern like this" → lost after session
- Developer explains "Platform code goes in Platforms/{os}/" → never captured
- Agent learns project-specific workflow → not available to other agents
- Same mistakes happen across sessions → no learning accumulation
Without export, every session starts from zero. With export, corrections become permanent repository context - whether that's a repository instruction, a path-specific rule, or a specialized agent.
Why This Matters for Adoption
Repository context (instructions, agents, skills) is powerful but underutilized. Teams don't iterate because:
- No obvious source material for what to document
- Writing context files from scratch is high effort
- No connection between "what I just explained" and "what should be permanent"
Session → Repository context export changes this:
Developer corrects Copilot → Correction captured in session
↓
"Export this session" → Suggest: instruction? agent? skill?
↓
Review and commit → Future sessions/agents succeed immediately
Every correction becomes a repository improvement opportunity.
The Workflow We Want
End of session:
Developer: /export
Copilot: "Found 3 patterns from this session:
1. [corrected 2x] Always null-check PlatformView before access
→ Suggest: .github/instructions/handlers.instructions.md
2. [workflow] Multi-step handler debugging process
→ Suggest: .github/agents/handler-debugger.agent.md
3. [repeated] PropertyMapper over manual setters
→ Suggest: .github/copilot-instructions.md
Export which?"
Or from CLI:
# Export specific session
gh copilot session export abc-123
# Analyze recent sessions for patterns
gh copilot context generate --from-recent 10
# Export to specific target
gh copilot session export --to-agent "handler-expert" abc-123The Gap
| What Exists | What's Missing |
|---|---|
VS Code /savePrompt (prompt files only) |
Export to instructions, agents, skills |
| Session persistence (JSONL, local) | Session → repository context export in CLI |
| Instructions, agents, skills (manual authoring) | Pattern/correction detection |
--resume for session continuity |
Multi-target intelligent suggestions |
| Copilot Memory (auto, 28-day expiry) | Permanent, version-controlled capture |
Note: VS Code's /savePrompt command creates prompt files from conversations, but:
- Not available in CLI (#618, #942)
- Only outputs
.prompt.mdfiles, not instructions/agents/skills - Generalizes conversation rather than detecting corrections and patterns
Minimal Version
Add /export slash command that:
- Analyzes current session for corrections, explanations, and workflows
- Suggests appropriate target (instruction, agent, skill, prompt)
- Generates draft content
- Outputs to clipboard or suggests file path
We'll handle the file creation and review ourselves.
Connection to Memory Graduation
This complements Memory → Instructions graduation:
| Memory Graduation | Session Export |
|---|---|
| Cross-session patterns (28 days) | Single session capture (immediate) |
| Automatic learning | Explicit developer action |
| Repository-scoped | Session-scoped |
| "What has Copilot learned?" | "What did I just teach Copilot?" |
| Outputs to instructions | Outputs to instructions, agents, skills, prompts |
Both create feedback loops for continuous repository improvement. Memory catches patterns over time; session export captures knowledge in the moment before it's lost.
Related Issues
| Issue | Relationship |
|---|---|
| #667 - Persistent Memory | Wants automatic cross-session learning. We want explicit export with human review. Complementary. |
| #618 - Custom slash commands from prompts | Wants to read prompt files in CLI. We want to write repository context from sessions. |
| #942 - Slash commands in CLI | Confirms prompt files don't work in CLI. Our ask extends beyond prompts to all context types. |
| #377 - Memory options | Wants visibility into context (/memory). We want export from context to files. |
| #714 - Session History Search | Search finds past sessions. Export captures learnings as repository context. |
| #934 - Plan Mode | Similar "session → file" concept but for plans, not learnings. |
| Memory graduation proposal | Complementary - Memory graduation handles cross-session patterns; session export handles in-the-moment capture. |
How This Differs
| Existing Feature/Request | This Proposal |
|---|---|
VS Code /savePrompt |
Multi-target (not just prompts), CLI support, pattern detection |
| Automatic memory (#667) | Explicit, reviewable export |
| Memory visibility (#377) | Export to version-controlled files |
| Session search (#714) | Convert sessions to reusable context |
| Plan mode (#934) | Captures learnings/corrections, not plans |
References
Our request adds: session export command, pattern detection, multi-target generation (instructions, agents, skills, prompts).