Active Context Writer
Description
A VS Code extension for sharing the currently open file, cursor position, and selection with AI agents and other external tools.
Output File
The active editor information is written to the following file:
.active-context.json
.active-context.json is a local file generated for each developer.
For team development, it is recommended to keep it out of Git and add it to .gitignore.
Output Location
- When a folder is open, the file is written directly under that folder.
- When multiple folders are open through a
.code-workspace file, the file is written directly under the first folder.
- When only a single file is open, no file is written because there is no workspace folder to use as the output location.
Output Example
{
"schema": "active-context-writer/v1",
"description": "Current VSCode active editor context for AI agents and external tools.",
"hint": "Use this to understand the user's current file, cursor position, and selection.",
"workspace": "/path/to/workspace",
"file": "/path/to/workspace/src/example.ts",
"relativeFile": "src/example.ts",
"cursor": {
"line": 10,
"character": 5
},
"activeLineText": "const value = example();",
"selection": {
"startLine": 10,
"startCharacter": 5,
"endLine": 10,
"endCharacter": 5
},
"updatedAt": "2026-07-07T10:00:00.000Z"
}
When It Updates
- After VS Code starts
- When the active editor changes
- When the selection changes
日本語
機能説明
AIエージェントなどの外部ツール向けに、現在開いているファイル・カーソル位置・選択範囲を伝えるための拡張機能です。
出力ファイル
VSCode のアクティブエディタ情報を、次のファイルに書き出します。
.active-context.json
.active-context.json は開発者ごとに生成されるローカルファイルです。
チーム開発では Git 管理せず、.gitignore に追加することを推奨します。
書き出し先
- フォルダを開いている場合は、そのフォルダ直下に出力します。
.code-workspace で複数フォルダを開いている場合は、先頭のフォルダ直下に出力します。
- ファイル単体だけを開いている場合は、出力先フォルダを決められないため書き出しません。
出力例
{
"schema": "active-context-writer/v1",
"description": "Current VSCode active editor context for AI agents and external tools.",
"hint": "Use this to understand the user's current file, cursor position, and selection.",
"workspace": "/path/to/workspace",
"file": "/path/to/workspace/src/example.ts",
"relativeFile": "src/example.ts",
"cursor": {
"line": 10,
"character": 5
},
"activeLineText": "const value = example();",
"selection": {
"startLine": 10,
"startCharacter": 5,
"endLine": 10,
"endCharacter": 5
},
"updatedAt": "2026-07-07T10:00:00.000Z"
}
書き出すタイミング
- VSCode 起動後
- アクティブエディタ変更時
- 選択範囲変更時