agentleFS
Simone-TarantinoSimone-Tarantino/godot-superpowers/skills/performance-audit/SKILL.md

performance-audit

Skill2 starsChanged 6 months agoMITView on GitHub

Audit a Godot 4.x project for common performance pitfalls — repeated node lookups, _process abuse, missing pooling, untyped collections, missing occlusion, heavy fragment shaders. Reports findings with severity and fix.

20 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use incident-response, threat-model and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • AnthropicSkill

    incident-response

    Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.

    Also in 4 projects that use this

  • OpenAISkill

    threat-model

    Use when Codex is already in the threat-modeling phase of a security scan, the user explicitly invokes $threat-model, or the user explicitly asks to create, update, or persist a repository threat model. Do not use as the primary trigger for full PR, commit, branch, patch, or repository scans.

    Also in 3 projects that use this

  • CloudflareSkill

    security-audit

    Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Also in 8 projects that use this

  • SentrySkill

    write-tests

    Write tests following project conventions. Use when adding new tests or modifying existing ones.

    Also in 3 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 3 projects that use this

  • SentrySkill

    security-review

    Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the path is a string literal, switch to preload.

    line 64
  2. Very specific:

    Check for GPUParticles2D / GPUParticles3D with amount over a few thousand or process_material rebuilt every emit.

    line 100
  3. Very specific:

    If 100+ instances of the same mesh, suggest MultiMeshInstance3D (or MultiMeshInstance2D).

    line 104
  4. Distinctive:

    Look for shaders with:

    line 116
  5. Very specific:

    Run code-reviewer agent for a deeper GDScript review (overlaps slightly with this audit but goes wider into correctness)

    line 196

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance Audit

Static-analysis-style scan plus runtime suggestions. Run this when frame rate drops, before a milestone, or when adding many entities at once.

Audit checklist

1. Repeated node lookups in hot paths

grep -rn '\$' --include='*.gd' scripts/ scenes/ | \
    grep -E '_process|_physics_process' | \
    grep -v '@onready'

Any $Path or get_node() inside _process / _physics_process is a candidate for @onready. Severity: HIGH.

2. find_child / find_node calls

grep -rn 'find_child\|find_node' --include='*.gd'

find_child walks the tree. Use unique names (%) or direct @onready references. Severity: HIGH.

3. Untyped collections used for homogeneous data

grep -rn ': Array =\|: Dictionary =' --include='*.gd' scripts/

Replace Array → Array[T], Dictionary → Dictionary[K, V] where contents are uniform. Severity: MEDIUM.

4. _process running on idle nodes

Any node with _process but no actual work happening every frame:

grep -B 1 -A 5 'func _process' --include='*.gd' -rn scripts/

Disable with set_process(false) until needed, or use Timer for periodic work. Severity: MEDIUM.

5. instantiate() in hot loops

grep -rn 'instantiate' --include='*.gd' scripts/ | \
    grep -v '_ready\|enter\|setup'

Frequent instantiation = pool candidate. Severity: HIGH if in _process / _physics_process / spawn loops.

6. load() where preload() works

grep -rn 'load(' --include='*.gd' scripts/ | grep -v 'preload\|^.*://\|"user://'

If the path is a string literal, switch to preload. Severity: LOW but free.

7. change_scene_to_file repeated

grep -rn 'change_scene_to_file' --include='*.gd'

Re-parses on every call. Switch to change_scene_to_packed(packed) with a preloaded PackedScene. Severity: MEDIUM.

8. Missing @onready for cached refs

grep -rn '^var .* = \$' --include='*.gd'

var x = $X runs at instantiation, not when the tree is ready — fragile. Always @onready. Severity: HIGH (correctness too).

9. TileMap (deprecated in 4.3+)

grep -rn '\[node .* type="TileMap"\]' --include='*.tscn'

Migrate to TileMapLayer (one node per layer). Severity: MEDIUM.

10. ParallaxBackground / ParallaxLayer (deprecated in 4.3+)

grep -rn 'type="ParallaxBackground"\|type="ParallaxLayer"' --include='*.tscn'

Migrate to Parallax2D. Severity: LOW.

11. Particles config

Check for GPUParticles2D / GPUParticles3D with amount over a few thousand or process_material rebuilt every emit. Severity: MEDIUM.

12. Many identical meshes

If 100+ instances of the same mesh, suggest MultiMeshInstance3D (or MultiMeshInstance2D). Severity: HIGH for stress scenes.

13. Missing occlusion (3D)

Project has 3D scenes but no OccluderInstance3D / Occlusion Culling enabled in the World Environment? Severity: MEDIUM.

14. Missing VisibleOnScreenNotifier for off-screen entities

Entities that _physics_process even when off-screen can be cheaper if disabled when invisible. Severity: LOW.

15. Fragment shader cost

Look for shaders with:

  • Loops over more than ~16 iterations
  • Multiple texture() calls with screen_texture / depth_texture
  • Per-pixel matrix math

Severity: HIGH on web/mobile, MEDIUM on desktop.

16. Resource not duplicated when mutated

grep -rn '\.tres' --include='*.gd' | grep -v 'duplicate\|preload'

Mutating a shared Resource mutates it for every consumer. Severity: HIGH (bug, not just perf).

17. Signal connected multiple times

grep -rn '\.connect(' --include='*.gd' | wc -l
# review for any signal connected in _ready of an instanced scene that's spawned often

Without CONNECT_ONE_SHOT or a guard, repeated connects trigger duplicate handlers. Severity: MEDIUM (bug + perf).

18. _input vs _unhandled_input

_input runs even after UI consumes the event. Use _unhandled_input unless you specifically need to override UI. Severity: LOW.

Runtime profiling

Direct the user to:

  1. Debugger → Profiler — start before reproducing, sort by self time. Look for unexpected _process consumers.
  2. Debugger → Visual Profiler — GPU-side, identifies render passes.
  3. Debugger → Monitor:
    • Object Count — should be stable; growth = leak
    • Node Count — bounded; growth in a long session = orphaned scenes
    • Resource Count — bounded; same logic
    • FPS — drops correlate with what frame in transcript
  4. Engine.get_frames_per_second() — log periodically during the suspect activity.
  5. Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME) — if > ~3000 on desktop or > ~1000 on web/mobile, batch with MultiMesh.

Reporting format

=== Performance Audit ===

HIGH (3 findings):
  scripts/player/player.gd:42 — get_node("Sprite2D") in _physics_process; cache via @onready
  scripts/enemies/spawner.gd:88 — instantiate() in _process; pool via genre-pack
  scenes/level_01.tscn — 600 identical TreeMesh instances; switch to MultiMeshInstance3D

MEDIUM (5 findings):
  ...

LOW (2 findings):
  ...

Recommended next steps:
  1. Apply HIGH fixes
  2. Profile after each fix to confirm impact
  3. Re-run audit

Anti-pattern reference

Anti-patternSymptomFix
$Path lookup in _processStable frame drop on a scene@onready
instantiate() in spawn loopFrame hitches on burstObject pool
Shared Resource mutatedConfusing stat / progression bugs.duplicate(true)
_process on idle entitiesHigh idle CPUset_process(false) until needed
_input instead of _unhandled_inputInput fires through UISwitch to _unhandled_input
Untyped ArrayMissed compile-time errorsArray[T]
100+ identical MeshInstance3DGPU draw call spikeMultiMeshInstance3D
Heavy fragment shader on big quadGPU fragment-boundReduce sample count, simpler ops
Big _physics_process switch on stateHard to refactorState machine (create-state-machine)

See also

  • Run code-reviewer agent for a deeper GDScript review (overlaps slightly with this audit but goes wider into correctness)
  • performance-profiler agent — for interactive investigation with the profiler

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.