.dev/contexts/ Read past dialogue contexts saved in .
Procedure
1. Get the branch name
Run the following with the Bash tool:
git branch --show-current
Sanitize the branch name
When using the branch name as a filename, replace the following characters with - :
/ \ : * ? " < > |
Example: dependabot/npm_and_yarn/feed-5.2.0 → dependabot-npm_and_yarn-feed-5.2.0
In the following steps, the sanitized branch name is referred to as the "sanitized branch name".
Determine the source directory
Determine the source based on the git worktree situation.
Run git worktree list with the Bash tool to determine whether the current working tree is the main worktree (the repository's main working tree) or a linked worktree. If working in a worktree, also identify the path of the main worktree.
If working in the main tree, set the source directory to .dev/contexts/ .
If working in a worktree, check for the existence of the file for the current branch ( .dev/contexts/ ) in both the main tree's and the worktree-local{サニタイズ済みブランチ名}.mdand determine the source directory:
- If it exists in both: present the full paths of both and use the AskUserQuestion tool to let the user choose which one to read. Use the
.dev/contexts/of the chosen side as the source directory - If it exists in only one: use that side's
.dev/contexts/as the source directory - If it exists in neither: use the main tree's
.dev/contexts/as the source directory
In the following steps, the determined path is referred to as the "source directory".
2. Check file existence
Check the files in the source directory.
Search for {読み込み元ディレクトリ}/*.md with the Glob tool and determine the following:
- Whether a file with the same name as the current branch (
{読み込み元ディレクトリ}/{サニタイズ済みブランチ名}.md) exists - Whether any other files exist
3. Determine what to read
Handle cases differently depending on file existence:
When only the current branch's file exists
Read that file without asking.
When only other files exist (no file for the current branch)
Read all files without asking.
When both exist
Present the following options with the AskUserQuestion tool:
- Read only the current branch's context:
{読み込み元ディレクトリ}/{サニタイズ済みブランチ名}.mdonly - Load all contexts: All files in the source directory (list and present the file names)
If no files exist
Report that no context files were found in the source directory and exit.
4. Loading and reporting
Read the target file with the Read tool.
After loading is complete, report to the user which files were loaded:
以下の対話コンテキストを読み込みました:
- `{読み込み元ディレクトリ}/feature-a.md`
- `{読み込み元ディレクトリ}/feature-b.md`
Related skills
- conversation-context-export: A skill that writes the current dialogue context to
.dev/contexts/. Used when saving context at development milestones.