godot-copilot-instructions / github
Copilot instructions18 starsChanged 13 months agoMITView on GitHub
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
21 rules. About 0 are common, 15 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 6
Use tabs for indentation, not spaces.
- Distinctive: line 9
Always use explicit static types.
- Very specific: line 16
Use @onready with explicit type annotations and node path syntax.
- Very specific: line 18
Always specify the full type name (e.g., CollisionShape3D, never inferred types).
- Distinctive: line 42
Use null checks and early returns instead of nested conditionals.
- Distinctive: line 43
Use guard clauses to exit early.
- Distinctive: line 66
Use explicit error handling.
- Very specific: line 81
Always use typed classes (Resource or RefCounted) instead of untyped dictionaries for data structures.
- Distinctive: line 83
Use for: data transfer objects, configuration objects, state containers.
- Very specific: line 86
Use Resource or RefCounted classes instead of dictionaries to pass data between nodes.
- Very specific: line 114
Use @abstract for base classes that define shared behavior but cannot be directly instantiated.
- Distinctive: line 138
Use composition and component-based architecture instead of deep inheritance hierarchies.
- Distinctive: line 140
Keep inheritance chains shallow (1-2 levels maximum).
- Distinctive: line 143
Avoid tight coupling between systems and scripts.
- Distinctive: line 144
Use signals and event buses for communication between unrelated systems.
- Distinctive: line 149
Keep scripts focused on a single responsibility.
- Distinctive: line 158
Use public signals (no underscore prefix) in event bus systems.
- Distinctive: line 179
Use self-documenting variable and function names.
- Distinctive: line 180
Only comment non-obvious logic or complex algorithms.
- Distinctive: line 183
Do not generate documentation (.md) files unless explicitly requested.
- Very specific: line 186
Never manually create or edit Godot .uid files (*.tscn.uid, *.gd.uid, etc.).
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for GDScript
Code Style
Indentation
- Use tabs for indentation, not spaces.
Type System
- Always use explicit static types. Never rely on type inference.
- Variables:
var player_id: int = 0 - Function returns:
func get_player_id() -> int: - Constants:
const MOVE_SPEED: float = 5.0 - Replace all magic numbers and strings with named constants.
Node References
- Use
@onreadywith explicit type annotations and node path syntax. - Example:
@onready var collision_shape: CollisionShape3D = $CollisionShape3D - Always specify the full type name (e.g.,
CollisionShape3D, never inferred types). - This ensures type safety, performance (nodes are cached), and self-documenting code.
Naming Conventions
snake_casefor functions and variables:var player_position,func calculate_damage()PascalCasefor classes and types:class PlayerController,enum GameState- Prefix private functions with underscore:
func _process_input() -> void:
Code Organization
Variable Declaration Order
- Signals
- Const declarations
- @export variables
- @onready variables
- Regular var declarations
Function Declaration Order
- Built-in lifecycle functions (_ready, _process, _physics_process, etc.)
- Private functions (prefixed with underscore)
- Public functions
Control Flow
- Use null checks and early returns instead of nested conditionals.
- Use guard clauses to exit early.
- Example:
# Bad: Nested conditionals func process_player(player: Node) -> void: if player != null: if player.is_alive(): if player.has_weapon(): player.attack() # Good: Early returns func process_player(player: Node) -> void: if player == null: return if not player.is_alive(): return if not player.has_weapon(): return player.attack()
Error Handling
- Use explicit error handling. Never fail silently.
- Print errors or emit signals when issues occur.
- Example:
func load_config(path: String) -> bool: if not FileAccess.file_exists(path): push_error("Config file not found: " + path) return false # Load config... return true
Data Structures
Typed Classes vs Dictionaries
- Always use typed classes (
ResourceorRefCounted) instead of untyped dictionaries for data structures. - Provides type safety, IDE autocomplete, and proper type inference.
- Use for: data transfer objects, configuration objects, state containers.
Data Transfer Objects
- Use
ResourceorRefCountedclasses instead of dictionaries to pass data between nodes. - Extend
Resourcefor serialization/saving, orRefCountedfor lightweight data objects. - Example:
class_name PlayerData extends Resource var player_name: String = "" var health: int = 100 var position: Vector3 = Vector3.ZERO func _init(name: String = "", hp: int = 100, pos: Vector3 = Vector3.ZERO) -> void: player_name = name health = hp position = pos - Usage:
# Bad: Untyped dictionary func get_player_info() -> Dictionary: return {"name": "Player", "health": 100, "position": Vector3.ZERO} # Good: Typed class func get_player_info() -> PlayerData: return PlayerData.new("Player", 100, Vector3.ZERO)
Abstract Base Classes
- Use
@abstractfor base classes that define shared behavior but cannot be directly instantiated. - Abstract classes must extend a Godot type (Node, CharacterBody3D, etc.) and are for inheritance only.
- Example:
@abstract class_name Character extends CharacterBody3D @export var health: int = 100 @export var speed: float = 5.0 @export var acc: float = 2.5 ## acceleration @export var dec: float = 5.0 ## deceleration - Extend in child classes:
class_name Player extends Character @export var stamina: float = 100.0
Code Architecture
Composition Over Inheritance
- Use composition and component-based architecture instead of deep inheritance hierarchies.
- Attach scripts as components to nodes rather than creating complex base classes.
- Keep inheritance chains shallow (1-2 levels maximum).
Loose Coupling
- Avoid tight coupling between systems and scripts.
- Use signals and event buses for communication between unrelated systems.
- Pass dependencies explicitly through function parameters or autoloads.
- Minimize direct node references. Use node paths or signals instead.
Modularity
- Keep scripts focused on a single responsibility.
- Split large functionality into separate scripts/components.
- Organize code:
systems/- Cross-cutting concerns and managersautoloads/- Global services used by multiple systems
Code Patterns
Event Bus Signals
- Use public signals (no underscore prefix) in event bus systems.
- Provide wrapper functions to emit signals. Never emit signals directly from external code.
- Cache values as private variables with getter functions when needed.
- Example:
signal player_moved(position: Vector3) var _current_player_position: Vector3 = Vector3.ZERO func emit_player_moved(position: Vector3) -> void: _current_player_position = position player_moved.emit(position) func get_player_position() -> Vector3: return _current_player_position - This provides encapsulation, validation hooks, and a clear API surface.
Documentation
Code Comments
- Avoid excessive documentation.
- Use self-documenting variable and function names.
- Only comment non-obvious logic or complex algorithms.
Markdown Files
- Do not generate documentation (.md) files unless explicitly requested.
UID Files
- Never manually create or edit Godot .uid files (
*.tscn.uid,*.gd.uid, etc.). - The Godot editor automatically manages these files.
- Manual editing causes conflicts and inconsistent asset metadata.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

