context-awareness
できること
このスキルは、Agent-Nativeのアプリが、画面に何が表示されているかをエージェントに伝える仕組みを説明します。ナビゲーションの状態、表示されているレコードの詳細、現在の選択を扱います。エージェントにユーザーの見ているものに基づいて動いてほしい開発者向けです。
使う場面
- ✓ひとつを見ているのに、どれのことかとエージェントが尋ねてくるとき。
- ✓アプリで現在の選択に対して、エージェントに行動させたいとき。
- ✓エージェントが現在の画面を知らないように見えて、その原因を調べているとき。
スキルのリンク
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/context-awareness/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“エージェントに、私が今開いているメールを把握させて、メールの名前を言わなくても返信を頼めるようにしてもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
アプリは、ページが変わると現在の画面の状態を、共有のルート状態のフックに書き込みます。エージェントの各ターンには現在の画面のスナップショットが含まれるので、表示と選択された項目が分かります。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Context Awareness
Rule
Apps can sync semantic navigation state when the route changes by using the
shared route-state hook. When screen context is available, Core includes a
<current-screen> snapshot in each agent turn, so the agent can get basic
route context without first calling another tool. Apps can add concise
visible-record details to that snapshot and expose selection in tab-scoped
state.
Why
Without context awareness, the agent is blind. It asks "which email?" when the user is staring at one. It cannot act on the current selection, cannot provide relevant suggestions, and cannot modify what the user sees. Context awareness is what makes the agent feel like a collaborator rather than a disconnected chatbot.
The Core Patterns
1. Navigation State (navigation key)
Use the shared route-state hook to write a tab-scoped navigation key as the
route changes. Include semantic screen state such as the view, open IDs, active
tab, and focused object.
UI side — use useAgentRouteState in the app's route-state hook. The app
can wrap it in an app-owned useNavigationState hook to map route paths to
semantic views and consume the agent's navigate command.
// app/hooks/use-navigation-state.ts
import { useAgentRouteState } from "@agent-native/core/client/navigation";
import { TAB_ID } from "@/lib/tab-id";
export function useNavigationState() {
useAgentRouteState({
browserTabId: TAB_ID,
requestSource: TAB_ID,
getNavigationState: ({ pathname, searchParams }) => ({
view:
pathname === "/"
? "home"
: pathname === "/sign-in"
? "sign-in"
: pathname.replace(/^\/+/, ""),
// Optional semantic alias. Raw query params are already exposed in
// <current-url> and controllable with set-search-params.
label: searchParams.get("label"),
}),
getCommandPath: (command: any) =>
command.path ?? `/${command.view === "home" ? "home" : command.view}`,
});
}
The default scaffold uses /home for home and /sign-in for authentication;
/ redirects according to the configured home route. Map navigation to the
app's actual routes and pass an explicit path for destinations that do not
follow the /<view> convention.
TAB_ID comes from the framework's getBrowserTabId() (see the scaffolded app/lib/tab-id.ts; never redefine it). The server resolves tab-scoped application_state writes and page-local WebMCP calls (X-Agent-Native-Browser-Tab) against this same id, so a hand-rolled random id silently breaks selection sync for hidden and background tabs.
Agent side — read before acting:
import { readAppState } from "@agent-native/core/application-state";
const navigation = await readAppState("navigation");
// e.g. { view: "thread", threadId: "abc123", subject: "Re: Q3 Planning" }
What to include in navigation state:
view— the current page/section (e.g., "inbox", "form-builder", "dashboard")- Item IDs — the selected/open item (e.g.,
threadId,formId,issueKey) - Semantic aliases — label names, active tabs, focused row, or stable filter names the agent should reason about
- Focused object IDs and active tabs that are not already represented by URL state
Keep text-selection ranges and excerpts in the tab-scoped selection key, not
in navigation.
Raw URL query params are already synced by the framework to __url__ and shown to the built-in agent as <current-url>. Keep shareable filters in URL state, then use view-screen to summarize important query params as activeFilters when helpful.
Keep application_state values small. Do not store pasted files, base64 images,
recording chunks, screenshots, or other large blobs in navigation or app-state
keys; upload them and store only a URL or storage handle.
Selection state
For app-owned per-tab selection, suffix the key with TAB_ID; requestSource
labels the write origin but does not scope the key. Keep the value to stable ids
and a short label or excerpt, never the full document:
import { writeClientAppState } from "@agent-native/core/client/hooks";
import { TAB_ID } from "@/lib/tab-id";
await writeClientAppState(
`selection:${TAB_ID}`,
{ kind: "text", id: "artifact-123", text: "short excerpt" },
{ requestSource: TAB_ID },
);
A server action can read that tab's value with
readAppStateForCurrentTab("selection"). A view-screen result may include the
selection and a specific next a
よくある質問
スナップショットには何が含まれますか?
現在の表示、開いているID、アクティブなタブ、フォーカスされたレコードなどの詳細が含まれます。
エージェントは画面を見るためにツールを呼ぶ必要がありますか?
基本的なルートの文脈は各ターンに含まれるので、その部分については追加のツール呼び出しは不要です。
エージェントは私が見ているものを変えられますか?
はい。エージェントがユーザーを画面に移動させられるナビゲーションのアクションも扱います。
詳細
作者による元の説明
How the agent knows what the user is looking at. Use when exposing UI state to the agent, implementing view-screen or navigate actions, wiring navigation state, or debugging agent context issues.
repo: BuilderIO/agent-native
人気
- GitHubのスター
- 7.6k
- ランキング
- #13148
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
design-exploration
7.6kUIの複数のデザインの方向性を並べて検討し、1つを選んでもらい、選んだデザインを磨き上げるようエージェントを支援します。
visual-edit
7.6k実行中のローカルのアプリをビジュアルエディターで開き、本物の画面をまとめて確認し編集できるようエージェントを支援します。
turn-into-app
7.6kワークフロー、スプレッドシート、プロジェクトを、画面にデータが入り、操作の裏でエージェントが働く、洗練されたビジュアルアプリに変えます。
visual-plan
7.6kプレーンテキストの計画を、図、ファイルのマップ、コードの断片、未解決の質問を含む、対話できるビジュアルな計画に変えます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。