mcpField
C
conversation-context-import

conversation-context-import

github.com/shokaiAgent workflows3143 installsUpdated 5d ago
Repository

About conversation-context-import

An Agent skill for finding and importing saved conversation context from `.dev/contexts/`. It accounts for the current Git worktree and branch, and asks the user to choose when multiple sources or file sets are available.

Key features

  1. 01Find context files for the current branch
  2. 02Sanitize special characters in branch names
  3. 03Distinguish main and linked worktrees
  4. 04Choose files based on their presence
  5. 05Report files read

Use cases

  1. 01Restore prior conversation context for a branch
  2. 02Import saved context from a linked worktree

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/shokai/agent-skills --skill conversation-context-import

After installing, type/conversation-context-importin Claude Code to confirm it loaded.

Details

From the project README

対話コンテキストのimport手順書

.dev/contexts/ に保存された過去の対話コンテキストを読み込む。

手順

1. ブランチ名を取得する

Bashツールで以下を実行する:

git branch --show-current
ブランチ名のサニタイズ

ブランチ名をファイル名として使う際、以下の文字を - に置換する:

/ \ : * ? " < > |

例: dependabot/npm_and_yarn/feed-5.2.0 → dependabot-npm_and_yarn-feed-5.2.0

以降の手順では、サニタイズ後のブランチ名を「サニタイズ済みブランチ名」と呼ぶ。

読み込み元ディレクトリの決定

読み込み元をgit worktreeの状況に応じて決める。

Bashツールで git worktree list を実行し、現在の作業ツリーがmain worktree(リポジトリ本体の作業ツリー)か、リンクされたworktreeかを判断する。worktreeで作業している場合はmain worktreeのパスも把握する。

main treeで作業中の場合は、読み込み元ディレクトリを .dev/contexts/ とする。

worktree内で作業中の場合は、main treeとworktreeローカルの両方の .dev/contexts/ で、カレントブランチ用ファイル({サニタイズ済みブランチ名}.md)の有無を確認して読み込み元ディレクトリを決める:

  • 両方に存在する場合: 両方のフルパスを提示し、AskUserQuestionツールでどちらを読み込むか選ばせる。選んだ側の .dev/contexts/ を読み込み元ディレクトリとする
  • 片方のみに存在する場合: そちらの .dev/contexts/ を読み込み元ディレクトリとする
  • どちらにも存在しない場合: main treeの .dev/contexts/ を読み込み元ディレクトリとする

以降の手順では、決定したパスを「読み込み元ディレクトリ」と呼ぶ。

2. ファイルの存在確認

読み込み元ディレクトリ内のファイルを確認する。

Globツールで {読み込み元ディレクトリ}/*.md を検索し、以下を把握する:

  • カレントブランチと同名のファイル({読み込み元ディレクトリ}/{サニタイズ済みブランチ名}.md)が存在するか
  • それ以外のファイルが存在するか
3. 読み込み対象の決定

ファイルの存在状況に応じて対応を分ける:

カレントブランチのファイルのみ存在する場合

質問せずにそのファイルを読み込む。

他のファイルのみ存在する場合(カレントブランチのファイルが無い)

質問せずに全ファイルを読み込む。

両方存在する場合

AskUserQuestionツールで以下の選択肢を提示する:

  • カレントブランチのコンテキストのみ読み込む: {読み込み元ディレクトリ}/{サニタイズ済みブランチ名}.md のみ
  • 全てのコンテキストを読み込む: 読み込み元ディレクトリ内の全ファイル(ファイル名を列挙して提示する)
ファイルが1つも存在しない場合

読み込み元ディレクトリにコンテキストファイルが見つからない旨を報告して終了する。

4. 読み込みと報告

Readツールで対象ファイルを読み込む。

読み込み完了後、どのファイルを読み込んだかをユーザーに報告する:

以下の対話コンテキストを読み込みました:
- `{読み込み元ディレクトリ}/feature-a.md`
- `{読み込み元ディレクトリ}/feature-b.md`

関連スキル

  • conversation-context-export: 現在の対話コンテキストを .dev/contexts/ に書き出すスキル。開発の区切りでコンテキストを保存する時に使用する。

Comments

Markdown supported