简介
每次使用 Copilot CLI 时,关于本次会话的完整数据——包括您的提示、Copilot 的响应、使用的工具以及被修改文件的细节——都会记录在本地机器上。随着时间推移,这将累积出一段丰富的历史,展示您曾经处理的内容、工作方式以及 Copilot 为您完成的任务。
这些会话数据驱动了多个功能
- 恢复会话:您可以在任何先前的会话中继续上次的操作。
- 询问您的历史记录:您可以向 Copilot 提问有关过去工作的内容,它会查询您的会话数据来回答。
- The
/chronicleslash command:一组专为生成站会报告、个性化提示以及改进自定义指令的建议而设计的子命令——全部基于您的会话历史。
This conceptual article explains how session data is stored, and how you can leverage it to enhance your workflow. For a practical guide to resuming a session, asking Copilot about your CLI sessions, and using the /chronicle slash command, see Using GitHub Copilot CLI session data.
注意
The /chronicle command, and Copilot's ability to answer questions about your session history, are currently experimental features and are only available if you have used the /experimental on slash command, or the --experimental command line option.
会话数据如何存储
每个 Copilot CLI 会话都会以文件集合的形式持久化在您机器上的 ~/.copilot/session-state/ 目录中。每个会话的文件包含该会话的完整记录。这些文件使您能够恢复交互式 CLI 会话。
除了会话文件外,Copilot CLI 还在本地 SQLite 数据库(即会话存储)中保存结构化的会话数据。这部分数据是会话文件中全部数据的子集。会话存储为 /chronicle 斜杠命令提供动力,同时也让 Copilot 能够回答您关于过去工作的提问。
隐私和数据位置
所有会话数据均保存在您主目录的本地,仅对您的用户账号可访问。当您向 Copilot 询问关于 CLI 交互的问题,或使用 /chronicle 斜杠命令时,Copilot 会在本机读取这些数据。您的先前提示、上下文数据以及收到的响应等会话数据可能会被发送至 AI 模型,就像在任何普通的 Copilot CLI 交互中一样。
If you want to remove data for a particular CLI session, you can delete the relevant session directory from ~/.copilot/session-state/. You can clear all session data by deleting everything under ~/.copilot/session-state/. After doing this you must manually reindex the session store. See the Reindexing the session store later in this article.
关于 /chronicle 斜杠命令
The /chronicle SUBCOMMAND command uses the data in the session store to provide insights and suggestions about your use of Copilot CLI.
You can enter the following commands in an interactive CLI session
/chronicle standup: Generates a short report summarizing what you worked on in your recent CLI sessions, including branch names, pull request links, and status checks./chronicle tips: Provides personalized tips for using Copilot CLI more effectively./chronicle improve: Analyzes your session history to identify patterns where Copilot may have misunderstood your intent or where there was a lot of back-and-forth, and generates custom instructions to help Copilot better understand you in the future./chronicle reindex: Rebuilds the session store from your session history files.
Benefits of /chronicle and the session data
-
Self-improving workflow: The
improvesubcommand creates a feedback loop that helps you to refine your custom instructions. Over time, this makes the agent more effective for your specific project. -
Effortless standup reports: Instead of manually reconstructing what you did yesterday,
/chronicle standupgenerates a standup summary from your actual session data. -
Personalized coaching: The
tipssubcommand acts as a personal productivity coach that knows both what Copilot CLI can do and how you actually use it. It bridges the gap between available features and your current workflow. -
Talk to your coding history: The session store lets Copilot answer any question that your past sessions might help with—from recalling a bug fix you did last week to analyzing your prompting patterns over time.
-
Local and private: All session data—both the raw JSONL files and the SQLite session store—stays on your machine. Nothing is uploaded or shared beyond the normal AI model interactions that happen in any Copilot CLI session. You have full control over your data and can delete it at any time.
When should you use these features?
- At the start of your day: Run
/chronicle standup last 3 daysto generate a reminder of what you worked on recently and the CLI session you were working in. - Periodically, to level up: Run
/chronicle tipsevery week or two to discover features and workflow improvements you might be missing. - When Copilot keeps making the same mistake: Run
/chronicle improveto identify the pattern and generate custom instructions to fix it. - To recall past work: Ask a free-form question like "Have I worked on anything related to the payments API?" and Copilot will search your history.
- To continue previous work: Use
copilot --continueorcopilot --resumeto pick up where you left off.
Reindexing the session store
The session store is populated incrementally during a CLI session. Data for a session is written to disk in a session-specific subdirectory of ~/.copilot/session-state/. This also happens periodically during a session, and also when the session ends.
You can reindex the session store from the session files on disk, although typically you will never need to do this.
Situations where you might need to reindex include
- Indexing old sessions: If you have old session files on disk that were created before the session store existed, reindexing will populate the session store with data from those sessions.
- Session deletion: If you want to delete a session from your history you can delete the session directory and then reindex the session store.
- Migrating/recovering sessions: If you moved your session files to another machine, or restored them from a backup, without also moving/restoring the session store file (
~/.copilot/session-store.db), you can use the reindex command to recreate the session store. - File corruption: If the session store file (
~/.copilot/session-store.db) becomes corrupted, or is accidentally deleted, you can recover the session store from the session files. - Unexpected termination: If a session terminates unexpectedly (for example, due to a crash or power loss) before data held in memory has been flushed to the session store you may be able to populate the session store with the missing data if it was written to disk, in the session files, prior to the termination.
To reindex the session store, use the following slash command in an interactive CLI session
/chronicle reindex
/chronicle reindex