GDSense reference

GDSense File and Script Context Commands

Use @file, @openscript, and @selection to attach the smallest useful GDScript or project-file context to a request.

Published Updated

All documentation

The short answer

Use @file when you know a res:// path and optionally want a line range or named symbol. Use @openscript to capture the script currently open in Godot, and @selection to capture the highlighted lines in the active script editor. Type @ to open the command picker; @file also opens a searchable project-file picker. These commands attach only the content they identify in Chat. In Agent Mode they provide path or selection hints so the Agent can read relevant content with its tools.

Choose the smallest file or script command

The @ picker lists all five context commands. Choosing @file opens fuzzy search over allowed project files. The picker excludes Godot internals, GDSense’s own addon folder, repository internals, and credential-bearing files. A blocked file cannot be attached by typing its path manually either.

File and script context command reference
CommandWhat it identifiesBest use
@fileAn allowed res:// file, optional line range, or named symbolA saved file you can name precisely
@openscriptA snapshot of the script currently open in the editorThe active script without typing its path
@selectionThe highlighted code plus its path and line numbersOne focused block or expression

Use @file for a path, line range, or symbol

File paths must be inside res:// and use an allowed text-based project extension. Quote a path when it contains spaces. A line range limits the attached content, while a #symbol anchor selects a named function or symbol when the parser can locate it.

Focused debugging request
@file "res://scripts/player_controller.gd":24-68
The player sometimes receives a second jump after landing. Trace state changes only in this range and tell me what additional dependency, if any, you need before proposing a fix.
Whole file
@file res://scripts/player_controller.gd
Quoted path with a line range
@file "res://scripts/player controller.gd":24-68
Named function
@file "res://scripts/player_controller.gd"#apply_gravity

Keep in mind: A narrower range can hide a dependency. Include the whole function or a directly related caller when the answer depends on state set outside the selected lines.

Use @openscript for the current editor script

@openscript captures the current CodeEdit content and its res:// path when the request is prepared. In a Chat session, the plugin can keep that snapshot pinned for later turns so follow-up questions retain the same evidence. The snapshot does not silently update just because you edit the file afterward.

Ask about the active script
@openscript
Explain how this state machine enters and exits the dash state. Identify any transition that can leave velocity locked, but do not rewrite the script.
  • Open the intended script before sending the request.
  • Use a new @openscript capture after making edits that the next answer must see.
  • Start a new Chat when you do not want earlier pinned script context carried forward.

Use @selection for highlighted code

@selection reads the active script editor’s highlighted text and records its file path and line numbers. It is the most precise choice for an expression, signal callback, or branch that needs explanation. If nothing is selected or no suitable script editor is active, the command reports an error instead of guessing.

Review one selected block
@selection
Explain which values can reach this branch and whether the null check covers a freed Godot object. Give me a verification step before any code suggestion.

Know what is transmitted in Chat and Agent Mode

In Chat, the plugin expands file and script commands into structured context before the request is sent. The transmitted content includes the prompt and the explicit attachment. In Agent Mode, these commands are converted to path or selection references; the Agent receives the shallow project path-name tree and can call supported read tools for actual content.

Neither workflow automatically sends every project file. Fresh Chat and Agent-start requests may additionally include your Settings rules and the optional res://AGENTS.md project rules. Retry preserves the original context and rules, and autocomplete does not use AGENTS.md.

Keep in mind: Review attachments for secrets and private data. Do not attach credential files or paste credentials into the prompt.

Try this workflow inside Godot

Use GDSense to ask questions, attach the context you choose, and review proposed changes without leaving the editor.