/bnsql:ui-contextfrom bnsql
Capture live Binary Ninja UI context. Use when the user references what's on screen, what's selected, the current view/function, or says 'here'/'this' in the BN GUI.
Ships in bnsql. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Answer "what am I looking at / where is my cursor / what's selected" for a live Binary Ninja GUI session, by capturing the current UI state as a JSON envelope.
SELECT get_ui_context_json();
One 0-arg scalar function; returns a JSON string. No table.
Call it first whenever the user's request is anchored to the live GUI rather than a fixed address:
Then use the returned addr / function to drive the follow-up query (decompile,
xrefs, disassembly, …).
get_ui_context_json() is registered in every bnsql runtime, but only returns
live data inside the GUI plugin, where it snapshots Binary Ninja's UIContext
(via BN's bundled Python binaryninjaui). Everywhere else it returns a stable
unavailable envelope — it never throws and never returns NULL.
available: true, live view/cursor/selection.--http / --mcp / headless → available: false,
capture.source: "cli". There is no GUI to read.capture.source says which path produced the answer:
source | meaning |
|---|---|
plugin | Binary Ninja was the focused window |
all_contexts | BN was not focused; read from the open context instead. capture.context_count says how many windows were open, so you can tell whether picking one was unambiguous |
no_ui_context | no open window at all |
no_view | a window exists but has no current view |
cli | not the GUI plugin — nothing to read |
A non-focused Binary Ninja is normal, not an error. Whoever asks "what is the
user looking at" — a terminal, an MCP client, an agent — holds focus at the moment
it asks, so BN usually does not. all_contexts is the ordinary path for remote
callers and its data is exactly as live as plugin.
When available is false, fall back to SQL orientation instead of guessing:
SELECT * FROM binary; (file/arch/entry point), SELECT * FROM entries;,
SELECT * FROM segments;.
{
"available": true,
"capture": { "source": "plugin", "fresh": true, "error": null },
"view": { "type": "Linear:PE", // view kind — Linear:PE / Graph:PE
"name": "prog.bndb", // the open file
"il": "HighLevelILFunctionGraph" },
"code_context": {
"has_address": true,
"addr": "0x140001000",
"function": { "name": "main", "start": "0x140001000", "end": "0x140001234" },
"segment": { "start": "0x140001000", "end": "0x140003000" },
"section": { "name": ".text", "start": "0x140001000", "end": "0x140003000" }
},
"selection": { "start": "0x140001010", "end": "0x140001020" },
"highlight": { "valid": true, "addr": "0x140001010", "text": "rax" },
"panes": [ // present when the tab is split
{ "is_current": false, "type": "Linear:PE", "il": "NormalFunctionGraph",
"addr": "0x1400019c0", "selection": { "start": "0x1400019c0", "end": "0x1400019c4" } },
{ "is_current": true, "type": "Linear:PE", "il": "LowLevelILFunctionGraph",
"addr": "0x14002333a", "selection": { "start": "0x140023308", "end": "0x140023341" } }
]
}
Fields degrade gracefully: any piece BN can't supply is omitted or null, and
code_context.has_address tells you whether a real address anchor exists (a
chooser/type view may not have one).
view.type and view.il are orthogonal — read bothtype is the view kind (Linear:PE, Graph:PE); il is the IL level
(NormalFunctionGraph = disassembly, MediumLevelILFunctionGraph,
HighLevelILFunctionGraph, …). Switching the IL dropdown does not change
type, and switching Linear↔Graph does not change il. Reading only type
cannot tell HLIL from disassembly — if the user says "this line", the IL level
decides what they are pointing at.
panes[] — a split tab shows two locations at onceA UIContext is a window, not a pane, so a split view still reports one
context. panes[] lists every frame with exactly one is_current: true; the
top-level code_context / selection / highlight always describe that current
pane. When the user is comparing two places side by side, the other pane is in
panes[] and is frequently the thing they mean by "the other one".
highlight.addr is the token's REFERENT, not the cursorClicking data_140034260 inside a function reports the data address, not the
instruction you clicked on. The two coincide only when a symbol is clicked at its
own definition. Use code_context.addr for "where the cursor is" and
highlight.addr for "what the token points at".
Related trap: the UI's token text (e.g. data_140034260) is a synthesized
display name. data_items.name holds only user-assigned names and is empty for
auto-named data, so joining highlight.text against data_items.name finds
nothing. Join on the address instead.
And when you follow a highlighted token into data_items, an undefined variable
reports data_type: "void" with size: 0 — Binary Ninja's own width for an
untyped variable, not a bnsql defect. addr .. addr + size is therefore an empty
range for those rows; filter size > 0 before doing range arithmetic.
When you capture context, orient the user before answering:
addr.SELECT get_ui_context_json(); → read code_context.addr →
SELECT decompile(<addr>);code_context.function.start →
SELECT * FROM callers WHERE callee_addr = <start>;selection.start/end →
SELECT * FROM instructions WHERE addr BETWEEN <start> AND <end>;--http/CLI and available:false → say so plainly and orient via
SELECT * FROM binary; rather than inventing a "current" address.available is false — fall back to SQL
orientation and tell the user the GUI context isn't reachable from this runtime.selection / highlight are GUI-only refinements; core fields
(view, addr, function, segment) are the reliable anchor.decompiler — decompile the captured address.xrefs — callers/callees from the captured function.disassembly — instructions over the captured selection.connect — runtime/routing; the canonical surface tally.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub 0xeb/bnsql-skills --plugin bnsql11 skills in this plugin
/analysisBNSQL analysis workflows: triage, security audit, crypto/network detection, multi-table queries./annotationsEdit Binary Ninja databases: comments, renames, types, patches. Mutations require SELECT save() to persist (explicit-save model, v0.0.9+)./connectConnect to Binary Ninja databases and bootstrap sessions. Use when starting analysis, routing to other skills, or setting up CLI/HTTP/MCP connections./dataQuery Binary Ninja strings, bytes, and binary patterns. Use the byte_search table for fast byte-pattern search.Other plugins' skills for the same job