Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问clear审计未展示

optimizationoptimization 搜索

Agent Skill

optimization 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

315

周安装

13

GitHub Stars

公开资料未说明

下载量

103
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:optimization(optimization 搜索)
来源仓库:https://github.com/taozhuo/game-dev-skills
仓库路径:skills/optimization
安装命令:
npx skills add taozhuo/game-dev-skills --skill "optimization"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add taozhuo/game-dev-skills --skill "optimization"

简介

optimization 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 适用于游戏开发相关的优化信息检索和处理场景。
  • 通过 npx skills add taozhuo/game-dev-skills --skill "optimization" 命令安装。
  • 安装前建议确认权限范围和维护状态,注意可能涉及游戏数据和性能分析操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

name
optimization
description
Implements optimization techniques for rendering, scripting, memory, physics, and networking. Use when improving game performance, reducing lag, or preparing for mobile/low-end devices.
allowed-tools
Read, Write, Edit, Glob, Grep

Roblox Performance Optimization

Quick Reference Links

Official Documentation:

Wiki References:


When optimizing games, follow these patterns for better performance across all devices.

Rendering Optimization

Part Count Reduction

-- Combine multiple parts into unions or meshes
local function combineStaticParts(model)
    local parts = {}
    for _, part in ipairs(model:GetDescendants()) do
        if part:IsA("BasePart") and part.Anchored then
            table.insert(parts, part)
        end
    end

    if #parts > 1 then
        local union = parts[1]:UnionAsync(parts, Enum.CollisionFidelity.Box)
        union.Name = model.Name .. "_Combined"
        union.Parent = model.Parent

        for _, part in ipairs(parts) do
            part:Destroy()
        end

        return union
    end
end

-- Better: Use MeshPart for complex static geometry
-- Import optimized meshes from Blender with proper LODs

Level of Detail (LOD)

local LODManager = {}
local LOD_DISTANCES = {50, 100, 200}  -- Distance thresholds

function LODManager.setup(model)
    local lodLevels = {
        model:FindFirstChild("LOD0"),  -- Highest detail
        model:FindFirstChild("LOD1"),
        model:FindFirstChild("LOD2"),
        model:FindFirstChild("LOD3")   -- Lowest detail
    }

    local function updateLOD()
        local camera = workspace.CurrentCamera
        local distance = (model.PrimaryPart.Position - camera.CFrame.Position).Magnitude

        local activeLOD = 1
        for i, threshold in ipairs(LOD_DISTANCES) do
            if distance > threshold then
                activeLOD = i + 1
            end
        end

        for i, lod in ipairs(lodLevels) do
            if lod then
                lod.Visible = (i == activeLOD)
            end
        end
    end

    RunService.RenderStepped:Connect(updateLOD)
end

-- Automatic LOD using Roblox's built-in system
local function setupAutomaticLOD(meshPart)
    -- RenderFidelity controls automatic LOD
    meshPart.RenderFidelity = Enum.RenderFidelity.Automatic

    -- CollisionFidelity affects physics performance
    meshPart.CollisionFidelity = Enum.CollisionFidelity.Box  -- Simplest
end

Streaming Enabled

-- Enable instance streaming for large worlds
workspace.StreamingEnabled = true
workspace.StreamingMinRadius = 64    -- Min loaded radius
workspace.StreamingTargetRadius = 256 -- Target loaded radius
workspace.StreamingIntegrityMode = Enum.StreamingIntegrityMode.Default

-- For important models that must always be loaded
local importantModel = workspace.ImportantModel
importantModel.ModelStreamingMode = Enum.ModelStreamingMode.Atomic -- Load together
-- or
importantModel.ModelStreamingMode = Enum.ModelStreamingMode.Persistent -- Always loaded

Texture Optimization

-- Use appropriate texture sizes
-- Mobile: 256x256 or 512x512
-- Desktop: 512x512 or 1024x1024 max

-- Reduce unique materials
local function consolidateMaterials(model)
    local materials = {}
    for _, part in ipairs(model:GetDescendants()) do
        if part:IsA("BasePart") then
            local key = tostring(part.Material) .. "_" .. tostring(part.Color)
            materials[key] = (materials[key] or 0) + 1
        end
    end
    -- Identify and consolidate similar materials
end

Script Optimization

Avoid wait() and Use task Library

-- BAD: Uses deprecated wait()
wait(1)
spawn(function() ... end)
delay(1, function() ... end)

-- GOOD: Use task library
task.wait(1)
task.spawn(function() ... end)
task.delay(1, function() ... end)

-- Even better: Use events when possible
part.Touched:Wait()  -- Yields until event fires

Event Connection Management

-- BAD: Memory leak - connection never disconnected
part.Touched:Connect(function()
    -- This connection persists even after part is destroyed
end)

-- GOOD: Store and disconnect connections
local connection
connection = part.Touched:Connect(function(hit)
    if someCondition then
        connection:Disconnect()
    end
end)

-- BEST: Use Maid/Janitor pattern for cleanup
local Maid = {}
Maid.__index = Maid

function Maid.new()
    return setmetatable({_tasks = {}}, Maid)
end

function Maid:GiveTask(task)
    table.insert(self._tasks, task)
end

function Maid:Cleanup()
    for _, task in ipairs(self._tasks) do
        if typeof(task) == "RBXScriptConnection" then
            task:Disconnect()
        elseif typeof(task) == "Instance" then
            task:Destroy()
        elseif type(task) == "function" then
            task()
        end
    end
    self._tasks = {}
end

Caching and Avoiding Repeated Lookups

-- BAD: Repeated FindFirstChild every frame
RunService.Heartbeat:Connect(function()
    local hrp = player.Character:FindFirstChild("HumanoidRootPart")
    local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
    -- ...
end)

-- GOOD: Cache references
local character, hrp, humanoid

local function cacheCharacter()
    character = player.Character
    if character then
        hrp = character:WaitForChild("HumanoidRootPart")
        humanoid = character:WaitForChild("Humanoid")
    end
end

player.CharacterAdded:Connect(cacheCharacter)
cacheCharacter()

RunService.Heartbeat:Connect(function()
    if hrp then
        -- Use cached reference
    end
end)

Table Operations

-- BAD: Creating new tables constantly
RunService.Heartbeat:Connect(function()
    local data = {x = 1, y = 2, z = 3}  -- New table every frame
end)

-- GOOD: Reuse tables
local data = {x = 0, y = 0, z = 0}
RunService.Heartbeat:Connect(function()
    data.x, data.y, data.z = 1, 2, 3
end)

-- Use table.create for known sizes
local arr = table.create(1000, 0)  -- Pre-allocate 1000 slots

-- Clear table without creating new one
local function clearTable(t)
    for k in pairs(t) do
        t[k] = nil
    end
end

Local vs Global Variables

-- BAD: Accessing globals is slower
for i = 1, 1000000 do
    local x = math.sin(i)  -- Global lookup each time
end

-- GOOD: Cache in local variable
local sin = math.sin
for i = 1, 1000000 do
    local x = sin(i)  -- Local lookup is faster
end

Memory Optimization

Instance Destruction

-- Properly destroy instances to free memory
local function cleanup(instance)
    -- Disconnect all connections first
    for _, connection in ipairs(instance:GetConnections()) do
        connection:Disconnect()
    end

    -- Clear attributes
    for _, attr in ipairs(instance:GetAttributes()) do
        instance:SetAttribute(attr, nil)
    end

    instance:Destroy()
end

-- Nil references after destroy
local part = Instance.new("Part")
part:Destroy()
part = nil  -- Allow garbage collection

Object Pooling

local ObjectPool = {}
ObjectPool.__index = ObjectPool

function ObjectPool.new(template, initialSize)
    local pool = setmetatable({
        template = template,
        available = {},
        active = {}
    }, ObjectPool)

    for i = 1, initialSize do
        local obj = template:Clone()
        obj.Parent = nil
        table.insert(pool.available, obj)
    end

    return pool
end

function ObjectPool:get()
    local obj = table.remove(self.available)
    if not obj then
        obj = self.template:Clone()
    end
    table.insert(self.active, obj)
    return obj
end

function ObjectPool:release(obj)
    local index = table.find(self.active, obj)
    if index then
        table.remove(self.active, index)
    end
    obj.Parent = nil  -- Remove from world
    -- Reset state...
    table.insert(self.available, obj)
end

Garbage Collection Awareness

-- Avoid creating garbage in hot loops
-- BAD:
RunService.Heartbeat:Connect(function()
    local info = {  -- Creates garbage every frame
        position = hrp.Position,
        velocity = hrp.AssemblyLinearVelocity
    }
end)

-- GOOD: Use primitives or reuse tables
local cachedPosition = Vector3.new()
local cachedVelocity = Vector3.new()

RunService.Heartbeat:Connect(function()
    -- Vectors are value types, no garbage created
    local pos = hrp.Position
    local vel = hrp.AssemblyLinearVelocity
end)

-- Manual GC control (use sparingly)
local function forceGC()
    collectgarbage("collect")
end

Physics Optimization

Collision Groups

local PhysicsService = game:GetService("PhysicsService")

-- Create collision groups
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:RegisterCollisionGroup("Enemies")
PhysicsService:RegisterCollisionGroup("Projectiles")
PhysicsService:RegisterCollisionGroup("Debris")

-- Disable unnecessary collisions
PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)
PhysicsService:CollisionGroupSetCollidable("Projectiles", "Projectiles", false)
PhysicsService:CollisionGroupSetCollidable("Debris", "Debris", false)

-- Assign to parts
local function setCollisionGroup(part, groupName)
    part.CollisionGroup = groupName
end

Anchored Parts

-- Anchor static parts to remove from physics simulation
local function optimizeStaticParts(model)
    for _, part in ipairs(model:GetDescendants()) do
        if part:IsA("BasePart") then
            local isStatic = not part:FindFirstChildOfClass("Motor6D")
                         and not part:FindFirstChildOfClass("Weld")
            if isStatic then
                part.Anchored = true
            end
        end
    end
end

Simplified Collision

-- Use simpler collision shapes
meshPart.CollisionFidelity = Enum.CollisionFidelity.Box  -- Fastest
meshPart.CollisionFidelity = Enum.CollisionFidelity.Hull -- Medium
meshPart.CollisionFidelity = Enum.CollisionFidelity.Default -- Detailed

-- Disable collisions for visual-only parts
visualPart.CanCollide = false
visualPart.CanQuery = false  -- Excludes from raycasts too
visualPart.CanTouch = false  -- Excludes from Touched events

Network Optimization

Minimize RemoteEvent Traffic

-- BAD: Fire every frame
RunService.Heartbeat:Connect(function()
    PositionRemote:FireServer(hrp.Position)
end)

-- GOOD: Throttle updates
local lastUpdate = 0
local UPDATE_RATE = 1/20  -- 20 updates per second

RunService.Heartbeat:Connect(function()
    local now = os.clock()
    if now - lastUpdate >= UPDATE_RATE then
        lastUpdate = now
        PositionRemote:FireServer(hrp.Position)
    end
end)

-- BETTER: Only send when changed significantly
local lastSentPosition = Vector3.new()
local POSITION_THRESHOLD = 0.5

RunService.Heartbeat:Connect(function()
    local pos = hrp.Position
    if (pos - lastSentPosition).Magnitude > POSITION_THRESHOLD then
        lastSentPosition = pos
        PositionRemote:FireServer(pos)
    end
end)

Data Compression

-- Quantize positions to reduce data size
local function quantizeVector3(v, precision)
    precision = precision or 0.1
    return Vector3.new(
        math.floor(v.X / precision) * precision,
        math.floor(v.Y / precision) * precision,
        math.floor(v.Z / precision) * precision
    )
end

-- Pack multiple values
local function packColor(color)
    return color.R * 65536 + color.G * 256 + color.B
end

local function unpackColor(packed)
    local r = math.floor(packed / 65536)
    local g = math.floor((packed % 65536) / 256)
    local b = packed % 256
    return Color3.fromRGB(r, g, b)
end

Profiling Tools

MicroProfiler

-- Use debug.profilebegin/end for custom profiling
debug.profilebegin("MyExpensiveFunction")
-- ... expensive code ...
debug.profileend()

-- View in MicroProfiler (Ctrl+F6 in Studio)

Performance Stats

local Stats = game:GetService("Stats")

local function logPerformance()
    print("Memory:", Stats:GetTotalMemoryUsageMb(), "MB")
    print("Instances:", Stats.InstanceCount)
    print("Data Receive:", Stats.DataReceiveKbps, "Kbps")
    print("Data Send:", Stats.DataSendKbps, "Kbps")
    print("Physics Step:", Stats.PhysicsStepTimeMs, "ms")
end

Frame Rate Monitoring

local frameCount = 0
local lastTime = os.clock()

RunService.RenderStepped:Connect(function()
    frameCount = frameCount + 1

    local now = os.clock()
    if now - lastTime >= 1 then
        local fps = frameCount / (now - lastTime)
        print("FPS:", math.floor(fps))
        frameCount = 0
        lastTime = now
    end
end)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Cursor

28.54%
按下载量换算29

Codex

21.85%
按下载量换算23

Claude Code

20.59%
按下载量换算21

windsurf

12.71%
按下载量换算13

OpenCode

7.4%
按下载量换算8

Antigravity

3.5%
按下载量换算4

安全审计

暂无安全审计结果可展示。

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add taozhuo/game-dev-skills --skill "optimization" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills