Skip to main contentContext Awareness
X21 continuously synchronises workbook context so Claude always knows what part of Excel you are working on. This context feeds into prompt construction, tool planning, and audit logs.
- The VSTO
ExcelSelection component listens to SheetSelectionChange events and exposes helpers such as:
GetSelectedRange() – Returns the active selection (e.g., B2:D10).
GetUsedRange() – Captures the extents of the active sheet.
GetAllSheetNames() – Provides a comma-separated list of worksheets.
GetWorkbookName() – Identifies the workbook for state scoping.
- Metadata is fetched via the Excel API (
/api/getMetadata) before each request and accompanies the prompt in requestMetadata.
Intelligent Prompt Construction
createPrompt (in stream/prompt-builder.ts) merges the user prompt with context about selection, workbook name, and enabled tools.
- When conversation history is compacted, the summarised prompt reiterates the workbook and worksheet list so Claude retains situational awareness.
- Tools like
read_values, read_format, and write_values include before/after ranges in their responses, giving Claude concrete data to reference.
write_format and formatting readers capture font, colour, alignment, and number formats, enabling style-aware suggestions.
- Structural tools (add/remove rows/columns/sheets) return the final workbook layout so subsequent operations stay aligned.
Attachments & External Context
- Document and image attachments are treated as additional context. The orchestrator annotates Langfuse traces with attachment metadata for auditing.
- Claude can cross-reference attachments with Excel data (e.g., summarise a PDF while inserting highlights in the sheet).
User Preferences
- Auto-approve settings, enabled tool lists, and conversation restarts are tracked per workbook to ensure future prompts honour previous decisions.
- UI-level toggles are sent alongside prompts so the backend knows which tools it can use without pausing.
Because context updates happen automatically, the copilot can produce precise formulas, formatting, and data transformations without lengthy back-and-forth instructions.