Saltar al contenido
Skillpedia
Sitios e interfaces (frontend)7,6 mil · #13148

context-awareness

Qué hace

Esta skill explica cómo una app Agent-Native indica al agente lo que aparece en pantalla. Cubre el estado de navegación, los detalles visibles del registro y la selección actual. Es para desarrolladores que quieren que el agente actúe sobre lo que el usuario ve.

Cuándo usarla

  • ✓Cuando el agente pregunta a qué elemento te refieres aunque estés viendo uno.
  • ✓Cuando quieres que el agente actúe sobre la selección actual de una app.
  • ✓Cuando depuras por qué el agente parece desconocer la pantalla actual.

Link de la skill

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/context-awareness/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/context-awareness/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Puedes hacer que el agente sepa qué correo tengo abierto, para pedirle que responda sin tener que nombrarlo?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La app escribe su estado de pantalla actual en un hook de estado de ruta compartido cuando cambia la página. Cada turno del agente incluye una instantánea de la pantalla actual, para que conozca la vista y el elemento seleccionado.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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

Preguntas frecuentes

¿Qué incluye la instantánea?

Incluye la vista actual y detalles como los identificadores abiertos, la pestaña activa y el registro enfocado.

¿Necesita el agente llamar a una herramienta para ver la pantalla?

El contexto básico de la ruta se incluye en cada turno, así que no hace falta una llamada extra para eso.

¿Puede el agente cambiar lo que veo?

La skill cubre las acciones de navegación que permiten al agente llevar al usuario a una pantalla.

Detalles

Descripción original del autor

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

Popularidad

Estrellas en GitHub
7,6 mil
Posición en el ranking
#13148
Licencia
MIT
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas