$npx -y skills add thedivergentai/GD-Agentic-Skills --skill godot-debugging-profilingExpert debugging workflows including print debugging (push_warning, push_error, assert), breakpoints (conditional breakpoints), Godot Debugger (stack trace, variables, remote debug), profiler (time profiler, memory monitor), error handling patterns, and performance optimization.
| 1 | ## Godot 4.7 Baseline |
| 2 | |
| 3 | - Expert patterns in this skill target **Godot 4.7+** (stable, 2026-06-18). |
| 4 | - Consult the [Godot 4.7 migration guide](https://docs.godotengine.org/en/4.7/tutorials/migrating/upgrading_to_godot_4.7.html) when upgrading projects from 4.6. |
| 5 | - **NEVER** assume 4.6 defaults (stretch mode, audio area_mask, RichTextLabel percent flags) without checking 4.7 migration notes. |
| 6 | |
| 7 | # Debugging & Profiling |
| 8 | |
| 9 | Expert guidance for finding and fixing bugs efficiently with Godot's debugging tools. |
| 10 | |
| 11 | ## NEVER Do |
| 12 | |
| 13 | - **NEVER use `print()` without descriptive context** — `print(value)` is useless. Use `print("Player health:", health)` with labels. |
| 14 | - **NEVER leave debug prints in release builds** — Wrap in `if OS.is_debug_build()` or use custom DEBUG const. Prints slow down release. |
| 15 | - **NEVER ignore `push_warning()` messages** — Warnings indicate potential bugs (null refs, deprecated APIs). Fix them before they become errors. |
| 16 | - **NEVER use `assert()` for runtime validation in release** — Asserts are disabled in release builds. Use `if not condition: push_error()` for runtime checks. |
| 17 | - **NEVER profile in debug mode** — Debug builds are 5-10x slower. Always profile with release exports or `--release` flag. |
| 18 | - **NEVER assume `Engine.capture_script_backtraces(true)` is cheap** — Capturing locals allocates significant memory and can prevent objects from being deallocated, causing artificial leaks [19]. |
| 19 | - **NEVER call `push_error()` or `print()` inside a custom `Logger._log_message` override** — This causes infinite recursion and crashes as the logger intercepts its own output [20]. |
| 20 | - **NEVER leave the Visual Profiler running during gameplay tests** — Continuous polling degrades framerates significantly, invalidating actual performance metrics [21]. |
| 21 | - **NEVER rely on `OS.get_ticks_msec()` for microbenchmarking** — Milliseconds lack precision for logic timing; ALWAYS use `Time.get_ticks_usec()` for microsecond precision [22]. |
| 22 | - **NEVER assume `OBJECT_ORPHAN_NODE_COUNT` works in production** — This monitor is strictly debug-only; it safely returns 0 in release builds, potentially hiding leaks [23]. |
| 23 | - **NEVER benchmark with V-Sync enabled** — V-Sync throttles metrics to the monitor refresh rate, masking the true CPU/GPU processing overhead [24]. |
| 24 | - **NEVER leave `print_stack()` or `print_debug()` in release builds** — These are often stripped or useless outside the debugger. Use structured logging for production [25]. |
| 25 | - **NEVER strip debugging symbols if using external C++ profilers** — Stripping destroys call stack readability for external tools like Perfetto or VerySleepy [26]. |
| 26 | - **NEVER forget to unregister an `EditorDebuggerPlugin` in `_exit_tree()`** — Failing to clean up leaves "ghost" connections in the engine's debugging loop [27]. |
| 27 | - **NEVER trust the Visual Profiler on macOS when using the Compatibility renderer** — Platform-specific driver limitations severely restrict OpenGL profiling accuracy on macOS [28]. |
| 28 | --- |
| 29 | |
| 30 | ## Available Scripts |
| 31 | |
| 32 | > **MANDATORY**: Read the appropriate script before implementing the corresponding pattern. |
| 33 | |
| 34 | ### [high_precision_benchmarker.gd](scripts/high_precision_benchmarker.gd) |
| 35 | Micrometer-precision execution timing using `Time.get_ticks_usec()`, essential for identifying CPU micro-bottlenecks. |
| 36 | |
| 37 | ### [orphan_node_detector.gd](scripts/orphan_node_detector.gd) |
| 38 | Automated detection and logging of "Orphan Nodes" (nodes removed from tree but not freed) using internal Performance monitors. |
| 39 | |
| 40 | ### [advanced_backtrace_recorder.gd](scripts/advanced_backtrace_recorder.gd) |
| 41 | Capturing detailed script backtraces programmatically, including local variable snapshots for deep crash reporting. |
| 42 | |
| 43 | ### [engine_error_interceptor.gd](scripts/engine_error_interceptor.gd) |
| 44 | Intercepting underlying C++ engine errors and piping them to custom backend logs or analytics services. |
| 45 | |
| 46 | ### [custom_editor_monitor.gd](scripts/custom_editor_monitor.gd) |
| 47 | Exposing game-specific performance metrics (AI counts, bullet physics) directly to the Godot Editor's Debugger > Monitors tab. |
| 48 | |
| 49 | ### [debugger_tab_plugin.gd](scripts/debugger_tab_plugin.gd) |
| 50 | Project-specific debugger extensions that inject custom visual tabs and data into the Godot bottom panel. |
| 51 | |
| 52 | ### [thread_safe_logger.gd](scripts/thread_safe_logger.gd) |
| 53 | Mutext-locked logger subclass for thread-safe writing of logs from worker threads to external files. |
| 54 | |
| 55 | ### [custom_debug_draw.gd](scripts/custom_debug_draw.gd) |
| 56 | Pro-level visualization patterns for non-visual |